add config files

This commit is contained in:
lxsang 2019-11-13 14:22:25 +01:00
parent 296fae73c3
commit 01722ae39c
6 changed files with 67 additions and 6 deletions

1
.gitignore vendored
View File

@ -67,7 +67,6 @@ libtool
config.log
config.status
config.sub
config.ini.tpl
configure
aclocal.m4
ltmain.sh

View File

@ -10,7 +10,7 @@ else
endif
AM_CPPFLAGS += -W -Wall -g -std=c99
AM_CPPFLAGS += -W -Wall -g -std=c99 -DCONFIG_FILE=\"$(sysconfdir)/antd-config.ini\"
lib_LTLIBRARIES = libantd.la
libantd_la_SOURCES = lib/ini.c \
@ -34,7 +34,7 @@ pkginclude_HEADERS = lib/ini.h \
lib/scheduler.h \
lib/plugin.h
EXTRA_DIST = plugin_manager.h http_server.h README.md LICENSE
EXTRA_DIST = plugin_manager.h http_server.h README.md LICENSE antd-config.ini
# check for db
if DB
libantd_la_SOURCES += lib/dbhelper.c
@ -46,3 +46,11 @@ bin_PROGRAMS = antd
# lib source files
antd_SOURCES = plugin_manager.c http_server.c httpd.c
antd_LDADD = libantd.la
sysconf_DATA = antd-config.ini
#install-data-local: $(srcdir)/conf/config.file $(srcdir)/conf/sub1/config.file
# mkdir $(sysconfdir)/conf
# cp $(srcdir)/conf/config.file $(sysconfdir)/conf
# mkdir $(sysconfdir)/conf/sub1
# cp $(srcdir)/conf/sub1/config.file $(sysconfdir)/conf/sub1

52
antd-config.ini Normal file
View File

@ -0,0 +1,52 @@
[SERVER]
; server port
; use 443 if one want to use
; SSL
port=8080
; plugin directory
plugins=/opt/www/plugins/
; plugin extension
plugins_ext=.dylib
; SQLITE database path
database=/opt/www/database/
; Website store here
htdocs=/opt/www/htdocs
; tmp dir
tmpdir=/opt/www/tmp/
; server backlocg
backlog=5000
; eable or disalbe SSL
ssl.enable=0
; if SSL is enable, one should specify
; the SSL cert and key files
; ssl.cert=fullchain.pem
; ssl.key=privkey.pem
; This enable some plugins to be initialised at server startup
[AUTOSTART]
; to start a plugin at server statup use:
;plugin = plugin_name_1
;plugin = plugin_name_2, etc
; sever rules
[RULES]
; For example the following rule will
; convert a request of type:
; name.example.com?rq=1
;TO:
; example.com/name/?rq=1
; this is helpful to redirect many sub domains
; to a sub folder of the same server
; ^([a-zA-Z][a-zA-Z0-9]*)\.[a-zA-Z0-9]+\..*$ = /<1><url>?<query>
; Sytax: [regular expression on the original request]=[new request rule]
[FILEHANDLER]
; specify a plugin for handling
; a file type
; lua page script
ls = lua-api
; pure lua script
lua = lua-api
; php and o ther scripting languages can be
; handled by the cgi plugin
; php = cgi

Binary file not shown.

View File

@ -15,7 +15,9 @@
#define PLUGIN_HANDLER "handle"
#define WS_MAGIC_STRING "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
#define CONFIG "config.ini"
#ifndef CONFIG_FILE
#define CONFIG_FILE "antd-config.ini"
#endif
config_t* config();
void destroy_config();

View File

@ -117,7 +117,7 @@ int main(int argc, char* argv[])
{
// load the config first
if(argc==1)
load_config(CONFIG);
load_config(CONFIG_FILE);
else
load_config(argv[1]);
unsigned port = config()->port;