diff --git a/include/japi.h b/include/japi.h index f5df23a..f30bf8f 100644 --- a/include/japi.h +++ b/include/japi.h @@ -130,7 +130,8 @@ int japi_destroy(japi_context *ctx); * -2 for empty request name, * -3 for empty request handler, * -4 for duplicate naming, - * -5 for failed memory allocation, is returned. + * -5 for failed memory allocation, + * -6 for bad request name (starting with "japi_") is returned. */ int japi_register_request(japi_context *ctx, const char *req_name, japi_req_handler req_handler); diff --git a/src/japi.c b/src/japi.c index fdfa87f..57af2e4 100644 --- a/src/japi.c +++ b/src/japi.c @@ -267,7 +267,7 @@ int japi_register_request(japi_context *ctx, const char *req_name, if (ctx->init && strncmp(req_name, bad_req_name, strlen(bad_req_name)) == 0) { fprintf(stderr, "ERROR: Request name is not allowed.\n"); - return -5; + return -6; } req = (japi_request *)malloc(sizeof(japi_request)); diff --git a/src/japi_pushsrv.c b/src/japi_pushsrv.c index b48877e..bf47e8b 100644 --- a/src/japi_pushsrv.c +++ b/src/japi_pushsrv.c @@ -179,7 +179,7 @@ void japi_pushsrv_subscribe(japi_context *ctx, json_object *jreq, json_object *j pushsrv_name = json_object_get_string(jval); ret = json_object_object_get_ex(jreq, "socket", &jval); socket = json_object_get_int(jval); - if (!ret | socket < 0) { + if (!ret || socket < 0) { json_object_object_add(jresp, "success", json_object_new_boolean(false)); json_object_object_add( jresp, "message", @@ -199,7 +199,7 @@ void japi_pushsrv_subscribe(japi_context *ctx, json_object *jreq, json_object *j json_object_object_add(jresp, "service", json_object_new_string(pushsrv_name)); /* Create JSON response object */ - if (psc == NULL | ret < 0) { + if (psc == NULL || ret < 0) { json_object_object_add(jresp, "success", json_object_new_boolean(false)); json_object_object_add(jresp, "message", json_object_new_string("Push service not found.")); @@ -237,7 +237,7 @@ void japi_pushsrv_unsubscribe(japi_context *ctx, json_object *jreq, json_object ret = json_object_object_get_ex(jreq, "socket", &jval); socket = json_object_get_int(jval); - if (!ret | socket < 0) { + if (!ret || socket < 0) { json_object_object_add(jresp, "success", json_object_new_boolean(false)); json_object_object_add( jresp, "message",