1992b5100025754413c57e2e630a060a5915d06f
[src/app-framework-binder.git] / src / local-def.h
1 /*
2    local-def.h -- provide a REST/HTTP interface
3
4    Copyright (C) 2015, Fulup Ar Foll
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 */
21 #ifndef LOCAL_DEF_H
22 #define LOCAL_DEF_H
23
24 #include <json.h>
25 #include <microhttpd.h>
26
27 /* other definitions --------------------------------------------------- */
28
29 // Note: because of a bug in libmagic MAGIC_DB NULL should not be used for default
30 #define MAX_ALIAS 10           // max number of aliases
31 #define COOKIE_NAME   "afb-session"
32
33 #define DEFLT_CNTX_TIMEOUT  3600   // default Client Connection Timeout
34 #define DEFLT_API_TIMEOUT   0      // default Plugin API Timeout [0=NoLimit for Debug Only]
35 #define DEFLT_CACHE_TIMEOUT 100000 // default Static File Chache [Client Side Cache 100000~=1day]
36 #define DEFLT_AUTH_TOKEN    NULL   // expect for debug should == NULL
37 #define DEFLT_HTTP_TIMEOUT  15     // Max MibMicroHttp timeout
38
39 #define CTX_NBCLIENTS   10   // allow a default of 10 authenticated clients
40
41
42 typedef struct {
43   char  *url;
44   char  *path;
45   size_t len;
46 } AFB_aliasdir;
47
48 // main config structure
49 struct AFB_config
50 {
51   char *console;           // console device name (can be a file or a tty)
52   int   httpdPort;
53   char *ldpaths;           // list of plugins directories
54   char *rootdir;           // base dir for httpd file download
55   char *rootbase;          // Angular HTML5 base URL
56   char *rootapi;           // Base URL for REST APIs
57   char *sessiondir;        // where to store mixer session files
58   char *token;             // initial authentication token [default NULL no session]
59   int  cacheTimeout;
60   int  apiTimeout;
61   int  cntxTimeout;        // Client Session Context timeout
62   int mode;           // mode of listening
63   AFB_aliasdir *aliasdir;  // alias mapping for icons,apps,...
64 };
65
66 struct afb_hsrv;
67 struct afb_hsrv_handler;
68 struct MHD_Daemon;
69
70 struct AFB_session
71 {
72   struct AFB_config  *config;   // pointer to current config
73   // List of commands to execute
74   int  background;        // run in backround mode
75   int  readyfd;           // a #fd to signal when ready to serve
76   struct afb_hsrv *hsrv;
77 };
78
79
80 typedef struct AFB_config AFB_config;
81 typedef struct AFB_session AFB_session;
82
83 #endif /* LOCAL_DEF_H */