+ hsrv = afb_hsrv_create();
+ if (hsrv == NULL) {
+ ERROR("memory allocation failure");
+ return NULL;
+ }
+
+ if (!afb_hsrv_set_cache_timeout(hsrv, config->cacheTimeout)
+ || !init_http_server(hsrv, config)) {
+ ERROR("initialisation of httpd failed");
+ afb_hsrv_put(hsrv);
+ return NULL;
+ }
+
+ NOTICE("Waiting port=%d rootdir=%s", config->httpdPort, config->rootdir);
+ NOTICE("Browser URL= http:/*localhost:%d", config->httpdPort);
+
+ rc = afb_hsrv_start(hsrv, (uint16_t) config->httpdPort, 15);
+ if (!rc) {
+ ERROR("starting of httpd failed");
+ afb_hsrv_put(hsrv);
+ return NULL;
+ }
+
+ return hsrv;
+}
+
+static void start_items(struct afb_config_item *item)
+{
+ if (item != NULL) {
+ /* keeps the order */
+ start_items(item->previous);
+ switch(item->kind) {
+ case DBUS_CLIENT:
+ if (afb_api_dbus_add_client(item->value) < 0) {
+ ERROR("can't start the afb-dbus client of path %s",item->value);
+ exit(1);
+ }
+ break;
+ case DBUS_SERVICE:
+ if (afb_api_dbus_add_server(item->value) < 0) {
+ ERROR("can't start the afb-dbus service of path %s",item->value);
+ exit(1);
+ }
+ break;
+ case WS_CLIENT:
+ if (afb_api_ws_add_client(item->value) < 0) {
+ ERROR("can't start the afb-websocket client of path %s",item->value);
+ exit(1);
+ }
+ break;
+ case WS_SERVICE:
+ if (afb_api_ws_add_server(item->value) < 0) {
+ ERROR("can't start the afb-websocket service of path %s",item->value);
+ exit(1);
+ }
+ break;
+ case SO_BINDING:
+ if (afb_api_so_add_binding(item->value) < 0) {
+ ERROR("can't start the binding of path %s",item->value);
+ exit(1);
+ }
+ break;
+ default:
+ ERROR("unexpected internal error");
+ exit(1);
+ }
+ /* frre the item */
+ free(item);
+ }