400 */
401 void setUserHome(java_props_t *sprops) {
402 if (sprops == NULL) { return; }
403 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
404 sprops->user_home = createUTF8CString((CFStringRef)NSHomeDirectory());
405 [pool drain];
406 }
407
408 /*
409 * Method for fetching proxy info and storing it in the property list.
410 */
411 void setProxyProperties(java_props_t *sProps) {
412 if (sProps == NULL) return;
413
414 char buf[16]; /* Used for %d of an int - 16 is plenty */
415 CFStringRef
416 cf_httpHost = NULL,
417 cf_httpsHost = NULL,
418 cf_ftpHost = NULL,
419 cf_socksHost = NULL,
420 cf_gopherHost = NULL;
421 int
422 httpPort = 80, // Default proxy port values
423 httpsPort = 443,
424 ftpPort = 21,
425 socksPort = 1080,
426 gopherPort = 70;
427
428 CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL);
429 if (dict == NULL) return;
430
431 /* Read the proxy exceptions list */
432 CFArrayRef cf_list = CFDictionaryGetValue(dict, kSCPropNetProxiesExceptionsList);
433
434 CFMutableStringRef cf_exceptionList = NULL;
435 if (cf_list != NULL) {
436 CFIndex len = CFArrayGetCount(cf_list), idx;
437
438 cf_exceptionList = CFStringCreateMutable(NULL, 0);
439 for (idx = (CFIndex)0; idx < len; idx++) {
440 CFStringRef cf_ehost;
441 if ((cf_ehost = CFArrayGetValueAtIndex(cf_list, idx))) {
442 /* Convert this exception from Mac OS X syntax to Java syntax.
443 See Radar #3441134 for details. This may generate a string
444 with multiple Java exceptions separated by '|'. */
445 char *c_exception = createConvertedException(cf_ehost);
446 if (c_exception) {
462 CFRelease(cf_exceptionList);
463 }
464
465 #define CHECK_PROXY(protocol, PROTOCOL) \
466 sProps->protocol##ProxyEnabled = \
467 getProxyInfoForProtocol(dict, kSCPropNetProxies##PROTOCOL##Enable, \
468 kSCPropNetProxies##PROTOCOL##Proxy, \
469 kSCPropNetProxies##PROTOCOL##Port, \
470 &cf_##protocol##Host, &protocol##Port); \
471 if (sProps->protocol##ProxyEnabled) { \
472 sProps->protocol##Host = createUTF8CString(cf_##protocol##Host); \
473 snprintf(buf, sizeof(buf), "%d", protocol##Port); \
474 sProps->protocol##Port = malloc(strlen(buf) + 1); \
475 strcpy(sProps->protocol##Port, buf); \
476 }
477
478 CHECK_PROXY(http, HTTP);
479 CHECK_PROXY(https, HTTPS);
480 CHECK_PROXY(ftp, FTP);
481 CHECK_PROXY(socks, SOCKS);
482 CHECK_PROXY(gopher, Gopher);
483
484 #undef CHECK_PROXY
485
486 CFRelease(dict);
487 }
|
400 */
401 void setUserHome(java_props_t *sprops) {
402 if (sprops == NULL) { return; }
403 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
404 sprops->user_home = createUTF8CString((CFStringRef)NSHomeDirectory());
405 [pool drain];
406 }
407
408 /*
409 * Method for fetching proxy info and storing it in the property list.
410 */
411 void setProxyProperties(java_props_t *sProps) {
412 if (sProps == NULL) return;
413
414 char buf[16]; /* Used for %d of an int - 16 is plenty */
415 CFStringRef
416 cf_httpHost = NULL,
417 cf_httpsHost = NULL,
418 cf_ftpHost = NULL,
419 cf_socksHost = NULL,
420 int
421 httpPort = 80, // Default proxy port values
422 httpsPort = 443,
423 ftpPort = 21,
424 socksPort = 1080,
425
426 CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL);
427 if (dict == NULL) return;
428
429 /* Read the proxy exceptions list */
430 CFArrayRef cf_list = CFDictionaryGetValue(dict, kSCPropNetProxiesExceptionsList);
431
432 CFMutableStringRef cf_exceptionList = NULL;
433 if (cf_list != NULL) {
434 CFIndex len = CFArrayGetCount(cf_list), idx;
435
436 cf_exceptionList = CFStringCreateMutable(NULL, 0);
437 for (idx = (CFIndex)0; idx < len; idx++) {
438 CFStringRef cf_ehost;
439 if ((cf_ehost = CFArrayGetValueAtIndex(cf_list, idx))) {
440 /* Convert this exception from Mac OS X syntax to Java syntax.
441 See Radar #3441134 for details. This may generate a string
442 with multiple Java exceptions separated by '|'. */
443 char *c_exception = createConvertedException(cf_ehost);
444 if (c_exception) {
460 CFRelease(cf_exceptionList);
461 }
462
463 #define CHECK_PROXY(protocol, PROTOCOL) \
464 sProps->protocol##ProxyEnabled = \
465 getProxyInfoForProtocol(dict, kSCPropNetProxies##PROTOCOL##Enable, \
466 kSCPropNetProxies##PROTOCOL##Proxy, \
467 kSCPropNetProxies##PROTOCOL##Port, \
468 &cf_##protocol##Host, &protocol##Port); \
469 if (sProps->protocol##ProxyEnabled) { \
470 sProps->protocol##Host = createUTF8CString(cf_##protocol##Host); \
471 snprintf(buf, sizeof(buf), "%d", protocol##Port); \
472 sProps->protocol##Port = malloc(strlen(buf) + 1); \
473 strcpy(sProps->protocol##Port, buf); \
474 }
475
476 CHECK_PROXY(http, HTTP);
477 CHECK_PROXY(https, HTTPS);
478 CHECK_PROXY(ftp, FTP);
479 CHECK_PROXY(socks, SOCKS);
480
481 #undef CHECK_PROXY
482
483 CFRelease(dict);
484 }
|