add const qualifiers to some variables

This commit is contained in:
josch
2014-09-21 15:59:52 +02:00
parent 675679acf7
commit 08c067a352
33 changed files with 123 additions and 98 deletions

View File

@@ -43,10 +43,12 @@ int mfconn_api_folder_get_info(mfconn * conn, mffolder * folder,
int mfconn_api_user_get_info(mfconn * conn); int mfconn_api_user_get_info(mfconn * conn);
int mfconn_api_user_get_session_token(mfconn * conn, char *server, int mfconn_api_user_get_session_token(mfconn * conn,
char *username, const char *server,
char *password, int app_id, const char *username,
char *app_key, const char *password,
int app_id,
const char *app_key,
uint32_t * secret_key, uint32_t * secret_key,
char **secret_time, char **secret_time,
char **session_token); char **session_token);

View File

@@ -32,7 +32,7 @@ static int _decode_file_get_info(mfhttp * conn, void *data);
int mfconn_api_file_get_info(mfconn * conn, mffile * file, char *quickkey) int mfconn_api_file_get_info(mfconn * conn, mffile * file, char *quickkey)
{ {
char *api_call; const char *api_call;
int retval; int retval;
int len; int len;
mfhttp *http; mfhttp *http;
@@ -59,7 +59,7 @@ int mfconn_api_file_get_info(mfconn * conn, mffile * file, char *quickkey)
retval = http_get_buf(http, api_call, _decode_file_get_info, file); retval = http_get_buf(http, api_call, _decode_file_get_info, file);
http_destroy(http); http_destroy(http);
free(api_call); free((void *)api_call);
return retval; return retval;
} }
@@ -86,15 +86,15 @@ static int _decode_file_get_info(mfhttp * conn, void *data)
quickkey = json_object_get(node, "quickkey"); quickkey = json_object_get(node, "quickkey");
if (quickkey != NULL) if (quickkey != NULL)
file_set_key(file, (char *)json_string_value(quickkey)); file_set_key(file, json_string_value(quickkey));
file_name = json_object_get(node, "filename"); file_name = json_object_get(node, "filename");
if (file_name != NULL) if (file_name != NULL)
file_set_name(file, (char *)json_string_value(file_name)); file_set_name(file, json_string_value(file_name));
file_hash = json_object_get(node, "hash"); file_hash = json_object_get(node, "hash");
if (file_hash != NULL) { if (file_hash != NULL) {
file_set_hash(file, (char *)json_string_value(file_hash)); file_set_hash(file, json_string_value(file_hash));
} }
if (quickkey == NULL) if (quickkey == NULL)

View File

@@ -32,7 +32,7 @@ static int _decode_file_get_links(mfhttp * conn, void *data);
int mfconn_api_file_get_links(mfconn * conn, mffile * file, char *quickkey) int mfconn_api_file_get_links(mfconn * conn, mffile * file, char *quickkey)
{ {
char *api_call; const char *api_call;
int retval; int retval;
int len; int len;
mfhttp *http; mfhttp *http;
@@ -59,7 +59,7 @@ int mfconn_api_file_get_links(mfconn * conn, mffile * file, char *quickkey)
retval = http_get_buf(http, api_call, _decode_file_get_links, file); retval = http_get_buf(http, api_call, _decode_file_get_links, file);
http_destroy(http); http_destroy(http);
free(api_call); free((void *)api_call);
return retval; return retval;
} }
@@ -96,15 +96,15 @@ static int _decode_file_get_links(mfhttp * conn, void *data)
quickkey = json_object_get(node, "quickkey"); quickkey = json_object_get(node, "quickkey");
if (quickkey != NULL) if (quickkey != NULL)
file_set_key(file, (char *)json_string_value(quickkey)); file_set_key(file, json_string_value(quickkey));
share_link = json_object_get(node, "normal_download"); share_link = json_object_get(node, "normal_download");
if (share_link != NULL) if (share_link != NULL)
file_set_share_link(file, (char *)json_string_value(share_link)); file_set_share_link(file, json_string_value(share_link));
direct_link = json_object_get(node, "direct_download"); direct_link = json_object_get(node, "direct_download");
if (direct_link != NULL) { if (direct_link != NULL) {
file_set_direct_link(file, (char *)json_string_value(direct_link)); file_set_direct_link(file, json_string_value(direct_link));
} }
onetime_link = json_object_get(node, "one_time_download"); onetime_link = json_object_get(node, "one_time_download");

View File

@@ -27,7 +27,7 @@
int mfconn_api_folder_create(mfconn * conn, char *parent, char *name) int mfconn_api_folder_create(mfconn * conn, char *parent, char *name)
{ {
char *api_call; const char *api_call;
int retval; int retval;
mfhttp *http; mfhttp *http;
@@ -64,7 +64,7 @@ int mfconn_api_folder_create(mfconn * conn, char *parent, char *name)
retval = http_get_buf(http, api_call, NULL, NULL); retval = http_get_buf(http, api_call, NULL, NULL);
http_destroy(http); http_destroy(http);
free(api_call); free((void *)api_call);
return retval; return retval;
} }

View File

@@ -27,7 +27,7 @@
int mfconn_api_folder_delete(mfconn * conn, const char *folderkey) int mfconn_api_folder_delete(mfconn * conn, const char *folderkey)
{ {
char *api_call; const char *api_call;
int retval; int retval;
mfhttp *http; mfhttp *http;
@@ -48,7 +48,7 @@ int mfconn_api_folder_delete(mfconn * conn, const char *folderkey)
retval = http_get_buf(http, api_call, NULL, NULL); retval = http_get_buf(http, api_call, NULL, NULL);
http_destroy(http); http_destroy(http);
free(api_call); free((void *)api_call);
return retval; return retval;
} }

View File

@@ -35,7 +35,7 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *data);
long long
mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr) mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr)
{ {
char *api_call; const char *api_call;
int retval; int retval;
char *content_type; char *content_type;
mfhttp *http; mfhttp *http;
@@ -75,7 +75,7 @@ mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr)
_decode_folder_get_content_files, NULL); _decode_folder_get_content_files, NULL);
http_destroy(http); http_destroy(http);
free(api_call); free((void *)api_call);
return retval; return retval;
} }

View File

@@ -33,7 +33,7 @@ static int _decode_folder_get_info(mfhttp * conn, void *data);
int int
mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, char *folderkey) mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, char *folderkey)
{ {
char *api_call; const char *api_call;
int retval; int retval;
mfhttp *http; mfhttp *http;
@@ -59,7 +59,7 @@ mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, char *folderkey)
retval = http_get_buf(http, api_call, _decode_folder_get_info, folder); retval = http_get_buf(http, api_call, _decode_folder_get_info, folder);
http_destroy(http); http_destroy(http);
free(api_call); free((void *)api_call);
return retval; return retval;
} }
@@ -86,15 +86,15 @@ static int _decode_folder_get_info(mfhttp * conn, void *data)
folderkey = json_object_get(node, "folderkey"); folderkey = json_object_get(node, "folderkey");
if (folderkey != NULL) if (folderkey != NULL)
folder_set_key(folder, (char *)json_string_value(folderkey)); folder_set_key(folder, json_string_value(folderkey));
folder_name = json_object_get(node, "name"); folder_name = json_object_get(node, "name");
if (folder_name != NULL) if (folder_name != NULL)
folder_set_name(folder, (char *)json_string_value(folder_name)); folder_set_name(folder, json_string_value(folder_name));
parent_folder = json_object_get(node, "parent_folderkey"); parent_folder = json_object_get(node, "parent_folderkey");
if (parent_folder != NULL) { if (parent_folder != NULL) {
folder_set_parent(folder, (char *)json_string_value(parent_folder)); folder_set_parent(folder, json_string_value(parent_folder));
} }
// infer that the parent folder must be "myfiles" root // infer that the parent folder must be "myfiles" root
if (parent_folder == NULL && folderkey != NULL) if (parent_folder == NULL && folderkey != NULL)

View File

@@ -30,7 +30,7 @@ static int _decode_user_get_info(mfhttp * conn, void *data);
int mfconn_api_user_get_info(mfconn * conn) int mfconn_api_user_get_info(mfconn * conn)
{ {
char *api_call; const char *api_call;
int retval; int retval;
mfhttp *http; mfhttp *http;
@@ -46,7 +46,7 @@ int mfconn_api_user_get_info(mfconn * conn)
retval = http_get_buf(http, api_call, _decode_user_get_info, NULL); retval = http_get_buf(http, api_call, _decode_user_get_info, NULL);
http_destroy(http); http_destroy(http);
free(api_call); free((void *)api_call);
return retval; return retval;
} }
@@ -69,15 +69,15 @@ static int _decode_user_get_info(mfhttp * conn, void *data)
email = json_object_get(node, "email"); email = json_object_get(node, "email");
if (email != NULL) if (email != NULL)
printf("Email: %s\n\r", (char *)json_string_value(email)); printf("Email: %s\n\r", json_string_value(email));
first_name = json_object_get(node, "first_name"); first_name = json_object_get(node, "first_name");
if (first_name != NULL) if (first_name != NULL)
printf("Name: %s ", (char *)json_string_value(first_name)); printf("Name: %s ", json_string_value(first_name));
last_name = json_object_get(node, "last_name"); last_name = json_object_get(node, "last_name");
if (node != NULL) if (node != NULL)
printf("%s", (char *)json_string_value(last_name)); printf("%s", json_string_value(last_name));
printf("\n\r"); printf("\n\r");

View File

@@ -38,15 +38,16 @@ struct user_get_session_token_response {
}; };
int int
mfconn_api_user_get_session_token(mfconn * conn, char *server, mfconn_api_user_get_session_token(mfconn * conn, const char *server,
char *username, char *password, const char *username, const char *password,
int app_id, char *app_key, int app_id, const char *app_key,
uint32_t * secret_key, uint32_t * secret_key,
char **secret_time, char **session_token) char **secret_time,
char **session_token)
{ {
char *login_url; char *login_url;
char *post_args; char *post_args;
char *user_signature; const char *user_signature;
int retval; int retval;
struct user_get_session_token_response response; struct user_get_session_token_response response;
mfhttp *http; mfhttp *http;
@@ -69,7 +70,7 @@ mfconn_api_user_get_session_token(mfconn * conn, char *server,
"&token_version=2" "&token_version=2"
"&response_format=json", "&response_format=json",
username, password, user_signature); username, password, user_signature);
free(user_signature); free((void *)user_signature);
http = http_create(); http = http_create();
retval = retval =

View File

@@ -217,11 +217,11 @@ const char *file_get_onetime_link(mffile * file)
return file->onetime_link; return file->onetime_link;
} }
ssize_t file_download_direct(mffile * file, char *local_dir) ssize_t file_download_direct(mffile * file, const char *local_dir)
{ {
const char *url; const char *url;
const char *file_name; const char *file_name;
char *file_path; const char *file_path;
struct stat file_info; struct stat file_info;
ssize_t bytes_read = 0; ssize_t bytes_read = 0;
int retval; int retval;
@@ -258,7 +258,7 @@ ssize_t file_download_direct(mffile * file, char *local_dir)
memset(&file_info, 0, sizeof(file_info)); memset(&file_info, 0, sizeof(file_info));
retval = stat(file_path, &file_info); retval = stat(file_path, &file_info);
free(file_path); free((void *)file_path);
if (retval != 0) if (retval != 0)
return -1; return -1;

View File

@@ -52,6 +52,6 @@ int file_set_onetime_link(mffile * file, const char *onetime_link);
const char *file_get_onetime_link(mffile * file); const char *file_get_onetime_link(mffile * file);
ssize_t file_download_direct(mffile * file, char *local_dir); ssize_t file_download_direct(mffile * file, const char *local_dir);
#endif #endif

View File

@@ -35,8 +35,9 @@ struct mfconn {
char *session_token; char *session_token;
}; };
mfconn *mfconn_create(char *server, char *username, char *password, mfconn *mfconn_create(const char *server, const char *username,
int app_id, char *app_key) const char *password, int app_id,
const char *app_key)
{ {
mfconn *conn; mfconn *conn;
int retval; int retval;
@@ -80,9 +81,10 @@ void mfconn_update_secret_key(mfconn * conn)
return; return;
} }
char *mfconn_create_user_signature(mfconn * conn, char *username, const char *mfconn_create_user_signature(mfconn * conn,
char *password, int app_id, const char *username,
char *app_key) const char *password, int app_id,
const char *app_key)
{ {
char *signature_raw; char *signature_raw;
unsigned char signature_enc[20]; // sha1 is 160 bits unsigned char signature_enc[20]; // sha1 is 160 bits
@@ -108,8 +110,8 @@ char *mfconn_create_user_signature(mfconn * conn, char *username,
return strdup((const char *)signature_hex); return strdup((const char *)signature_hex);
} }
char *mfconn_create_call_signature(mfconn * conn, char *url, const char *mfconn_create_call_signature(mfconn * conn, const char *url,
char *args) const char *args)
{ {
char *signature_raw; char *signature_raw;
unsigned char signature_enc[16]; // md5 is 128 bits unsigned char signature_enc[16]; // md5 is 128 bits
@@ -148,13 +150,14 @@ char *mfconn_create_call_signature(mfconn * conn, char *url,
return strdup((const char *)signature_hex); return strdup((const char *)signature_hex);
} }
char *mfconn_create_signed_get(mfconn * conn, int ssl, char *api, const char *mfconn_create_signed_get(mfconn * conn, int ssl,
char *fmt, ...) const char *api,
const char *fmt, ...)
{ {
char *api_request = NULL; char *api_request = NULL;
char *api_args = NULL; char *api_args = NULL;
char *signature; char *signature;
char *call_hash; const char *call_hash;
char *session_token; char *session_token;
int bytes_to_alloc; int bytes_to_alloc;
int api_args_len; int api_args_len;
@@ -200,14 +203,14 @@ char *mfconn_create_signed_get(mfconn * conn, int ssl, char *api,
// correct user error of trailing slash // correct user error of trailing slash
if (api[api_len - 1] == '/') if (api[api_len - 1] == '/')
api[api_len - 1] = '\0'; return NULL;
api_request = strdup_printf("%s//%s/api/%s", api_request = strdup_printf("%s//%s/api/%s",
(ssl ? "https:" : "http:"), conn->server, api); (ssl ? "https:" : "http:"), conn->server, api);
call_hash = mfconn_create_call_signature(conn, api_request, api_args); call_hash = mfconn_create_call_signature(conn, api_request, api_args);
signature = strdup_printf("&signature=%s", call_hash); signature = strdup_printf("&signature=%s", call_hash);
free(call_hash); free((void *)call_hash);
// compute the amount of space requred to realloc() the request // compute the amount of space requred to realloc() the request
bytes_to_alloc = api_args_len; bytes_to_alloc = api_args_len;

View File

@@ -26,19 +26,22 @@
typedef struct mfconn mfconn; typedef struct mfconn mfconn;
mfconn *mfconn_create(char *server, char *username, char *password, mfconn *mfconn_create(const char *server, const char *username,
int app_id, char *app_key); const char *password, int app_id,
const char *app_key);
void mfconn_destroy(mfconn * conn); void mfconn_destroy(mfconn * conn);
ssize_t mfconn_download_direct(mffile * file, char *local_dir); ssize_t mfconn_download_direct(mffile * file, const char *local_dir);
char *mfconn_create_signed_get(mfconn * conn, int ssl, char *api, const char *mfconn_create_signed_get(mfconn * conn, int ssl,
char *fmt, ...); const char *api, const char *fmt,
...);
char *mfconn_create_user_signature(mfconn * conn, char *username, const char *mfconn_create_user_signature(mfconn * conn,
char *password, int app_id, const char *username,
char *app_key); const char *password, int app_id,
const char *app_key);
void mfconn_update_secret_key(mfconn * conn); void mfconn_update_secret_key(mfconn * conn);

View File

@@ -22,36 +22,52 @@
#include "mfshell.h" #include "mfshell.h"
int mfshell_cmd_help(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_help(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_debug(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_debug(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_host(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_host(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_auth(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_auth(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_whomai(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_whomai(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_list(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_list(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_chdir(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_chdir(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_pwd(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_pwd(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_lpwd(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_lpwd(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_lcd(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_lcd(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_file(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_file(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_links(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_links(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_mkdir(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_mkdir(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_get(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_get(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_whoami(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_whoami(mfshell * mfshell, int argc,
char *const argv[]);
int mfshell_cmd_rmdir(mfshell * mfshell, int argc, char **argv); int mfshell_cmd_rmdir(mfshell * mfshell, int argc,
char *const argv[]);
#endif #endif

View File

@@ -32,7 +32,7 @@ static char *_get_login_from_user(void);
static char *_get_passwd_from_user(void); static char *_get_passwd_from_user(void);
int mfshell_cmd_auth(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_auth(mfshell * mfshell, int argc, char *const argv[])
{ {
char *username; char *username;
char *password; char *password;

View File

@@ -26,7 +26,7 @@
#include "../../mfapi/mfconn.h" #include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_chdir(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_chdir(mfshell * mfshell, int argc, char *const argv[])
{ {
mffolder *folder_new; mffolder *folder_new;
const char *folder_curr; const char *folder_curr;

View File

@@ -25,7 +25,7 @@
#include "../../mfapi/mfconn.h" #include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_debug(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_debug(mfshell * mfshell, int argc, char *const argv[])
{ {
(void)argv; (void)argv;
if (argc != 1) { if (argc != 1) {

View File

@@ -26,7 +26,7 @@
#include "../../mfapi/mfconn.h" #include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_file(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_file(mfshell * mfshell, int argc, char *const argv[])
{ {
mffile *file; mffile *file;
int len; int len;

View File

@@ -29,7 +29,7 @@
#include "../../mfapi/mfconn.h" #include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_get(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_get(mfshell * mfshell, int argc, char *const argv[])
{ {
mffile *file; mffile *file;
int len; int len;

View File

@@ -23,7 +23,7 @@
#include "../mfshell.h" #include "../mfshell.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_help(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_help(mfshell * mfshell, int argc, char *const argv[])
{ {
(void)argv; (void)argv;
unsigned int column1_width = 0; unsigned int column1_width = 0;

View File

@@ -28,7 +28,7 @@
static char *_get_host_from_user(void); static char *_get_host_from_user(void);
int mfshell_cmd_host(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_host(mfshell * mfshell, int argc, char *const argv[])
{ {
char *alt_host = NULL; char *alt_host = NULL;
char *host; char *host;

View File

@@ -25,7 +25,7 @@
#include "../mfshell.h" #include "../mfshell.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_lcd(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_lcd(mfshell * mfshell, int argc, char *const argv[])
{ {
int retval; int retval;
const char *dir; const char *dir;

View File

@@ -26,7 +26,7 @@
#include "../../mfapi/mfconn.h" #include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_links(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_links(mfshell * mfshell, int argc, char *const argv[])
{ {
mffile *file; mffile *file;
int len; int len;

View File

@@ -25,7 +25,7 @@
#include "../../mfapi/mfconn.h" #include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_list(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[])
{ {
(void)argv; (void)argv;
int retval; int retval;

View File

@@ -25,7 +25,7 @@
#include "../mfshell.h" #include "../mfshell.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_lpwd(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_lpwd(mfshell * mfshell, int argc, char *const argv[])
{ {
(void)argv; (void)argv;
if (mfshell == NULL) if (mfshell == NULL)

View File

@@ -25,7 +25,7 @@
#include "../../mfapi/mfconn.h" #include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_mkdir(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_mkdir(mfshell * mfshell, int argc, char *const argv[])
{ {
int retval; int retval;
const char *folder_curr; const char *folder_curr;

View File

@@ -25,7 +25,7 @@
#include "../../mfapi/folder.h" #include "../../mfapi/folder.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_pwd(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_pwd(mfshell * mfshell, int argc, char *const argv[])
{ {
(void)argv; (void)argv;
const char *folder_name; const char *folder_name;

View File

@@ -25,7 +25,7 @@
#include "../../mfapi/mfconn.h" #include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_rmdir(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_rmdir(mfshell * mfshell, int argc, char *const argv[])
{ {
int retval; int retval;
const char *folderkey; const char *folderkey;

View File

@@ -24,7 +24,7 @@
#include "../../mfapi/mfconn.h" #include "../../mfapi/mfconn.h"
#include "../commands.h" // IWYU pragma: keep #include "../commands.h" // IWYU pragma: keep
int mfshell_cmd_whoami(mfshell * mfshell, int argc, char **argv) int mfshell_cmd_whoami(mfshell * mfshell, int argc, char *const argv[])
{ {
(void)argv; (void)argv;
int retval; int retval;

View File

@@ -31,7 +31,7 @@ static void mfshell_run(mfshell * shell);
static void mfshell_parse_commands(mfshell * shell, char *command); static void mfshell_parse_commands(mfshell * shell, char *command);
void print_help(char *cmd) void print_help(const char *cmd)
{ {
fprintf(stderr, "A shell to access a MediaFire account.\n"); fprintf(stderr, "A shell to access a MediaFire account.\n");
fprintf(stderr, "\n"); fprintf(stderr, "\n");
@@ -61,7 +61,7 @@ void print_help(char *cmd)
} }
void void
parse_argv(int argc, char **argv, char **username, parse_argv(int argc, char *const argv[], char **username,
char **password, char **server, char **command) char **password, char **server, char **command)
{ {
static struct option long_options[] = { static struct option long_options[] = {
@@ -117,7 +117,7 @@ parse_argv(int argc, char **argv, char **username,
} }
} }
int main(int argc, char **argv) int main(int argc, char *const argv[])
{ {
mfshell *shell; mfshell *shell;
char *server = "www.mediafire.com"; char *server = "www.mediafire.com";

View File

@@ -85,7 +85,7 @@ mfshell *mfshell_create(int app_id, char *app_key, char *server)
return shell; return shell;
} }
int mfshell_exec(mfshell * shell, int argc, char **argv) int mfshell_exec(mfshell * shell, int argc, char *const argv[])
{ {
mfcmd *curr_cmd; mfcmd *curr_cmd;

View File

@@ -33,7 +33,7 @@ struct mfcmd {
char *name; char *name;
char *argstring; char *argstring;
char *help; char *help;
int (*handler) (mfshell * mfshell, int argc, char **argv); int (*handler) (mfshell * mfshell, int argc, char *const argv[]);
}; };
struct mfshell { struct mfshell {
@@ -57,7 +57,7 @@ mfshell *mfshell_create(int app_id, char *app_key, char *server);
int mfshell_authenticate_user(mfshell * mfshell); int mfshell_authenticate_user(mfshell * mfshell);
int mfshell_exec(mfshell * mfshell, int argc, char **argv); int mfshell_exec(mfshell * mfshell, int argc, char *const argv[]);
int mfshell_exec_shell_command(mfshell * mfshell, char *command); int mfshell_exec_shell_command(mfshell * mfshell, char *command);

View File

@@ -17,4 +17,4 @@ esac
cmd="valgrind --suppressions="${source_dir}/valgrind.supp" --fullpath-after="$source_dir" --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes" cmd="valgrind --suppressions="${source_dir}/valgrind.supp" --fullpath-after="$source_dir" --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes"
$cmd "${binary_dir}/mfshell" -c "help; whoami" $cmd "${binary_dir}/mediafire-shell" -c "help; whoami"