Skip to content
Snippets Groups Projects
Commit cdddc494 authored by Razvan Deaconescu's avatar Razvan Deaconescu
Browse files

src: Add generated source code


Add generated skeleton source code files. Skeleton is generated from
solution, to keep items in sync.

Signed-off-by: default avatarRazvan Deaconescu <razvan.deaconescu@upb.ro>
parent 6c03d21b
Branches master
No related tags found
No related merge requests found
aws /aws
*.o /*.o
utils/*.o /utils/*.o
http-parser/*o /http-parser/*.o
\ No newline at end of file
...@@ -42,23 +42,21 @@ static int aws_on_path_cb(http_parser *p, const char *buf, size_t len) ...@@ -42,23 +42,21 @@ static int aws_on_path_cb(http_parser *p, const char *buf, size_t len)
return 0; return 0;
} }
static void prepare_connection_send_reply_header(struct connection *conn) static void connection_prepare_send_reply_header(struct connection *conn)
{ {
/* TODO: Prepare the connection buffer to send the reply header. */ /* TODO: Prepare the connection buffer to send the reply header. */
} }
static void prepare_connection_send_404(struct connection *conn) static void connection_prepare_send_404(struct connection *conn)
{ {
/* TODO: Prepare the connection buffer to send the 404 header. */ /* TODO: Prepare the connection buffer to send the 404 header. */
} }
static enum resource_type connection_get_resource_type(struct connection *conn) static enum resource_type connection_get_resource_type(struct connection *conn)
{ {
/* /* TODO: Get resource type depending on request path/filename. Filename should
* TODO: Get resource type depending on request path/filename. Filename should
* point to the static or dynamic folder. * point to the static or dynamic folder.
*/ */
return RESOURCE_TYPE_NONE; return RESOURCE_TYPE_NONE;
} }
...@@ -66,7 +64,6 @@ static enum resource_type connection_get_resource_type(struct connection *conn) ...@@ -66,7 +64,6 @@ static enum resource_type connection_get_resource_type(struct connection *conn)
struct connection *connection_create(int sockfd) struct connection *connection_create(int sockfd)
{ {
/* TODO: Initialize connection structure on given socket. */ /* TODO: Initialize connection structure on given socket. */
return NULL; return NULL;
} }
...@@ -77,29 +74,26 @@ void connection_start_async_io(struct connection *conn) ...@@ -77,29 +74,26 @@ void connection_start_async_io(struct connection *conn)
*/ */
} }
void connection_remove(struct connection *conn) void connection_remove(struct connection *conn)
{ {
/* TODO: Remove connection handler. */ /* TODO: Remove connection handler. */
} }
void handle_new_connection(void) void handle_new_connection(void)
{ {
/* TODO: Handle a new connection request on the server socket. */ /* TODO: Handle a new connection request on the server socket. */
/* TODO a: Accept new connection. */ /* TODO: Accept new connection. */
/* TODO b: Set socket to be non-blocking. */ /* TODO: Set socket to be non-blocking. */
/* TODO c: Instantiate new connection handler. */ /* TODO: Instantiate new connection handler. */
/* TODO d: Add socket to epoll. */ /* TODO: Add socket to epoll. */
/* TODO e: Initialize HTTP_REQUEST parser. */ /* TODO: Initialize HTTP_REQUEST parser. */
} }
void receive_data(struct connection *conn) void receive_data(struct connection *conn)
{ {
/* TODO: Receive message on socket. /* TODO: Receive message on socket.
...@@ -111,7 +105,7 @@ int connection_open_file(struct connection *conn) ...@@ -111,7 +105,7 @@ int connection_open_file(struct connection *conn)
{ {
/* TODO: Open file and update connection fields. */ /* TODO: Open file and update connection fields. */
return 0; return -1;
} }
void connection_complete_async_io(struct connection *conn) void connection_complete_async_io(struct connection *conn)
...@@ -124,7 +118,6 @@ void connection_complete_async_io(struct connection *conn) ...@@ -124,7 +118,6 @@ void connection_complete_async_io(struct connection *conn)
int parse_header(struct connection *conn) int parse_header(struct connection *conn)
{ {
/* TODO: Parse the HTTP header and extract the file path. */ /* TODO: Parse the HTTP header and extract the file path. */
/* Use mostly null settings except for on_path callback. */ /* Use mostly null settings except for on_path callback. */
http_parser_settings settings_on_path = { http_parser_settings settings_on_path = {
.on_message_begin = 0, .on_message_begin = 0,
...@@ -138,26 +131,22 @@ int parse_header(struct connection *conn) ...@@ -138,26 +131,22 @@ int parse_header(struct connection *conn)
.on_headers_complete = 0, .on_headers_complete = 0,
.on_message_complete = 0 .on_message_complete = 0
}; };
return 0; return 0;
} }
enum connection_state connection_send_static(struct connection *conn) enum connection_state connection_send_static(struct connection *conn)
{ {
/* TODO: Send static data using sendfile(2). */ /* TODO: Send static data using sendfile(2). */
/* Return value is the state of the connection at the time this function reaches the end. */
return STATE_NO_STATE; return STATE_NO_STATE;
} }
int connection_send_data(struct connection *conn) int connection_send_data(struct connection *conn)
{ {
/* May be used as a helper function. /* May be used as a helper function. */
* TODO: Send as much data as possible from the connection send buffer. /* TODO: Send as much data as possible from the connection send buffer.
* Returns the number of bytes sent or -1 if an error occurred * Returns the number of bytes sent or -1 if an error occurred
*/ */
return -1;
return 0;
} }
...@@ -166,7 +155,6 @@ int connection_send_dynamic(struct connection *conn) ...@@ -166,7 +155,6 @@ int connection_send_dynamic(struct connection *conn)
/* TODO: Read data asynchronously. /* TODO: Read data asynchronously.
* Returns 0 on success and -1 on error. * Returns 0 on success and -1 on error.
*/ */
return 0; return 0;
} }
...@@ -179,8 +167,7 @@ void handle_input(struct connection *conn) ...@@ -179,8 +167,7 @@ void handle_input(struct connection *conn)
switch (conn->state) { switch (conn->state) {
default: default:
ERR("Unexpected state\n"); printf("shouldn't get here %d\n", conn->state);
exit(1);
} }
} }
...@@ -206,6 +193,8 @@ void handle_client(uint32_t event, struct connection *conn) ...@@ -206,6 +193,8 @@ void handle_client(uint32_t event, struct connection *conn)
int main(void) int main(void)
{ {
int rc;
/* TODO: Initialize asynchronous operations. */ /* TODO: Initialize asynchronous operations. */
/* TODO: Initialize multiplexing. */ /* TODO: Initialize multiplexing. */
...@@ -223,13 +212,10 @@ int main(void) ...@@ -223,13 +212,10 @@ int main(void)
/* TODO: Wait for events. */ /* TODO: Wait for events. */
/* /* TODO: Switch event types; consider
* TODO: Switch event types; consider
* - new connection requests (on server socket) * - new connection requests (on server socket)
* - socket communication (on connection sockets) * - socket communication (on connection sockets)
*/ */
switch (rev.data.fd) { }
} }
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment