Main Page   Compound List   File List   Compound Members   File Members  

lib/gobj/iface.h

Go to the documentation of this file.
00001 /* lib/iface.h - IO interface management
00002    Copyright (C) 1999, 2000, 2001 Thomas Uehlinger
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 2, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software
00016    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
00017 
00025 #include <gobjconfig.h>
00026 
00027 #ifndef gobj_lib_iface_h
00028 #define gobj_lib_iface_h
00029 
00030 #include <gobj/context.h>
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif /* __cplusplus */
00035 #if 0
00036 }
00037 #endif
00038 
00039 
00044 typedef void Gj_IfaceData;
00045 
00046 
00051 typedef void Gj_IfacePort;
00052 
00053 
00058 typedef struct Gj_IfaceIncomingConn_struct {
00059   
00060   Gj_Ctx* ctx;
00061 
00062   Gj_Iface* iface;
00063 
00064   Gj_IfacePort* port;
00065 
00066   char* clientaddr;
00067 
00068 } Gj_IfaceIncomingConn;
00069 
00070 
00071 /*
00072  * IO function typedefs
00073  *
00074  */
00075 
00080 typedef Gj_IfacePort* Gj_Iface_openPortFunc(Gj_Ctx* ctx, Gj_Iface* iface, char* addr);
00081 
00082 
00087 typedef int Gj_Iface_closePortFunc(Gj_Ctx* ctx, Gj_Iface* iface, Gj_IfacePort* port);
00088 
00089 
00094 typedef int Gj_Iface_writeFunc(Gj_Ctx* ctx, Gj_Iface* iface, Gj_IfacePort* port, void* ptr, int size);
00095 
00096 
00101 typedef int Gj_Iface_readFunc(Gj_Ctx* ctx, Gj_Iface* iface, Gj_IfacePort* port, void* ptr, int size);
00102 
00103 
00108 typedef int Gj_Iface_read2writeFunc(Gj_Ctx* ctx, Gj_Iface* iface, Gj_IfacePort* port);
00109 
00110 
00115 typedef int Gj_Iface_write2readFunc(Gj_Ctx* ctx, Gj_Iface* iface, Gj_IfacePort* port);
00116 
00117 
00122 typedef int Gj_Iface_flushFunc(Gj_Ctx* ctx, Gj_Iface* iface, Gj_IfacePort* port);
00123 
00124 
00132 typedef int Gj_Iface_listenFunc(Gj_Ctx* ctx, Gj_Iface* iface);
00133 
00134 
00139 struct Gj_IfaceFuncs_struct {
00140   
00141   Gj_Id* id;
00142 
00143   Gj_Iface_openPortFunc* openPort;
00144   Gj_Iface_closePortFunc* closePort;
00145   Gj_Iface_writeFunc* write; /* required */
00146   Gj_Iface_readFunc* read; /* required */
00147   Gj_Iface_read2writeFunc* read2write;
00148   Gj_Iface_write2readFunc* write2read;
00149   Gj_Iface_flushFunc* flush;
00150   Gj_Iface_listenFunc* listen;
00151 
00152 };
00153 
00154 
00159 struct Gj_Iface_struct {
00160 
00161   Gj_IfaceData* data;
00162 
00163   /*Gj_Bool listening;
00164   Gj_Bool stopListening;*/
00165 
00166   Gj_IfaceFuncs* funcs;
00167 
00168   Gj_Iface* next;
00169 
00170 };
00171 
00172 
00179 Gj_Id* Gj_iface_getId(Gj_Iface* iface);
00180 
00181 
00188 int Gj_iface_listen(Gj_Ctx* ctx, Gj_Iface* iface);
00189 
00190 
00191 /*
00192  * Write size bytes from a given memory location to the interface
00193  * Error: returns 0 on success, -1 otherwise
00194  *
00195  */
00196 /*int Gj_io_write(Gj_Ctx* ctx, Gj_Iface* iface, void* ptr, int size);*/
00197 
00198 
00199 /*
00200  * Read size bytes from the interface and write them to the given memory location
00201  * Error: returns 0 on success, -1 otherwise
00202  *
00203  */
00204 /*int Gj_io_read(Gj_Ctx* ctx, Gj_Iface* io, void* ptr, int size);*/
00205 
00206 
00213 int gj_iface_serve(Gj_Ctx* ctx, Gj_IfaceIncomingConn* conn);
00214   
00215 
00216 #ifdef __cplusplus
00217 }
00218 #endif /* __cplusplus */
00219 
00220 #endif /* !gobj_lib_iface_h */
00221 

Generated at Fri Aug 17 18:28:55 2001 for Gobj by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000