added lighttpd.c, modified action und option stuff

personal/stbuehler/wip
Thomas Porzelt 14 years ago
parent 5cc704884a
commit 5cee4c1fa4
  1. 17
      src/actions.c
  2. 6
      src/actions.h
  3. 3
      src/base.h
  4. 6
      src/config_parser.h
  5. 14
      src/config_parser.rl
  6. 10
      src/lighttpd.c
  7. 15
      src/options.c
  8. 2
      src/options.h
  9. 14
      src/server.c
  10. 5
      src/tests.c
  11. 3
      src/wscript

@ -1,4 +1,5 @@
#include "log.h"
#include "actions.h"
#include "condition.h"
@ -149,3 +150,19 @@ action_result action_execute(server *srv, connection *con) {
}
return ACTION_GO_ON;
}
action *action_new_setting(server *srv, GString *name, option *value) {
gsize ndx;
if (!option_get_index(srv, name, &ndx))
ERROR("unknown setting: \"%s\"", name->str);
action *a = g_slice_new(action);
a->refcount = 1;
a->type = ACTION_TSETTING;
return a;
}

@ -74,4 +74,10 @@ LI_API void action_stack_clear(action_stack *as);
LI_API void action_enter(connection *con, action_list *al);
LI_API action_result action_execute(server *srv, connection *con);
/* create new action */
action *action_new_setting(server *srv, GString *name, option *value);
action *action_new_function();
action *action_new_condition_string(comp_key_t comp, comp_operator_t op, GString *str);
action *action_new_condition_int(comp_key_t comp, comp_operator_t op, guint64 i);
#endif

@ -38,4 +38,7 @@ struct connection {
physical physical;
};
server* server_new();
void server_free(server* srv);
#endif

@ -7,11 +7,11 @@ struct config_parser_filestack_entry_t;
typedef struct config_parser_filestack_entry_t config_parser_filestack_entry_t;
/* loads a file into memory and parses it */
gboolean config_parser_file(const gchar *path);
gboolean config_parser_file(server *srv, const gchar *path);
/* launched a command through the shell and parses the stdout it returns */
gboolean config_parser_shell(const gchar *command);
gboolean config_parser_shell(server *srv, const gchar *command);
/* parses a buffer pointed to by the previously allocated config_parser_data struct */
gboolean config_parser_buffer();
gboolean config_parser_buffer(server *srv);
struct config_parser_data_t {
/* information of currently parsed file */

@ -135,11 +135,11 @@
action incl {
_printf("including file %s in line %zd of %s\n", cpd->val_str->str, cpd->line, cpd->filename);
if (!config_parser_file(cpd->val_str->str))
if (!config_parser_file(srv, cpd->val_str->str))
return FALSE;
}
action incl_shell {
if (!config_parser_shell(cpd->val_str->str))
if (!config_parser_shell(srv, cpd->val_str->str))
return FALSE;
}
@ -210,7 +210,7 @@ void config_parser_init() {
config_parser_data = NULL;
}
gboolean config_parser_file(const gchar *path)
gboolean config_parser_file(server *srv, const gchar *path)
{
gboolean res;
config_parser_data_t *cpd;
@ -232,7 +232,7 @@ gboolean config_parser_file(const gchar *path)
config_parser_data = g_list_prepend(config_parser_data, cpd);
res = config_parser_buffer();
res = config_parser_buffer(srv);
config_parser_data = g_list_delete_link(config_parser_data, config_parser_data);
@ -245,7 +245,7 @@ gboolean config_parser_file(const gchar *path)
return res;
}
gboolean config_parser_shell(const gchar *command)
gboolean config_parser_shell(server *srv, const gchar *command)
{
gboolean res;
gchar* _stdout;
@ -282,7 +282,7 @@ gboolean config_parser_shell(const gchar *command)
_printf("included shell output from \"%s\" (%zu bytes):\n%s\n", command, cpd->len, _stdout);
config_parser_data = g_list_prepend(config_parser_data, cpd);
res = config_parser_buffer();
res = config_parser_buffer(srv);
config_parser_data = g_list_delete_link(config_parser_data, config_parser_data);
g_free(_stdout);
@ -295,7 +295,7 @@ gboolean config_parser_shell(const gchar *command)
return res;
}
gboolean config_parser_buffer()
gboolean config_parser_buffer(server *srv)
{
config_parser_data_t *cpd;

@ -0,0 +1,10 @@
#include "base.h"
#include "log.h"
int main() {
TRACE("%s", "Test!");
return 0;
}

@ -1,4 +1,5 @@
#include "base.h"
#include "options.h"
option* option_new_bool(gboolean val) {
@ -119,3 +120,17 @@ gpointer option_extract_value(option *opt) {
g_slice_free(option, opt);
return val;
}
gboolean option_get_index(server *srv, GString *name, gsize *ndx)
{
gpointer ptr;
ptr = g_hash_table_lookup(srv->options, (gconstpointer) name);
if (ptr == NULL)
return FALSE;
*ndx = 0;
return TRUE;
}

@ -53,4 +53,6 @@ LI_API void option_list_free(GArray *optlist);
/* Extract value from option, destroy option */
LI_API gpointer option_extract_value(option *opt);
gboolean option_get_index(server *srv, GString *name, gsize *ndx);
#endif

@ -1,26 +1,16 @@
#include "base.h"
#include "log.h"
static server* server_new() {
server* server_new() {
server* srv = g_slice_new0(server);
srv->plugins = g_hash_table_new(g_str_hash, g_str_equal);
srv->options = g_hash_table_new(g_str_hash, g_str_equal);
return srv;
}
static void server_free(server* srv) {
void server_free(server* srv) {
if (!srv) return;
/* TODO */
g_slice_free(server, srv);
}
int main() {
TRACE("%s", "Test!");
return 0;
}

@ -33,13 +33,16 @@ int request_test() {
}
int main() {
server *srv;
GTimeVal start, end;
gboolean result;
srv = server_new();
/* config parser test */
config_parser_init();
g_get_current_time(&start);
result = config_parser_file("../test.conf");
result = config_parser_file(srv, "../test.conf");
g_get_current_time(&end);
printf("parsed config in %ld seconds %ld milliseconds and %ld microseconds\n",

@ -19,6 +19,7 @@ common_source='''
options.c
plugin.c
request.c
server.c
sys-files.c
sys-socket.c
'''
@ -28,7 +29,7 @@ common_source_lua='''
'''
main_source = '''
server.c
lighttpd.c
'''
#def node_in_same_dir(node, name):

Loading…
Cancel
Save