sockhdr.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* sockhdr.h Copyright (C) 1997-2002 Codemist Ltd */
  2. /*
  3. * pull in headers suitable for socket-related code.
  4. */
  5. /*
  6. * This code may be used and modified, and redistributed in binary
  7. * or source form, subject to the "CCL Public License", which should
  8. * accompany it. This license is a variant on the BSD license, and thus
  9. * permits use of code derived from this in either open and commercial
  10. * projects: but it does require that updates to this code be made
  11. * available back to the originators of the package.
  12. * Before merging other code in with this or linking this code
  13. * with other packages or libraries please check that the license terms
  14. * of the other material are compatible with those of this.
  15. */
  16. /* Signature: 0776390f 10-Oct-2002 */
  17. #ifdef __WATCOMC__
  18. /*
  19. * Use of Watcom C++: please compile in Windows NT/95 mode.
  20. * wcl386 -bt=nt webget.c
  21. */
  22. # include <conio.h>
  23. # define ms_windows 1
  24. #endif
  25. #ifdef _MSC_VER
  26. /*
  27. * Use of Microsoft Visual C++ version 5.0
  28. */
  29. # define ms_windows 1
  30. #endif
  31. #ifdef GCC386
  32. /*
  33. * At present GCC for DOS (the D J Delorie port) does not seem to have
  34. * socket support in its libraries (very reasonably) so I can not support
  35. * this code with it. But I want to be able to compile this file as part of
  36. * larger programs, so I can arrange to build a dummy version that always
  37. * reports failure to access any net resources!
  38. */
  39. # define NOT_SUPPORTED 1
  40. typedef int SOCKET;
  41. #else
  42. #ifdef GCCWIN
  43. /*
  44. * Use of Cygnus GCC for Win32. I have not yet managed to make this work
  45. * since both the Windows API headers and the relevant library stubs are
  46. * still in the process of emerging (Nov 1996), but it seems probable that
  47. * sometime during 1997 this will become a viable possibility, and anybody
  48. * who is keen to experiment is encouaged to do so (and report their
  49. * experiences back to me).
  50. */
  51. # define ms_windows 1
  52. #include <netdb.h>
  53. #include <mywinsock.h>
  54. #else
  55. #include <errno.h>
  56. #ifdef ms_windows
  57. #include <winsock.h>
  58. #else
  59. #define unix_posix 1 /* Assume all non-windows systems are Unix! */
  60. /*
  61. * There may well be terrible delicacies re different variants on Unix. I
  62. * have (initially) tested this using Solaris and Linux.
  63. */
  64. #include <sys/types.h>
  65. #include <sys/socket.h>
  66. #include <netinet/in.h>
  67. #include <netdb.h>
  68. #include <arpa/inet.h>
  69. #include <sys/time.h>
  70. #include <fcntl.h>
  71. #define WSAGetLastError() errno /* retrieve error code */
  72. #define WSACleanup() /* tidy up at end of day */
  73. #define closesocket(a) close(a)
  74. #define SOCKET int
  75. #define SOCKET_ERROR (-1)
  76. #ifndef INADDR_NONE
  77. # define INADDR_NONE 0xffffffff
  78. #endif
  79. #ifdef unix_posix
  80. #include <termios.h> /* So I can do non-echo terminal input */
  81. #endif
  82. #endif
  83. #endif
  84. #endif
  85. #define standard_ftp_port 21
  86. #define standard_gopher_port 70
  87. #define standard_telnet_port 23
  88. #define standard_wais_port 210
  89. #define standard_http_port 80
  90. #define standard_local_port (-1)
  91. #define default_csl_server_port 1206
  92. #define MAX_USERS 10 /* approx concurrent remote users */
  93. #define REMOTE_STORE 8000 /* Allow 8 Mbytes per remote user */
  94. #define MAX_CPU_TIME 300 /* Approx CPU limit (seconds) */
  95. #define MAX_ELAPSED_TIME 45 /* Approx elapsed time limit (mins) */
  96. extern clock_t cpu_timeout;
  97. extern time_t elapsed_timeout;
  98. /*
  99. * Now some declarations for my own variables and functions.
  100. */
  101. #ifndef header_tags_h
  102. /*
  103. * If used as part of the CSL Lisp system header_tags_h will already
  104. * be defined, and the type Lisp_Object will exist. Otherwise I should
  105. * define it here.
  106. */
  107. typedef int Lisp_Object;
  108. #endif
  109. #define PERMITTED_BACKLOG 5
  110. extern int sockets_ready;
  111. extern SOCKET socket_server;
  112. extern char *WSAErrName(int i);
  113. extern int ensure_sockets_ready(void);
  114. /* End of sockhdr.h */