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

ioheader.h File Reference


Detailed Description

Asynchronous I/O header parsing routines.

Author:
Raphael Manfredi
Date:
2002-2003

#include "common.h"
#include "bsched.h"

Go to the source code of this file.

Data Structures

struct  io_error
 This structure holds all the per-resource callbacks that can be used during header processing in case something goes wrong. More...

Defines

#define IO_HEAD_ONLY   0x00000001
 No data expected after EOH.
#define IO_SAVE_FIRST   0x00000002
 Save 1st line in socket's getline.
#define IO_SINGLE_LINE   0x00000004
 Get one line only, then process.
#define IO_3_WAY   0x00000008
 In 3-way handshaking.
#define IO_SAVE_HEADER   0x00000010
 Save header text for later perusal.

Typedefs

typedef void(* io_done_cb_t )(gpointer resource, struct header *header)
typedef void(* io_start_cb_t )(gpointer resource)

Functions

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_get_header (gpointer resource, gpointer *io_opaque, bsched_bws_t bws, struct gnutella_socket *s, gint flags, io_done_cb_t done, io_start_cb_t start, const struct io_error *error)
 Mandatory: error callbacks for resource.
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 IO_3_WAY   0x00000008
 

In 3-way handshaking.

#define IO_HEAD_ONLY   0x00000001
 

No data expected after EOH.

#define IO_SAVE_FIRST   0x00000002
 

Save 1st line in socket's getline.

#define IO_SAVE_HEADER   0x00000010
 

Save header text for later perusal.

#define IO_SINGLE_LINE   0x00000004
 

Get one line only, then process.


Typedef Documentation

typedef void(* io_done_cb_t)(gpointer resource, struct header *header)
 

typedef void(* io_start_cb_t)(gpointer resource)
 


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_bws_t  bws,
struct gnutella_socket s,
gint  flags,
io_done_cb_t  done,
io_start_cb_t  start,
const struct io_error error
 

Mandatory: error callbacks for resource.

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
bws  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.


Generated on Sat Jun 30 17:53:28 2007 for gtk-gnutella by  doxygen 1.3.9.1