comparison rogue5/mdport.c @ 34:655c317b6237

rogue5: add savedir, logfile, bugfixes
author elwin
date Mon, 24 May 2010 20:16:15 +0000
parents f502bf60e6e4
children 05018c63a721
comparison
equal deleted inserted replaced
33:f502bf60e6e4 34:655c317b6237
446 #elif defined(HAVE_GETPWUID)&& !defined(__DJGPP__) 446 #elif defined(HAVE_GETPWUID)&& !defined(__DJGPP__)
447 struct passwd *pw; 447 struct passwd *pw;
448 448
449 pw = getpwuid(getuid()); 449 pw = getpwuid(getuid());
450 450
451 l = pw->pw_name; 451 if (pw != NULL)
452 l = pw->pw_name;
453 else
454 l = NULL;
452 #endif 455 #endif
453 456
454 if ((l == NULL) || (*l == '\0')) 457 if ((l == NULL) || (*l == '\0'))
455 if ( (l = getenv("USERNAME")) == NULL ) 458 if ( (l = getenv("USERNAME")) == NULL )
456 if ( (l = getenv("LOGNAME")) == NULL ) 459 if ( (l = getenv("LOGNAME")) == NULL )
477 #else 480 #else
478 char slash = '/'; 481 char slash = '/';
479 struct passwd *pw; 482 struct passwd *pw;
480 pw = getpwuid(getuid()); 483 pw = getpwuid(getuid());
481 484
482 h = pw->pw_dir; 485 if (pw != NULL)
486 h = pw->pw_dir;
487 else
488 h = NULL;
483 489
484 if (strcmp(h,"/") == 0) 490 if (strcmp(h,"/") == 0)
485 h = NULL; 491 h = NULL;
486 #endif 492 #endif
487 homedir[0] = 0; 493 homedir[0] = 0;
541 char *def = "C:\\COMMAND.COM"; 547 char *def = "C:\\COMMAND.COM";
542 #else 548 #else
543 char *def = "/bin/sh"; 549 char *def = "/bin/sh";
544 struct passwd *pw; 550 struct passwd *pw;
545 pw = getpwuid(getuid()); 551 pw = getpwuid(getuid());
546 s = pw->pw_shell; 552 if (pw != NULL)
553 s = pw->pw_shell;
547 #endif 554 #endif
548 if ((s == NULL) || (*s == '\0')) 555 if ((s == NULL) || (*s == '\0'))
549 if ( (s = getenv("COMSPEC")) == NULL) 556 if ( (s = getenv("COMSPEC")) == NULL)
550 if ( (s = getenv("SHELL")) == NULL) 557 if ( (s = getenv("SHELL")) == NULL)
551 if ( (s = getenv("SystemRoot")) == NULL) 558 if ( (s = getenv("SystemRoot")) == NULL)