summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2015-12-07 01:39:27 +0100
committerFulup Ar Foll <fulup@iot.bzh>2015-12-07 01:39:27 +0100
commitc2bda43c447016a20ed061078b0dff3e64d09940 (patch)
tree1c0bbb0f4a0b659703f66eeb90c02d998bc84e11 /include
parentcd054544444e92e7695dd288f0c04b7af0f668e3 (diff)
Almost working
Diffstat (limited to 'include')
-rw-r--r--include/local-def.h16
-rw-r--r--include/proto-def.h23
2 files changed, 26 insertions, 13 deletions
diff --git a/include/local-def.h b/include/local-def.h
index f69ddcbe..3f0a26a0 100644
--- a/include/local-def.h
+++ b/include/local-def.h
@@ -17,7 +17,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: $
*/
#define _GNU_SOURCE
@@ -35,7 +34,7 @@
#include <time.h>
#include <json.h>
#include <microhttpd.h>
-
+#include <magic.h>
#define AJQ_VERSION "0.1"
@@ -54,7 +53,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 +70,7 @@ typedef struct {
int level;
char* label;
json_object *json;
-} AFB_ErrorT;
+} AFB_errorT;
// Post handler
typedef struct {
@@ -79,6 +79,11 @@ typedef struct {
int uid;
} AFB_HttpPost;
+typedef struct {
+ char path[512];
+ int fd;
+} AFB_staticfile;
+
// some usefull static object initialized when entering listen loop.
extern int verbose;
@@ -112,7 +117,6 @@ typedef struct {
char *configfile; // where to store configuration on gateway exit
uid_t setuid;
int cacheTimeout;
- AFB_redirect_msg html5; // html5 redirect message
} AFB_config;
// Command line structure hold cli --command + help text
@@ -137,6 +141,7 @@ typedef struct {
AFB_type type;
char *info;
char *prefix;
+ size_t prefixlen;
json_object *jtype;
AFB_restapi *apis;
} AFB_plugin;
@@ -154,6 +159,7 @@ 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
} AFB_session;
diff --git a/include/proto-def.h b/include/proto-def.h
index 934bf30f..d1b0c3fb 100644
--- a/include/proto-def.h
+++ b/include/proto-def.h
@@ -23,31 +23,38 @@
// Rest-api
PUBLIC json_object* pingSample (AFB_plugin *plugin, AFB_session *session, AFB_request *post);
PUBLIC const char* getQueryValue (AFB_request * request, char *name);
-PUBLIC AFB_plugin *afsvRegister (AFB_session *session);
PUBLIC int doRestApi(struct MHD_Connection *connection, AFB_session *session, const char *method, const char* url);
+void initPlugins (AFB_session *session);
+
+typedef AFB_plugin* (*AFB_pluginCB)(AFB_session *session);
+PUBLIC AFB_plugin* afsvRegister (AFB_session *session);
+PUBLIC AFB_plugin* dbusRegister (AFB_session *session);
+PUBLIC AFB_plugin* alsaRegister (AFB_session *session);
+
+
// Session handling
-PUBLIC AFB_ERROR sessionCheckdir (AFB_session *session);
+PUBLIC AFB_error sessionCheckdir (AFB_session *session);
PUBLIC json_object *sessionList (AFB_session *session, AFB_request *request);
PUBLIC json_object *sessionToDisk (AFB_session *session, AFB_request *request, char *name,json_object *jsonSession);
PUBLIC json_object *sessionFromDisk (AFB_session *session, AFB_request *request, char *name);
// Httpd server
-PUBLIC AFB_ERROR httpdStart (AFB_session *session);
-PUBLIC AFB_ERROR httpdLoop (AFB_session *session);
+PUBLIC AFB_error httpdStart (AFB_session *session);
+PUBLIC AFB_error httpdLoop (AFB_session *session);
PUBLIC void httpdStop (AFB_session *session);
// config management
PUBLIC char *configTime (void);
PUBLIC AFB_session *configInit (void);
-PUBLIC json_object *jsonNewMessage (AFB_ERROR level, char* format, ...);
-PUBLIC json_object *jsonNewStatus (AFB_ERROR level);
+PUBLIC json_object *jsonNewMessage (AFB_error level, char* format, ...);
+PUBLIC json_object *jsonNewStatus (AFB_error level);
PUBLIC json_object *jsonNewjtype (void);
-PUBLIC json_object *jsonNewMessage (AFB_ERROR level, char* format, ...);
+PUBLIC json_object *jsonNewMessage (AFB_error level, char* format, ...);
PUBLIC void jsonDumpObject (json_object * jObject);
-PUBLIC AFB_ERROR configLoadFile (AFB_session * session, AFB_config *cliconfig);
+PUBLIC AFB_error configLoadFile (AFB_session * session, AFB_config *cliconfig);
PUBLIC void configStoreFile (AFB_session * session);