aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Marec <frederic.marec@iot.bzh>2019-05-09 18:56:06 +0200
committerFrederic Marec <frederic.marec@iot.bzh>2019-05-09 18:56:06 +0200
commit395554e75a52056ff6cbff9c2a9a62f401e287a9 (patch)
treeee779fe56b0ba9e87ccae8cad0d1fe1a0ae73e8e
parentd285cf2515dc1f65cae7c685f6da18351a0a5429 (diff)
Git submodule migration to separated libraries
Bug-AGL: SPEC-2139 Change-Id: Ie96b5a51b8e725a175a824236a11eb29de3631fc Signed-off-by: Frederic Marec <frederic.marec@iot.bzh>
-rw-r--r--.gitmodules6
m---------afb-helpers0
m---------app-controller0
-rw-r--r--conf.d/cmake/config.cmake2
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/plugins/CMakeLists.txt6
-rw-r--r--src/plugins/supervisor-api.c70
-rw-r--r--src/plugins/supervisor.c46
-rw-r--r--src/plugins/supervisor.h6
-rw-r--r--src/xds-binding.c36
10 files changed, 81 insertions, 97 deletions
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 9b45c19..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,6 +0,0 @@
-[submodule "afb-helpers"]
- path = afb-helpers
- url = https://gerrit.automotivelinux.org/gerrit/apps/app-afb-helpers-submodule
-[submodule "app-controller"]
- path = app-controller
- url = https://gerrit.automotivelinux.org/gerrit/apps/app-controller-submodule
diff --git a/afb-helpers b/afb-helpers
deleted file mode 160000
-Subproject 52f04783535948f2782780992710276f3419e56
diff --git a/app-controller b/app-controller
deleted file mode 160000
-Subproject 440be0984f16562fdf321c770d65787ecea0e36
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index 500854a..51e7d64 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -73,6 +73,8 @@ set (PKG_REQUIRED_LIST
libsystemd>=222
afb-daemon>=4.0
libmicrohttpd>=0.9.55
+ appcontroller
+ afb-helpers
)
# Prefix path where will be installed the files
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index df8cae1..f6f4a8a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -36,10 +36,4 @@ PROJECT_TARGET_ADD(xds)
OUTPUT_NAME ${TARGET_NAME}
)
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- afb-helpers
- ctl-utilities
- ${link_libraries})
-
add_subdirectory("plugins")
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 1c1c557..e6593be 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -32,11 +32,5 @@ PROJECT_TARGET_ADD(supervisor)
OUTPUT_NAME ${TARGET_NAME}
)
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- afb-helpers
- ${link_libraries}
- )
-
target_include_directories(${TARGET_NAME}
PRIVATE "${CMAKE_SOURCE_DIR}/app-controller/ctl-lib")
diff --git a/src/plugins/supervisor-api.c b/src/plugins/supervisor-api.c
index 50e4808..33e52c6 100644
--- a/src/plugins/supervisor-api.c
+++ b/src/plugins/supervisor-api.c
@@ -36,7 +36,7 @@ static int* TracePidsArr = NULL;
nb++; \
json_object_array_add(res, json_object_new_int(dd->pid)); \
if ((rc = trace_daemon(src->api, dd, lvl)) < 0) { \
- AFB_ReqFailF(src->request, "failed", "Trace pid %d error %d", dd->pid, rc); \
+ afb_req_fail_f(src->request, "failed", "Trace pid %d error %d", dd->pid, rc); \
goto error; \
} \
}
@@ -55,11 +55,11 @@ CTLP_CAPI(list, source, argsJ, eventJ)
getDaemons(source->api, &daemons);
if (daemons == NULL) {
- AFB_ReqFail(source->request, "Failed", "Error daemon list null");
+ afb_req_fail(source->request, "Failed", "Error daemon list null");
return ERROR;
}
- AFB_ApiInfo(source->api, "Build response (nb daemons %d)", daemons->count);
+ AFB_API_INFO(source->api, "Build response (nb daemons %d)", daemons->count);
result = json_object_new_array();
for (int i = 0; i < daemons->count; i++) {
@@ -75,8 +75,8 @@ CTLP_CAPI(list, source, argsJ, eventJ)
json_object_array_add(result, item);
}
- AFB_ApiInfo(source->api, "Send response");
- AFB_ReqSuccess(source->request, result, NULL);
+ AFB_API_INFO(source->api, "Send response");
+ afb_req_success(source->request, result, NULL);
return 0;
}
@@ -95,27 +95,27 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ)
// a specific pid or an array of pids or a specific ws name
if (wrap_json_unpack(queryJ, "{s:?i s:?o s:?s s:?s}",
"pid", &pid, "pids", &j_pids, "ws", &ws_name, "level", &level)) {
- AFB_ReqFail(source->request, "Failed", "Error processing arguments.");
+ afb_req_fail(source->request, "Failed", "Error processing arguments.");
return ERROR;
}
if (pid == -1 && j_pids == NULL && strlen(ws_name) == 0) {
- AFB_ReqFail(source->request, "failed", "one of pid or pids or ws parameter must be set");
+ afb_req_fail(source->request, "failed", "one of pid or pids or ws parameter must be set");
return ERROR;
}
if (TracePidsNum > 0) {
- AFB_ReqFail(source->request, "failed", "already tracing");
+ afb_req_fail(source->request, "failed", "already tracing");
return ERROR;
}
- AFB_ApiDebug(source->api, "Trace ws=%s, pid=%d, pids=%s", ws_name, pid, json_object_to_json_string(j_pids));
+ AFB_API_DEBUG(source->api, "Trace ws=%s, pid=%d, pids=%s", ws_name, pid, json_object_to_json_string(j_pids));
if (j_pids != NULL && json_object_is_type(j_pids, json_type_array)) {
TracePidsNum = (int)json_object_array_length(j_pids);
TracePidsArr = malloc(sizeof(int) * TracePidsNum);
if (TracePidsArr == NULL) {
- AFB_ReqFail(source->request, "failed", "out of memory");
+ afb_req_fail(source->request, "failed", "out of memory");
goto error;
}
int i = 0;
@@ -127,7 +127,7 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ)
getDaemons(source->api, &daemons);
if (daemons == NULL || daemons->count <= 0) {
- AFB_ReqFail(source->request, "failed", "No daemon found");
+ afb_req_fail(source->request, "failed", "No daemon found");
goto error;
}
@@ -136,9 +136,9 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ)
nb_traced_daemons = 0;
result = json_object_new_array();
for (int i = 0; i < daemons->count; i++) {
- AFB_ApiDebug(source->api, "_DEBUG_ svr %s",
+ AFB_API_DEBUG(source->api, "_DEBUG_ svr %s",
json_object_to_json_string(daemons->daemons[i]->ws_servers));
- AFB_ApiDebug(source->api, "_DEBUG_ cli %s",
+ AFB_API_DEBUG(source->api, "_DEBUG_ cli %s",
json_object_to_json_string(daemons->daemons[i]->ws_clients));
if (pid != -1 && pid == daemons->daemons[i]->pid) {
@@ -147,7 +147,7 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ)
TracePidsNum = 1;
TracePidsArr = malloc(sizeof(int) * TracePidsNum);
if (TracePidsArr == NULL) {
- AFB_ReqFail(source->request, "failed", "out of memory");
+ afb_req_fail(source->request, "failed", "out of memory");
goto error;
}
TracePidsArr[0] = daemons->daemons[i]->pid;
@@ -171,7 +171,7 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ)
TracePidsNum++;
int* tmpPtr = realloc(TracePidsArr, sizeof(int) * TracePidsNum);
if (tmpPtr == NULL) {
- AFB_ReqFail(source->request, "failed", "out of memory");
+ afb_req_fail(source->request, "failed", "out of memory");
goto error;
}
TracePidsArr = tmpPtr;
@@ -189,7 +189,7 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ)
TracePidsNum++;
int* tmpPtr = realloc(TracePidsArr, sizeof(int) * TracePidsNum);
if (tmpPtr == NULL) {
- AFB_ReqFail(source->request, "failed", "out of memory");
+ afb_req_fail(source->request, "failed", "out of memory");
goto error;
}
TracePidsArr = tmpPtr;
@@ -201,11 +201,11 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ)
}
if (nb_traced_daemons == 0) {
- AFB_ReqFail(source->request, "failed", "No daemon found match criteria");
+ afb_req_fail(source->request, "failed", "No daemon found match criteria");
goto error;
}
- AFB_ReqSuccess(source->request, result, "Trace successfully started");
+ afb_req_success(source->request, result, "Trace successfully started");
return 0;
@@ -223,7 +223,7 @@ CTLP_CAPI(trace_stop, source, argsJ, queryJ)
json_object* result = NULL;
if (TracePidsNum == 0) {
- AFB_ReqFail(source->request, "failed", "Trace already stopped");
+ afb_req_fail(source->request, "failed", "Trace already stopped");
return ERROR;
}
@@ -240,10 +240,10 @@ CTLP_CAPI(trace_stop, source, argsJ, queryJ)
TracePidsArr = NULL;
if (nbErr) {
- AFB_ReqFailF(source->request, "failed", "Error while stopping tracing (%d)", nbErr);
+ afb_req_fail_f(source->request, "failed", "Error while stopping tracing (%d)", nbErr);
return ERROR;
}
- AFB_ReqSuccess(source->request, result, "Trace successfully stopped");
+ afb_req_success(source->request, result, "Trace successfully stopped");
return 0;
}
@@ -259,7 +259,7 @@ uint64_t get_ts()
static void cb_harvester_write(void* closure, int status, struct json_object* result, struct afb_dynapi* dynapi)
{
- AFB_ApiDebug(dynapi, "SEB cb_harvester_write");
+ AFB_API_DEBUG(dynapi, "SEB cb_harvester_write");
}
static int harvester_post_data(CtlSourceT* source, METRIC_T* metric)
@@ -285,34 +285,34 @@ static int harvester_post_data(CtlSourceT* source, METRIC_T* metric)
"values", "value", metric->data,
"timestamp", metric->timestamp);
} else {
- AFB_ReqFail(source->request, "Failed", "Unsupported dataType");
+ afb_req_fail(source->request, "Failed", "Unsupported dataType");
return ERROR;
}
if (rc < 0) {
- AFB_ReqFail(source->request, "Failed", "Error packing metric, rc=%d", rc);
+ afb_req_fail(source->request, "Failed", "Error packing metric, rc=%d", rc);
return rc;
}
rc = wrap_json_pack(&j_query, "{s:s s:i s:o }", "host",
"localhost", "port", 8086, "metric", j_metric);
if (rc < 0) {
- AFB_ReqFail(source->request, "Failed", "Error packing query, rc=%d", rc);
+ afb_req_fail(source->request, "Failed", "Error packing query, rc=%d", rc);
return rc;
}
- AFB_ApiDebug(source->api, "%s write: %s", SRV_HARVESTER_NAME,
+ AFB_API_DEBUG(source->api, "%s write: %s", SRV_HARVESTER_NAME,
json_object_to_json_string(j_query));
/* SEB
- rc = AFB_ServiceSync(source->api, SRV_HARVESTER_NAME, "write", j_query, &j_res);
+ rc = afb_api_call_sync_legacy(source->api, SRV_HARVESTER_NAME, "write", j_query, &j_res);
if (rc < 0) {
- AFB_ReqFail(source->request, "Failed", "Error %s write : rc=%d, j_res=%s", SRV_HARVESTER_NAME, rc,
+ afb_req_fail(source->request, "Failed", "Error %s write : rc=%d, j_res=%s", SRV_HARVESTER_NAME, rc,
json_object_to_json_string(j_res));
return rc;
}
*/
- AFB_ServiceCall(source->api, SRV_HARVESTER_NAME, "write", j_query, cb_harvester_write, &j_res);
+ afb_api_call_legacy(source->api, SRV_HARVESTER_NAME, "write", j_query, cb_harvester_write, &j_res);
return 0;
}
@@ -326,25 +326,25 @@ CTLP_CAPI(tracing_events, source, argsJ, eventJ)
//struct signalCBT* ctx = (struct signalCBT*)source->context;
- AFB_ApiDebug(source->api, ">>> RECV Event uid %s : %s", source->uid,
+ AFB_API_DEBUG(source->api, ">>> RECV Event uid %s : %s", source->uid,
json_object_to_json_string(eventJ));
if (strcmp(source->uid, "xds/supervisor/trace") != 0) {
- AFB_ApiNotice(source->api, "WARNING: un-handle uid '%s'", source->uid);
+ AFB_API_NOTICE(source->api, "WARNING: un-handle uid '%s'", source->uid);
return 0;
}
if ((rc = wrap_json_unpack(eventJ, "{s:?s}", "type", &type)) < 0) {
- AFB_ReqFail(source->request, "Failed", "Cannot decode event type");
+ afb_req_fail(source->request, "Failed", "Cannot decode event type");
return ERROR;
}
if (strcmp(type, "request") != 0) {
- AFB_ReqFail(source->request, "Failed", "Cannot retrieve request");
+ afb_req_fail(source->request, "Failed", "Cannot retrieve request");
return ERROR;
}
if (!json_object_object_get_ex(eventJ, "request", &request)) {
- AFB_ReqFail(source->request, "Failed", "Cannot decode event request");
+ afb_req_fail(source->request, "Failed", "Cannot decode event request");
return ERROR;
}
@@ -361,7 +361,7 @@ CTLP_CAPI(tracing_events, source, argsJ, eventJ)
rc = harvester_post_data(source, &metric);
if (rc < 0) {
- AFB_ReqFail(source->request, "Failed", "ERROR harvester_post_data: rc %d", rc);
+ afb_req_fail(source->request, "Failed", "ERROR harvester_post_data: rc %d", rc);
return rc;
}
diff --git a/src/plugins/supervisor.c b/src/plugins/supervisor.c
index 598ba68..168e298 100644
--- a/src/plugins/supervisor.c
+++ b/src/plugins/supervisor.c
@@ -37,7 +37,7 @@ static const char* null_str = "null";
struct decode_daemon_str {
DAEMONS_T* daemons;
- AFB_ApiT api;
+ afb_api_t api;
const char* ignored_daemon;
int* ret_code;
};
@@ -62,19 +62,19 @@ static void decode_daemons_cb(void* closure, json_object* obj, const char* fName
return;
}
- AFB_ApiInfo(clStr->api, "Get supervisor/config - pid %d", cred.pid);
+ AFB_API_INFO(clStr->api, "Get supervisor/config - pid %d", cred.pid);
daemon->pid = cred.pid;
// Get config
wrap_json_pack(&j_query, "{s:i}", "pid", cred.pid);
- rc = AFB_ServiceSync(clStr->api, SRV_SUPERVISOR_NAME, "config", j_query, &j_response);
+ rc = afb_api_call_sync_legacy(clStr->api, SRV_SUPERVISOR_NAME, "config", j_query, &j_response);
if (rc < 0) {
- AFB_ApiError(clStr->api, "Cannot get config of pid %d", cred.pid);
+ AFB_API_ERROR(clStr->api, "Cannot get config of pid %d", cred.pid);
*clStr->ret_code = rc;
return;
}
- AFB_ApiDebug(clStr->api, "%s config result, res=%s", SRV_SUPERVISOR_NAME,
+ AFB_API_DEBUG(clStr->api, "%s config result, res=%s", SRV_SUPERVISOR_NAME,
json_object_to_json_string(j_response));
if (json_object_object_get_ex(j_response, "response", &j_config)) {
@@ -86,7 +86,7 @@ static void decode_daemons_cb(void* closure, json_object* obj, const char* fName
"ws_servers", &j_ws_servers,
"ws_clients", &j_ws_clients);
if (rc < 0) {
- AFB_ApiError(clStr->api, "Error decoding config response %s", wrap_json_get_error_string(rc));
+ AFB_API_ERROR(clStr->api, "Error decoding config response %s", wrap_json_get_error_string(rc));
return;
}
@@ -105,7 +105,7 @@ static void decode_daemons_cb(void* closure, json_object* obj, const char* fName
}
// Get apis
- AFB_ApiInfo(clStr->api, "Get supervisor/do monitor get apis - pid %d", cred.pid);
+ AFB_API_INFO(clStr->api, "Get supervisor/do monitor get apis - pid %d", cred.pid);
// '{"pid":6262,"api":"monitor","verb":"get","args":{"apis":true}}
wrap_json_pack(&j_query, "{si ss ss s {sb}}",
@@ -113,12 +113,12 @@ static void decode_daemons_cb(void* closure, json_object* obj, const char* fName
"api", "monitor",
"verb", "get",
"args", "apis", true);
- rc = AFB_ServiceSync(clStr->api, SRV_SUPERVISOR_NAME, "do", j_query, &j_response);
+ rc = afb_api_call_sync_legacy(clStr->api, SRV_SUPERVISOR_NAME, "do", j_query, &j_response);
if (rc < 0) {
- AFB_ApiError(clStr->api, "Cannot get apis of pid %d", cred.pid);
+ AFB_API_ERROR(clStr->api, "Cannot get apis of pid %d", cred.pid);
return;
} else {
- AFB_ApiDebug(clStr->api, "%s do ...get apis result, res=%s", SRV_SUPERVISOR_NAME, json_object_to_json_string(j_response));
+ AFB_API_DEBUG(clStr->api, "%s do ...get apis result, res=%s", SRV_SUPERVISOR_NAME, json_object_to_json_string(j_response));
if (json_object_object_get_ex(j_response, "response", &j_config) && json_object_object_get_ex(j_config, "apis", &j_apis)) {
// Don't forward monitor config details
@@ -138,29 +138,29 @@ static void decode_daemons_cb(void* closure, json_object* obj, const char* fName
clStr->daemons->count++;
}
-int getDaemons(AFB_ApiT apiHandle, DAEMONS_T** daemons)
+int getDaemons(afb_api_t apiHandle, DAEMONS_T** daemons)
{
int rc;
json_object *j_response, *j_daemons = NULL;
*daemons = calloc(sizeof(DAEMONS_T), 1);
- AFB_ApiInfo(apiHandle, "Call supervisor/discover");
- if ((rc = AFB_ServiceSync(apiHandle, SRV_SUPERVISOR_NAME, "discover", NULL,
+ AFB_API_INFO(apiHandle, "Call supervisor/discover");
+ if ((rc = afb_api_call_sync_legacy(apiHandle, SRV_SUPERVISOR_NAME, "discover", NULL,
&j_response))
< 0) {
return rc;
}
- AFB_ApiInfo(apiHandle, "Call supervisor/list");
- if ((rc = AFB_ServiceSync(apiHandle, SRV_SUPERVISOR_NAME, "list", NULL,
+ AFB_API_INFO(apiHandle, "Call supervisor/list");
+ if ((rc = afb_api_call_sync_legacy(apiHandle, SRV_SUPERVISOR_NAME, "list", NULL,
&j_response))
< 0) {
return rc;
}
- AFB_ApiInfo(apiHandle, "Get details info for each daemon");
- AFB_ApiDebug(apiHandle, "%s list result, res=%s", SRV_SUPERVISOR_NAME, json_object_to_json_string(j_response));
+ AFB_API_INFO(apiHandle, "Get details info for each daemon");
+ AFB_API_DEBUG(apiHandle, "%s list result, res=%s", SRV_SUPERVISOR_NAME, json_object_to_json_string(j_response));
if (!json_object_object_get_ex(j_response, "response", &j_daemons)) {
}
@@ -179,7 +179,7 @@ int getDaemons(AFB_ApiT apiHandle, DAEMONS_T** daemons)
#define XDS_TAG_EVENT "xds:trace/event"
#define XDS_TRACE_NAME "xds-trace"
-int trace_daemon(AFB_ApiT apiHandle, DAEMON_T* dm, const char* level)
+int trace_daemon(afb_api_t apiHandle, DAEMON_T* dm, const char* level)
{
int rc;
json_object *j_response, *j_query, *j_tracereq, *j_traceevt;
@@ -214,8 +214,8 @@ int trace_daemon(AFB_ApiT apiHandle, DAEMON_T* dm, const char* level)
"tag", XDS_TAG_REQUEST, "name", XDS_TRACE_NAME, "request", j_tracereq,
"tag", XDS_TAG_EVENT, "name", XDS_TRACE_NAME, "event", j_traceevt);
- if ((rc = AFB_ServiceSync(apiHandle, SRV_SUPERVISOR_NAME, "trace", j_query, &j_response)) < 0) {
- AFB_ApiError(apiHandle, "ERROR tracing pid %d result: %s", dm->pid,
+ if ((rc = afb_api_call_sync_legacy(apiHandle, SRV_SUPERVISOR_NAME, "trace", j_query, &j_response)) < 0) {
+ AFB_API_ERROR(apiHandle, "ERROR tracing pid %d result: %s", dm->pid,
json_object_to_json_string(j_response));
return rc;
}
@@ -223,14 +223,14 @@ int trace_daemon(AFB_ApiT apiHandle, DAEMON_T* dm, const char* level)
return 0;
}
-// FIXME prototype must be int trace_drop(AFB_ApiT apiHandle, DAEMON_T* dm)
-int trace_drop(AFB_ApiT apiHandle, int pid)
+// FIXME prototype must be int trace_drop(afb_api_t apiHandle, DAEMON_T* dm)
+int trace_drop(afb_api_t apiHandle, int pid)
{
json_object *j_response, *j_query;
// monitor/trace({ "drop": { "tag": "trace/request" } })
wrap_json_pack(&j_query, "{s:i s:{s:[s s]}}", "pid", pid, "drop", "tag", XDS_TAG_REQUEST, XDS_TAG_EVENT);
- return AFB_ServiceSync(apiHandle, SRV_SUPERVISOR_NAME, "trace", j_query, &j_response);
+ return afb_api_call_sync_legacy(apiHandle, SRV_SUPERVISOR_NAME, "trace", j_query, &j_response);
}
int supervisor_init(void)
diff --git a/src/plugins/supervisor.h b/src/plugins/supervisor.h
index a7779ce..557f4ce 100644
--- a/src/plugins/supervisor.h
+++ b/src/plugins/supervisor.h
@@ -48,7 +48,7 @@ typedef struct daemons_result_
} DAEMONS_T;
-extern int getDaemons(AFB_ApiT apiHandle, DAEMONS_T **daemons);
-extern int trace_daemon(AFB_ApiT apiHandle, DAEMON_T *dm, const char *level);
-extern int trace_drop(AFB_ApiT apiHandle, int pid);
+extern int getDaemons(afb_api_t apiHandle, DAEMONS_T **daemons);
+extern int trace_daemon(afb_api_t apiHandle, DAEMON_T *dm, const char *level);
+extern int trace_drop(afb_api_t apiHandle, int pid);
extern int supervisor_init(void);
diff --git a/src/xds-binding.c b/src/xds-binding.c
index c4193b0..f93a121 100644
--- a/src/xds-binding.c
+++ b/src/xds-binding.c
@@ -35,37 +35,37 @@ static CtlSectionT ctrlSections[] = {
{ .key = NULL }
};
-static void ctrlapi_ping(AFB_ReqT request)
+static void ctrlapi_ping(afb_req_t request)
{
static int count = 0;
json_object* resJ;
int rc;
count++;
- AFB_ReqNotice(request, "Controller:ping count=%d", count);
+ AFB_REQ_NOTICE(request, "Controller:ping count=%d", count);
rc = wrap_json_pack(&resJ, "{ss si}", "status", "pong", "count", count);
if (rc < 0) {
- AFB_ReqFailF(request, "ERROR", "wrap_json_pack rc=%d", rc);
+ afb_req_fail_f(request, "ERROR", "wrap_json_pack rc=%d", rc);
return;
}
- AFB_ReqSuccess(request, resJ, NULL);
+ afb_req_success(request, resJ, NULL);
return;
}
-void ctrlapi_auth(AFB_ReqT request)
+void ctrlapi_auth(afb_req_t request)
{
- AFB_ReqSetLOA(request, 1);
- AFB_ReqSuccess(request, NULL, NULL);
+ afb_req_session_set_LOA(request, 1);
+ afb_req_success(request, NULL, NULL);
}
-static AFB_ApiVerbs CtrlApiVerbs[] = {
+static afb_verb_t CtrlApiVerbs[] = {
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
{ .verb = "ping", .callback = ctrlapi_ping, .info = "ping test for API" },
{ .verb = "auth", .callback = ctrlapi_auth, .info = "Authenticate session to raise Level Of Assurance of the session" },
{ .verb = NULL } /* marker for end of the array */
};
-static int CtrlLoadStaticVerbs(afb_dynapi* apiHandle, AFB_ApiVerbs* verbs)
+static int CtrlLoadStaticVerbs(afb_dynapi* apiHandle, afb_verb_t* verbs)
{
int errcount = 0;
@@ -78,7 +78,7 @@ static int CtrlLoadStaticVerbs(afb_dynapi* apiHandle, AFB_ApiVerbs* verbs)
return errcount;
};
-static int CtrlInitOneApi(AFB_ApiT apiHandle)
+static int CtrlInitOneApi(afb_api_t apiHandle)
{
int err = 0;
@@ -88,7 +88,7 @@ static int CtrlInitOneApi(AFB_ApiT apiHandle)
CtlConfigT* ctrlConfig = (CtlConfigT*)afb_dynapi_get_userdata(apiHandle);
err = CtlConfigExec(apiHandle, ctrlConfig);
if (err) {
- AFB_ApiError(apiHandle, "Error at CtlConfigExec step");
+ AFB_API_ERROR(apiHandle, "Error at CtlConfigExec step");
return err;
}
@@ -98,7 +98,7 @@ static int CtrlInitOneApi(AFB_ApiT apiHandle)
// next generation dynamic API-V3 mode
#include <signal.h>
-static int CtrlLoadOneApi(void* cbdata, AFB_ApiT apiHandle)
+static int CtrlLoadOneApi(void* cbdata, afb_api_t apiHandle)
{
CtlConfigT* ctrlConfig = (CtlConfigT*)cbdata;
@@ -108,7 +108,7 @@ static int CtrlLoadOneApi(void* cbdata, AFB_ApiT apiHandle)
// add static controls verbs
int err = CtrlLoadStaticVerbs(apiHandle, CtrlApiVerbs);
if (err) {
- AFB_ApiError(apiHandle, "CtrlLoadSection fail to register static V2 verbs");
+ AFB_API_ERROR(apiHandle, "CtrlLoadSection fail to register static V2 verbs");
return ERROR;
}
@@ -129,7 +129,7 @@ int afbBindingEntry(afb_dynapi* apiHandle)
{
AFB_default = apiHandle;
- AFB_ApiNotice(apiHandle, "Controller in afbBindingEntry");
+ AFB_API_NOTICE(apiHandle, "Controller in afbBindingEntry");
const char* dirList = getenv("CONTROL_CONFIG_PATH");
if (!dirList)
@@ -137,27 +137,27 @@ int afbBindingEntry(afb_dynapi* apiHandle)
const char* configPath = CtlConfigSearch(apiHandle, dirList, "");
if (!configPath) {
- AFB_ApiError(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList);
+ AFB_API_ERROR(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList);
return ERROR;
}
// load config file and create API
CtlConfigT* ctrlConfig = CtlLoadMetaData(apiHandle, configPath);
if (!ctrlConfig) {
- AFB_ApiError(apiHandle,
+ AFB_API_ERROR(apiHandle,
"CtrlBindingDyn No valid control config file in:\n-- %s",
configPath);
return ERROR;
}
if (!ctrlConfig->api) {
- AFB_ApiError(apiHandle,
+ AFB_API_ERROR(apiHandle,
"CtrlBindingDyn API Missing from metadata in:\n-- %s",
configPath);
return ERROR;
}
- AFB_ApiNotice(apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api,
+ AFB_API_NOTICE(apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api,
ctrlConfig->info);
// create one API per config file (Pre-V3 return code ToBeChanged)