X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fsamples%2FHelloWorld.c;h=067365dd115c79206d6e02334661bb3161e8a404;hb=ca208671cc79bbc05c574df788035878e5d39382;hp=70de03f022278ad3916a45deaf4646980ac1caa4;hpb=e2d857c5f05f84de8e2642ff9272a80ea9e5fed6;p=src%2Fapp-framework-binder.git diff --git a/plugins/samples/HelloWorld.c b/plugins/samples/HelloWorld.c index 70de03f0..067365dd 100644 --- a/plugins/samples/HelloWorld.c +++ b/plugins/samples/HelloWorld.c @@ -20,7 +20,7 @@ #include "local-def.h" STATIC json_object* pingSample (AFB_request *request) { - static pingcount = 0; + static int pingcount = 0; json_object *response; char query [512]; int len; @@ -30,7 +30,7 @@ STATIC json_object* pingSample (AFB_request *request) { if (len == 0) strcpy (query,"NoSearchQueryList"); // check if we have some post data - if (request->post == NULL) request->post->data="NoData"; + if (request->post != NULL) request->post->data="NoData"; // return response to caller response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon %d query={%s} PostData: \'%s\' ", pingcount++, query, request->post); @@ -57,7 +57,7 @@ STATIC json_object* pingBug (AFB_request *request) { // For samples https://linuxprograms.wordpress.com/2010/05/20/json-c-libjson-tutorial/ -STATIC json_object* pingJson (AFB_session *session, AFB_request *request) { +STATIC json_object* pingJson (AFB_request *request) { json_object *jresp, *embed; jresp = json_object_new_object(); @@ -73,23 +73,22 @@ STATIC json_object* pingJson (AFB_session *session, AFB_request *request) { return jresp; } - +// NOTE: this sample does not use session to keep test a basic as possible +// in real application most APIs should be protected with AFB_SESSION_CHECK STATIC AFB_restapi pluginApis[]= { {"ping" , AFB_SESSION_NONE, (AFB_apiCB)pingSample , "Ping Application Framework"}, {"pingnull" , AFB_SESSION_NONE, (AFB_apiCB)pingFail , "Return NULL"}, {"pingbug" , AFB_SESSION_NONE, (AFB_apiCB)pingBug , "Do a Memory Violation"}, {"pingJson" , AFB_SESSION_NONE, (AFB_apiCB)pingJson , "Return a JSON object"}, - {"ctx-store", AFB_SESSION_NONE, (AFB_apiCB)pingSample , "Verbose Mode"}, - {"ctx-load" , AFB_SESSION_NONE, (AFB_apiCB)pingSample , "Verbose Mode"}, {NULL} }; -PUBLIC AFB_plugin *dbusRegister () { +PUBLIC AFB_plugin *pluginRegister () { AFB_plugin *plugin = malloc (sizeof (AFB_plugin)); plugin->type = AFB_PLUGIN_JSON; - plugin->info = "Application Framework Binder Service"; - plugin->prefix= "dbus"; + plugin->info = "Minimal Hello World Sample"; + plugin->prefix= "hello"; plugin->apis = pluginApis; return (plugin); -}; \ No newline at end of file +};