00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016
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
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 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;
00146 Gj_Iface_readFunc* read;
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 00164
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 00193 00194 00195
00196
00197
00198
00199 00200 00201 00202 00203
00204
00205
00206
00213 int gj_iface_serve(Gj_Ctx* ctx, Gj_IfaceIncomingConn* conn);
00214
00215
00216 #ifdef __cplusplus
00217 }
00218 #endif
00219
00220 #endif
00221