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

parse input apn profile to json, replace strtok with strsep for does not work with empty signs

parent e8c5ac4e
Branches
No related tags found
No related merge requests found
......@@ -24,11 +24,16 @@ fail:
int write_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx, struct ubus_request_data *req)
{
struct blob_buf bb;
printf("här kan man va\n");
memset(&bb, 0, sizeof(struct blob_buf));
printf("här kan man va\n");
blob_buf_init(&bb, 0);
printf("här kan man va\n");
printf("och här!\n");
bb = json_to_blob(parsed_response, bb);
printf("här kan man va\n");
ubus_send_reply(ctx, req, bb.head);
printf("här kan man va\n");
blob_buf_free(&bb);
//json_object_put(parsed_response);
return 0;
......@@ -36,12 +41,13 @@ int write_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb)
{
printf("och här!\n");
void *arr, *obj;
int i;
printf("och här!\n");
json_object_object_foreach(response, key, val) {
int val_type = json_object_get_type(val);
printf("och här!\n");
switch (val_type) {
case json_type_int:
blobmsg_add_u32(&bb, key, json_object_get_int(val));
......@@ -67,4 +73,4 @@ struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb)
}
return bb;
}
\ No newline at end of file
}
......@@ -6,7 +6,8 @@
fprintf(stdout, "\n(DEBUG)\t"); \
fprintf(stdout, message, ##__VA_ARGS__);\
} while (0)
#include "libtrace.h"
#include <libmobile.h>
#include <json-c/json.h>
#include <string.h>
#include <libubox/blobmsg.h>
......
......@@ -12,7 +12,6 @@
#include <libubox/list.h>
#include "libmobile.h"
#include "common.h"
struct ubus_context *ctx;
......@@ -31,8 +30,12 @@ int list_apn_profiles(struct ubus_context *ctx, struct ubus_object *obj,
struct blob_attr *msg)
{
char *response = mobile_get_apn_profiles();
struct json_object *parsed_response = parse_apn_profiles(response);
return parse_and_print(response, ctx, req);
printf("here we are once again my old friend!\n");
write_to_ubus(parsed_response, ctx, req);
return 0;
//return parse_and_print(response, ctx, req);
}
int delete_apn_profile(struct ubus_context *ctx, struct ubus_object *obj,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment