src/ebb.h in ebb-0.0.4 vs src/ebb.h in ebb-0.1.0
- old
+ new
@@ -2,24 +2,20 @@
* Copyright (c) 2008 Ry Dahl. This software is released under the MIT
* License. See README file for details.
*/
#ifndef ebb_h
#define ebb_h
-
+#define EV_STANDALONE 1
+#include <ev.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <glib.h>
-
-#define EV_STANDALONE 1
-#include <ev.h>
-
#include "parser.h"
-
typedef struct ebb_server ebb_server;
typedef struct ebb_client ebb_client;
-
+#define EBB_VERSION "0.1.0"
#define EBB_BUFFERSIZE (1024 * (80 + 33))
#define EBB_MAX_CLIENTS 200
#define EBB_TIMEOUT 30.0
#define EBB_MAX_ENV 500
#define EBB_TCP_COMMON \
@@ -27,26 +23,26 @@
int fd; \
struct sockaddr_in sockaddr;
/*** Ebb Client ***/
void ebb_client_close(ebb_client*);
+/* user MUST call this function on each client passed by the request_cb */
+void ebb_client_release(ebb_client*);
int ebb_client_read(ebb_client *client, char *buffer, int length);
void ebb_client_write_status(ebb_client*, int status, const char *human_status);
void ebb_client_write_header(ebb_client*, const char *field, const char *value);
void ebb_client_write(ebb_client*, const char *data, int length);
-void ebb_client_finished( ebb_client *client);
+void ebb_client_begin_transmission( ebb_client *client);
-
struct ebb_env_item {
enum { EBB_FIELD_VALUE_PAIR
, EBB_REQUEST_METHOD
, EBB_REQUEST_URI
, EBB_FRAGMENT
, EBB_REQUEST_PATH
, EBB_QUERY_STRING
, EBB_HTTP_VERSION
- , EBB_SERVER_NAME
, EBB_SERVER_PORT
, EBB_CONTENT_LENGTH
} type;
const char *field;
int field_length;
@@ -55,14 +51,16 @@
};
struct ebb_client {
EBB_TCP_COMMON
+ unsigned int in_use : 1;
+
ebb_server *server;
http_parser parser;
- char request_buffer[EBB_BUFFERSIZE];
+ char *request_buffer;
ev_io read_watcher;
size_t read, nread_from_body;
char upload_file_filename[200];
FILE *upload_file;
@@ -73,13 +71,14 @@
GString *response_buffer;
size_t written;
ev_timer timeout_watcher;
- int status_sent;
- int headers_sent;
- int body_sent;
+ unsigned int status_written : 1;
+ unsigned int headers_written : 1;
+ unsigned int body_written : 1;
+ unsigned int began_transmission : 1;
/* the ENV structure */
int env_size;
struct ebb_env_item env[EBB_MAX_ENV];
};
@@ -108,6 +107,6 @@
struct ev_loop *loop;
void *request_cb_data;
ebb_request_cb request_cb;
};
-#endif
+#endif
\ No newline at end of file