From 72d47c05951b4b67b0d236509f26f4774c827e84 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Mon, 10 Jan 2011 22:12:45 -0500 Subject: [PATCH] Remove DEBUG lines. --- src/modules/login.c | 41 ++++++++++------------------------------- src/modules/mail.c | 38 +++++--------------------------------- src/modules/passwd.c | 40 ++++++---------------------------------- src/ui.c | 1 - 4 files changed, 21 insertions(+), 99 deletions(-) diff --git a/src/modules/login.c b/src/modules/login.c index ad97535..7c3449d 100644 --- a/src/modules/login.c +++ b/src/modules/login.c @@ -55,20 +55,12 @@ char *stamp(time_t, const char *); void ui_module_init(int *chainable) { -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_init()\n", __FILE__); -#endif - *chainable = 0; time(&now); } void ui_module_exit() { -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_exit()\n", __FILE__); -#endif - #ifdef HAVE_PROCFS if (procdir) closedir(procdir); @@ -86,7 +78,7 @@ void ui_module_exit() #ifndef HAVE_UTMPX_H /* This is for *BSD (login process id). */ #ifdef BSD_KVM -char *ui_module_pid(uid_t uid, int multi) +static char *get_pid(uid_t uid, int multi) { static int firstrun; static char line[LINE_MAX]; @@ -162,7 +154,7 @@ char *ui_module_pid(uid_t uid, int multi) #include #endif -char *ui_module_pid(uid_t uid, int multi) +static char *get_pid(uid_t uid, int multi) { static int firstrun; struct dirent *ent; @@ -289,7 +281,7 @@ again: } #else /* Unsupported OS. */ -char *ui_module_pid(uid_t uid, int multi) +static char *get_pid(uid_t uid, int multi) { return "!"; } @@ -600,10 +592,6 @@ static char *idle(UTMP **u, int multi) */ void ui_module_help() { -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_help()\n", __FILE__); -#endif - printf(" Login information [-L (-%s)]:\n", LOGIN_OPTION_ORDER); printf("\t-y tty\t\t\t\t"); printf("-m message status\n"); @@ -752,7 +740,7 @@ int ui_module_exec(char ***s, const struct passwd *pw, const int multi, add_string(&strings, line); #else - add_string(&strings, (u) ? ui_module_pid(pw->pw_uid, multi) : "!"); + add_string(&strings, (u) ? get_pid(pw->pw_uid, multi) : "!"); #endif break; default: @@ -805,16 +793,18 @@ int ui_module_options(int argc, char **argv) int opt; char *p = options; -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_options()\n", __FILE__); -#endif - while ((opt = getopt(argc, argv, LOGIN_OPTION_STRING)) != -1) { switch (opt) { case 'l': + if (parse_last_options(optarg)) + return 1; + last_options = optarg; break; case 'L': + strncpy(options, LOGIN_OPTION_ORDER, sizeof(options)); + last_options = "a"; + return 0; case 'p': case 'd': case 'i': @@ -829,17 +819,6 @@ int ui_module_options(int argc, char **argv) return 1; } - if (opt == 'l') { - if (parse_last_options(last_options)) - return 1; - } - - if (opt == 'L') { - strncpy(options, LOGIN_OPTION_ORDER, sizeof(options)); - last_options = "a"; - break; - } - *p++ = opt; *p = '\0'; } diff --git a/src/modules/mail.c b/src/modules/mail.c index 9023c6f..73d2cfd 100644 --- a/src/modules/mail.c +++ b/src/modules/mail.c @@ -80,19 +80,11 @@ char *stamp(time_t, const char *); void ui_module_init(int *chainable) { -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_init()\n", __FILE__); -#endif - *chainable = 0; } void ui_module_exit() { -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_exit()\n", __FILE__); -#endif - if (aliasbuf) munmap(aliasbuf, strlen(aliasbuf)); @@ -217,11 +209,10 @@ static char *forwards(const char *dir, const int multi) { FILE *fp; char buf[LINE_MAX], *s; - static char buf2[FILENAME_MAX]; + static char buf2[LINE_MAX]; int n = 0; char m[2] = { multi, '\0' }; - buf[0] = buf2[0] = '\0'; snprintf(buf2, sizeof(buf2), "%s/.forward", dir); if ((fp = fopen(buf2, "r")) == NULL) { @@ -260,8 +251,6 @@ static char *foldersize(struct stat st) { static char str[33], *p; - str[0] = '\0'; - snprintf(str, sizeof(str), "%lu", (unsigned long) st.st_size); p = str; return p; @@ -271,17 +260,12 @@ static char *foldersize(struct stat st) */ void ui_module_help() { -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_help()\n", __FILE__); -#endif - printf(" Mail information [-M (-%s)]:\n", MAIL_OPTION_ORDER); printf("\t-f forwarding addresses\t"); printf("-a mail aliases\n"); printf("\t-r folder access (read) time\t"); printf("-m folder modification time\n"); printf("\t-s folder size\n\n"); - return; } /* This is the equivalent to main() only without argc and argv available. */ @@ -300,7 +284,7 @@ int ui_module_exec(char ***s, const struct passwd *pw, const int multi_char, if (stat(folder, &st) != -1) gotstat = 1; - while (*p) { + for (; *p; p++) { switch (*p) { case 's': add_string(&strings, (gotstat) ? foldersize(st) : "!"); @@ -320,8 +304,6 @@ int ui_module_exec(char ***s, const struct passwd *pw, const int multi_char, default: break; } - - p++; } *s = strings; @@ -340,18 +322,16 @@ int ui_module_options(int argc, char **argv) int opt; char *p = options; -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_options()\n", __FILE__); -#endif - while ((opt = getopt(argc, argv, MAIL_OPTION_STRING)) != -1) { switch (opt) { + case 'M': + strncpy(options, MAIL_OPTION_ORDER, sizeof(options)); + return 0; case 'f': case 's': case 'r': case 'm': case 'a': - case 'M': break; case '?': warnx("mail: invalid option -- %c", optopt); @@ -359,14 +339,6 @@ int ui_module_options(int argc, char **argv) return 1; } - /* - * This option '-M' sets all available options for this module. - */ - if (opt == 'M') { - strncpy(options, MAIL_OPTION_ORDER, sizeof(options)); - break; - } - *p++ = opt; *p = '\0'; } diff --git a/src/modules/passwd.c b/src/modules/passwd.c index 6f33caf..003c2b8 100644 --- a/src/modules/passwd.c +++ b/src/modules/passwd.c @@ -81,10 +81,6 @@ char *stamp(time_t, const char *); void ui_module_init(int *chainable) { -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_init()\n", __FILE__); -#endif - /* * Keep the password file open if possible (*BSD). */ @@ -100,10 +96,6 @@ void ui_module_init(int *chainable) void ui_module_exit() { -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_exit()\n", __FILE__); -#endif - #ifdef HAVE_GETSPNAM if (amroot) endspent(); @@ -252,10 +244,6 @@ static void groups(const struct passwd *pw, const int multi, */ void ui_module_help() { -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_help()\n", __FILE__); -#endif - printf(" Password/Group file information [-P (-%s)]:\n", PASSWD_OPTION_ORDER); printf("\t-l login name\t\t"); @@ -281,10 +269,6 @@ int ui_module_exec(char ***s, const struct passwd *pw, const int multi_char, struct spwd *spwd = NULL; #endif -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_exec()\n", __FILE__); -#endif - #ifdef HAVE_GETSPNAM if (amroot) { if ((spwd = getspnam(pw->pw_name)) == NULL) @@ -391,16 +375,18 @@ int ui_module_options(int argc, char **argv) int opt; char *p = options; -#ifdef DEBUG - fprintf(stderr, "%s: ui_module_options()\n", __FILE__); -#endif - while ((opt = getopt(argc, argv, PASSWD_OPTION_STRING)) != -1) { switch (opt) { case 'i': + if (parse_gecos_options(optarg)) + return 1; + gecos_options = optarg; break; case 'P': + strncpy(options, PASSWD_OPTION_ORDER, sizeof(options)); + gecos_options = "a"; + return 0; case 'l': case 'p': case 'u': @@ -417,20 +403,6 @@ int ui_module_options(int argc, char **argv) return 1; } - if (opt == 'i') { - if (parse_gecos_options(gecos_options)) - return 1; - } - - /* - * This option '-P' sets all available options for this module. - */ - if (opt == 'P') { - strncpy(options, PASSWD_OPTION_ORDER, sizeof(options)); - gecos_options = "a"; - break; - } - *p++ = opt; *p = '\0'; } diff --git a/src/ui.c b/src/ui.c index 6344c92..4aeb1d3 100644 --- a/src/ui.c +++ b/src/ui.c @@ -79,7 +79,6 @@ void add_string(char ***buf, const char *str) s[i++] = strdup(str); s[i] = NULL; *buf = s; - return; } /* This is for the field separators (-F and -m). */ -- 2.11.4.GIT