aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgi.h6
-rw-r--r--src/fastcgi.h12
-rw-r--r--src/field.c53
-rw-r--r--src/field.h41
-rw-r--r--src/file.c0
-rw-r--r--src/file.h0
-rw-r--r--src/multipart.h6
-rw-r--r--src/param.h2
-rw-r--r--src/request.h7
9 files changed, 24 insertions, 103 deletions
diff --git a/src/cgi.h b/src/cgi.h
index 331e306..ee818ac 100644
--- a/src/cgi.h
+++ b/src/cgi.h
@@ -14,8 +14,10 @@ int magi_cgi(struct magi_request * request,
/* Null callback disables callback system. */
void (*callback)(struct magi_field * field,
char * buffer,
- int len),
- int max_post);
+ int len,
+ void * thing),
+ void * thing,
+ int max_post);
#endif
diff --git a/src/fastcgi.h b/src/fastcgi.h
index 1c2cda7..d2199b4 100644
--- a/src/fastcgi.h
+++ b/src/fastcgi.h
@@ -11,12 +11,20 @@ struct magi_session {
struct magi_socket_list * sockets;
};
-int magi_fcgi(struct magi_session * session);
+int magi_fcgi(struct magi_session * session, int socket);
/*
* Returns null if succeed, otherwise error code.
*/
-int magi_accept(struct magi_request * request, struct magi_session * session);
+int magi_fcgi_accept(
+ struct magi_request * request,
+ struct magi_session * session,
+ /* Callback will be used only for files loaded via multipart. */
+ /* Null callback disables callback system. */
+ void (*callback)(
+ struct magi_field * field, char * buffer, int len, void * thing),
+ void * thing,
+ int max_post);
#endif
diff --git a/src/field.c b/src/field.c
deleted file mode 100644
index 6358151..0000000
--- a/src/field.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "field.h"
-
-#include "error.h"
-#include "param.h"
-#include <stdlib.h>
-#include <string.h>
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Form Field
- */
-int magi_field_list_add(struct magi_field_list ** list,
- struct magi_field * item)
-{
- struct magi_field_list * old = *list;
- int ok = 1;
- *list = malloc(sizeof(**list));
- if (*list) {
- (*list)->next = old;
- (*list)->item = *item;
- } else {
- ok = 0;
- magi_error_set("[field:list] Cannot allocate new list node.");
- *list = old;
- }
- return ok;
-}
-
-struct magi_field * magi_field_list_get(struct magi_field_list * list,
- const char * name)
-{
- struct magi_field * item = 0;
- if (list && name) {
- if (!strcmp(list->item.name, name)) {
- item = &list->item;
- } else {
- item = magi_field_list_get(list->next, name);
- }
- }
- return item;
-}
-
-void magi_field_list_destroy(struct magi_field_list * list)
-{
- if (list) {
- magi_field_list_destroy(list->next);
- magi_param_list_destroy(list->item.params);
- free(list->next);
- free(list->item.name);
- free(list->item.data);
- free(list->item.params);
- }
-}
diff --git a/src/field.h b/src/field.h
deleted file mode 100644
index 04c8411..0000000
--- a/src/field.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef MAGI_INCLUDED_FIELD
-#define MAGI_INCLUDED_FIELD
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Form Field
- */
-struct magi_field {
- char * name; /* name: free(name) is valid. */
- char * data; /* data: free(data) is valid. */
- int len; /* Length of data. */
- struct magi_param_list * params; /* Only used if field is for file. */
-};
-
-/* Null is valid "struct magi_field_list *" object. */
-struct magi_field_list {
- struct magi_field_list * next;
- struct magi_field item;
-};
-
-/*
- * Adds *item to the begining of *list, item and list are dereferencable;
- * Returns null in case of error.
- */
-int magi_field_list_add(struct magi_field_list ** list,
- struct magi_field * item);
-
-/*
- * Searchs for first node in list: node.name == name, name is C-string;
- * Returns node itself if succeed, otherwise result is null.
- */
-struct magi_field * magi_field_list_get(struct magi_field_list * list,
- const char * name);
-
-/*
- * Destroys list; list is not valid after destruction.
- */
-void magi_field_list_destroy(struct magi_field_list * list);
-
-
-#endif
diff --git a/src/file.c b/src/file.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/file.c
diff --git a/src/file.h b/src/file.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/file.h
diff --git a/src/multipart.h b/src/multipart.h
index 43b6212..bb51d5c 100644
--- a/src/multipart.h
+++ b/src/multipart.h
@@ -13,8 +13,10 @@ int magi_parse_multipart(
void * get_next_arg,
char * boundary,
/* End if size < magi_parse_multipart_callback_size. */
- /* Null callback means filling list. */
- void (*callback)(struct magi_field * field, char * buffer, int size));
+ /* Null callback means skipping. */
+ void (*callback)(
+ struct magi_file * file, char * buffer, int size, void * thing),
+ void * thing);
#endif
diff --git a/src/param.h b/src/param.h
index b06c59f..21e9538 100644
--- a/src/param.h
+++ b/src/param.h
@@ -5,6 +5,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Parameter
*/
+enum { magi_param_max = 1024 };
+
struct magi_param {
char * name; /* name: free(name) is valid. */
char * data; /* data: free(data) is valid. */
diff --git a/src/request.h b/src/request.h
index 89181d1..d74dced 100644
--- a/src/request.h
+++ b/src/request.h
@@ -30,8 +30,9 @@
* path_info: /foo/bar
*/
struct magi_request {
- /* TODO: struct magi_param_list * url_params; */
- struct magi_field_list * fields;
+ struct magi_param_list * url_params;
+ struct magi_param_list * params;
+ struct magi_file_list * files;
struct magi_cookie_list * cookies;
char * method;
char * uri;
@@ -48,7 +49,7 @@ struct magi_request {
char * server_software;
char * path_info;
struct magi_param_list * http_params;
- struct magi_error * error;
+ enum magi_error error;
};