Fixed a couple of HWND type mismatches.
[wine/multimedia.git] / dlls / wininet / utility.c
blob224d9490b13cebc14537dc390f73feab258fdeef
1 /*
2 * Wininet - Utility functions
4 * Copyright 1999 Corel Corporation
6 * Ulrich Czekalla
8 */
10 #include "config.h"
12 #include <stdlib.h>
13 #include <string.h>
14 #include <time.h>
16 #include "windef.h"
17 #include "winbase.h"
18 #include "wininet.h"
19 #include "winerror.h"
21 #include "debugtools.h"
22 #include "internet.h"
24 DEFAULT_DEBUG_CHANNEL(wininet);
26 #define TIME_STRING_LEN 30
28 time_t ConvertTimeString(LPCSTR asctime)
30 char tmpChar[TIME_STRING_LEN];
31 char *tmpChar2;
32 struct tm t;
33 int timelen = strlen(asctime);
35 if(!asctime || !timelen)
36 return 0;
38 strncpy(tmpChar, asctime, TIME_STRING_LEN);
40 /* Assert that the string is the expected length */
41 if (tmpChar[TIME_STRING_LEN] != '\0')
43 tmpChar[TIME_STRING_LEN] = '\0';
44 FIXME("\n");
47 /* Convert a time such as 'Mon, 15 Nov 1999 16:09:35 GMT' into a SYSTEMTIME structure
48 * We assume the time is in this format
49 * and divide it into easy to swallow chunks
51 tmpChar[3]='\0';
52 tmpChar[7]='\0';
53 tmpChar[11]='\0';
54 tmpChar[16]='\0';
55 tmpChar[19]='\0';
56 tmpChar[22]='\0';
57 tmpChar[25]='\0';
59 t.tm_year = atoi(tmpChar+12) - 1900;
60 t.tm_mday = atoi(tmpChar+5);
61 t.tm_hour = atoi(tmpChar+17);
62 t.tm_min = atoi(tmpChar+20);
63 t.tm_sec = atoi(tmpChar+23);
65 /* and month */
66 tmpChar2 = tmpChar + 8;
67 switch(tmpChar2[2])
69 case 'n':
70 if(tmpChar2[1]=='a')
71 t.tm_mon = 0;
72 else
73 t.tm_mon = 5;
74 break;
75 case 'b':
76 t.tm_mon = 1;
77 break;
78 case 'r':
79 if(tmpChar2[1]=='a')
80 t.tm_mon = 2;
81 else
82 t.tm_mon = 3;
83 break;
84 case 'y':
85 t.tm_mon = 4;
86 break;
87 case 'l':
88 t.tm_mon = 6;
89 break;
90 case 'g':
91 t.tm_mon = 7;
92 break;
93 case 'p':
94 t.tm_mon = 8;
95 break;
96 case 't':
97 t.tm_mon = 9;
98 break;
99 case 'v':
100 t.tm_mon = 10;
101 break;
102 case 'c':
103 t.tm_mon = 11;
104 break;
105 default:
106 FIXME("\n");
109 return mktime(&t);
113 BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
114 struct hostent **phe, struct sockaddr_in *psa)
116 TRACE("%s\n", lpszServerName);
118 *phe = gethostbyname(lpszServerName);
119 if (NULL == *phe)
121 TRACE("Failed to get hostname: (%s)\n", lpszServerName);
122 return FALSE;
125 memset(psa,0,sizeof(struct sockaddr_in));
126 memcpy((char *)&psa->sin_addr, (*phe)->h_addr, (*phe)->h_length);
127 psa->sin_family = (*phe)->h_addrtype;
128 psa->sin_port = htons((u_short)nServerPort);
130 return TRUE;