On Sat, Oct 29, 2005 at 04:13:24PM -0400, Buddy Bell wrote: > I am trying to modify elinks to reload and then save to file a certain > web page every five minutes. In the process of getting the html source > saved without a dialog requiring input I ran across the statement > "std(data, def.source);" at stmt 581 of menu.c under dialogs. It must > be what is saving the html but I can find no other reference to it > searching for "std(" in the source directories. Is it a subroutine, a > macro, a c statement? Using google I can't find anything on it. There > is also no man page for std. If you could explain to a relative newbie > were it comes from I would appreciate it. Thanks. BB
I believe that you are looking at the query_file routine in src/dialogs/menu.c. std is a parameter to query_file. Today's new word is callback: if you grep the source, you'll see that functions call query_file with any of start_download, continue_download, download, or save_formatted as the argument for std; these are called callbacks. query_file needs to know what to do with the file, so to keep it nice and generic, it takes a callback function either to call or to pass as a callback to input_dialog so that the callback is eventually registered as the callback for the OK button in the prompt for the file's name. The complicated type for the std parameter: void (*std)(void *, unsigned char *) is saying that std must be a pointer to a function that takes a void pointer and a string and returns nothing (void). Any callback for query_file must have this type. Other than that, there is nothing special one must do to use a function as a callback. In tp_save in src/session/download.c, for example, we have: query_file(type_query->ses, type_query->uri, type_query, continue_download, tp_cancel, 1); continue_download is defined above: static void continue_download(void *data, unsigned char *file) ... In C, continue_download and &continue_download are equivalent (AIUI). So, tp_save is passing query_file the callback continue_download. Also, tp_cancel is given as the callback for query_file's cancel parameter. I hope that that helps, -- Miciah Masters <[EMAIL PROTECTED]> / <[EMAIL PROTECTED]> _______________________________________________ elinks-dev mailing list elinks-dev@linuxfromscratch.org http://linuxfromscratch.org/mailman/listinfo/elinks-dev