fix indentation

This commit is contained in:
josch
2014-12-28 09:40:52 +01:00
parent b83eb74551
commit 0bd253bf28
9 changed files with 23 additions and 33 deletions

View File

@@ -335,8 +335,8 @@ static int filecache_download_file(const char *filecache_path,
file = file_alloc(); file = file_alloc();
retval = mfconn_api_file_get_links(conn, file, retval = mfconn_api_file_get_links(conn, file,
(char *)quickkey, (char *)quickkey,
LINK_TYPE_DIRECT_DOWNLOAD); LINK_TYPE_DIRECT_DOWNLOAD);
if (retval != 0) { if (retval != 0) {
fprintf(stderr, "mfconn_api_file_get_links failed\n"); fprintf(stderr, "mfconn_api_file_get_links failed\n");

View File

@@ -23,12 +23,12 @@
#include "../utils/http.h" #include "../utils/http.h"
#define X_LINK_TYPE(a,b,c) c, #define X_LINK_TYPE(a,b,c) c,
const char *link_types[]={ const char *link_types[] = {
#include "link_type.def" #include "link_type.def"
NULL NULL
}; };
#undef X_LINK_TYPE
#undef X_LINK_TYPE
int mfapi_check_response(json_t * response, const char *apicall) int mfapi_check_response(json_t * response, const char *apicall)
{ {

View File

@@ -47,8 +47,8 @@ enum mfconn_device_change_type {
enum { enum {
#include "link_type.def" #include "link_type.def"
}; };
#undef X_LINK_TYPE
#undef X_LINK_TYPE
struct mfconn_device_change { struct mfconn_device_change {
enum mfconn_device_change_type change; enum mfconn_device_change_type change;

View File

@@ -28,19 +28,17 @@
#include "../file.h" #include "../file.h"
#include "../apicalls.h" // IWYU pragma: keep #include "../apicalls.h" // IWYU pragma: keep
static int _decode_file_get_links(mfhttp * conn, void *data); static int _decode_file_get_links(mfhttp * conn, void *data);
int mfconn_api_file_get_links(mfconn * conn, mffile * file, int mfconn_api_file_get_links(mfconn * conn, mffile * file,
const char *quickkey,uint32_t link_mask) const char *quickkey, uint32_t link_mask)
{ {
const char *api_call; const char *api_call;
extern const char *link_types[]; // declared in apicalls.c extern const char *link_types[]; // declared in apicalls.c
char *link_params = NULL; int retval;
int retval; int len;
int len; mfhttp *http;
mfhttp *http; int i;
int i;
if (conn == NULL) if (conn == NULL)
return -1; return -1;
@@ -56,18 +54,14 @@ int mfconn_api_file_get_links(mfconn * conn, mffile * file,
if (len != 11 && len != 15) if (len != 11 && len != 15)
return -1; return -1;
link_params = strdup_printf("link_type=%s",
link_types[link_mask]);
for (i = 0; i < mfconn_get_max_num_retries(conn); i++) { for (i = 0; i < mfconn_get_max_num_retries(conn); i++) {
api_call = mfconn_create_signed_get(conn, 0, "file/get_links.php", api_call = mfconn_create_signed_get(conn, 0, "file/get_links.php",
"?quick_key=%s" "?quick_key=%s"
"&%s" "&link_type=%s"
"&response_format=json", "&response_format=json",
quickkey,link_params); quickkey, link_types[link_mask]);
if (api_call == NULL) { if (api_call == NULL) {
fprintf(stderr, "mfconn_create_signed_get failed\n"); fprintf(stderr, "mfconn_create_signed_get failed\n");
if(link_params != NULL) free(link_params);
return -1; return -1;
} }
@@ -95,8 +89,6 @@ int mfconn_api_file_get_links(mfconn * conn, mffile * file,
} }
} }
if(link_params != NULL) free(link_params);
return retval; return retval;
} }

View File

@@ -18,7 +18,7 @@
*/ */
#define _POSIX_C_SOURCE 200809L // for strdup #define _POSIX_C_SOURCE 200809L // for strdup
#define _BSD_SOURCE // for strdup on old systems #define _BSD_SOURCE // for strdup on old systems
#include <jansson.h> #include <jansson.h>
#include <stdlib.h> #include <stdlib.h>

View File

@@ -18,7 +18,7 @@
*/ */
#define _POSIX_C_SOURCE 200809L // for strdup #define _POSIX_C_SOURCE 200809L // for strdup
#define _BSD_SOURCE // for strdup on old systems #define _BSD_SOURCE // for strdup on old systems
#include <jansson.h> #include <jansson.h>
#include <stdlib.h> #include <stdlib.h>

View File

@@ -266,8 +266,7 @@ const char *mfconn_create_unsigned_get(mfconn * conn, int ssl,
api_request = strdup_printf("%s//%s/api/%s/%s", api_request = strdup_printf("%s//%s/api/%s/%s",
(ssl ? "https:" : "http:"), (ssl ? "https:" : "http:"),
conn->server, conn->server, MFAPI_VERSION, api);
MFAPI_VERSION, api);
// 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;
@@ -356,8 +355,7 @@ const char *mfconn_create_signed_get(mfconn * conn, int ssl,
api_request = strdup_printf("%s//%s/api/%s/%s", api_request = strdup_printf("%s//%s/api/%s/%s",
(ssl ? "https:" : "http:"), (ssl ? "https:" : "http:"),
conn->server, conn->server, MFAPI_VERSION, api);
MFAPI_VERSION, 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);

View File

@@ -79,8 +79,8 @@ int mfshell_cmd_get(mfshell * mfshell, int argc, char *const argv[])
} }
// request a direct download (streaming) link // request a direct download (streaming) link
retval = mfconn_api_file_get_links(mfshell->conn, file, retval = mfconn_api_file_get_links(mfshell->conn, file,
(char *)quickkey, (char *)quickkey,
LINK_TYPE_DIRECT_DOWNLOAD); LINK_TYPE_DIRECT_DOWNLOAD);
if (retval != 0) { if (retval != 0) {
file_free(file); file_free(file);

View File

@@ -62,8 +62,8 @@ int mfshell_cmd_links(mfshell * mfshell, int argc, char *const argv[])
// when the lower-level call gets updated to support multiple link types // when the lower-level call gets updated to support multiple link types
// this should be updated. // this should be updated.
retval = mfconn_api_file_get_links(mfshell->conn, file, retval = mfconn_api_file_get_links(mfshell->conn, file,
(char *)quickkey, (char *)quickkey,
LINK_TYPE_DIRECT_DOWNLOAD); LINK_TYPE_DIRECT_DOWNLOAD);
if (retval != 0) { if (retval != 0) {
fprintf(stderr, "api call unsuccessful\n"); fprintf(stderr, "api call unsuccessful\n");
} }