Ignore:
Timestamp:
Dec 28, 2000, 12:06:39 AM (25 years ago)
Author:
sandervl
Message:

JH: Resync with latest Wine + fixes/additions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wininet/utility.c

    r3898 r4842  
    1 /* $Id: utility.c,v 1.2 2000-07-29 14:10:09 bird Exp $
     1/* $Id: utility.c,v 1.3 2000-12-27 23:06:17 sandervl Exp $
    22 *
    33 * Wininet - Utility functions
     
    2727time_t ConvertTimeString(LPCSTR asctime)
    2828{
    29         char tmpChar[TIME_STRING_LEN];
    30         char *tmpChar2;
    31         struct tm SystemTime;
    32         int timelen = strlen(asctime);
     29        char tmpChar[TIME_STRING_LEN];
     30        char *tmpChar2;
     31        struct tm SystemTime;
     32        int timelen = strlen(asctime);
    3333
    34         if(!asctime || !timelen)
    35                 return 0;
     34        if(!asctime || !timelen)
     35                return 0;
    3636
    37         strncpy(tmpChar, asctime, TIME_STRING_LEN);
     37        strncpy(tmpChar, asctime, TIME_STRING_LEN);
    3838
    39         //Assert that the string is the expected length
    40         if (tmpChar[TIME_STRING_LEN] != '\0')
    41         {
    42                 tmpChar[TIME_STRING_LEN] = '\0';
    43                 FIXME("\n");
    44         }
     39        //Assert that the string is the expected length
     40        if (tmpChar[TIME_STRING_LEN] != '\0')
     41        {
     42                tmpChar[TIME_STRING_LEN] = '\0';
     43                FIXME("\n");
     44        }
    4545
    46         //Convert a time such as 'Mon, 15 Nov 1999 16:09:35 GMT' into a SYSTEMTIME structure
    47         //We assume the time is in this format
    48         //and divide it into easy to swallow chunks
    49         tmpChar[3]='\0';
    50         tmpChar[7]='\0';
    51         tmpChar[11]='\0';
    52         tmpChar[16]='\0';
    53         tmpChar[19]='\0';
    54         tmpChar[22]='\0';
    55         tmpChar[25]='\0';
     46        //Convert a time such as 'Mon, 15 Nov 1999 16:09:35 GMT' into a SYSTEMTIME structure
     47        //We assume the time is in this format
     48        //and divide it into easy to swallow chunks
     49        tmpChar[3]='\0';
     50        tmpChar[7]='\0';
     51        tmpChar[11]='\0';
     52        tmpChar[16]='\0';
     53        tmpChar[19]='\0';
     54        tmpChar[22]='\0';
     55        tmpChar[25]='\0';
    5656
    57         SystemTime.tm_year = atoi(tmpChar+12) - 1900;
    58         SystemTime.tm_mday = atoi(tmpChar+5);
    59         SystemTime.tm_hour = atoi(tmpChar+17);
    60         SystemTime.tm_min = atoi(tmpChar+20);
    61         SystemTime.tm_sec = atoi(tmpChar+23);
     57        SystemTime.tm_year = atoi(tmpChar+12) - 1900;
     58        SystemTime.tm_mday = atoi(tmpChar+5);
     59        SystemTime.tm_hour = atoi(tmpChar+17);
     60        SystemTime.tm_min = atoi(tmpChar+20);
     61        SystemTime.tm_sec = atoi(tmpChar+23);
    6262
    63         //and month
    64         tmpChar2 = tmpChar + 8;
    65         switch(tmpChar2[2])
    66         {
    67                 case 'n':
    68                         if(tmpChar2[1]=='a')
    69                                 SystemTime.tm_mon = 0;
    70                         else
    71                                 SystemTime.tm_mon = 5;
    72                         break;
    73                 case 'b':
    74                         SystemTime.tm_mon = 1;
    75                         break;
    76                 case 'r':
    77                         if(tmpChar2[1]=='a')
    78                                 SystemTime.tm_mon = 2;
    79                         else
    80                                 SystemTime.tm_mon = 3;
    81                         break;
    82                 case 'y':
    83                         SystemTime.tm_mon = 4;
    84                         break;
    85                 case 'l':
    86                         SystemTime.tm_mon = 6;
    87                         break;
    88                 case 'g':
    89                         SystemTime.tm_mon = 7;
    90                         break;
    91                 case 'p':
    92                         SystemTime.tm_mon = 8;
    93                         break;
    94                 case 't':
    95                         SystemTime.tm_mon = 9;
    96                         break;
    97                 case 'v':
    98                         SystemTime.tm_mon = 10;
    99                         break;
    100                 case 'c':
    101                         SystemTime.tm_mon = 11;
    102                         break;
    103                 default:
    104                         FIXME("\n");
    105         }//switch
     63        //and month
     64        tmpChar2 = tmpChar + 8;
     65        switch(tmpChar2[2])
     66        {
     67                case 'n':
     68                        if(tmpChar2[1]=='a')
     69                                SystemTime.tm_mon = 0;
     70                        else
     71                                SystemTime.tm_mon = 5;
     72                        break;
     73                case 'b':
     74                        SystemTime.tm_mon = 1;
     75                        break;
     76                case 'r':
     77                        if(tmpChar2[1]=='a')
     78                                SystemTime.tm_mon = 2;
     79                        else
     80                                SystemTime.tm_mon = 3;
     81                        break;
     82                case 'y':
     83                        SystemTime.tm_mon = 4;
     84                        break;
     85                case 'l':
     86                        SystemTime.tm_mon = 6;
     87                        break;
     88                case 'g':
     89                        SystemTime.tm_mon = 7;
     90                        break;
     91                case 'p':
     92                        SystemTime.tm_mon = 8;
     93                        break;
     94                case 't':
     95                        SystemTime.tm_mon = 9;
     96                        break;
     97                case 'v':
     98                        SystemTime.tm_mon = 10;
     99                        break;
     100                case 'c':
     101                        SystemTime.tm_mon = 11;
     102                        break;
     103                default:
     104                        FIXME("\n");
     105        }//switch
    106106
    107         return mktime(&SystemTime);
     107        return mktime(&SystemTime);
    108108}
    109109
    110110
    111111BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
    112         struct hostent **phe, struct sockaddr_in *psa)
     112        struct hostent **phe, struct sockaddr_in *psa)
    113113{
    114         *phe = gethostbyname(lpszServerName);
    115         if (NULL == *phe)
    116         {
    117             TRACE("Failed to get hostname %s\n", lpszServerName);
    118             return FALSE;
    119         }
     114        *phe = gethostbyname(lpszServerName);
     115        if (NULL == *phe)
     116        {
     117            TRACE("Failed to get hostname %s\n", lpszServerName);
     118            return FALSE;
     119        }
    120120
    121         memcpy((char *)&psa->sin_addr, (*phe)->h_addr, (*phe)->h_length);
    122         psa->sin_family = (*phe)->h_addrtype;
    123         psa->sin_port = htons((u_short)nServerPort);
     121        memset(psa,0,sizeof(struct sockaddr_in));
     122        memcpy((char *)&psa->sin_addr, (*phe)->h_addr, (*phe)->h_length);
     123        psa->sin_family = (*phe)->h_addrtype;
     124        psa->sin_port = htons((u_short)nServerPort);
    124125
    125         return TRUE;
     126        return TRUE;
    126127}
Note: See TracChangeset for help on using the changeset viewer.