aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/samples
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-04-01 16:20:12 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-04-01 16:20:12 +0200
commitbbe18a624f4961165cf52d7f4c25de6f3a7ec012 (patch)
tree8167fa621fbcdcd91e11988ce6d8c9cf4072fc48 /plugins/samples
parentc95f72616f59a317f72c58c0e5664992504a48e5 (diff)
work in progress
Change-Id: I3df95def03bb26ca4d1a52f7cd94b0fb67375d4c Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'plugins/samples')
-rw-r--r--plugins/samples/ClientCtx.c1
-rw-r--r--plugins/samples/HelloWorld.c35
2 files changed, 21 insertions, 15 deletions
diff --git a/plugins/samples/ClientCtx.c b/plugins/samples/ClientCtx.c
index b59400e1..175b9387 100644
--- a/plugins/samples/ClientCtx.c
+++ b/plugins/samples/ClientCtx.c
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdio.h>
#include "local-def.h"
diff --git a/plugins/samples/HelloWorld.c b/plugins/samples/HelloWorld.c
index 6c2d0cf9..85e92f45 100644
--- a/plugins/samples/HelloWorld.c
+++ b/plugins/samples/HelloWorld.c
@@ -16,31 +16,35 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdio.h>
+#include <string.h>
#include "local-def.h"
+#include "afb-req-itf.h"
-STATIC json_object* pingSample (AFB_request *request) {
+static json_object* pingSample (AFB_request *request) {
static int pingcount = 0;
json_object *response;
char query [512];
- int len;
+ size_t len;
// request all query key/value
len = getQueryAll (request, query, sizeof(query));
if (len == 0) strcpy (query,"NoSearchQueryList");
// return response to caller
- response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon %d query={%s}", pingcount++, query);
+// response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon %d query={%s}", pingcount++, query);
+ afb_req_success_f(*request->areq, NULL, "Ping Binder Daemon %d query={%s}", pingcount++, query);
if (verbose) fprintf(stderr, "%d: \n", pingcount);
- return (response);
+ return NULL; //(response);
}
-STATIC json_object* pingFail (AFB_request *request) {
+static json_object* pingFail (AFB_request *request) {
return NULL;
}
-STATIC json_object* pingBug (AFB_request *request) {
+static json_object* pingBug (AFB_request *request) {
int a,b,c;
fprintf (stderr, "Use --timeout=10 to trap error\n");
@@ -54,7 +58,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_request *request) {
+static json_object* pingJson (AFB_request *request) {
json_object *jresp, *embed;
jresp = json_object_new_object();
@@ -72,7 +76,7 @@ STATIC json_object* pingJson (AFB_request *request) {
// 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[]= {
+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"},
@@ -80,12 +84,13 @@ STATIC AFB_restapi pluginApis[]= {
{NULL}
};
+static const AFB_plugin plugin = {
+ .type = AFB_PLUGIN_JSON,
+ .info = "Minimal Hello World Sample",
+ .prefix = "hello",
+ .apis = pluginApis
+};
-PUBLIC AFB_plugin *pluginRegister () {
- AFB_plugin *plugin = malloc (sizeof (AFB_plugin));
- plugin->type = AFB_PLUGIN_JSON;
- plugin->info = "Minimal Hello World Sample";
- plugin->prefix= "hello";
- plugin->apis = pluginApis;
- return (plugin);
+const AFB_plugin *pluginRegister () {
+ return &plugin;
};