aboutsummaryrefslogtreecommitdiff
path: root/bin/kiss-stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/kiss-stat.c')
-rw-r--r--bin/kiss-stat.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/bin/kiss-stat.c b/bin/kiss-stat.c
index ebb6f52..4380503 100644
--- a/bin/kiss-stat.c
+++ b/bin/kiss-stat.c
@@ -14,27 +14,28 @@
struct passwd *pw;
struct stat sb;
-int main (int argc, char *argv[]) {
+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 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 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;
+ }
- /* 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);
-}
+ /* Print the user name of file owner. */
+ pw = getpwuid(sb.st_uid);
+ printf("%s\n", pw->pw_name);
+ return 0;
+}