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
226d4768
Commit
226d4768
authored
Sep 29, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved more defines to internal.h. Squashed some warnings in win32
parent
21965e0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
104 deletions
+106
-104
internal.h
build/src/internal.h
+102
-0
mongoose.c
build/src/mongoose.c
+0
-101
mongoose.c
mongoose.c
+4
-3
No files found.
build/src/internal.h
View file @
226d4768
...
...
@@ -255,3 +255,105 @@ typedef int SOCKET;
#define MG_BUF_LEN 8192
#define MAX_REQUEST_SIZE 16384
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
#ifdef DEBUG_TRACE
#undef DEBUG_TRACE
#define DEBUG_TRACE(x)
#else
#if defined(DEBUG)
#define DEBUG_TRACE(x) do { \
flockfile
(
stdout
);
\
printf
(
"*** %lu.%p.%s.%d: "
,
\
(
unsigned
long
)
time
(
NULL
),
(
void
*
)
pthread_self
(),
\
__func__
,
__LINE__
);
\
printf
x
;
\
putchar
(
'\n'
);
\
fflush
(
stdout
);
\
funlockfile
(
stdout
);
\
}
while
(
0
)
#else
#define DEBUG_TRACE(x)
#endif // DEBUG
#endif // DEBUG_TRACE
// Darwin prior to 7.0 and Win32 do not have socklen_t
#ifdef NO_SOCKLEN_T
typedef
int
socklen_t
;
#endif // NO_SOCKLEN_T
#define _DARWIN_UNLIMITED_SELECT
#define IP_ADDR_STR_LEN 50 // IPv6 hex string is 46 chars
#if !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif
#if !defined(SOMAXCONN)
#define SOMAXCONN 100
#endif
#if !defined(PATH_MAX)
#define PATH_MAX 4096
#endif
// Size of the accepted socket queue
#if !defined(MGSQLEN)
#define MGSQLEN 20
#endif
// Extra HTTP headers to send in every static file reply
#if !defined(EXTRA_HTTP_HEADERS)
#define EXTRA_HTTP_HEADERS ""
#endif
static
const
char
*
http_500_error
=
"Internal Server Error"
;
#if defined(NO_SSL_DL)
#include <openssl/ssl.h>
#include <openssl/err.h>
#else
// SSL loaded dynamically from DLL.
// I put the prototypes here to be independent from OpenSSL source installation.
typedef
struct
ssl_st
SSL
;
typedef
struct
ssl_method_st
SSL_METHOD
;
typedef
struct
ssl_ctx_st
SSL_CTX
;
struct
ssl_func
{
const
char
*
name
;
// SSL function name
void
(
*
ptr
)(
void
);
// Function pointer
};
#define SSL_free (* (void (*)(SSL *)) ssl_sw[0].ptr)
#define SSL_accept (* (int (*)(SSL *)) ssl_sw[1].ptr)
#define SSL_connect (* (int (*)(SSL *)) ssl_sw[2].ptr)
#define SSL_read (* (int (*)(SSL *, void *, int)) ssl_sw[3].ptr)
#define SSL_write (* (int (*)(SSL *, const void *,int)) ssl_sw[4].ptr)
#define SSL_get_error (* (int (*)(SSL *, int)) ssl_sw[5].ptr)
#define SSL_set_fd (* (int (*)(SSL *, SOCKET)) ssl_sw[6].ptr)
#define SSL_new (* (SSL * (*)(SSL_CTX *)) ssl_sw[7].ptr)
#define SSL_CTX_new (* (SSL_CTX * (*)(SSL_METHOD *)) ssl_sw[8].ptr)
#define SSLv23_server_method (* (SSL_METHOD * (*)(void)) ssl_sw[9].ptr)
#define SSL_library_init (* (int (*)(void)) ssl_sw[10].ptr)
#define SSL_CTX_use_PrivateKey_file (* (int (*)(SSL_CTX *, \
const
char
*
,
int
))
ssl_sw
[
11
].
ptr
)
#define SSL_CTX_use_certificate_file (* (int (*)(SSL_CTX *, \
const
char
*
,
int
))
ssl_sw
[
12
].
ptr
)
#define SSL_CTX_set_default_passwd_cb \
(
*
(
void
(
*
)(
SSL_CTX
*
,
mg_event_handler_t
))
ssl_sw
[
13
].
ptr
)
#define SSL_CTX_free (* (void (*)(SSL_CTX *)) ssl_sw[14].ptr)
#define SSL_load_error_strings (* (void (*)(void)) ssl_sw[15].ptr)
#define SSL_CTX_use_certificate_chain_file \
(
*
(
int
(
*
)(
SSL_CTX
*
,
const
char
*
))
ssl_sw
[
16
].
ptr
)
#define SSLv23_client_method (* (SSL_METHOD * (*)(void)) ssl_sw[17].ptr)
#define SSL_pending (* (int (*)(SSL *)) ssl_sw[18].ptr)
#define SSL_CTX_set_verify (* (void (*)(SSL_CTX *, int, int)) ssl_sw[19].ptr)
#define SSL_shutdown (* (int (*)(SSL *)) ssl_sw[20].ptr)
#define CRYPTO_num_locks (* (int (*)(void)) crypto_sw[0].ptr)
#define CRYPTO_set_locking_callback \
(
*
(
void
(
*
)(
void
(
*
)(
int
,
int
,
const
char
*
,
int
)))
crypto_sw
[
1
].
ptr
)
#define CRYPTO_set_id_callback \
(
*
(
void
(
*
)(
unsigned
long
(
*
)(
void
)))
crypto_sw
[
2
].
ptr
)
#define ERR_get_error (* (unsigned long (*)(void)) crypto_sw[3].ptr)
#define ERR_error_string (* (char * (*)(unsigned long,char *)) crypto_sw[4].ptr)
build/src/mongoose.c
View file @
226d4768
#include "internal.h"
#ifdef DEBUG_TRACE
#undef DEBUG_TRACE
#define DEBUG_TRACE(x)
#else
#if defined(DEBUG)
#define DEBUG_TRACE(x) do { \
flockfile
(
stdout
);
\
printf
(
"*** %lu.%p.%s.%d: "
,
\
(
unsigned
long
)
time
(
NULL
),
(
void
*
)
pthread_self
(),
\
__func__
,
__LINE__
);
\
printf
x
;
\
putchar
(
'\n'
);
\
fflush
(
stdout
);
\
funlockfile
(
stdout
);
\
}
while
(
0
)
#else
#define DEBUG_TRACE(x)
#endif // DEBUG
#endif // DEBUG_TRACE
// Darwin prior to 7.0 and Win32 do not have socklen_t
#ifdef NO_SOCKLEN_T
typedef
int
socklen_t
;
#endif // NO_SOCKLEN_T
#define _DARWIN_UNLIMITED_SELECT
#define IP_ADDR_STR_LEN 50 // IPv6 hex string is 46 chars
#if !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif
#if !defined(SOMAXCONN)
#define SOMAXCONN 100
#endif
#if !defined(PATH_MAX)
#define PATH_MAX 4096
#endif
// Size of the accepted socket queue
#if !defined(MGSQLEN)
#define MGSQLEN 20
#endif
// Extra HTTP headers to send in every static file reply
#if !defined(EXTRA_HTTP_HEADERS)
#define EXTRA_HTTP_HEADERS ""
#endif
static
const
char
*
http_500_error
=
"Internal Server Error"
;
#if defined(NO_SSL_DL)
#include <openssl/ssl.h>
#include <openssl/err.h>
#else
// SSL loaded dynamically from DLL.
// I put the prototypes here to be independent from OpenSSL source installation.
typedef
struct
ssl_st
SSL
;
typedef
struct
ssl_method_st
SSL_METHOD
;
typedef
struct
ssl_ctx_st
SSL_CTX
;
struct
ssl_func
{
const
char
*
name
;
// SSL function name
void
(
*
ptr
)(
void
);
// Function pointer
};
#define SSL_free (* (void (*)(SSL *)) ssl_sw[0].ptr)
#define SSL_accept (* (int (*)(SSL *)) ssl_sw[1].ptr)
#define SSL_connect (* (int (*)(SSL *)) ssl_sw[2].ptr)
#define SSL_read (* (int (*)(SSL *, void *, int)) ssl_sw[3].ptr)
#define SSL_write (* (int (*)(SSL *, const void *,int)) ssl_sw[4].ptr)
#define SSL_get_error (* (int (*)(SSL *, int)) ssl_sw[5].ptr)
#define SSL_set_fd (* (int (*)(SSL *, SOCKET)) ssl_sw[6].ptr)
#define SSL_new (* (SSL * (*)(SSL_CTX *)) ssl_sw[7].ptr)
#define SSL_CTX_new (* (SSL_CTX * (*)(SSL_METHOD *)) ssl_sw[8].ptr)
#define SSLv23_server_method (* (SSL_METHOD * (*)(void)) ssl_sw[9].ptr)
#define SSL_library_init (* (int (*)(void)) ssl_sw[10].ptr)
#define SSL_CTX_use_PrivateKey_file (* (int (*)(SSL_CTX *, \
const
char
*
,
int
))
ssl_sw
[
11
].
ptr
)
#define SSL_CTX_use_certificate_file (* (int (*)(SSL_CTX *, \
const
char
*
,
int
))
ssl_sw
[
12
].
ptr
)
#define SSL_CTX_set_default_passwd_cb \
(
*
(
void
(
*
)(
SSL_CTX
*
,
mg_event_handler_t
))
ssl_sw
[
13
].
ptr
)
#define SSL_CTX_free (* (void (*)(SSL_CTX *)) ssl_sw[14].ptr)
#define SSL_load_error_strings (* (void (*)(void)) ssl_sw[15].ptr)
#define SSL_CTX_use_certificate_chain_file \
(
*
(
int
(
*
)(
SSL_CTX
*
,
const
char
*
))
ssl_sw
[
16
].
ptr
)
#define SSLv23_client_method (* (SSL_METHOD * (*)(void)) ssl_sw[17].ptr)
#define SSL_pending (* (int (*)(SSL *)) ssl_sw[18].ptr)
#define SSL_CTX_set_verify (* (void (*)(SSL_CTX *, int, int)) ssl_sw[19].ptr)
#define SSL_shutdown (* (int (*)(SSL *)) ssl_sw[20].ptr)
#define CRYPTO_num_locks (* (int (*)(void)) crypto_sw[0].ptr)
#define CRYPTO_set_locking_callback \
(
*
(
void
(
*
)(
void
(
*
)(
int
,
int
,
const
char
*
,
int
)))
crypto_sw
[
1
].
ptr
)
#define CRYPTO_set_id_callback \
(
*
(
void
(
*
)(
unsigned
long
(
*
)(
void
)))
crypto_sw
[
2
].
ptr
)
#define ERR_get_error (* (unsigned long (*)(void)) crypto_sw[3].ptr)
#define ERR_error_string (* (char * (*)(unsigned long,char *)) crypto_sw[4].ptr)
// set_ssl_option() function updates this array.
// It loads SSL library dynamically and changes NULLs to the actual addresses
// of respective functions. The macros above (like SSL_connect()) are really
...
...
mongoose.c
View file @
226d4768
...
...
@@ -357,6 +357,7 @@ struct ssl_func {
#define ERR_get_error (* (unsigned long (*)(void)) crypto_sw[3].ptr)
#define ERR_error_string (* (char * (*)(unsigned long,char *)) crypto_sw[4].ptr)
// set_ssl_option() function updates this array.
// It loads SSL library dynamically and changes NULLs to the actual addresses
// of respective functions. The macros above (like SSL_connect()) are really
...
...
@@ -3172,7 +3173,7 @@ static int forward_body_data(struct mg_connection *conn, FILE *fp,
if
(
left
>
(
int64_t
)
sizeof
(
buf
))
{
left
=
sizeof
(
buf
);
}
nread
=
pull
(
NULL
,
conn
,
buf
,
left
);
nread
=
pull
(
NULL
,
conn
,
buf
,
(
int
)
left
);
if
(
nread
<=
0
||
push
(
fp
,
sock
,
ssl
,
buf
,
nread
)
!=
nread
)
{
break
;
}
...
...
@@ -4250,7 +4251,7 @@ FILE *mg_upload(struct mg_connection *conn, const char *destination_dir,
assert
(
len
>=
0
&&
len
<=
buf_len
);
to_read
=
buf_len
-
len
;
if
(
to_read
>
left_to_read
(
conn
))
{
to_read
=
left_to_read
(
conn
);
to_read
=
(
int
)
left_to_read
(
conn
);
}
while
(
len
<
buf_len
&&
(
n
=
pull
(
NULL
,
conn
,
buf
+
len
,
to_read
))
>
0
)
{
...
...
@@ -4322,7 +4323,7 @@ FILE *mg_upload(struct mg_connection *conn, const char *destination_dir,
}
to_read
=
buf_len
-
len
;
if
(
to_read
>
left_to_read
(
conn
))
{
to_read
=
left_to_read
(
conn
);
to_read
=
(
int
)
left_to_read
(
conn
);
}
}
while
(
!
eof
&&
(
n
=
pull
(
NULL
,
conn
,
buf
+
len
,
to_read
))
>
0
);
conn
->
data_len
=
conn
->
request_len
+
len
;
...
...
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