Fix building with libxml2-2.12.0
[shigofumi.git] / src / completion.h
blob582d8847be292b250d02d956daddb5ea1886a175
1 #ifndef __SHI_COMPLETITION_H__
2 #define __SHI_COMPLETITION_H__
4 typedef enum {
5 ARGTYPE_NONE,
6 ARGTYPE_COMMAND,
7 ARGTYPE_FILE,
8 ARGTYPE_MSGID,
9 ARGTYPE_DOCID,
10 ARGTYPE_BOXID
11 } arg_type;
13 struct command {
14 char *name; /* Full command name */
15 int (*function)(int, const char **); /* Command implementation */
16 char *description; /* Help text for the command */
17 void (*usage)(const char*); /* Manual for the command */
18 arg_type arg; /* Defines argument completion */
21 extern struct command base_commands[], message_commands[], list_commands[];
22 extern struct command (*commands)[];
23 extern char *prompt;
25 typedef enum {
26 COMPL_NONE,
27 COMPL_COMMAND,
28 COMPL_MSG,
29 COMPL_LIST
30 } completion_type;
32 /* Switch completion function */
33 int select_completion(const completion_type completion);
35 struct command *find_command(const char *text);
37 /* Free list of chars recursively */
38 void argv_free(char **argv);
40 /* Decides whether character at @index offset of @text is quoted */
41 int shi_char_is_quoted(char *text, int index);
43 /* Escapes file name */
44 char *shi_quote_filename(char *text, int match_type, char *quote_pointer);
46 /* Deescapes file name */
47 char *shi_dequote_filename(char *text, int quote_char);
50 /* Split string into tokens
51 * @command_line is line to parse
52 * @argc outputs number of parsed arguments
53 * @shell is optional automatically reallocated shell command following pipe
54 * in @command_line
55 * @return NULL-terminated array of tokens or NULL in case of error */
56 char **tokenize(const char *command_line, int *argc, char **shell);
58 /* Add line into history if not NULL or empty string */
59 void shi_add_history(const char *line);
61 /* Ask user for a password */
62 char *ask_for_password(const char *prompt);
64 /* Prompt user and supply default value if user does input nothing. Original
65 * default value can be deallocated in this function. If *@value is NULL, use
66 * as default read-only @backup_value. You can always free *@value. * */
67 void shi_ask_for_string(char **value, const char *prompt,
68 const char *backup_value, _Bool batch_mode);
70 /* Prompt user for password and supply default value if user does input
71 * nothing. Original default value can be deallocated in this function. If
72 * *@value is NULL, use as default read-only @backup_value. You can always
73 * free *@value. * */
74 void shi_ask_for_password(char **value, const char *prompt,
75 const char *backup_value, _Bool batch_mode);
77 /* Ask Yes-No question.
78 * @prompt is question to ask the user
79 * @default_value specifies default answer if user puts nothing. True is for
80 * Yes, false is for No.
81 * @batch_mode is true for non-interctive mode, true for interactive
82 * @return true for yes, false for no. */
83 _Bool shi_ask_yes_no(const char *prompt, _Bool default_value,
84 _Bool batch_mode);
86 /* This is ISDS context network progress call back. It prints progress meter
87 * and allows user to abort current network transfer. */
88 int shi_progressbar(double upload_total, double upload_current,
89 double download_total, double download_current, void *data);
91 /* Finish progress meter output. */
92 void shi_progressbar_finish(void);
94 #endif