Skip to content
Snippets Groups Projects
Commit 4de59035 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

small change to output format

parent a928df73
Branches
No related tags found
No related merge requests found
...@@ -179,6 +179,34 @@ static char *lexer(char **input, char *delimiter) { ...@@ -179,6 +179,34 @@ static char *lexer(char **input, char *delimiter) {
return substr; return substr;
} }
/**
* Function: get_query_wrapper
* Wraps the input comma-separated values to the appropriate address format for a GET request.
*
* Parameters:
* vars - Char pointer pointing to comma-separated values to retreive.
*
* Returns:
* The entire query on success.
* NULL on failure.
*/
static char *get_query_wrapper(char *vars)
{
if (strlen(vars) == 0)
{
printf("No GET input provided!\n");
return NULL;
}
char query[1024] = {0};
strncpy(query, "http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=", 1023);
strncat(query + strlen(query), vars, 1023);
strncat(query + strlen(query), "&multi_data=1", 1023);
return strdup(query);
}
struct json_object *parse_apn_profiles(char *apn_profiles) struct json_object *parse_apn_profiles(char *apn_profiles)
{ {
if (strlen(apn_profiles) <= 0) { if (strlen(apn_profiles) <= 0) {
...@@ -210,8 +238,10 @@ struct json_object *parse_apn_profiles(char *apn_profiles) ...@@ -210,8 +238,10 @@ struct json_object *parse_apn_profiles(char *apn_profiles)
i++; i++;
free(field_val); free(field_val);
} }
char name[1024]; char name[1024] = {0};
sprintf(name, "%d", apn_counter);
strncpy(name, "apn_config_", 1023);
sprintf(name + strlen(name), "%d", apn_counter);
json_object_object_add(parsed_profiles, name, json_object_get(apn_profile)); json_object_object_add(parsed_profiles, name, json_object_get(apn_profile));
json_object_put(apn_profile); json_object_put(apn_profile);
apn_counter++; apn_counter++;
...@@ -224,7 +254,6 @@ free_objects: ...@@ -224,7 +254,6 @@ free_objects:
fail: fail:
return NULL; return NULL;
finished: finished:
//best guess, free: apn_profiles_json
json_object_put(apn_profiles_json); json_object_put(apn_profiles_json);
return parsed_profiles; return parsed_profiles;
} }
...@@ -439,33 +468,6 @@ fail: ...@@ -439,33 +468,6 @@ fail:
return NULL; return NULL;
} }
/**
* Function: get_query_wrapper
* Wraps the input comma-separated values to the appropriate address format for a GET request.
*
* Parameters:
* vars - Char pointer pointing to comma-separated values to retreive.
*
* Returns:
* The entire query on success.
* NULL on failure.
*/
char *get_query_wrapper(char *vars)
{
if (strlen(vars) == 0) {
printf("No GET input provided!\n");
return NULL;
}
char query[1024] = {0};
strncpy(query, "http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=", 1023);
strncat(query + strlen(query), vars, 1023);
strncat(query + strlen(query), "&multi_data=1", 1023);
return strdup(query);
}
char *mobile_get_request(char *vars) char *mobile_get_request(char *vars)
{ {
CURL *curl; CURL *curl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment