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

minor error fix, does not work yet

parent 139f59e4
Branches
No related tags found
No related merge requests found
...@@ -48,3 +48,8 @@ struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb) ...@@ -48,3 +48,8 @@ struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb)
return bb; return bb;
} }
void set_debug(int debug_arg)
{
debug = debug_arg;
}
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <libubox/blobmsg.h> #include <libubox/blobmsg.h>
#include <libubus.h> #include <libubus.h>
extern int debug; int debug;
#define debug_print(...) \ #define debug_print(...) \
do \ do \
...@@ -57,4 +57,6 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx, ...@@ -57,4 +57,6 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
* Blob buffer containing the replicated json_object. * Blob buffer containing the replicated json_object.
*/ */
struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb); struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb);
void set_debug(int debug_arg);
#endif #endif
...@@ -15,17 +15,19 @@ int parse_args(int argc, char **argv) ...@@ -15,17 +15,19 @@ int parse_args(int argc, char **argv)
{ {
char ch; char ch;
printf("hallå1\n");
while ((ch = getopt_long(argc, argv, ":d:", long_options, NULL)) != -1) { while ((ch = getopt_long(argc, argv, ":d:", long_options, NULL)) != -1) {
int flag; int debug_arg;
printf("hallå2\n");
switch (ch) { switch (ch) {
case 'd': case 'd':
flag = atoi(ch); debug_arg = atoi(optarg);
if (flag > 1 || flag < 0) { if (debug_arg > 1 || debug_arg < 0) {
debug_print("%s: option '-%c' is invalid.\n", argv[0], optopt); debug_print("%s: option '-%c' is invalid.\n", argv[0], optopt);
goto fail; goto fail;
} }
debug = flag; printf("hallå3\n");
//set_debug(debug_arg);
break; break;
case ':': case ':':
debug_print(stderr, "%s: option '-%c' requires an argument\n", argv[0], optopt); debug_print(stderr, "%s: option '-%c' requires an argument\n", argv[0], optopt);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment