int for_each_file_ex(const char *name, int in_attrib, int out_attrib, int (*callback)(const char *filename, int attrib, void *param), void *param);
The callback function will be passed three arguments: the first is a string which contains the completed filename (exactly the same string you passed to for_each_file_ex() but with meta characters), the second is the actual attributes of the file, and the third is a void pointer which is simply a copy of `param' (you can use this for whatever you like). The callback must return zero to let the enumeration proceed, or any non-zero value to stop it. If an error occurs, the error code will be stored in `errno' but the enumeration won't stop. Example:
int show_name(const char *filename, int attrib, void *param) { allegro_message("Caught `%s', attribs %d\n", filename, attrib); return 0; } ... count = for_each_file_ex("data/level*", FA_DIREC, 0, show_name, 0); allegro_message("%d game directories\n", count);