blob: b4ff098395910472f7bdd318d81a7bda5182eeac (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/* SPDX-License-Identifier: BSD-3-Clause */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#include <errno.h>
#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */
#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */
#define DESCRIPTION "Return directory portion of <string>."
#define OPERANDS "string"
#include "../common/common.h"
int main(int argc, char *argv[]) {
char *dirnamestr;
if (argc != 2) {
print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION);
return 1;
}
dirnamestr = dirname(argv[1]);
printf("%s\n", dirnamestr);
return errprint(argv[0], NULL, errno);
}
|