Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

ioheader.c File Reference


Detailed Description

Asynchronous I/O header parsing.

Author:
Raphael Manfredi
Date:
2002-2003

#include "common.h"
#include "ioheader.h"
#include "sockets.h"
#include "bsched.h"
#include "lib/getline.h"
#include "lib/header.h"
#include "lib/inputevt.h"
#include "lib/misc.h"
#include "lib/walloc.h"
#include "if/gnet_property_priv.h"
#include "lib/override.h"

Data Structures

struct  io_header
 This structure is used to encapsulate the various arguments required by the header parsing I/O callbacks. More...


Defines

#define DFLT_SIZE   2048 /**< Expected headers should not be larger */
 Expected headers should not be larger.


Functions

 RCSID ("$Id:ioheader.c, v 1.12 2005/09/17 22:30:28 rmanfredi Exp $")
void io_free (gpointer opaque)
 Free the opaque I/O data.

headerio_header (gpointer opaque)
 Fetch header structure from opaque I/O data.

getlineio_getline (gpointer opaque)
 Fetch getline structure from opaque I/O data.

gchar * io_gettext (gpointer opaque)
 Fetch header text as C string from opaque I/O data.

void io_header_parse (struct io_header *ih)
 This routine is called to parse the input buffer (the socket's buffer), a line at a time, until EOH is reached.

void io_read_data (gpointer data, gint unused_source, inputevt_cond_t cond)
 This routine is installed as an input callback to read the headers into the socket's buffer.

void io_get_header (gpointer resource, gpointer *io_opaque, bsched_t *bs, struct gnutella_socket *s, gint flags, io_done_cb_t done, io_start_cb_t start, const struct io_error *error)
 Setup input callback and context for reading/parsing the header.

void io_continue_header (gpointer opaque, gint flags, io_done_cb_t done, io_start_cb_t start)
 Optional: called when reading 1st byte.


Define Documentation

#define DFLT_SIZE   2048 /**< Expected headers should not be larger */
 

Expected headers should not be larger.


Function Documentation

void io_continue_header gpointer  opaque,
gint  flags,
io_done_cb_t  done,
io_start_cb_t  start
 

Optional: called when reading 1st byte.

This is used when we're receiving an incoming connection. Once we have parsed the initial handshaking headers, we're replying and then we have to parse the final handshaking headers from our peer. That's when this routine is called.

Parameters:
opaque  Existing header parsing context
flags  New I/O parsing flags
done  Mandatory: final callback when all done
start  Optional: called when reading 1st byte

void io_free gpointer  opaque  ) 
 

Free the opaque I/O data.

void io_get_header gpointer  resource,
gpointer *  io_opaque,
bsched_t bs,
struct gnutella_socket s,
gint  flags,
io_done_cb_t  done,
io_start_cb_t  start,
const struct io_error error
 

Setup input callback and context for reading/parsing the header.

The I/O parsing context is directly written into the structure.

Data is read into the supplied socket's buffer, and then stuffed into the headers, unless the IO_SAVE_FIRST flag is set, in which case the very first line will be copied into the (dynamically allocated) socket's getline buffer.

Parameters:
resource  Resource for which we're reading headers
io_opaque  Field address in resource's structure
bs  B/w scheduler from which we read
s  Socket from which we're reading
flags  I/O parsing flags
done  Mandatory: final callback when all done
start  Optional: called when reading 1st byte
error  Mandatory: error callbacks for resource

struct getline* io_getline gpointer  opaque  ) 
 

Fetch getline structure from opaque I/O data.

gchar* io_gettext gpointer  opaque  ) 
 

Fetch header text as C string from opaque I/O data.

It is up to the caller to strdup the data if needed. The returned data will be freed when io_free() is called.

struct header* io_header gpointer  opaque  ) 
 

Fetch header structure from opaque I/O data.

void io_header_parse struct io_header ih  )  [static]
 

This routine is called to parse the input buffer (the socket's buffer), a line at a time, until EOH is reached.

void io_read_data gpointer  data,
gint  unused_source,
inputevt_cond_t  cond
[static]
 

This routine is installed as an input callback to read the headers into the socket's buffer.

Read data is then handed out to io_header_parse() for analysis.

RCSID "$Id:ioheader.  c,
v 1.12 2005/09/17 22:30:28 rmanfredi Exp $" 
 


Generated on Sun Feb 12 10:50:03 2006 for Gtk-Gnutella by doxygen 1.3.6