Annotation of src/usr.bin/dirname/dirname.c, Revision 1.8
1.8 ! deraadt 1: /* $OpenBSD: dirname.c,v 1.7 2003/06/03 01:52:41 millert Exp $ */
1.1 deraadt 2:
1.3 millert 3: /*
4: * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
1.1 deraadt 5: *
1.7 millert 6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
1.1 deraadt 9: *
1.7 millert 10: * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
11: * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
12: * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
13: * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15: * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16: * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 deraadt 17: */
18:
19: #ifndef lint
1.8 ! deraadt 20: static char rcsid[] = "$OpenBSD: dirname.c,v 1.7 2003/06/03 01:52:41 millert Exp $";
1.3 millert 21: #endif /* not lint */
1.1 deraadt 22:
1.5 pjanzen 23: #include <err.h>
1.3 millert 24: #include <libgen.h>
25: #include <locale.h>
1.1 deraadt 26: #include <stdio.h>
27:
28: int
1.8 ! deraadt 29: main(int argc, char *argv[])
1.1 deraadt 30: {
1.3 millert 31: char *dir;
32: extern char *__progname;
1.1 deraadt 33:
34: setlocale(LC_ALL, "");
35:
1.3 millert 36: if (argc != 2) {
1.6 millert 37: (void)fprintf(stderr, "Usage: %s pathname\n", __progname);
1.3 millert 38: exit(1);
1.1 deraadt 39: }
40:
1.3 millert 41: if ((dir = dirname(argv[1])) == NULL)
42: err(1, NULL);
43: puts(dir);
1.1 deraadt 44: exit(0);
45: }