allow to pass username and password by commandline arguments

This commit is contained in:
josch
2014-09-23 09:26:28 +02:00
parent 08c067a352
commit 8f726ab5e5

View File

@@ -25,6 +25,7 @@
#include <string.h>
#include <wordexp.h>
#include "../utils/strings.h"
#include "mfshell.h"
static void mfshell_run(mfshell * shell);
@@ -124,6 +125,7 @@ int main(int argc, char *const argv[])
char *username = NULL;
char *password = NULL;
char *command = NULL;
char *auth_cmd;
SSL_library_init();
@@ -132,6 +134,16 @@ int main(int argc, char *const argv[])
shell = mfshell_create(35860, "2c6dq0gb2sr8rgsue5a347lzpjnaay46yjazjcjg",
server);
if (username != NULL) {
if (password != NULL) {
auth_cmd = strdup_printf("auth %s %s", username, password);
} else {
auth_cmd = strdup_printf("auth %s", username);
}
mfshell_parse_commands(shell, auth_cmd);
free(auth_cmd);
}
if (command == NULL) {
// begin shell mode
mfshell_run(shell);