.\" Generated by the Allegro makedoc utility .TH load_datafile_callback 3alleg4 "version 4.4.3" "Allegro" "Allegro manual" .SH NAME load_datafile_callback \- Loads a datafile into memory, calling a hook per object. Allegro game programming library.\& .SH SYNOPSIS .B #include .sp .B DATAFILE *load_datafile_callback(const char *filename, .B void (*callback)(DATAFILE *d)); .SH DESCRIPTION Loads a datafile into memory, calling the specified hook function once for each object in the file, passing it a pointer to the object just read. You can use this to implement very simple loading screens where every time the hook is called, the screen is updated to let the user know your program is still loading from disk: .nf void load_callback(DATAFILE *dat_obj) { static const char indicator[] = "-\\\\|/-.oOXOo."; static int current = 0; /* Show a different character every time. */ textprintf_ex(screen, font, 0, 0, makecol(0, 0, 0), makecol(255, 255, 255), "%c Loading %c", indicator[current], indicator[current]); /* Increase index and check if we need to reset it. */ current++; if (!indicator[current]) current = 0; } ... dat = load_datafile_callback("data.dat", load_callback); .fi .SH "RETURN VALUE" Returns a pointer to the DATAFILE or NULL on error. Remember to free this DATAFILE later to avoid memory leaks. .SH SEE ALSO .BR load_datafile (3alleg4), .BR unload_datafile (3alleg4), .BR load_datafile_object (3alleg4), .BR set_color_conversion (3alleg4), .BR fixup_datafile (3alleg4), .BR packfile_password (3alleg4), .BR find_datafile_object (3alleg4), .BR register_datafile_object (3alleg4)