Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
3330bca4
Commit
3330bca4
authored
Dec 05, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using mg_handler_t
parent
31f0409b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
16 deletions
+8
-16
core.c
build/src/core.c
+2
-2
core.h
build/src/core.h
+6
-14
No files found.
build/src/core.c
View file @
3330bca4
...
@@ -148,7 +148,7 @@ struct vec {
...
@@ -148,7 +148,7 @@ struct vec {
struct
uri_handler
{
struct
uri_handler
{
struct
linked_list_link
link
;
struct
linked_list_link
link
;
char
*
uri
;
char
*
uri
;
mg_
uri_
handler_t
handler
;
mg_handler_t
handler
;
};
};
// NOTE(lsm): this enum shoulds be in sync with the config_options.
// NOTE(lsm): this enum shoulds be in sync with the config_options.
...
@@ -1942,7 +1942,7 @@ static int mg_iterate_over_connections(struct mg_server *server,
...
@@ -1942,7 +1942,7 @@ static int mg_iterate_over_connections(struct mg_server *server,
}
}
void
mg_add_uri_handler
(
struct
mg_server
*
server
,
const
char
*
uri
,
void
mg_add_uri_handler
(
struct
mg_server
*
server
,
const
char
*
uri
,
mg_
uri_
handler_t
handler
)
{
mg_handler_t
handler
)
{
struct
uri_handler
*
p
=
(
struct
uri_handler
*
)
malloc
(
sizeof
(
*
p
));
struct
uri_handler
*
p
=
(
struct
uri_handler
*
)
malloc
(
sizeof
(
*
p
));
if
(
p
!=
NULL
)
{
if
(
p
!=
NULL
)
{
LINKED_LIST_ADD_TO_FRONT
(
&
server
->
uri_handlers
,
&
p
->
link
);
LINKED_LIST_ADD_TO_FRONT
(
&
server
->
uri_handlers
,
&
p
->
link
);
...
...
build/src/core.h
View file @
3330bca4
...
@@ -47,25 +47,23 @@ struct mg_connection {
...
@@ -47,25 +47,23 @@ struct mg_connection {
int
content_len
;
// content length
int
content_len
;
// content length
int
is_websocket
;
// Connection is a websocket connection
int
is_websocket
;
// Connection is a websocket connection
int
status_code
;
// HTTP status code for HTTP error handler
unsigned
char
wsbits
;
// First byte of the websocket frame
unsigned
char
wsbits
;
// First byte of the websocket frame
void
*
server_param
;
// Parameter passed to mg_add_uri_handler()
void
*
server_param
;
// Parameter passed to mg_add_uri_handler()
void
*
connection_param
;
// Placeholder for connection-specific data
void
*
connection_param
;
// Placeholder for connection-specific data
};
};
struct
mg_server
;
// Opaque structure describing server instance
struct
mg_server
;
// Opaque structure describing server instance
typedef
int
(
*
mg_uri_handler_t
)(
struct
mg_connection
*
);
typedef
int
(
*
mg_handler_t
)(
struct
mg_connection
*
);
typedef
int
(
*
mg_error_handler_t
)(
struct
mg_connection
*
,
int
http_error_code
);
// Server management functions
// Server management functions
struct
mg_server
*
mg_create_server
(
void
*
server_param
);
struct
mg_server
*
mg_create_server
(
void
*
server_param
);
void
mg_destroy_server
(
struct
mg_server
**
);
void
mg_destroy_server
(
struct
mg_server
**
);
const
char
*
mg_set_option
(
struct
mg_server
*
,
const
char
*
opt
,
const
char
*
val
);
const
char
*
mg_set_option
(
struct
mg_server
*
,
const
char
*
opt
,
const
char
*
val
);
void
mg_poll_server
(
struct
mg_server
*
,
int
milliseconds
);
void
mg_poll_server
(
struct
mg_server
*
,
int
milliseconds
);
void
mg_add_uri_handler
(
struct
mg_server
*
,
const
char
*
uri
,
mg_uri_handler_t
);
void
mg_add_uri_handler
(
struct
mg_server
*
,
const
char
*
uri
,
mg_handler_t
);
#if 0
void
mg_set_error_handler
(
struct
mg_server
*
,
mg_handler_t
);
void mg_set_error_handler(struct mg_server *, mg_error_handler_t);
void
mg_set_log_handler
(
struct
mg_server
*
,
mg_handler_t
);
void mg_set_log_handler(struct mg_server*, int (*)(struct mg_connection*, int));
#endif
const
char
**
mg_get_valid_option_names
(
void
);
const
char
**
mg_get_valid_option_names
(
void
);
const
char
*
mg_get_option
(
const
struct
mg_server
*
server
,
const
char
*
name
);
const
char
*
mg_get_option
(
const
struct
mg_server
*
server
,
const
char
*
name
);
...
@@ -73,16 +71,10 @@ const char *mg_get_option(const struct mg_server *server, const char *name);
...
@@ -73,16 +71,10 @@ const char *mg_get_option(const struct mg_server *server, const char *name);
int
mg_write
(
struct
mg_connection
*
,
const
void
*
buf
,
int
len
);
int
mg_write
(
struct
mg_connection
*
,
const
void
*
buf
,
int
len
);
const
char
*
mg_get_header
(
const
struct
mg_connection
*
,
const
char
*
name
);
const
char
*
mg_get_header
(
const
struct
mg_connection
*
,
const
char
*
name
);
const
char
*
mg_get_mime_type
(
const
char
*
file_name
);
const
char
*
mg_get_mime_type
(
const
char
*
file_name
);
int
mg_get_var
(
const
struct
mg_connection
*
conn
,
#if 0
int mg_printf(struct mg_connection *, const char *fmt, ...);
void mg_send_file(struct mg_connection *, const char *path);
int mg_read(struct mg_connection *, void *buf, int len);
int mg_get_var(const char *data, size_t data_len,
const
char
*
var_name
,
char
*
dst
,
size_t
dst_len
);
const
char
*
var_name
,
char
*
dst
,
size_t
dst_len
);
int
mg_get_cookie
(
const
char
*
cookie
,
const
char
*
var_name
,
int
mg_get_cookie
(
const
char
*
cookie
,
const
char
*
var_name
,
char
*
buf
,
size_t
buf_len
);
char
*
buf
,
size_t
buf_len
);
#endif
// Utility functions
// Utility functions
int
mg_start_thread
(
void
*
(
*
func
)(
void
*
),
void
*
param
);
int
mg_start_thread
(
void
*
(
*
func
)(
void
*
),
void
*
param
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment