Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit b3d378d

Browse files
committed
Add simple makefile and skeleton for session module.
1 parent 8aacd2d commit b3d378d

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CC?=gcc
2+
CFLAGS=-DPLATFORM_POSIX
3+
4+
session.o: http.h session.c
5+
$(CC) $(CFLAGS) -c session.c -o $@
6+
7+
clean:
8+
rm *.o
9+

session.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "http.h"
2+
3+
#include <stdlib.h>
4+
5+
#ifdef PLATFORM_POSIX
6+
#include <unistd.h>
7+
#endif
8+
9+
struct http_session_s {
10+
int sockfd;
11+
};
12+
13+
http_session* http_session_init(int sockfd) {
14+
http_session* session = malloc(sizeof(http_session));
15+
if (!session) return NULL;
16+
17+
session->sockfd = sockfd;
18+
19+
return session;
20+
}
21+
22+
void http_session_close(http_session* session) {
23+
close(session->sockfd);
24+
free(session);
25+
}
26+
27+
http_message* http_session_parse_request(http_session* session) {
28+
// TODO: implement
29+
return NULL;
30+
}
31+
32+
http_message* http_session_parse_response(http_session* session) {
33+
// TODO: implement
34+
return NULL;
35+
}
36+
37+
int http_session_send_message(http_session* session, const http_message* msg) {
38+
// TODO: implement
39+
return HTTP_ENOTIMPL;
40+
}
41+

0 commit comments

Comments
 (0)