diff options
author | merakor <cem@ckyln.com> | 2020-07-24 09:08:10 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-07-24 09:08:10 +0000 |
commit | 48b69beda9d38ea8d4211a9f8e037dc1851cc5f9 (patch) | |
tree | 4ff8b501feacc22aaf75866ab09b4dbefdf769dc /bin/kiss-stat.c | |
parent | 191a1a9bb5c2092424311780334ac0ca8237220b (diff) | |
download | cpt-48b69beda9d38ea8d4211a9f8e037dc1851cc5f9.tar.gz |
rename binary programs
FossilOrigin-Name: f404639f07097134f93aa22cc5583ff73a6cd281aa4b1bbfd10053ebd97d7bf4
Diffstat (limited to 'bin/kiss-stat.c')
-rw-r--r-- | bin/kiss-stat.c | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/bin/kiss-stat.c b/bin/kiss-stat.c deleted file mode 100644 index 4380503..0000000 --- a/bin/kiss-stat.c +++ /dev/null @@ -1,41 +0,0 @@ -/* kiss-stat --- a utility for getting the user name of file owner - * See LICENSE for copyright information - * - * The reason this simple tool exists is because 'stat' is not - * portable and ls is not exactly stable enough for scripting. - * This program is for outputting the owner name, and that's it. - */ - -#include <pwd.h> -#include <sys/stat.h> -#include <stdio.h> -#include <string.h> - -struct passwd *pw; -struct stat sb; - -int -main (int argc, char *argv[]) -{ - /* Exit if no or multiple arguments are given. */ - if (argc != 2 || strcmp(argv[1], "--help") == 0) { - fprintf(stderr, "Usage: %s [pathname]\n", argv[0]); - return 1; - } - - /* Exit if file stat cannot be obtained. */ - if (lstat(argv[1], &sb) == -1) { - perror(argv[0]); - return 1; - } - - /* Exit if name of the owner cannot be retrieved. */ - if (!getpwuid(sb.st_uid)) { - return 1; - } - - /* Print the user name of file owner. */ - pw = getpwuid(sb.st_uid); - printf("%s\n", pw->pw_name); - return 0; -} |