pidgin/win32/winpidgin.c

changeset 23936
67df298c2b9b
parent 23934
4f928192592f
child 24433
a5213aeff14c
equal deleted inserted replaced
23935:317e5babd704 23936:67df298c2b9b
439 _snprintf(envstr, 25, "LANG=%s", locale); 439 _snprintf(envstr, 25, "LANG=%s", locale);
440 printf("Setting locale: %s\n", envstr); 440 printf("Setting locale: %s\n", envstr);
441 _putenv(envstr); 441 _putenv(envstr);
442 } 442 }
443 443
444 static void winpidgin_add_perl_to_path() { 444
445 static void winpidgin_add_stuff_to_path() {
445 char perl_path[MAX_PATH + 1]; 446 char perl_path[MAX_PATH + 1];
446 DWORD plen = sizeof(perl_path); 447 char *ppath = NULL;
448 char mit_kerberos_path[MAX_PATH + 1];
449 char *mpath = NULL;
450 DWORD plen;
447 451
448 printf("%s", "Looking for Perl... "); 452 printf("%s", "Looking for Perl... ");
449 453
454 plen = sizeof(perl_path);
450 if (read_reg_string(HKEY_LOCAL_MACHINE, "SOFTWARE\\Perl", "", 455 if (read_reg_string(HKEY_LOCAL_MACHINE, "SOFTWARE\\Perl", "",
451 (LPBYTE) &perl_path, &plen)) { 456 (LPBYTE) &perl_path, &plen)) {
457 /* We *could* check for perl510.dll, but it seems unnecessary. */
458 printf("found in '%s'.\n", perl_path);
459
460 if (perl_path[strlen(perl_path) - 1] != '\\')
461 strcat(perl_path, "\\");
462 strcat(perl_path, "bin");
463
464 ppath = perl_path;
465 } else
466 printf("%s", "not found.\n");
467
468 printf("%s", "Looking for MIT Kerberos... ");
469
470 plen = sizeof(mit_kerberos_path);
471 if (read_reg_string(HKEY_LOCAL_MACHINE, "SOFTWARE\\MIT\\Kerberos", "InstallDir",
472 (LPBYTE) &mit_kerberos_path, &plen)) {
473 /* We *could* check for gssapi32.dll */
474 printf("found in '%s'.\n", mit_kerberos_path);
475
476 if (mit_kerberos_path[strlen(mit_kerberos_path) - 1] != '\\')
477 strcat(mit_kerberos_path, "\\");
478 strcat(mit_kerberos_path, "bin");
479
480 mpath = mit_kerberos_path;
481 } else
482 printf("%s", "not found.\n");
483
484 if (ppath != NULL || mpath != NULL) {
452 const char *path = getenv("PATH"); 485 const char *path = getenv("PATH");
453 /* Enough to add "PATH=" + ";" + perl_path + "\\bin" + \0 */ 486 BOOL add_ppath = ppath != NULL && (path == NULL || !strstr(path, ppath));
454 487 BOOL add_mpath = mpath != NULL && (path == NULL || !strstr(path, mpath));
455 /* We *could* check for perl510.dll, but it seems unnecessary. */ 488 char *newpath;
456 489 int newlen;
457 printf("found in '%s'.\n", perl_path); 490
458 491 if (add_ppath || add_mpath) {
459 if (perl_path[strlen(perl_path) - 1] != '\\') { 492 /* Enough to add "PATH=" + path + ";" + ppath + ";" + mpath + \0 */
460 strcat(perl_path, "\\"); 493 newlen = 6 + (path ? strlen(path) + 1 : 0);
461 } 494 if (add_ppath)
462 strcat(perl_path, "bin"); 495 newlen += strlen(ppath) + 1;
463 496 if (add_mpath)
464 if (path == NULL || !strstr(path, perl_path)) { 497 newlen += strlen(mpath) + 1;
465 int newlen = (path ? strlen(path) : 0) + strlen(perl_path) + 10; 498 newpath = malloc(newlen);
466 char *newpath = malloc(newlen);
467 *newpath = '\0'; 499 *newpath = '\0';
468 500
469 _snprintf(newpath, newlen, "PATH=%s%s%s", 501 _snprintf(newpath, newlen, "PATH=%s%s%s%s%s%s",
470 path ? path : "", 502 path ? path : "",
471 path ? ";" : "", 503 path ? ";" : "",
472 perl_path); 504 add_ppath ? ppath : "",
473 505 add_ppath ? ";" : "",
474 printf("Adding Perl to PATH: %s\n", newpath); 506 add_mpath ? mpath : "",
507 add_mpath ? ";" : "");
508
509 printf("New PATH: %s\n", newpath);
475 510
476 _putenv(newpath); 511 _putenv(newpath);
477 free(newpath); 512 free(newpath);
478 } else 513 }
479 printf("%s\n", "Perl already in PATH."); 514 }
480 } else
481 printf("%s", "not found.\n");
482
483 } 515 }
484 516
485 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13) 517 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13)
486 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14) 518 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14)
487 519
670 else if (!getenv("PIDGIN_NO_DLL_CHECK")) 702 else if (!getenv("PIDGIN_NO_DLL_CHECK"))
671 dll_prep(); 703 dll_prep();
672 704
673 winpidgin_set_locale(); 705 winpidgin_set_locale();
674 706
675 winpidgin_add_perl_to_path(); 707 winpidgin_add_stuff_to_path();
676 708
677 /* If help, version or multiple flag used, do not check Mutex */ 709 /* If help, version or multiple flag used, do not check Mutex */
678 if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v")) 710 if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v"))
679 if (!winpidgin_set_running(getenv("PIDGIN_MULTI_INST") == NULL && strstr(lpszCmdLine, "-m") == NULL)) 711 if (!winpidgin_set_running(getenv("PIDGIN_MULTI_INST") == NULL && strstr(lpszCmdLine, "-m") == NULL))
680 return 0; 712 return 0;

mercurial