1load_datafile_callback(3) Allegro manual load_datafile_callback(3)
2
3
4
6 load_datafile_callback - Loads a datafile into memory, calling a hook
7 per object. Allegro game programming library.
8
10 #include <allegro.h>
11
12
13 DATAFILE *load_datafile_callback(const char *filename, void (*call‐
14 back)(DATAFILE *d));
15
17 Loads a datafile into memory, calling the specified hook function once
18 for each object in the file, passing it a pointer to the object just
19 read. You can use this to implement very simple loading screens where
20 every time the hook is called, the screen is updated to let the user
21 know your program is still loading from disk:
22
23 void load_callback(DATAFILE *dat_obj)
24 {
25 static const char indicator[] = "-\\|/-.oOXOo.";
26 static int current = 0;
27
28 /* Show a different character every time. */
29 textprintf_ex(screen, font, 0, 0, makecol(0, 0, 0),
30 makecol(255, 255, 255), "%c Loading %c",
31 indicator[current], indicator[current]);
32 /* Increase index and check if we need to reset it. */
33 current++;
34 if (!indicator[current])
35 current = 0;
36 }
37 ...
38 dat = load_datafile_callback("data.dat", load_callback);
39
41 Returns a pointer to the DATAFILE or NULL on error. Remember to free
42 this DATAFILE later to avoid memory leaks.
43
44
46 load_datafile(3), unload_datafile(3), load_datafile_object(3),
47 set_color_conversion(3), fixup_datafile(3), packfile_password(3),
48 find_datafile_object(3), register_datafile_object(3)
49
50
51
52Allegro version 4.2.3 load_datafile_callback(3)