aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunk@stsci.edu>2011-04-06 15:39:33 -0400
committerJoseph Hunkeler <jhunk@stsci.edu>2011-04-06 15:39:33 -0400
commitb2d8181bbebae60f1296f8577efed4b976fe9dc2 (patch)
tree6145f1eb760d53212c1228488b3a3483a2f9a3d7
parent6c81e2b11d5339ec290945b480c9054f5f9ba556 (diff)
downloadduser-b2d8181bbebae60f1296f8577efed4b976fe9dc2.tar.gz
Debugging disabled
Program name is now global
-rw-r--r--Makefile2
-rw-r--r--duser.c12
2 files changed, 9 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index a5581f4..8940b86 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
CC=gcc
-CFLAGS=-g -Wall -Wextra
+CFLAGS=-O2 -Wall -Wextra
LDFLAGS=
PROG="duser"
SRC=duser.c duser.h log.c cfg.c
diff --git a/duser.c b/duser.c
index 8273c80..a6a372c 100644
--- a/duser.c
+++ b/duser.c
@@ -20,6 +20,7 @@
char list_path[PATH_MAX];
char logfile[PATH_MAX];
+static char progname[FILENAME_MAX];
int CMD_FLAG_NOOPT = 0;
int CMD_FLAG_DEL = 0;
@@ -98,7 +99,7 @@ int user_del_all(const char* needle)
snprintf(tmp, PATH_MAX, "%s%s", list_path, list[i]);
if((rp = find_in_file(tmp, needle)) != NULL)
{
- printf("%20s\t%5d\n", basename(rp->file), rp->index);
+ printf("%20s\t%5d%23s\n", basename(rp->file), rp->index, rp->name);
processed.matches++;
}
}
@@ -584,7 +585,8 @@ int check_cmd_string(char** args, const char* str2, int count)
int user_new_list(const char* fname)
{
- char* filename = strdup(fname);
+ char *filename = strdup(fname);
+ char *timestr;
char message[BUFSIZ];
FILE *fp = NULL;
time_t ttm;
@@ -604,7 +606,9 @@ int user_new_list(const char* fname)
time(&ttm);
tmptr = localtime(&ttm);
- snprintf(message, BUFSIZ, "#\n# Created on %s by UID %d\n#\n", asctime(tmptr), getuid());
+ timestr = asctime(tmptr);
+ timestr[strlen(timestr)-1] = '\0';
+ snprintf(message, BUFSIZ, "#\n# Created by %s on %s. UID %d\n#\n", basename(progname), timestr, getuid());
fputs(message, fp);
fflush(fp);
fclose(fp);
@@ -627,7 +631,7 @@ int main(int argc, char* argv[])
return -1;
}
- const char* progname = argv[0];
+ strncpy(progname, argv[0], strlen(argv[0]));
const char* needle = argv[2];
const char* single_list = argv[3];