[BACK]Return to dirname.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / dirname

Annotation of src/usr.bin/dirname/dirname.c, Revision 1.10

1.10    ! david       1: /*     $OpenBSD: dirname.c,v 1.9 2003/06/17 21:56:25 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.9       millert    10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1       deraadt    17:  */
                     18:
                     19: #ifndef lint
1.10    ! david      20: static char rcsid[] = "$OpenBSD: dirname.c,v 1.9 2003/06/17 21:56:25 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>
1.10    ! david      27: #include <stdlib.h>
1.1       deraadt    28:
                     29: int
1.8       deraadt    30: main(int argc, char *argv[])
1.1       deraadt    31: {
1.3       millert    32:        char *dir;
                     33:        extern char *__progname;
1.1       deraadt    34:
                     35:        setlocale(LC_ALL, "");
                     36:
1.3       millert    37:        if (argc != 2) {
1.6       millert    38:                (void)fprintf(stderr, "Usage: %s pathname\n", __progname);
1.3       millert    39:                exit(1);
1.1       deraadt    40:        }
                     41:
1.3       millert    42:        if ((dir = dirname(argv[1])) == NULL)
                     43:                err(1, NULL);
                     44:        puts(dir);
1.1       deraadt    45:        exit(0);
                     46: }