blob: 094ac811d0a49e7110b9b07518875768a67f5663 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/*
* FILE: basename.c
* PURPOSE: a reimplementation of BSD's basename so that it can also be
* used as a function in other programs (see filenames.c and
* filenames.h)
* AUTHOR: Piet Tutelaers
* VERSION: 1.0 (Sept. 1995)
*/
#include <stdlib.h> /* exit() */
#include <stdio.h> /* printf() */
#include "basics.h" /* fatal() */
#include "filenames.h" /* basename() */
int main(int argc, char **argv)
{
if (argc < 2 || argc > 3)
fatal("Usage: basename string [suffix]\n");
if (argc == 2)
printf("%s\n", basename(argv[1], NULL));
else
printf("%s\n", basename(argv[1], argv[2]));
exit(0);
}
|