QDNix
Quick’n’dirty *NIX
mtree.c
1
#include <stdlib.h>
2
#include <stdio.h>
3
#include <string.h>
4
5
typedef
enum
{
6
T_BLOCK,
7
T_CHAR,
8
T_DIR,
9
T_FIFO,
10
T_FILE,
11
T_LINK,
12
T_SOCKET
13
} Type;
14
15
static
const
char
*prg_name;
16
17
/* cmd args */
18
static
int
opt_dir_only = 0;
/* ignore all except dir */
19
static
int
opt_ignore_missmatch = 0;
20
static
const
char
*opt_path = NULL;
21
static
const
FILE *opt_file;;
22
23
/* config */
24
static
char
*set_uname;
25
static
char
*set_gname;
26
static
int
set_mode;
27
static
Type set_type = T_FILE;
28
static
int
set_optional = 0;
29
30
static
void
31
version(
void
)
32
{
33
printf(
"%s v%v\n"
, prg_name, MTREE_VERSION);
34
printf(
"Copyright (C) 2023 d0p1\n"
);
35
printf(
"License BSD-3: <https://directory.fsf.org/wiki/License:BSD-3-Clause>\n"
);
36
printf(
"This is free software: you are free to change and redistribute it.\n"
);
37
printf(
"There is NO WARRANTY, to the extent permitted by law.\n"
);
38
exit(EXIT_SUCCESS);
39
}
40
41
static
void
42
usage(
int
retval)
43
{
44
printf(
"Usage: %s [OPTION]..\n\n"
, prg_name);
45
printf(
"\tOptions:\n"
);
46
printf(
"\t-d,\t\tignore everything except directory type files.\n"
);
47
printf(
"\t-f [file]\tread the specification from file instead of stdin\n"
);
48
printf(
"\t-p [path]\tuse path as root directory instead of current.\n"
);
49
printf(
"\t-h,--help\tdisplay this menu and exit\n"
);
50
printf(
"\t-V,--version\toutput version information and exit\n"
);
51
exit(retval);
52
}
53
54
int
55
main(
int
argc,
char
**argv)
56
{
57
opt_file = stdin;
58
prg_name = *argv++;
59
argc--;
60
61
62
return
(EXIT_SUCCESS);
63
}
sbin
mtree
mtree.c
Generated by
1.9.1