Changeset 4842 for trunk/src/wininet/utility.c
- Timestamp:
- Dec 28, 2000, 12:06:39 AM (25 years ago)
- 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 birdExp $1 /* $Id: utility.c,v 1.3 2000-12-27 23:06:17 sandervl Exp $ 2 2 * 3 3 * Wininet - Utility functions … … 27 27 time_t ConvertTimeString(LPCSTR asctime) 28 28 { 29 30 31 32 29 char tmpChar[TIME_STRING_LEN]; 30 char *tmpChar2; 31 struct tm SystemTime; 32 int timelen = strlen(asctime); 33 33 34 35 34 if(!asctime || !timelen) 35 return 0; 36 36 37 37 strncpy(tmpChar, asctime, TIME_STRING_LEN); 38 38 39 40 41 42 43 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 } 45 45 46 47 48 49 50 51 52 53 54 55 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'; 56 56 57 58 59 60 61 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); 62 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 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 106 106 107 107 return mktime(&SystemTime); 108 108 } 109 109 110 110 111 111 BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort, 112 112 struct hostent **phe, struct sockaddr_in *psa) 113 113 { 114 115 116 117 118 119 114 *phe = gethostbyname(lpszServerName); 115 if (NULL == *phe) 116 { 117 TRACE("Failed to get hostname %s\n", lpszServerName); 118 return FALSE; 119 } 120 120 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); 124 125 125 126 return TRUE; 126 127 }
Note:
See TracChangeset
for help on using the changeset viewer.