You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
3.7 KiB

  1. /*
  2. * fcgios.h --
  3. *
  4. * Description of file.
  5. *
  6. *
  7. * Copyright (c) 1996 Open Market, Inc.
  8. * All rights reserved.
  9. *
  10. * This file contains proprietary and confidential information and
  11. * remains the unpublished property of Open Market, Inc. Use,
  12. * disclosure, or reproduction is prohibited except as permitted by
  13. * express written license agreement with Open Market, Inc.
  14. *
  15. * Bill Snapper
  16. * snapper@openmarket.com
  17. */
  18. #ifndef _FCGIOS_H
  19. #define _FCGIOS_H
  20. #ifdef _WIN32
  21. #define WIN32_LEAN_AND_MEAN
  22. #include <windows.h>
  23. #include <winsock2.h>
  24. #endif
  25. #include "fcgi_config.h"
  26. #ifdef HAVE_SYS_TIME_H
  27. #include <sys/time.h>
  28. #endif
  29. #if defined (c_plusplus) || defined (__cplusplus)
  30. extern "C" {
  31. #endif
  32. #ifdef _WIN32
  33. #define OS_Errno GetLastError()
  34. #define OS_SetErrno(err) SetLastError(err)
  35. #ifndef O_NONBLOCK
  36. #define O_NONBLOCK 0x0004 /* no delay */
  37. #endif
  38. #else /* !_WIN32 */
  39. #define OS_Errno errno
  40. #define OS_SetErrno(err) errno = (err)
  41. #endif /* !_WIN32 */
  42. #ifndef DLLAPI
  43. #ifdef _WIN32
  44. #if defined(_LIB) || defined(FCGI_STATIC)
  45. #define DLLAPI
  46. #else
  47. #define DLLAPI __declspec(dllimport)
  48. #endif
  49. #else
  50. #define DLLAPI
  51. #endif
  52. #endif
  53. /* This is the initializer for a "struct timeval" used in a select() call
  54. * right after a new request is accept()ed to determine readablity. Its
  55. * a drop-dead timer. Its only used for AF_UNIX sockets (not TCP sockets).
  56. * Its a workaround for a kernel bug in Linux 2.0.x and SCO Unixware.
  57. * Making this as small as possible, yet remain reliable would be best.
  58. * 2 seconds is very conservative. 0,0 is not reliable. The shorter the
  59. * timeout, the faster request processing will recover. The longer the
  60. * timeout, the more likely this application being "busy" will cause other
  61. * requests to abort and cause more dead sockets that need this timeout. */
  62. #define READABLE_UNIX_FD_DROP_DEAD_TIMEVAL 2,0
  63. #ifndef STDIN_FILENO
  64. #define STDIN_FILENO 0
  65. #endif
  66. #ifndef STDOUT_FILENO
  67. #define STDOUT_FILENO 1
  68. #endif
  69. #ifndef STDERR_FILENO
  70. #define STDERR_FILENO 2
  71. #endif
  72. #ifndef MAXPATHLEN
  73. #define MAXPATHLEN 1024
  74. #endif
  75. #ifndef X_OK
  76. #define X_OK 0x01
  77. #endif
  78. #ifndef _CLIENTDATA
  79. # if defined(__STDC__) || defined(__cplusplus)
  80. typedef void *ClientData;
  81. # else
  82. typedef int *ClientData;
  83. # endif /* __STDC__ */
  84. #define _CLIENTDATA
  85. #endif
  86. #define MUTEX_VARNAME "_FCGI_MUTEX_"
  87. #define SHUTDOWN_EVENT_NAME "_FCGI_SHUTDOWN_EVENT_"
  88. typedef void (*OS_AsyncProc) (ClientData clientData, int len);
  89. DLLAPI int OS_LibInit(int stdioFds[3]);
  90. DLLAPI void OS_LibShutdown(void);
  91. DLLAPI int OS_CreateLocalIpcFd(const char *bindPath, int backlog, int bCreateMutex);
  92. DLLAPI int OS_FcgiConnect(char *bindPath);
  93. DLLAPI int OS_Read(int fd, char * buf, size_t len);
  94. DLLAPI int OS_Write(int fd, char * buf, size_t len);
  95. #ifdef _WIN32
  96. DLLAPI int OS_SpawnChild(char *execPath, int listenFd, PROCESS_INFORMATION *pInfo, char *env);
  97. #else
  98. DLLAPI int OS_SpawnChild(char *execPath, int listenfd);
  99. #endif
  100. DLLAPI int OS_AsyncReadStdin(void *buf, int len, OS_AsyncProc procPtr,
  101. ClientData clientData);
  102. DLLAPI int OS_AsyncRead(int fd, int offset, void *buf, int len,
  103. OS_AsyncProc procPtr, ClientData clientData);
  104. DLLAPI int OS_AsyncWrite(int fd, int offset, void *buf, int len,
  105. OS_AsyncProc procPtr, ClientData clientData);
  106. DLLAPI int OS_Close(int fd);
  107. DLLAPI int OS_CloseRead(int fd);
  108. DLLAPI int OS_DoIo(struct timeval *tmo);
  109. DLLAPI int OS_Accept(int listen_sock, int fail_on_intr, const char *webServerAddrs);
  110. DLLAPI int OS_IpcClose(int ipcFd);
  111. DLLAPI int OS_IsFcgi(int sock);
  112. DLLAPI void OS_SetFlags(int fd, int flags);
  113. DLLAPI void OS_ShutdownPending(void);
  114. #ifdef _WIN32
  115. DLLAPI int OS_SetImpersonate(void);
  116. #endif
  117. #if defined (__cplusplus) || defined (c_plusplus)
  118. } /* terminate extern "C" { */
  119. #endif
  120. #endif /* _FCGIOS_H */