blob: 2508a2eeabaa185c8b4eb5b9ad7a2eb31cd699e6 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "config.h"
#include <stdio.h>
#include <string.h>
/**
* grab_file - file helper routines
*
* This contains simple functions for getting the contents of a file.
*
* Example:
* #include <err.h>
* #include <stdio.h>
* #include <string.h>
* #include <ccan/grab_file/grab_file.h>
* #include <ccan/talloc/talloc.h> // For talloc_free()
*
* int main(int argc, char *argv[])
* {
* size_t len;
* char *file;
*
* file = grab_file(NULL, argv[1], &len);
* if (!file)
* err(1, "Could not read file %s", argv[1]);
* if (strlen(file) != len)
* printf("File contains NUL characters\n");
* else if (len == 0)
* printf("File contains nothing\n");
* else if (strchr(file, '\n'))
* printf("File contains multiple lines\n");
* else
* printf("File contains one line\n");
* talloc_free(file);
*
* return 0;
* }
*
* License: LGPL (v2.1 or any later version)
* Author: Rusty Russell <rusty@rustcorp.com.au>
*/
int main(int argc, char *argv[])
{
if (argc != 2)
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("ccan/talloc\n");
printf("ccan/noerr\n");
return 0;
}
return 1;
}
|