diff --git a/libmobile.c b/libmobile.c index 0484c46fcb40e41ff889d96e0599a668b010f1bf..e856f1e58b992e4df2fe244c9af9a0f8ecaadee9 100644 --- a/libmobile.c +++ b/libmobile.c @@ -12,12 +12,22 @@ struct string { size_t len; }; +enum { + POST, + GET +}; + static void curl_cleaner(CURLcode *curl); -static size_t write_func(void *buffer, size_t size, size_t nmemb, void *userp); +static size_t write_func(void *buffer, size_t size, size_t nmemb, void *data); static int apn_profile_idx(struct json_object *apn_profiles, char *name); static int get_apn_profiles_len(void); static char *lexer(char **input, char *delimiter); static char *get_query_wrapper(char *vars); +static CURLcode *perform_post_request(curl, query, str); +static CURLcode *perform_post_request(curl, query, str); +static struct json_object *perform_post_request(char *query); +static struct json_object *perform_get_request(char *vars); +static struct json_object *parse_apn_profiles(char *apn_profiles); /** * Function: curl_cleaner @@ -36,32 +46,35 @@ static void curl_cleaner(CURLcode *curl) /** * Function: write_func * - * The callback function from performing the curl command, response from server will be parsed here. + * The callback function from performing the curl command, response from server will be reconstructed here. * * Parameters: * buffer - Contains chunk of response from server. * size - Size (byte) of type in buffer array. * nmemb - Number of members in buffer. - * userp - Pointer to area allocated for storing results from server. + * data - Pointer to area allocated for storing results from server. * * Returns: * Number of bytes managed (size*nmemb). */ -static size_t write_func(void *buffer, size_t size, size_t nmemb, void *userp) +static size_t write_func(void *buffer, size_t size, size_t nmemb, void *data) { - struct string *str = (struct string *)userp; - size_t new_len = str->len + (size * nmemb); + struct string *str = (struct string *)data; + size_t len = size *nmemb; + size_t new_len = str->len + (len); + char *tmp_ptr = str->ptr; str->ptr = realloc(str->ptr, new_len + 1); - if (str->ptr == NULL) { - printf("not enough ptr (realloc returned NULL)\n"); + if (!str->ptr) { + printf("not enough memory (realloc returned NULL)\n"); + free(tmp_ptr); return 0; } - memcpy(str->ptr + str->len, buffer, size * nmemb); + memcpy(str->ptr + str->len, buffer, len); str->ptr[new_len] = '\0'; str->len = new_len; - return size * nmemb; + return len; } /** @@ -207,18 +220,130 @@ static char *get_query_wrapper(char *vars) return strdup(query); } -struct json_object *parse_apn_profiles(char *apn_profiles) +/** + * Function: perform_post_request + * + * Executes a prepared HTTP POST query through use of the libcurl lbirary. + * + * Parameter: + * curl - the CURL environment. + * query - The HTTP POST query to execute. + * str - a string struct containing the current data pointer and the length of the data currently written. + * + * Returns: + * The CURLcode indicating the success or failure of the curl execution. + */ +static CURLcode *perform_post_request(curl, query, str) +{ + curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.0.1/goform/goform_set_cmd_process"); + curl_easy_setopt(curl, CURLOPT_REFERER, "http://192.168.0.1/index.html"); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, query); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_func); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, str); + + return curl_easy_perform(curl); +} + +/** + * Function: perform_get_request + * + * Executes a prepared HTTP GET query through use of the libcurl lbirary. + * + * Parameter: + * curl - the CURL environment. + * query - The HTTP GET query to execute. + * str - a string struct containing the current data pointer and the length of the data currently written. + * + * Returns: + * The CURLcode indicating the success or failure of the curl execution. + */ +static CURLcode *perform_get_request(CURL *curl, char *query, struct string *str) +{ + curl_easy_setopt(curl, CURLOPT_URL, query); + curl_easy_setopt(curl, CURLOPT_REFERER, "http://192.168.0.1/index.html"); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_func); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, str); + + return curl_easy_perform(curl); +} + +/** + * Function: send_post_request + * + * Function that prepares curl environment and final POST query, then executes said query. + * + * Parameter: + * query - The POST query content to execute. + * + * Returns: + * A pointer to a json_object containing the JSON response from the server. + * NULL on failure. + */ +static struct json_object *prepare_request(char *query, int option) { - if (strlen(apn_profiles) <= 0) { - printf("No APN profiles provided!\n"); + CURL *curl; + CURLcode rv; + struct string str = {NULL, 0}; + + str.ptr = calloc(1, 1); + if (!str.ptr) { + printf("Error allocating memory with calloc"); goto fail; } - struct json_object *apn_profiles_json = json_tokener_parse(apn_profiles); - - if (!apn_profiles_json) { - printf("Not valid json!\n"); + curl = curl_easy_init(); + if (!curl) { + printf("Failed to prepare curl environment!\n"); + goto fail_curl; + } + if (option == POST) + rv = perform_post_request(curl, query, &str); + else if (option == GET) { + query = get_query_wrapper(query); + rv = perform_get_request(curl, query, &str); + } + if (rv) { + printf("error performing curl, %s\n", curl_easy_strerror(rv)); goto fail; } + if (!str.ptr) + goto fail_ptr; + struct json_object *parsed_response = json_tokener_parse(str.ptr); + + if (!parsed_response) { + DEBUG("No valid JSON, failed parsing!\n"); + goto fail_json; + } + + free(query); + curl_cleaner(curl); + free(str.ptr); + return parsed_response; +fail_json: +fail_ptr: + curl_cleaner(curl); +fail_curl: + free(str.ptr); +fail: + free(query); + return NULL; +} + +/** + * Function: parse_apn_profiles + * + * Takes a string of APN profile configurations provided by zte-mf823 (which is in an awkward, difficult to read format) + * and transforms them into a more easily read and worked with JSON format. + * + * Parameters: + * apn_profiles - A character string containing the APN profiles. + * + * Returns: + * The newly generated JSON on success. + * NULL on failure. + */ + +static struct json_object *parse_apn_profiles(json_object *apn_profiles) +{ struct json_object *parsed_profiles = json_object_new_object(); int apn_counter = 0; char *field_names[13] = {"profile_name", "apn_name", "mode", "wan_dial", "ppp_auth_mode", "ppp_username", "ppp_passwd", "pdp", "pdpd_select", "pdp_addr", "dns_mode", "prefer_dns_manual", "standby_dns_manual"}; @@ -259,17 +384,17 @@ finished: } -char *mobile_connect_network(void) +struct json_object *mobile_connect_network(void) { - return mobile_post_request("isTest=false&goformId=CONNECT_NETWORK"); + return prepare_request("isTest=false&goformId=CONNECT_NETWORK", POST); } -char *mobile_disconnect_network(void) +struct json_object *mobile_disconnect_network(void) { - return mobile_post_request("isTest=false&goformId=DISCONNECT_NETWORK"); + return prepare_request("isTest=false&goformId=DISCONNECT_NETWORK", POST); } -char *mobile_delete_apn(char *name) +struct json_object *mobile_delete_apn(char *name) { char *response = mobile_get_apn_profiles(); @@ -296,7 +421,7 @@ char *mobile_delete_apn(char *name) json_object_put(parsed_response); free(response); - return mobile_post_request(query); + return prepare_request(query, POST); free_all: json_object_put(parsed_response); @@ -306,52 +431,60 @@ fail: return NULL; } -char *mobile_enable_roaming(void) +struct json_object *mobile_enable_roaming(void) { - return mobile_post_request("isTest=false&goformId=SET_CONNECTION_MODE&roam_setting_option=on"); + return prepare_request("isTest=false&goformId=SET_CONNECTION_MODE&roam_setting_option=on", POST); } -char *mobile_disable_roaming(void) +struct json_object *mobile_disable_roaming(void) { - return mobile_post_request("isTest=false&goformId=SET_CONNECTION_MODE&roam_setting_option=off"); + return prepare_request("isTest=false&goformId=SET_CONNECTION_MODE&roam_setting_option=off", POST); } -char *mobile_get_roam_status(void) +struct json_object *mobile_get_roam_status(void) { - return mobile_get_request("roam_setting_option"); + return prepare_request("roam_setting_option", GET); } -char *mobile_get_wan_apn(void) +struct json_object *mobile_get_wan_apn(void) { - return mobile_get_request("wan_apn"); + return prepare_request("wan_apn", GET); } -char *mobile_get_pinnumber(void) +struct json_object *mobile_get_pinnumber(void) { - return mobile_get_request("pinnumber"); + return prepare_request("pinnumber", GET); } -char *mobile_get_pin_status(void) +struct json_object *mobile_get_pin_status(void) { - return mobile_get_request("pin_status"); + return prepare_request("pin_status", GET); } -char *mobile_get_rssi(void) +struct json_object *mobile_get_rssi(void) { - return mobile_get_request("rssi"); + return prepare_request("rssi", GET); } -char *mobile_get_modem_state(void) +struct json_object *mobile_get_modem_state(void) { - return mobile_get_request("&sms_received_flag_flag=0&sts_received_flag_flag=0&cmd=modem_main_state%2Cpin_status%2Cloginfo%2Cnew_version_state%2Ccurrent_upgrade_state%2Cis_mandatory%2Csms_received_flag%2Csts_received_flag%2Csignalbar%2Cnetwork_type%2Cnetwork_provider%2Cppp_status%2CEX_SSID1%2Cex_wifi_status%2CEX_wifi_profile%2Cm_ssid_enable%2Csms_unread_num%2CRadioOff%2Csimcard_roam%2Clan_ipaddr%2Cstation_mac%2Cbattery_charging%2Cbattery_vol_percent%2Cbattery_pers%2Cspn_display_flag%2Cplmn_display_flag%2Cspn_name_data%2Cspn_b1_flag%2Cspn_b2_flag%2Crealtime_tx_bytes%2Crealtime_rx_bytes%2Crealtime_time%2Crealtime_tx_thrpt%2Crealtime_rx_thrpt%2Cmonthly_rx_bytes%2Cmonthly_tx_bytes%2Cmonthly_time%2Cdate_month%2Cdata_volume_limit_switch%2Cdata_volume_limit_size%2Cdata_volume_alert_percent%2Cdata_volume_limit_unit%2Croam_setting_option%2Cupg_roam_switch%2Chplmn"); + return prepare_request("&sms_received_flag_flag=0&sts_received_flag_flag=0&cmd=modem_main_state%2Cpin_status%2Cloginfo%2Cnew_version_state%2Ccurrent_upgrade_state%2Cis_mandatory%2Csms_received_flag%2Csts_received_flag%2Csignalbar%2Cnetwork_type%2Cnetwork_provider%2Cppp_status%2CEX_SSID1%2Cex_wifi_status%2CEX_wifi_profile%2Cm_ssid_enable%2Csms_unread_num%2CRadioOff%2Csimcard_roam%2Clan_ipaddr%2Cstation_mac%2Cbattery_charging%2Cbattery_vol_percent%2Cbattery_pers%2Cspn_display_flag%2Cplmn_display_flag%2Cspn_name_data%2Cspn_b1_flag%2Cspn_b2_flag%2Crealtime_tx_bytes%2Crealtime_rx_bytes%2Crealtime_time%2Crealtime_tx_thrpt%2Crealtime_rx_thrpt%2Cmonthly_rx_bytes%2Cmonthly_tx_bytes%2Cmonthly_time%2Cdate_month%2Cdata_volume_limit_switch%2Cdata_volume_limit_size%2Cdata_volume_alert_percent%2Cdata_volume_limit_unit%2Croam_setting_option%2Cupg_roam_switch%2Chplmn", GET); } -char *mobile_get_apn_profiles(void) +struct json_object *mobile_get_apn_profiles(void) { - return mobile_get_request("APN_config0,APN_config1,APN_config2,APN_config3,APN_config4,APN_config5,APN_config6,APN_config7,APN_config8,APN_config9,APN_config10,APN_config11,APN_config12,APN_config13,APN_config14,APN_config15,APN_config16,APN_config17,APN_config18,APN_config19"); + struct json_object *parsed_response = prepare_request("APN_config0,APN_config1,APN_config2,APN_config3,APN_config4,APN_config5,APN_config6,APN_config7,APN_config8,APN_config9,APN_config10,APN_config11,APN_config12,APN_config13,APN_config14,APN_config15,APN_config16,APN_config17,APN_config18,APN_config19", GET); + + if (!parsed_response) { + printf("Error getting profiles!\n"); + goto fail; + } + return parse_apn_profiles(parsed_response); +fail: + return NULL; } -char *mobile_create_apn_profile(char *name) +struct json_object *mobile_create_apn_profile(char *name) { char query[1024] = {0}; @@ -363,10 +496,10 @@ char *mobile_create_apn_profile(char *name) strncat(query + strlen(query), name, 1023); strncat(query + strlen(query), "&ppp_auth_mode=none&ppp_username=&ppp_passwd=&dns_mode=auto&prefer_dns_manual=&standby_dns_manual=", 1023); - return mobile_post_request(query); + return prepare_request(query, POST); } -char *mobile_set_apn_profile(char *name) +struct json_object *mobile_set_apn_profile(char *name) { char *response = mobile_get_apn_profiles(); @@ -393,7 +526,7 @@ char *mobile_set_apn_profile(char *name) json_object_put(parsed_response); free(response); - return mobile_post_request(query); + return prepare_request(query, POST); free_all: json_object_put(parsed_response); @@ -403,7 +536,7 @@ fail: return NULL; } -char *mobile_enable_pin(char *pin) +struct json_object *mobile_enable_pin(char *pin) { char query[1024] = {0}; @@ -411,10 +544,10 @@ char *mobile_enable_pin(char *pin) strncat(query + strlen(query), pin, 1023); strncat(query + strlen(query), "&pin_save_flag=0&isTest=false", 1023); - return mobile_post_request(query); + return prepare_request(query, POST); } -char *mobile_set_pin(char *current_pin, char *new_pin) +struct json_object *mobile_set_pin(char *current_pin, char *new_pin) { char query[1024] = {0}; @@ -424,10 +557,10 @@ char *mobile_set_pin(char *current_pin, char *new_pin) strncat(query + strlen(query), new_pin, 1023); strncat(query + strlen(query), "&pin_save_flag=0&isTest=false", 1023); - return mobile_post_request(query); + return prepare_request(query, POST); } -char *mobile_disable_pin(char *pin) +struct json_object *mobile_disable_pin(char *pin) { char query[1024] = {0}; @@ -435,67 +568,5 @@ char *mobile_disable_pin(char *pin) strncat(query + strlen(query), pin, 1023); strncat(query + strlen(query), "&pin_save_flag=0&isTest=false", 1023); - return mobile_post_request(query); -} - -char *mobile_post_request(char *query) -{ - CURL *curl; - CURLcode res; - struct string str; - - str.ptr = calloc(1, 1); - str.len = 0; - curl = curl_easy_init(); - - if (curl) { - curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.0.1/goform/goform_set_cmd_process"); - curl_easy_setopt(curl, CURLOPT_REFERER, "http://192.168.0.1/index.html"); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, query); - - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_func); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &str); - res = curl_easy_perform(curl); - if (res) { - printf("errored when performing curl, %s\n", curl_easy_strerror(res)); - goto fail; - } - } - - curl_cleaner(curl); - return str.ptr; -fail: - return NULL; -} - -char *mobile_get_request(char *vars) -{ - CURL *curl; - CURLcode res; - struct string str; - char *query = get_query_wrapper(vars); - - if (!query) - goto fail; - - str.ptr = calloc(1, 1); - str.len = 0; - curl = curl_easy_init(); - if (curl) { - curl_easy_setopt(curl, CURLOPT_URL, query); - curl_easy_setopt(curl, CURLOPT_REFERER, "http://192.168.0.1/index.html"); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_func); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &str); - res = curl_easy_perform(curl); - if (res) { - printf("errored when performing curl, %s\n", curl_easy_strerror(res)); - goto fail; - } - } - - free(query); - curl_cleaner(curl); - return str.ptr; -fail: - return NULL; -} + return prepare_request(query, POST); +} \ No newline at end of file diff --git a/libmobile.h b/libmobile.h index 2d7e50a94248f5bc086974b861e7813e69de0bcc..c31381d2917078d0336cc80af92a1ded384d641b 100644 --- a/libmobile.h +++ b/libmobile.h @@ -41,33 +41,16 @@ * ***************************************************/ -/** - * __TEMPORARILY PLACED IN THIS HEAD__ - * Function: parse_apn_profiles - * - * Takes a string of APN profile configurations provided by zte-mf823 (which is in an awkward, difficult to read format) - * and transforms them into a more easily read and worked with JSON format. - * - * Parameters: - * apn_profiles - A character string containing the APN profiles. - * - * Returns: - * The newly generated JSON on success. - * NULL on failure. - */ -struct json_object *parse_apn_profiles(char *apn_profiles); - /** * Function: mobile_connect_network * * Connects the dongle's network. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. +* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_connect_network(void); +struct json_object *mobile_connect_network(void); /** * Function: mobile_disconnect_network @@ -75,11 +58,10 @@ char *mobile_connect_network(void); * Disconnects the dongle's network. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. +* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_disconnect_network(void); +struct json_object *mobile_disconnect_network(void); /** * Function: mobile_delete_apn @@ -90,11 +72,10 @@ char *mobile_disconnect_network(void); * name - The name of the APN profile to be removed. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. +* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_delete_apn(char *name); +struct json_object *mobile_delete_apn(char *name); /** * Function: mobile_enable_roaming @@ -102,11 +83,10 @@ char *mobile_delete_apn(char *name); * Enables the roaming option on the dongle. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. +* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_enable_roaming(void); +struct json_object *mobile_enable_roaming(void); /** * Function: mobile_disable_roaming @@ -114,11 +94,10 @@ char *mobile_enable_roaming(void); * Disables the roaming option on the dongle. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. +* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_disable_roaming(void); +struct json_object *mobile_disable_roaming(void); /** * Function: mobile_disable_roaming @@ -126,10 +105,10 @@ char *mobile_disable_roaming(void); * Gets the current roam status of the dongle. * * Returns: - * A string containing the servers response in JSON format, {"roam_setting_option": "on"/"off" } + * A pointer to a json_object containing the JSON response from the server. {"roam_setting_option": "on"/"off" } * NULL on failure. */ -char *mobile_get_roam_status(void); +struct json_object *mobile_get_roam_status(void); /** * Function: mobile_get_wan_apn @@ -137,10 +116,10 @@ char *mobile_get_roam_status(void); * Gets the currently active APN profile's WAN name. * * Returns: - * A string containing the servers response in JSON format, {"wan_apn": "<name>" } on success. + * A pointer to a json_object containing the JSON response from the server. {"wan_apn": "<name>" } on success. * NULL on failure. */ -char *mobile_get_wan_apn(void); +struct json_object *mobile_get_wan_apn(void); /** * Function: mobile_get_pinnumber @@ -148,10 +127,10 @@ char *mobile_get_wan_apn(void); * Gets the pinnumber, indicating how many tries are remaining before the SIM card is locked. * * Returns: - * A string containing the servers response in JSON format, {"pinnumber": {1..3} } on success. + * A pointer to a json_object containing the JSON response from the server. {"pinnumber": {1..3} } on success. * NULL on failure. */ -char *mobile_get_pinnumber(void); +struct json_object *mobile_get_pinnumber(void); /** * Function: mobile_get_pin_status @@ -159,10 +138,10 @@ char *mobile_get_pinnumber(void); * Gets the pinnumber, indicating whether pin is enabled or not. * * Returns: - * A string containing the servers response in JSON format, {"pinnumber": {0..1} } on success. + * A pointer to a json_object containing the JSON response from the server. {"pinnumber": {0..1} } on success. * NULL on failure. */ -char *mobile_get_pin_status(void); +struct json_object *mobile_get_pin_status(void); /** * Function: mobile_get_rssi @@ -170,10 +149,10 @@ char *mobile_get_pin_status(void); * Gets the rssi, indicating the signal strength. * * Returns: - * A string containing the servers response in JSON format, {"rssi": {} } on success. + * A pointer to a json_object containing the JSON response from the server. {"rssi": {} } on success. * NULL on failure. */ -char *mobile_get_rssi(void); +struct json_object *mobile_get_rssi(void); /** * Function: mobile_get_modem_state @@ -181,10 +160,10 @@ char *mobile_get_rssi(void); * Gets a variety of variables related to the modems state, i.e. network. * * Returns: - * A string containing the servers response in JSON format on success. + * A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_get_modem_state(void); +struct json_object *mobile_get_modem_state(void); /** * Function: mobile_get_apn_profiles @@ -192,10 +171,10 @@ char *mobile_get_modem_state(void); * Gets all available APN profile names. * * Returns: - * A string containing the servers response in JSON format on success. + * A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_get_apn_profiles(void); +struct json_object *mobile_get_apn_profiles(void); /** * Function: mobile_create_apn_profile @@ -206,11 +185,10 @@ char *mobile_get_apn_profiles(void); * name - Name of the APN (and WAN) profile to create. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. + * A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_create_apn_profile(char *name); +struct json_object *mobile_create_apn_profile(char *name); /** * Function: mobile_set_apn_profile @@ -221,11 +199,10 @@ char *mobile_create_apn_profile(char *name); * name - Name of the APN profile to activate. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. + * A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_set_apn_profile(char *name); +struct json_object *mobile_set_apn_profile(char *name); /** * Function: mobile_enable_pin @@ -236,11 +213,10 @@ char *mobile_set_apn_profile(char *name); * pin - The current pin card of the SIM. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. + * A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_enable_pin(char *pin); +struct json_object *mobile_enable_pin(char *pin); /** * Function: mobile_set_pin @@ -252,11 +228,10 @@ char *mobile_enable_pin(char *pin); * new_pin - The pin code which to set as the active pin for the SIM card. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. + * A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_set_pin(char *current_pin, char *new_pin); +struct json_object *mobile_set_pin(char *current_pin, char *new_pin); /** * Function: mobile_disable_pin @@ -267,39 +242,8 @@ char *mobile_set_pin(char *current_pin, char *new_pin); * pin - Currently active pin. * * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. - * NULL on failure. - */ -char *mobile_disable_pin(char *pin); - -/** - * Function: mobile_post_request - * - * Function that prepares curl environment and final POST query, then executes said query. - * - * Parameter: - * query - The POST query content to execute. - * - * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. - * NULL on failure. - */ -char *mobile_post_request(char *query); - -/** - * Function: mobile_get_request - * - * Function that prepares curl environment and final GET query, then executes said query. - * - * Parameter: - * vars - A string of comma separated values which to get from the server. - * - * Returns: - * A string containing the servers response (a json string containing {"result": "success"/"failure" }), - indicating whether the server successfully executed the query. + * A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"} * NULL on failure. */ -char *mobile_get_request(char *vars); +struct json_object *mobile_disable_pin(char *pin); #endif \ No newline at end of file