Adds 2017 to copyrights
[src/app-framework-binder.git] / bindings / samples / DemoContext.c
index ef70375..66dc6cc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015, 2016 "IoT.bzh"
+ * Copyright (C) 2015, 2016, 2017 "IoT.bzh"
  * Author "Fulup Ar Foll"
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
 #include <stdio.h>
 #include <json-c/json.h>
 
-#include <afb/afb-plugin.h>
+#include <afb/afb-binding.h>
 
 typedef struct {
-  /* 
+  /*
    * client context is attached a session but private to a each plugin.
    * Context is passed to each API under request->context
-   * 
+   *
    * Note:
    *  -client context is free when a session is closed. Developer should not
    *   forget that even if context is private to each plugin, session is unique
@@ -38,13 +38,13 @@ typedef struct {
    *  -when an API use AFB_SESSION_RESET this close the session and each plugin
    *   will be notified to free ressources.
    */
-    
+
   int  count;
   char *abcd;
-  
+
 } MyClientContextT;
 
-// This function is call at session open time. Any client trying to 
+// This function is call at session open time. Any client trying to
 // call it with an already open session will be denied.
 // Ex: http://localhost:1234/api/context/create?token=123456789
 static void myCreate (struct afb_req request)
@@ -53,7 +53,7 @@ static void myCreate (struct afb_req request)
 
     // store something in our plugin private client context
     ctx->count = 0;
-    ctx->abcd  = "SomeThingUseful";        
+    ctx->abcd  = "SomeThingUseful";
 
     afb_req_context_set(request, ctx, free);
     afb_req_success_f(request, NULL, "SUCCESS: create client context for plugin [%s]", ctx->abcd);
@@ -66,7 +66,7 @@ static void myCreate (struct afb_req request)
 static void myAction (struct afb_req request)
 {
     MyClientContextT *ctx = (MyClientContextT*) afb_req_context_get(request);
-    
+
     // store something in our plugin private client context
     ctx->count++;
     afb_req_success_f(request, NULL, "SUCCESS: plugin [%s] Check=[%d]\n", ctx->abcd, ctx->count);
@@ -79,7 +79,7 @@ static void myAction (struct afb_req request)
 static void myClose (struct afb_req request)
 {
     MyClientContextT *ctx = (MyClientContextT*) afb_req_context_get(request);
-    
+
     // store something in our plugin private client context
     ctx->count++;
     afb_req_success_f(request, NULL, "SUCCESS: plugin [%s] Close=[%d]\n", ctx->abcd, ctx->count);
@@ -121,7 +121,7 @@ static void clientCheckLOA(struct afb_req 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 const struct AFB_verb_desc_v1 verbs[]= {
+static const struct afb_verb_desc_v1 verbs[]= {
   {"create", AFB_SESSION_CREATE, myCreate  , "Create a new session"},
   {"action", AFB_SESSION_CHECK , myAction  , "Use Session Context"},
   {"close" , AFB_SESSION_CLOSE , myClose   , "Free Context"},
@@ -144,8 +144,8 @@ static const struct AFB_verb_desc_v1 verbs[]= {
   {NULL}
 };
 
-static const struct AFB_plugin plugin_desc = {
-       .type = AFB_PLUGIN_VERSION_1,
+static const struct afb_binding plugin_desc = {
+       .type = AFB_BINDING_VERSION_1,
        .v1 = {
                .info = "Sample of Client Context Usage",
                .prefix = "context",
@@ -153,7 +153,7 @@ static const struct AFB_plugin plugin_desc = {
        }
 };
 
-const struct AFB_plugin *pluginAfbV1Register (const struct AFB_interface *itf)
+const struct afb_binding *afbBindingV1Register (const struct afb_binding_interface *itf)
 {
        return &plugin_desc;
 }