btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / bin / logname.c
blob3c7de112b72abdb702e43db4f64d329a93208e18
1 /*
2 * OBOS Command line apps
3 * logname.c
4 * Larry Cow <larrycow@free.fr>
5 */
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <string.h>
11 #define DEFAULT_USER "baron"
13 #define HELP_TIP "Try '%s --help' for more information.\n"
15 #define HELP_MESSAGE "Usage: /bin/logname [OPTION]...
16 Print the name of the current
18 --help\t display this help and exit
19 --version\t output version information and exit
21 Reports bugs to <larrycow@free.fr>."
23 #define VERSION_MESSAGE "logname (OBOS) 1.0
24 Written by Larry Cow
26 Coded by Larry Cow 2002
27 Released under the MIT license with OpenBeOS."
29 void dispatch_args(char* av0, char* av1)
31 if (!strcmp(av1, "--help"))
33 puts(HELP_MESSAGE);
34 return;
36 if (!strcmp(av1, "--version"))
38 puts(VERSION_MESSAGE);
39 return;
41 printf(HELP_TIP, av0);
44 int main(int argc, char* argv[])
46 if (argc > 1)
47 dispatch_args(argv[0], argv[1]);
48 else
50 char* user = getenv("USER");
51 if (user == NULL)
52 puts(DEFAULT_USER);
53 else
54 puts(user);
56 return 0;