]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
last: consolidate btmp/wtmp file paths
authorKarel Zak <kzak@redhat.com>
Mon, 12 Aug 2013 11:42:25 +0000 (13:42 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 12 Aug 2013 11:42:25 +0000 (13:42 +0200)
 .. so share the paths with another utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/last.c

index 76db12aa2a8e98ab164a996db37ead62fe068dca..3b59bb5d2aa78427b023beb519d5dbe6712b8154 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "c.h"
 #include "nls.h"
+#include "pathnames.h"
 
 #ifndef SHUTDOWN_TIME
 # define SHUTDOWN_TIME 254
@@ -176,27 +177,6 @@ static int uread(FILE *fp, struct utmp *u, int *quit)
        return 1;
 }
 
-/*
- *     Try to be smart about the location of the BTMP file
- */
-#ifndef BTMP_FILE
-#define BTMP_FILE getbtmp()
-static char *getbtmp(void)
-{
-       static char btmp[128];
-       char *p;
-
-       strcpy(btmp, WTMP_FILE);
-       if ((p = strrchr(btmp, '/')) == NULL)
-               p = btmp;
-       else
-               p++;
-       *p = 0;
-       strcat(btmp, "btmp");
-       return btmp;
-}
-#endif
-
 /*
  *     Print a short date.
  */
@@ -460,7 +440,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
        fputs(_(" -a, --hostlast       display hostnames in the last column\n"), out);
        fputs(_(" -d, --dns            translate the IP number back into a hostname\n"), out);
        fprintf(out,
-             _(" -f, --file <file>    use a specific file instead of %s\n"), WTMP_FILE);
+             _(" -f, --file <file>    use a specific file instead of %s\n"), _PATH_WTMP);
        fputs(_(" -F, --fulltimes      print full login and logout times and dates\n"), out);
        fputs(_(" -i, --ip             display IP numbers in numbers-and-dots notation\n"), out);
        fputs(_(" -n, --limit <number> how many lines to show\n"), out);
@@ -629,10 +609,10 @@ int main(int argc, char **argv)
    *   Which file do we want to read?
    */
   if (strcmp(progname, "lastb") == 0) {
-       ufile = BTMP_FILE;
+       ufile = _PATH_BTMP;
        lastb = 1;
   } else
-       ufile = WTMP_FILE;
+       ufile = _PATH_WTMP;
   if (altufile)
        ufile = altufile;
   time(&lastdown);