mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 13:14:29 -08:00
add function to execute raw commands via argc and argv
This commit is contained in:
21
console.c
21
console.c
@@ -91,6 +91,17 @@ console_get_metrics(int *height,int *width)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_execute(mfshell_t *mfshell, int argc, char **argv)
|
||||||
|
{
|
||||||
|
_cmd_t* curr_cmd;
|
||||||
|
for (curr_cmd = mfshell->commands; curr_cmd->name != NULL; curr_cmd++) {
|
||||||
|
if (strcmp(argv[0], curr_cmd->name) == 0) {
|
||||||
|
return curr_cmd->handler(mfshell, argc, argv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_execute_shell_command(mfshell_t *mfshell,char *command)
|
_execute_shell_command(mfshell_t *mfshell,char *command)
|
||||||
{
|
{
|
||||||
@@ -125,14 +136,8 @@ _execute_shell_command(mfshell_t *mfshell,char *command)
|
|||||||
|
|
||||||
argc = stringv_len(argv);
|
argc = stringv_len(argv);
|
||||||
|
|
||||||
_cmd_t* curr_cmd;
|
// TODO: handle retval
|
||||||
for (curr_cmd = mfshell->commands; curr_cmd->name != NULL; curr_cmd++) {
|
retval = _execute(mfshell, argc, argv);
|
||||||
if (strcmp(argv[0], curr_cmd->name) == 0) {
|
|
||||||
// TODO: handle retval
|
|
||||||
retval = curr_cmd->handler(mfshell, argc, argv);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stringv_free(argv,STRINGV_FREE_ALL);
|
stringv_free(argv,STRINGV_FREE_ALL);
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ mfshell_create(int app_id,char *app_key,char *server)
|
|||||||
mfshell->create_call_signature = _create_call_signature;
|
mfshell->create_call_signature = _create_call_signature;
|
||||||
mfshell->create_signed_get = _create_signed_get;
|
mfshell->create_signed_get = _create_signed_get;
|
||||||
|
|
||||||
mfshell->exec = _execute_shell_command;
|
mfshell->exec = _execute;
|
||||||
|
mfshell->exec_string = _execute_shell_command;
|
||||||
|
|
||||||
// configure REST API callbacks
|
// configure REST API callbacks
|
||||||
mfshell->get_session_token = _get_session_token;
|
mfshell->get_session_token = _get_session_token;
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ struct _mfshell_s
|
|||||||
char* (*create_signed_get) (_mfshell_t*,int,char*,char*,...);
|
char* (*create_signed_get) (_mfshell_t*,int,char*,char*,...);
|
||||||
char* (*create_signed_post) (_mfshell_t*,int,char*,char*,...);
|
char* (*create_signed_post) (_mfshell_t*,int,char*,char*,...);
|
||||||
|
|
||||||
int (*exec) (_mfshell_t*,char*);
|
int (*exec) (_mfshell_t*, int argc, char **argv);
|
||||||
|
int (*exec_string) (_mfshell_t*,char*);
|
||||||
|
|
||||||
/* REST API calls */
|
/* REST API calls */
|
||||||
int (*get_session_token) (_mfshell_t*);
|
int (*get_session_token) (_mfshell_t*);
|
||||||
@@ -120,6 +121,9 @@ _create_call_signature(_mfshell_t *mfshell,char *url,char *args);
|
|||||||
char*
|
char*
|
||||||
_create_signed_get(_mfshell_t *mfshell,int ssl,char *api,char *fmt,...);
|
_create_signed_get(_mfshell_t *mfshell,int ssl,char *api,char *fmt,...);
|
||||||
|
|
||||||
|
int
|
||||||
|
_execute(_mfshell_t *mfshell, int argc, char **argv);
|
||||||
|
|
||||||
int
|
int
|
||||||
_execute_shell_command(_mfshell_t *mfshell,char *command);
|
_execute_shell_command(_mfshell_t *mfshell,char *command);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user