home *** CD-ROM | disk | FTP | other *** search
- /*
- tcpip.h - header file
- Copyright ⌐2000 Andreas Schneider
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
- #ifndef tcpipINCLUDED
- #define tcpipINCLUDED
-
- #ifdef linux
- #include <stdarg.h>
- #else
- #include <unix_stdarg.h>
- #endif
-
- // As the network functions are supposed to work with PalmOS
- // as well as under Linux, I want an operating system independant
- // way of displaying error messages:
- typedef void (*tcpipStatusCallback)(char *status);
- typedef void (*tcpipErrorCallback)(char *problem, char *extra_info);
- typedef void (*tcpipDebugCallback)(char *format,va_list args);
-
- typedef struct SocketStruct
- {
- int socket; // the actual socket
- char *buffer; // pointer to a buffer buffering received data
- size_t buffer_len; // the size of that buffer
- size_t buffer_content; // how many bytes in buffer
- size_t buffer_index; // keep track of where we are in the buffer
- }
- Socket;
-
- extern void TcpipSetStatusCallback(tcpipStatusCallback function);
- extern void TcpipSetErrorCallback(tcpipErrorCallback function);
- extern void TcpipSetDebugCallback(tcpipDebugCallback function);
-
- // now the interesting stuff: TCP/IP!!
- extern Socket MakeConnection(char *service,char *protocol,char *host_address,
- char *buffer,size_t buffer_len);
- extern int SocketWrite(Socket *sock,char *buffer,unsigned int num_bytes);
- extern int SocketReadByte(Socket *sock, char*byte);
- extern int SocketReadLine(Socket *sock, char *buffer, size_t buffer_size);
- extern void SocketClose(Socket *sock);
-
- #endif
-