minor fixes.
This commit is contained in:
parent
9836ee3d94
commit
77d8085ed1
25
slock.c
25
slock.c
@ -312,7 +312,7 @@ usage(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
read_pw(char *name) {
|
read_pfile(char *name) {
|
||||||
FILE *f = fopen(name, "r");
|
FILE *f = fopen(name, "r");
|
||||||
|
|
||||||
struct stat s;
|
struct stat s;
|
||||||
@ -325,7 +325,7 @@ read_pw(char *name) {
|
|||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
fprintf(stderr, "Could not open: %s.\n", name);
|
fprintf(stderr, "Could not open: %s.\n", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -338,19 +338,25 @@ main(int argc, char **argv) {
|
|||||||
Display *dpy;
|
Display *dpy;
|
||||||
int screen;
|
int screen;
|
||||||
|
|
||||||
|
#ifdef SLOCK_QUIET
|
||||||
|
freopen("/dev/null", "a", stdout);
|
||||||
|
freopen("/dev/null", "a", stderr);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
char buf[255];
|
char buf[255] = {0};
|
||||||
sprintf(buf, "%s/.slock_passwd", getenv("HOME"));
|
snprintf(buf, sizeof(buf), "%s/.slock_passwd", getenv("HOME"));
|
||||||
g_pw = read_pw(buf);
|
g_pw = read_pfile(buf);
|
||||||
} else if((argc >= 2) && !strcmp("-p", argv[1])) {
|
} else if((argc >= 2) && !strcmp("-p", argv[1])) {
|
||||||
g_pw = strdup(argv[2]);
|
g_pw = strdup(argv[2]);
|
||||||
} else if((argc >= 2) && !strcmp("-f", argv[1])) {
|
} else if((argc >= 2) && !strcmp("-f", argv[1])) {
|
||||||
g_pw = read_pw(argv[2]);
|
g_pw = read_pfile(argv[2]);
|
||||||
if (g_pw == NULL) return 1;
|
if (g_pw == NULL) return 1;
|
||||||
} else if((argc >= 2) && !strcmp("-v", argv[1]))
|
} else if((argc >= 2) && !strcmp("-v", argv[1])) {
|
||||||
die("slock-%s, © 2006-2012 Anselm R Garbe\n", VERSION);
|
die("slock-%s, © 2006-2012 Anselm R Garbe\n", VERSION);
|
||||||
else if(argc != 1)
|
} else if(argc != 1) {
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
if (g_pw) {
|
if (g_pw) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -363,9 +369,6 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// freopen("/dev/null", "a", stdout);
|
|
||||||
// freopen("/dev/null", "a", stderr);
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
dontkillme();
|
dontkillme();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user