home *** CD-ROM | disk | FTP | other *** search
/ Palm Utilities / Palm_Utilities_CD-ROM_2001_2001.iso / files / internet misc / GetTLE 1.0 / GetTLE.exe / Src / tcpip.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-15  |  2.2 KB  |  59 lines

  1. /*
  2.     tcpip.h - header file 
  3.     Copyright ⌐2000 Andreas Schneider
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18. */
  19.  
  20. #ifndef tcpipINCLUDED
  21. #define tcpipINCLUDED
  22.  
  23. #ifdef linux
  24. #include <stdarg.h>
  25. #else
  26. #include <unix_stdarg.h>
  27. #endif
  28.  
  29. // As the network functions are supposed to work with PalmOS
  30. // as well as under Linux, I want an operating system independant
  31. // way of displaying error messages:
  32. typedef void (*tcpipStatusCallback)(char *status);
  33. typedef void (*tcpipErrorCallback)(char *problem, char *extra_info);
  34. typedef void (*tcpipDebugCallback)(char *format,va_list args);
  35.  
  36. typedef struct SocketStruct
  37. {
  38.   int socket; // the actual socket
  39.   char *buffer; // pointer to a buffer buffering received data
  40.   size_t buffer_len; // the size of that buffer
  41.   size_t buffer_content; // how many bytes in buffer
  42.   size_t buffer_index; // keep track of where we are in the buffer
  43. }
  44. Socket;
  45.  
  46. extern void TcpipSetStatusCallback(tcpipStatusCallback function);
  47. extern void TcpipSetErrorCallback(tcpipErrorCallback function);
  48. extern void TcpipSetDebugCallback(tcpipDebugCallback function);
  49.  
  50. // now the interesting stuff: TCP/IP!!
  51. extern Socket MakeConnection(char *service,char *protocol,char *host_address,
  52.                              char *buffer,size_t buffer_len);
  53. extern int SocketWrite(Socket *sock,char *buffer,unsigned int num_bytes);
  54. extern int SocketReadByte(Socket *sock, char*byte);
  55. extern int SocketReadLine(Socket *sock, char *buffer, size_t buffer_size);
  56. extern void SocketClose(Socket *sock);
  57.  
  58. #endif
  59.