Main Page   File List   File Members  

snl.h

Go to the documentation of this file.
00001 /*
00002    The SNL (Simple Network Layer) provides a neat C API for network programming.
00003    Copyright (C) 2001 Clemens Kirchgatterer <clemens@thf.ath.cx>
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00035 #ifndef _SNL_H_
00036 #define _SNL_H_
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00048 #define SNL_LISTEN_CALLBACK(CB) void (CB)(unsigned short port, int error, int fd, void *data)
00049 
00056 #define SNL_READ_CALLBACK(CB) void (CB)(int fd, int error, void *buf, int len, void *data)
00057 
00058 #define SNL_ERR_OK       0   
00059 #define SNL_ERR_OPEN    -1   
00060 #define SNL_ERR_LISTEN  -2   
00061 #define SNL_ERR_CONNECT -3   
00062 #define SNL_ERR_BIND    -4   
00063 #define SNL_ERR_ACCEPT  -5   
00064 #define SNL_ERR_READ    -6   
00065 #define SNL_ERR_WRITE   -7   
00066 #define SNL_ERR_CLOSED  -8   
00067 #define SNL_ERR_BUFFER  -9   
00068 #define SNL_ERR_ADDRESS -10  
00069 
00070 
00081 int snl_write(int fd, void *buf, unsigned long int len);
00082 
00094 int snl_read(int fd, SNL_READ_CALLBACK(*cb), void *data);
00095 
00108 int snl_listen(const char *name, unsigned short port, SNL_LISTEN_CALLBACK(*cb), void *data);
00109 
00122 int snl_connect(const char *name, unsigned short port);
00123 
00124 #ifndef NULL
00125 #define NULL ((void *)0) 
00126 #endif
00127 
00128 #ifndef FALSE
00129 #define FALSE (0)        
00130 #endif
00131 
00132 #ifndef TRUE
00133 #define TRUE (!FALSE)    
00134 #endif
00135 
00136 #ifdef __cplusplus
00137 }
00138 #endif
00139 
00140 #endif /* _SNL_H_ */

Generated on Sat Mar 30 10:17:18 2002 for SNL (Simple Network Layer) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002