]> git.ipfire.org Git - thirdparty/git.git/blame - t/helper/test-crontab.c
Merge branch 'rs/bisect-start-leakfix' into maint-2.38
[thirdparty/git.git] / t / helper / test-crontab.c
CommitLineData
2fec604f
DS
1#include "test-tool.h"
2#include "cache.h"
3
4/*
0682bc43 5 * Usage: test-tool crontab <file> -l|<input>
2fec604f
DS
6 *
7 * If -l is specified, then write the contents of <file> to stdout.
0682bc43 8 * Otherwise, copy the contents of <input> into <file>.
2fec604f
DS
9 */
10int cmd__crontab(int argc, const char **argv)
11{
12 int a;
13 FILE *from, *to;
14
0682bc43
JK
15 if (argc != 3)
16 usage("test-tool crontab <file> -l|<input>");
17
18 if (!strcmp(argv[2], "-l")) {
2fec604f
DS
19 from = fopen(argv[1], "r");
20 if (!from)
21 return 0;
22 to = stdout;
0682bc43
JK
23 } else {
24 from = xfopen(argv[2], "r");
25 to = xfopen(argv[1], "w");
26 }
2fec604f
DS
27
28 while ((a = fgetc(from)) != EOF)
29 fputc(a, to);
30
0682bc43
JK
31 fclose(from);
32 if (to != stdout)
2fec604f
DS
33 fclose(to);
34
35 return 0;
36}