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

tx.h

Go to the documentation of this file.
00001 /*
00002  * $Id: tx.h,v 1.13 2005/11/29 22:14:56 rmanfredi Exp $
00003  *
00004  * Copyright (c) 2002-2003, Raphael Manfredi
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *----------------------------------------------------------------------
00024  */
00025 
00036 #ifndef _core_tx_h_
00037 #define _core_tx_h_
00038 
00039 #include <glib.h>
00040 
00041 #include "if/core/hosts.h"
00042 
00043 struct txdrv_ops;
00044 struct iovec;
00045 struct bio_source;
00046 struct gnutella_node;
00047 
00048 typedef void (*tx_service_t)(gpointer obj);
00049 
00054 typedef struct txdriver {
00055     gpointer owner;                 
00056     gnet_host_t host;               
00057     const struct txdrv_ops *ops;    
00058     struct txdriver *upper;         
00059     struct txdriver *lower;         
00060     gint flags;                     
00061     tx_service_t srv_routine;       
00062     gpointer srv_arg;               
00063     gpointer opaque;                
00064 } txdrv_t;
00065 
00066 /*
00067  * Driver flags.
00068  */
00069 
00070 #define TX_SERVICE      0x00000001  
00071 #define TX_ERROR        0x00000002  
00072 #define TX_DOWN         0x00000004  
00073 #define TX_CLOSING      0x00000008  
00074 #define TX_EAGER        0x00000010  
00080 typedef void (*tx_closed_t)(txdrv_t *tx, gpointer arg);
00081 
00082 struct txdrv_ops {
00083     gpointer (*init)(txdrv_t *tx, gpointer args);
00084     void (*destroy)(txdrv_t *tx);
00085     ssize_t (*write)(txdrv_t *tx, gpointer data, size_t len);
00086     ssize_t (*writev)(txdrv_t *tx, struct iovec *iov, gint iovcnt);
00087     ssize_t (*sendto)(txdrv_t *tx, gnet_host_t *to, gpointer data, size_t len);
00088     void (*enable)(txdrv_t *tx);
00089     void (*disable)(txdrv_t *tx);
00090     size_t (*pending)(txdrv_t *tx);
00091     void (*flush)(txdrv_t *tx);
00092     void (*shutdown)(txdrv_t *tx);
00093     void (*close)(txdrv_t *tx, tx_closed_t cb, gpointer arg);
00094     struct bio_source *(*bio_source)(txdrv_t *tx);
00095 };
00096 
00097 /*
00098  * Public interface
00099  */
00100 
00101 txdrv_t *tx_make(gpointer owner, gnet_host_t *host,
00102     const struct txdrv_ops *ops, gpointer args);
00103 txdrv_t *tx_make_above(txdrv_t *ltx, const struct txdrv_ops *ops,
00104     gpointer args);
00105 
00106 void tx_free(txdrv_t *tx);
00107 void tx_collect(void);
00108 ssize_t tx_write(txdrv_t *tx, gpointer data, size_t len);
00109 ssize_t tx_writev(txdrv_t *tx, struct iovec *iov, gint iovcnt);
00110 ssize_t tx_sendto(txdrv_t *tx, gnet_host_t *to, gpointer data, size_t len);
00111 void tx_srv_register(txdrv_t *d, tx_service_t srv_fn, gpointer srv_arg);
00112 void tx_srv_enable(txdrv_t *tx);
00113 void tx_srv_disable(txdrv_t *tx);
00114 size_t tx_pending(txdrv_t *tx);
00115 struct bio_source *tx_bio_source(txdrv_t *tx);
00116 ssize_t tx_no_write(txdrv_t *tx, gpointer data, size_t len);
00117 ssize_t tx_no_writev(txdrv_t *tx, struct iovec *iov, gint iovcnt);
00118 ssize_t tx_no_sendto(txdrv_t *tx, gnet_host_t *to, gpointer data, size_t len);
00119 void tx_flush(txdrv_t *tx);
00120 void tx_shutdown(txdrv_t *tx);
00121 void tx_close(txdrv_t *d, tx_closed_t cb, gpointer arg);
00122 void tx_close_noop(txdrv_t *tx, tx_closed_t cb, gpointer arg);
00123 gboolean tx_has_error(txdrv_t *tx);
00124 void tx_eager_mode(txdrv_t *tx, gboolean on);
00125 
00126 struct bio_source *tx_no_source(txdrv_t *tx);
00127 
00128 #endif  /* _core_tx_h_ */
00129 
00130 /* vi: set ts=4 sw=4 cindent: */
00131 

Generated on Sun Feb 12 10:49:57 2006 for Gtk-Gnutella by doxygen 1.3.6