Add CMake build files (required by Yocto build process)
[src/app-framework-binder.git] / include / local-def.h
index f69ddcb..8fe87d0 100644 (file)
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-   $Id: $
 */
 
-#define _GNU_SOURCE
+#ifndef _GNU_SOURCE
+  #define _GNU_SOURCE
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <json.h>
 #include <microhttpd.h>
+#include <magic.h>
+#include <setjmp.h>
+#include <signal.h>
+
 
 
 #define AJQ_VERSION "0.1"
 
 /* other definitions --------------------------------------------------- */
 
+// Note: because of a bug in libmagic MAGIC_DB NULL should not be used for default
+#define MAGIC_DB "/usr/share/misc/magic.mgc"
+#define OPA_INDEX "index.html"
+#define MAX_ALIAS 10  // max number of aliases
+
 typedef int BOOL;
 #ifndef FALSE
   #define FALSE 0
@@ -54,7 +64,8 @@ typedef int BOOL;
 #define FAILED    -1
 
 // prebuild json error are constructed in config.c
-typedef enum  { AFB_FALSE, AFB_TRUE, AFB_FATAL, AFB_FAIL, AFB_WARNING, AFB_EMPTY, AFB_SUCCESS} AFB_ERROR;
+typedef enum  { AFB_FALSE, AFB_TRUE, AFB_FATAL, AFB_FAIL, AFB_WARNING, AFB_EMPTY, AFB_SUCCESS} AFB_error;
+
 extern char *ERROR_LABEL[];
 #define ERROR_LABEL_DEF {"false", "true","fatal", "fail", "warning", "empty", "success"}
 
@@ -70,7 +81,7 @@ typedef struct {
   int   level;
   char* label;
   json_object *json;
-} AFB_ErrorT;
+} AFB_errorT;
 
 // Post handler
 typedef struct {
@@ -79,6 +90,17 @@ typedef struct {
   int   uid;
 } AFB_HttpPost;
 
+typedef struct {
+  char  path[512];
+  int   fd;
+} AFB_staticfile;
+
+typedef struct {
+  char  *url;
+  char  *path;
+  size_t len;
+} AFB_aliasdir;
+
 
 // some usefull static object initialized when entering listen loop.
 extern int verbose;
@@ -89,11 +111,12 @@ typedef struct {
   char *api;
   char *post;
   struct MHD_Connection *connection;
+  sigjmp_buf checkPluginCall; // context save for timeout set/longjmp
 } AFB_request;
 
 typedef struct {
-     char *msg;
-     int  len;
+     char    *msg;
+     size_t  len;
 } AFB_redirect_msg;
 
 // main config structure
@@ -112,7 +135,8 @@ typedef struct {
   char *configfile;        // where to store configuration on gateway exit
   uid_t setuid;
   int  cacheTimeout;
-  AFB_redirect_msg html5;  // html5 redirect message
+  int  apiTimeout;
+  AFB_aliasdir *aliasdir;  // alias mapping for icons,apps,...
 } AFB_config;
 
 // Command line structure hold cli --command + help text
@@ -130,6 +154,7 @@ typedef struct {
   char *name;
   AFB_apiCB callback;
   char *info;
+  void * handle;
 } AFB_restapi;
 
 // Plugin definition
@@ -137,6 +162,7 @@ typedef struct {
   AFB_type type;  
   char *info;
   char *prefix;
+  size_t prefixlen;
   json_object *jtype;
   AFB_restapi *apis;
 } AFB_plugin;
@@ -154,6 +180,8 @@ typedef struct {
   int  fakemod;           // respond to GET/POST request without interacting with sndboard
   int  forceexit;         // when autoconfig from script force exit before starting server
   AFB_plugin **plugins;   // pointer to REST/API plugins 
+  magic_t  magic;         // Mime type file magic lib
+  sigjmp_buf restartCkpt; // context save for restart set/longjmp
 } AFB_session;