comparison src/win32/win32dep.c @ 4406:217572342740

[gaim-migrate @ 4675] wgaim_escape_dirsep committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Thu, 23 Jan 2003 19:25:48 +0000
parents ebfb80bbe1ed
children 2ad81729c049
comparison
equal deleted inserted replaced
4405:cb629f3efee6 4406:217572342740
88 */ 88 */
89 89
90 /* Misc Wingaim functions */ 90 /* Misc Wingaim functions */
91 HINSTANCE wgaim_hinstance(void) { 91 HINSTANCE wgaim_hinstance(void) {
92 return gaimexe_hInstance; 92 return gaimexe_hInstance;
93 }
94
95 /* Escape windows dir separators. This is needed when paths are saved,
96 and on being read back have their '\' chars used as an escape char.
97 Returns and allocated string which needs to be freed.
98 */
99 char* wgaim_escape_dirsep( char* filename ) {
100 int sepcount=0;
101 char* ret=NULL;
102 int cnt=0;
103
104 ret = filename;
105 while(*ret) {
106 if(*ret == '\\')
107 sepcount++;
108 ret++;
109 }
110 ret = g_malloc0(strlen(filename) + sepcount + 1);
111 while(*filename) {
112 ret[cnt] = *filename;
113 if(*filename == '\\')
114 ret[++cnt] = '\\';
115 filename++;
116 cnt++;
117 }
118 ret[cnt] = '\0';
119 return ret;
93 } 120 }
94 121
95 /* Determine whether the specified dll contains the specified procedure. 122 /* Determine whether the specified dll contains the specified procedure.
96 If so, load it (if not already loaded). */ 123 If so, load it (if not already loaded). */
97 FARPROC wgaim_find_and_loadproc( char* dllname, char* procedure ) { 124 FARPROC wgaim_find_and_loadproc( char* dllname, char* procedure ) {
208 /* Windows Initializations */ 235 /* Windows Initializations */
209 236
210 void wgaim_init(void) { 237 void wgaim_init(void) {
211 WORD wVersionRequested; 238 WORD wVersionRequested;
212 WSADATA wsaData; 239 WSADATA wsaData;
213 int err;
214 char* locale=0; 240 char* locale=0;
215 char newenv[128]; 241 char newenv[128];
216 242
217 debug_printf("wgaim_init\n"); 243 debug_printf("wgaim_init\n");
218 244
224 /* 250 /*
225 * Winsock init 251 * Winsock init
226 */ 252 */
227 wVersionRequested = MAKEWORD( 2, 2 ); 253 wVersionRequested = MAKEWORD( 2, 2 );
228 254
229 err = WSAStartup( wVersionRequested, &wsaData ); 255 WSAStartup( wVersionRequested, &wsaData );
230 if ( err != 0 ) {
231 return 1;
232 }
233 256
234 /* Confirm that the winsock DLL supports 2.2 */ 257 /* Confirm that the winsock DLL supports 2.2 */
235 /* Note that if the DLL supports versions greater than 258 /* Note that if the DLL supports versions greater than
236 2.2 in addition to 2.2, it will still return 2.2 in 259 2.2 in addition to 2.2, it will still return 2.2 in
237 wVersion since that is the version we requested. */ 260 wVersion since that is the version we requested. */
238 261
239 if ( LOBYTE( wsaData.wVersion ) != 2 || 262 if ( LOBYTE( wsaData.wVersion ) != 2 ||
240 HIBYTE( wsaData.wVersion ) != 2 ) { 263 HIBYTE( wsaData.wVersion ) != 2 ) {
241 debug_printf("Could not find a usable WinSock DLL. Oh well.\n"); 264 debug_printf("Could not find a usable WinSock DLL. Oh well.\n");
242 WSACleanup( ); 265 WSACleanup( );
243 return 1;
244 } 266 }
245 267
246 /* get default locale */ 268 /* get default locale */
247 locale = g_win32_getlocale(); 269 locale = g_win32_getlocale();
248 debug_printf("Language profile used: %s\n", locale); 270 debug_printf("Language profile used: %s\n", locale);