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
#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"}
int level;
char* label;
json_object *json;
-} AFB_ErrorT;
+} AFB_errorT;
// Post handler
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;
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
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
char *name;
AFB_apiCB callback;
char *info;
+ void * handle;
} AFB_restapi;
// Plugin definition
AFB_type type;
char *info;
char *prefix;
+ size_t prefixlen;
json_object *jtype;
AFB_restapi *apis;
} AFB_plugin;
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;