1 #include <mailutils/mailutils.h>
2
3 int owner_option;
4 int mode_option;
5 int force_option;
6 int deref_option;
7
8 static struct mu_option copy_options[] = {
9 { "owner", 'u', NULL, MU_OPTION_DEFAULT,
10 "copy ownership",
11 mu_c_bool, &owner_option },
12 { "mode", 'm', NULL, MU_OPTION_DEFAULT,
13 "copy mode",
14 mu_c_bool, &mode_option },
15 { "force", 'f', NULL, MU_OPTION_DEFAULT,
16 "force overwriting the destination file if it exists",
17 mu_c_bool, &force_option },
18 { "overwrite", 0, NULL, MU_OPTION_ALIAS },
19 { "dereference", 'h', NULL, MU_OPTION_DEFAULT,
20 "dereference symbolic links",
21 mu_c_bool, &deref_option },
22 MU_OPTION_END
23 }, *options[] = { copy_options, NULL };
24
25 struct mu_cli_setup cli = {
26 options,
27 NULL,
28 "copy file",
29 "SRC DST"
30 };
31
32 static char *capa[] = {
33 "debug",
34 NULL
35 };
36
37 int
main(int argc,char ** argv)38 main (int argc, char **argv)
39 {
40 int rc;
41 int flags;
42
43 mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
44
45 if (argc != 2)
46 {
47 mu_error ("wrong number of arguments");
48 return 1;
49 }
50
51 flags = (owner_option ? MU_COPY_OWNER : 0)
52 | (mode_option ? MU_COPY_MODE : 0)
53 | (force_option ? MU_COPY_OVERWRITE : 0)
54 | (deref_option ? MU_COPY_DEREF : 0);
55 rc = mu_copy_file (argv[0], argv[1], flags);
56
57 if (rc)
58 mu_diag_funcall (MU_DIAG_ERROR, "mu_copy_file", NULL, rc);
59
60 return !!rc;
61 }
62
63
64