Annotation of src/usr.bin/dirname/dirname.c, Revision 1.7
1.7 ! millert 1: /* $OpenBSD: dirname.c,v 1.6 2001/12/02 01:04:12 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.7 ! millert 20: static char rcsid[] = "$OpenBSD: dirname.c,v 1.6 2001/12/02 01:04:12 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
29: main(argc, argv)
30: int argc;
31: char **argv;
32: {
1.3 millert 33: char *dir;
34: extern char *__progname;
1.1 deraadt 35:
36: setlocale(LC_ALL, "");
37:
1.3 millert 38: if (argc != 2) {
1.6 millert 39: (void)fprintf(stderr, "Usage: %s pathname\n", __progname);
1.3 millert 40: exit(1);
1.1 deraadt 41: }
42:
1.3 millert 43: if ((dir = dirname(argv[1])) == NULL)
44: err(1, NULL);
45: puts(dir);
1.1 deraadt 46: exit(0);
47: }