diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2020-06-21 21:27:46 +0000 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2020-06-21 21:27:46 +0000 |
commit | 4570daec42c1e38c2df88facc23743f45f907b3d (patch) | |
tree | 3ebfe39d2764d79506cf86359d5ac36b89b01352 /include | |
parent | 07657b8a9f5c2fd9047594ec8604b9c439a999e4 (diff) | |
download | magi-4570daec42c1e38c2df88facc23743f45f907b3d.tar magi-4570daec42c1e38c2df88facc23743f45f907b3d.tar.xz magi-4570daec42c1e38c2df88facc23743f45f907b3d.zip |
Documentation started.
Diffstat (limited to 'include')
-rw-r--r-- | include/magi/cookie.h | 5 | ||||
-rw-r--r-- | include/magi/error.h | 22 | ||||
-rw-r--r-- | include/magi/response.h | 11 |
3 files changed, 25 insertions, 13 deletions
diff --git a/include/magi/cookie.h b/include/magi/cookie.h index 4760b75..7573747 100644 --- a/include/magi/cookie.h +++ b/include/magi/cookie.h @@ -27,9 +27,8 @@ void magi_cookies_free(magi_cookies *cookies); /* Add newitem onto top of cookies. */ void magi_cookies_add(magi_cookies **cookies, magi_cookie *newitem); -/* Get last from top of cookies cookie with name, null if no such cookie. - * Cookies are in reversed request order, and first cookie from request is - * the most accurate in terms of domain and path. */ +/* Get first cookie with given name, null if no such cookie. + * First cookie is the most accurate in terms of domain and path. */ const magi_cookie *magi_cookies_get(const magi_cookies *cookies, const char *name); diff --git a/include/magi/error.h b/include/magi/error.h index 19538ae..6f64228 100644 --- a/include/magi/error.h +++ b/include/magi/error.h @@ -5,22 +5,24 @@ */ +/* Magi error codes. */ typedef enum magi_error { - magi_error_none = 0, - magi_error_nobound, - magi_error_unknown, - magi_error_notype, - magi_error_length, - magi_error_memory, - magi_error_cookies, - magi_error_urlenc, - magi_error_multipart, - magi_error_limit + magi_error_none = 0, /* No error, all is ok. */ + magi_error_nobound, /* No boundary provided for multipart/form-data. */ + magi_error_unknown, /* Unknown Content Type. */ + magi_error_notype, /* No Content Type provided. */ + magi_error_length, /* Wrong Content Length. */ + magi_error_cookies, /* Bad Cookies header. */ + magi_error_urlenc, /* Wrong url encoding. */ + magi_error_multipart, /* Malformed multipart/form-data. */ + magi_error_limit /* One of specified limits reached. */ } magi_error; +/* Get description message of given error. */ const char *magi_error_message(magi_error error); +/* Response default error page for given error. */ void magi_error_response(magi_error error); diff --git a/include/magi/response.h b/include/magi/response.h index e67b279..9364fd4 100644 --- a/include/magi/response.h +++ b/include/magi/response.h @@ -13,6 +13,7 @@ #include <stdarg.h> +/* Response headers as three sequential groups. */ typedef struct magi_response { magi_params *head_response; magi_params *head_general; @@ -20,21 +21,31 @@ typedef struct magi_response { } magi_response; +/* Response initialiser, setup defaults. */ void magi_response_init(magi_response *r); +/* Send response headers and free memory used by it. */ void magi_response_free(magi_response *r); +/* Just response defaults. (text/html, 200 Ok) */ void magi_response_default(); +/* Change resposne status header. */ void magi_response_status(magi_response *r, int code, const char *description); +/* Add cookie to response. */ void magi_response_cookie(magi_response *r, const char *n, const char *d); +/* Add cookie with additional information to response. */ void magi_response_cookie_complex(magi_response *r, magi_cookie *c); +/* Add request to discard cookie to response. */ void magi_response_cookie_discard(magi_response *r, const char *name); +/* Just add some general custom header. */ void magi_response_header(magi_response *r, const char *n, const char *d); +/* Change Content-Length header. */ void magi_response_content_length(magi_response *r, int length); +/* Change Content-Type header. */ void magi_response_content_type(magi_response *r, const char *type); |