X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fhelper-api.c;h=912093bbdba33bfd6b1c8117deafeae425ae42a5;hb=ca208671cc79bbc05c574df788035878e5d39382;hp=50abcea6a1c259df2226337e9e20edfac57883a9;hpb=631b0be76caa4ad4bbbbbfe1ca333dc9aa192ce0;p=src%2Fapp-framework-binder.git diff --git a/src/helper-api.c b/src/helper-api.c index 50abcea6..912093bb 100644 --- a/src/helper-api.c +++ b/src/helper-api.c @@ -21,6 +21,7 @@ #include #include #include +#include // handle to hold queryAll values @@ -37,53 +38,13 @@ typedef struct { json_object *json; } AFB_errorT; -static AFB_errorT AFBerr [AFB_SUCCESS+1]; +static AFB_errorT AFBerr [AFB_UNAUTH+1]; static json_object *jTypeStatic; PUBLIC int verbose; -static const char *ERROR_LABEL[] = {"false", "true", "fatal", "fail", "warning", "empty", "success"}; +static const char *ERROR_LABEL[] = {"false", "true", "fatal", "fail", "warning", "empty", "success", "done", "unauth"}; -/* ------------------------------------------------------------------------------ - * Get localtime and return in a string - * ------------------------------------------------------------------------------ */ - -PUBLIC char * configTime (void) { - static char reqTime [26]; - time_t tt; - struct tm *rt; - - /* Get actual Date and Time */ - time (&tt); - rt = localtime (&tt); - - strftime (reqTime, sizeof (reqTime), "(%d-%b %H:%M)",rt); - - // return pointer on static data - return (reqTime); -} - - -// Sample Generic Ping Debug API -json_object* getPingTest(AFB_request *request) { - static int pingcount = 0; - json_object *response; - char query [256]; - char session[256]; - int len; - - // request all query key/value - len = getQueryAll (request, query, sizeof(query)); - if (len == 0) strncpy (query, "NoSearchQueryList", sizeof(query)); - - // check if we have some post data - if (request->post == NULL) request->post->data="NoData"; - - // return response to caller - response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon count=%d uuid=%s query={%s} session={0x%x} PostData: [%s] " - , pingcount++, request->uuid, query, session, request->post->data); - return (response); -} // Helper to retrieve argument from connection @@ -264,7 +225,7 @@ static void jsoninit() verbosesav = verbose; verbose = 0; // run initialisation in silent mode jTypeStatic = json_object_new_string ("AFB_message"); - for (idx = 0; idx <= AFB_SUCCESS; idx++) { + for (idx = 0; idx <= AFB_UNAUTH; idx++) { AFBerr[idx].level = idx; AFBerr[idx].label = ERROR_LABEL [idx]; AFBerr[idx].json = jsonNewMessage (idx, NULL);