Diff for /XML/nanohttp.c between versions 1.29 and 1.30

version 1.29, 2000/10/11 23:57:11 version 1.30, 2000/10/12 23:23:35
Line 65 Line 65
 #include <libxml/parser.h> /* for xmlStr(n)casecmp() */  #include <libxml/parser.h> /* for xmlStr(n)casecmp() */
 #include <libxml/nanohttp.h>  #include <libxml/nanohttp.h>
   
   /**
    * A couple portability macros
    */
   #ifndef _WINSOCKAPI_
   #define closesocket(s) close(s)
   #define SOCKET int
   #endif
   
 #ifdef STANDALONE  #ifdef STANDALONE
 #define DEBUG_HTTP  #define DEBUG_HTTP
 #define xmlStrncasecmp(a, b, n) strncasecmp((char *)a, (char *)b, n)  #define xmlStrncasecmp(a, b, n) strncasecmp((char *)a, (char *)b, n)
Line 85  typedef struct xmlNanoHTTPCtxt { Line 93  typedef struct xmlNanoHTTPCtxt {
     char *hostname;     /* the host name */      char *hostname;     /* the host name */
     int port;           /* the port */      int port;           /* the port */
     char *path;         /* the path within the URL */      char *path;         /* the path within the URL */
     int fd;             /* the file descriptor for the socket */      SOCKET fd;          /* the file descriptor for the socket */
     int state;          /* WRITE / READ / CLOSED */      int state;          /* WRITE / READ / CLOSED */
     char *out;          /* buffer sent (zero terminated) */      char *out;          /* buffer sent (zero terminated) */
     char *outptr;       /* index within the buffer sent */      char *outptr;       /* index within the buffer sent */
Line 106  static int proxyPort; /* the proxy port Line 114  static int proxyPort; /* the proxy port
 static unsigned int timeout = 60;/* the select() timeout in seconds */  static unsigned int timeout = 60;/* the select() timeout in seconds */
   
 /**  /**
  * A bit of portability macros and functions   * A portability function
  */   */
 #ifdef _WINSOCKAPI_  
   
 WSADATA wsaData;  
   
 #else  
   
 #define closesocket(s) close(s)  
   
 #endif  
   
 int socket_errno(void) {  int socket_errno(void) {
 #ifdef _WINSOCKAPI_  #ifdef _WINSOCKAPI_
     return(WSAGetLastError());      return(WSAGetLastError());
Line 136  int socket_errno(void) { Line 134  int socket_errno(void) {
 void  void
 xmlNanoHTTPInit(void) {  xmlNanoHTTPInit(void) {
     const char *env;      const char *env;
   #ifdef _WINSOCKAPI_
       WSADATA wsaData;    
   #endif
   
     if (initialized)      if (initialized)
         return;          return;
   
 #ifdef _WINSOCKAPI_  #ifdef _WINSOCKAPI_
     if (WSAStartup(0x0101, &wsaData) != 0)      if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0)
         WSACleanup();          return;
 #endif  #endif
   
     if (proxy == NULL) {      if (proxy == NULL) {
Line 175  void Line 176  void
 xmlNanoHTTPCleanup(void) {  xmlNanoHTTPCleanup(void) {
     if (proxy != NULL)      if (proxy != NULL)
         xmlFree(proxy);          xmlFree(proxy);
     initialized = 0;  
 #ifdef _WINSOCKAPI_  #ifdef _WINSOCKAPI_
     WSACleanup();      if (initialized)
           WSACleanup();
 #endif  #endif
       initialized = 0;
     return;      return;
 }  }
   
Line 612  xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr Line 614  xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr
 static int  static int
 xmlNanoHTTPConnectAttempt(struct in_addr ia, int port)  xmlNanoHTTPConnectAttempt(struct in_addr ia, int port)
 {  {
     int s=socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);      SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
     struct sockaddr_in sin;      struct sockaddr_in sin;
     fd_set wfd;      fd_set wfd;
     struct timeval tv;      struct timeval tv;
Line 663  xmlNanoHTTPConnectAttempt(struct in_addr Line 665  xmlNanoHTTPConnectAttempt(struct in_addr
     sin.sin_addr   = ia;      sin.sin_addr   = ia;
     sin.sin_port   = htons(port);      sin.sin_port   = htons(port);
           
     if ((connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1) &&      if ((connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1)) {
        (socket_errno() != EINPROGRESS) && (socket_errno() != EWOULDBLOCK)) {          switch (socket_errno()) {
         perror("connect");              case EINPROGRESS:
         closesocket(s);              case EWOULDBLOCK:
         return(-1);                  break;
               default:
                   perror("connect");
                   closesocket(s);
                   return(-1);
           }
     }         }   
           
     tv.tv_sec = timeout;      tv.tv_sec = timeout;
Line 694  xmlNanoHTTPConnectAttempt(struct in_addr Line 701  xmlNanoHTTPConnectAttempt(struct in_addr
     if ( FD_ISSET(s, &wfd) ) {      if ( FD_ISSET(s, &wfd) ) {
         SOCKLEN_T len;          SOCKLEN_T len;
         len = sizeof(status);          len = sizeof(status);
         if (getsockopt(s, SOL_SOCKET, SO_ERROR, &status, &len) < 0 ) {          if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*)&status, &len) < 0 ) {
             /* Solaris error code */              /* Solaris error code */
             return (-1);              return (-1);
         }          }

Removed from v.1.29  
changed lines
  Added in v.1.30


Webmaster