1 #ifndef __SHI_COMPLETITION_H__
2 #define __SHI_COMPLETITION_H__
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
)[];
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
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
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
,
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);