[hackers] [sbase] Remove stat(1) from sbase as it is not portable || sin

From: <git_AT_suckless.org>
Date: Thu, 30 Jan 2014 17:26:44 +0100

commit f4609e28368d3e7a90cbfe602566469bd5fe53a4
Author: sin <sin_AT_2f30.org>
Date: Thu Jan 30 16:23:55 2014 +0000

    Remove stat(1) from sbase as it is not portable
    
    This utility uses major()/minor() and they are not portable.
    It belongs in ubase.

diff --git a/Makefile b/Makefile
index 204e05c..8a6790e 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -92,7 +92,6 @@ SRC = \
         sha1sum.c \
         sha256sum.c\
         sha512sum.c\
- stat.c \
         wc.c \
         who.c \
         xargs.c \
diff --git a/stat.1 b/stat.1
deleted file mode 100644
index 7391edf..0000000
--- a/stat.1
+++ /dev/null
_AT_@ -1,17 +0,0 @@
-.TH STAT 1 sbase\-VERSION
-.SH NAME
-stat \- display file status
-.SH SYNOPSIS
-.B stat
-.RB [ \-L ]
-.RI [ file ...]
-.SH DESCRIPTION
-.B stat
-displays information about the given files or stdin if no files
-are specified.
-.SH OPTIONS
-.TP
-.B \-L
-follow links
-.SH SEE ALSO
-.IR stat (2)
diff --git a/stat.c b/stat.c
deleted file mode 100644
index 37d8676..0000000
--- a/stat.c
+++ /dev/null
_AT_@ -1,72 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include "util.h"
-
-static void show_stat(const char *file, struct stat *st);
-
-static void
-usage(void)
-{
- eprintf("usage: %s [-L] [file...]
", argv0);
-}
-
-int
-main(int argc, char *argv[])
-{
- struct stat st;
- int i, ret = EXIT_SUCCESS;
- int Lflag = 0;
- int (*fn)(const char *, struct stat *);
-
- ARGBEGIN {
- case 'L':
- Lflag = 1;
- break;
- default:
- usage();
- } ARGEND;
-
- if (argc == 0) {
- if (fstat(STDIN_FILENO, &st) < 0)
- eprintf("stat <stdin>:");
- show_stat("<stdin>", &st);
- }
-
- for (i = 0; i < argc; i++) {
- fn = Lflag ? stat : lstat;
- if (fn(argv[i], &st) == -1) {
- weprintf("%s %s:", Lflag ? "stat" : "lstat", argv[i]);
- ret = EXIT_FAILURE;
- continue;
- }
- show_stat(argv[i], &st);
- }
-
- return ret;
-}
-
-static void
-show_stat(const char *file, struct stat *st)
-{
- char buf[100];
-
- printf(" File: ā€˜%sā€™
", file);
- printf(" Size: %lu Blocks: %lu IO Block: %lu
", (unsigned long)st->st_size,
- (unsigned long)st->st_blocks, (unsigned long)st->st_blksize);
- printf("Device: %xh/%ud Inode: %lu Links %lu
", major(st->st_dev),
- minor(st->st_dev), (unsigned long)st->st_ino, (unsigned long)st->st_nlink);
- printf("Access: %04o Uid: %u Gid: %u
", st->st_mode & 0777, st->st_uid, st->st_gid);
- strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localtime(&st->st_atime));
- printf("Access: %s
", buf);
- strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localtime(&st->st_mtime));
- printf("Modify: %s
", buf);
- strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localtime(&st->st_ctime));
- printf("Change: %s
", buf);
-}
Received on Thu Jan 30 2014 - 17:26:44 CET

This archive was generated by hypermail 2.3.0 : Thu Jan 30 2014 - 17:36:12 CET