debug fastcgi streams while forwarding them
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.0 KiB

14 years ago
#include <ev.h>
#include <glib.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <unistd.h>
#define UNUSED(x) ( (void)(x) )
14 years ago
#define MAX_STREAM_BUF_SIZE (128*1024)
14 years ago
struct addr;
typedef struct addr addr;
struct server;
typedef struct server server;
14 years ago
struct stream;
typedef struct stream stream;
14 years ago
struct connection;
typedef struct connection connection;
struct addr {
struct sockaddr *saddr;
socklen_t addr_len;
struct server {
struct ev_loop *loop;
14 years ago
guint next_con_id;
14 years ago
ev_child w_child;
ev_io w_accept;
int child;
gchar *tmpfile_name, *sockfile_name;
addr client;
gboolean exiting, stopped_signals;
14 years ago
struct stream {
stream *other;
int fd;
ev_io watcher;
GString *buffer;
14 years ago
struct connection {
server *srv;
14 years ago
guint con_id;
stream s_server, s_client;
14 years ago
gboolean client_connected;
/* tools.c */
void move2fd(int srcfd, int dstfd);
void move2devnull(int fd);
void fd_init(int fd);
void ev_io_add_events(struct ev_loop *loop, ev_io *watcher, int events);
void ev_io_rem_events(struct ev_loop *loop, ev_io *watcher, int events);
void ev_io_set_events(struct ev_loop *loop, ev_io *watcher, int events);
14 years ago
GString* g_string_set_const(GString* s, const gchar *data, gsize len);
14 years ago
/* connection.c */
void connection_new(server *srv, int fd_server);
14 years ago
/* stream.c */
typedef void (*ev_io_cb)(struct ev_loop *loop, ev_io *w, int revents);
void stream_init(server *srv, stream *s1, stream *s2, int fd1, int fd2, ev_io_cb cb1, ev_io_cb cb2, void* data);
void stream_close(server *srv, stream *s1, stream *s2);
void stream_clean(server *srv, stream *s1, stream *s2);
void stream_start(server *srv, stream *s);
gssize stream_read(server *srv, stream *s, char *buf, gssize bufsize);
void stream_append(server *srv, stream *s, char *buf, gssize bufsize);
gssize stream_write(server *srv, stream *s);
/* log.c */
void log_raw(const gchar *head, guint con_id, GString *data);