Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ape_http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ typedef enum classes {
} parser_class;


static int ascii_class[128] = {
static parser_class ascii_class[128] = {
/*
This array maps the 128 ASCII characters into character classes.
The remaining Unicode characters should be mapped to C_ETC.
Expand Down Expand Up @@ -126,7 +126,7 @@ typedef enum actions {
} parser_actions;


static int state_transition_table[NR_STATES][NR_CLASSES] = {
static int8_t /*parser_state*/ state_transition_table[NR_STATES][NR_CLASSES] = {
/*
nul white etc ABDF
| space | \r\n : , " \ / + - . ? % 09 | * | E G T P H O S C N L _ */
Expand Down Expand Up @@ -211,7 +211,7 @@ int parse_http_char(struct _http_parser *parser, const unsigned char c)
#define HTTP_BODY_AS_ENDED() (HTTP_ISBODYCONTENT() && --parser->cl == 0 && (parser->rx |= HTTP_FLG_READY, 1))

parser_class c_classe;
int8_t state;
int8_t /*parser_state*/ state;
unsigned char ch;

if (c >= 128) {
Expand Down Expand Up @@ -376,7 +376,7 @@ int parse_http_char(struct _http_parser *parser, const unsigned char c)
parser->state = R9;
break;
case RC: /* HTTP response code */
if ((parser->rcode = (parser->rcode*10) + (c - '0')) > MAX_RCODE) {
if ((parser->rcode = (uint16_t) ((parser->rcode*10) + (c - '0')) > MAX_RCODE)) {
return 0;
}
parser->state = RN;
Expand All @@ -400,7 +400,7 @@ static int parse_callback(void **ctx, callback_type type, int value, uint32_t st
{
switch(type) {
case HTTP_METHOD:
switch(value) {
switch( (http_method_t) value) {
case HTTP_GET:
printf("GET method detected\n");
break;
Expand Down Expand Up @@ -447,7 +447,7 @@ static int parse_callback(void **ctx, callback_type type, int value, uint32_t st
int main()
{
int length = 0, i;
struct _http_parser p;
http_parser p;

/* Process BYTE_GET/POST opti check before running the parser */

Expand Down
2 changes: 1 addition & 1 deletion ape_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ __inline static void ape_socket_release_data(unsigned char *data, ape_socket_dat
}
}

ape_socket *APE_socket_new(uint8_t pt, int from, ape_global *ape)
ape_socket *APE_socket_new(enum ape_socket_proto pt, int from, ape_global *ape)
{
int sock = from, proto = SOCK_STREAM;

Expand Down
35 changes: 29 additions & 6 deletions ape_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,43 @@ struct iovec
enum ape_socket_flags {
APE_SOCKET_WOULD_BLOCK = (1 << 0),
APE_SOCKET_CORK = (1 << 1)
#ifdef _MSC_VER
};
#else
} __attribute__ ((__packed__));
#endif

enum ape_socket_proto {
APE_SOCKET_PT_TCP,
APE_SOCKET_PT_UDP,
APE_SOCKET_PT_SSL
#ifdef _MSC_VER
};
#else
} __attribute__ ((__packed__));
#endif

enum ape_socket_type {
APE_SOCKET_TP_UNKNOWN,
APE_SOCKET_TP_SERVER,
APE_SOCKET_TP_CLIENT
#ifdef _MSC_VER
};
#else
} __attribute__ ((__packed__));
#endif

enum ape_socket_state {
APE_SOCKET_ST_ONLINE,
APE_SOCKET_ST_PROGRESS,
APE_SOCKET_ST_PENDING,
APE_SOCKET_ST_OFFLINE,
APE_SOCKET_ST_SHUTDOWN
#ifdef _MSC_VER
};

#else
} __attribute__ ((__packed__));
#endif

typedef enum _ape_socket_data_autorelease {
APE_DATA_STATIC,
Expand Down Expand Up @@ -173,12 +188,20 @@ struct _ape_socket {

struct _ape_dns_cb_argv *dns_state;

#ifdef _MSC_VER
#pragma pack(push, 1)
struct {
uint8_t flags;
uint8_t proto;
uint8_t type;
uint8_t state;
#else
struct __attribute__ ((__packed__)) {
#endif
enum ape_socket_flags flags;
enum ape_socket_proto proto;
enum ape_socket_type type;
enum ape_socket_state state;
} states;
#ifdef _MSC_VER
#pragma pack(pop)
#endif

#ifdef _HAVE_SSL_SUPPORT
struct {
Expand Down Expand Up @@ -206,7 +229,7 @@ struct _ape_socket_packet {
extern "C" {
#endif

ape_socket *APE_socket_new(uint8_t pt, int from, ape_global *ape);
ape_socket *APE_socket_new(enum ape_socket_proto pt, int from, ape_global *ape);

int APE_socket_listen(ape_socket *socket, uint16_t port,
const char *local_ip, int defer_accept, int reuse_port);
Expand Down
2 changes: 1 addition & 1 deletion ape_timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct _ticks_callback
int delta;
int times;
unsigned int identifier;
int flag;
ape_timer_flags flag;

void *func;
void *params;
Expand Down
6 changes: 3 additions & 3 deletions ape_timers_next.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

typedef int (*timer_callback)(void *arg);

enum {
typedef enum {
APE_TIMER_IS_PROTECTED = 1 << 0,
APE_TIMER_IS_CLEARED = 1 << 1
};
} ape_timerng_flags;

typedef struct _ape_timer
{
int identifier;
int flags;
ape_timerng_flags flags;
uint64_t ticks_needs;
uint64_t schedule;
int nexec;
Expand Down