#define _GNU_SOURCE #include #include #include #include #include #include #include #include static int ui_stop = 0; typedef struct { char *name; /**< User printable name of the function. */ rl_icpfunc_t *func; /**< Function to call to do the job. */ char *doc; /**< Documentation for this function. */ } command_t; void cred(); void exist( char *file ); void list( char *dir ); void get( char *src, char *dst, int statistics ); #define ui_get_next_word( word ) \ ( word ) ? ( ui_get_word( word + 1 + strlen( word ) ) ) : ( NULL ) int ui_comm_quit __P( ( char *argument ) ); int ui_comm_help __P( ( char *argument ) ); int ui_comm_exist __P( ( char *argument ) ); int ui_comm_list __P( ( char *argument ) ); int ui_comm_get __P( ( char *argument ) ); int ui_comm_get_stat __P( ( char *argument ) ); int ui_comm_cred __P( ( char *argument ) ); char **ui_completion __P( ( const char *text, int start, int end ) ); char *ui_command_generator __P( ( const char *text, int state ) ); command_t *ui_find_command( char *name ); command_t commands[] = { { "quit", ui_comm_quit, "Quit" }, { "exit", ui_comm_quit, "Synonym for 'quit'" }, { "help", ui_comm_help, "Display this help" }, { "list", ui_comm_list, "List files in dir (optional parameter)" }, { "exist", ui_comm_exist, "Tests if the given file exists" }, { "get", ui_comm_get, "Get a given file" }, { "getstat", ui_comm_get_stat, "Get a given file" }, { "cred", ui_comm_cred, "Show credits" }, { (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL } };