char *wordfile;
/* read in the words */
- wordfile = grab_file(NULL, "test/api-lazytrie-words.txt");
+ wordfile = grab_file_str(NULL, "test/api-lazytrie-words.txt");
ok1(wordfile);
wordarray = tal_strsplit(NULL, take(wordfile), "\n", STR_NO_EMPTY);
ok1(wordarray);
* fprintf(stderr, "Usage: %s source_file\n", argv[0]);
* return 1;
* }
- * file = grab_file(NULL, argv[1]);
+ * file = grab_file_str(NULL, argv[1]);
* if (!file)
* err(1, "Could not read file %s", argv[1]);
*
* size_t j;
*
* // Read code from stdin.
- * code = grab_file(NULL, NULL);
+ * code = grab_file_str(NULL, NULL);
*
* defs = cdump_extract(NULL, code, &problems);
* if (!defs)
if (argc < 2)
errx(1, "Usage: cdump-enumstr <filename> [<enums>...]");
- code = grab_file(NULL, streq(argv[1], "-") ? NULL : argv[1]);
+ code = grab_file_str(NULL, streq(argv[1], "-") ? NULL : argv[1]);
if (!code)
err(1, "Reading %s", argv[1]);
* {
* char *input;
*
- * input = grab_file(NULL, NULL);
+ * input = grab_file_str(NULL, NULL);
* if (!input)
* err(1, "Error reading input");
* if (!utf8_validate(input, tal_count(input)-1)) {
if (argc < 2 || (runs = atol(argv[1])) == 0)
errx(1, "Usage: bench <num-runs> [<file>]");
- p = grab_file(NULL, argv[2]);
+ p = grab_file_str(NULL, argv[2]);
if (!p)
err(1, "Reading %s", argv[2] ? argv[2] : "<stdin>");
len = tal_count(p) - 1;
* errx(1, "Usage: %s <blocksize> <file> <crc>...\n"
* "OR: %s <blocksize> <file>", argv[0], argv[0]);
*
- * file = grab_file(NULL, argv[2]);
+ * file = grab_file_str(NULL, argv[2]);
* if (!file)
* err(1, "Opening file %s", argv[2]);
* len = tal_count(file) - 1;
char **w;
ENTRY *words, *misswords;
- w = tal_strsplit(NULL, grab_file(NULL,
+ w = tal_strsplit(NULL, grab_file_str(NULL,
argv[1] ? argv[1] : "/usr/share/dict/words"), "\n", STR_NO_EMPTY);
num = tal_count(w) - 1;
printf("%zu words\n", num);
struct htable_str ht;
char **words, **misswords;
- words = tal_strsplit(NULL, grab_file(NULL,
+ words = tal_strsplit(NULL, grab_file_str(NULL,
argv[1] ? argv[1] : "/usr/share/dict/words"), "\n",
STR_NO_EMPTY);
htable_str_init(&ht);
struct rfc822_msg *msg;
struct rfc822_header *hdr;
- buf = grab_file(ctx, name, &size);
+ buf = grab_file_str(ctx, name, &size);
msg = rfc822_start(ctx, buf, size);
mr = rune_new(NULL, secret_zero, sizeof(secret_zero), NULL);
/* Python runes library generates test vectors */
- vecs = grab_file(mr, "test/test_vectors.csv");
+ vecs = grab_file_str(mr, "test/test_vectors.csv");
assert(vecs);
lines = tal_strsplit(mr, take(vecs), "\n", STR_NO_EMPTY);
* char *file, *word;
*
* strset_init(&words);
- * file = grab_fd(NULL, 0);
+ * file = grab_fd_str(NULL, 0);
* if (!file)
* err(1, "Reading stdin");
*
critbit0_tree ct;
char **words, **misswords;
- words = tal_strsplit(NULL, grab_file(NULL,
+ words = tal_strsplit(NULL, grab_file_str(NULL,
argv[1] ? argv[1] : "/usr/share/dict/words"), "\n", STR_NO_EMPTY);
ct.root = NULL;
num = tal_count(words) - 1;
struct strset set;
char **words, **misswords;
- words = tal_strsplit(NULL, grab_file(NULL,
+ words = tal_strsplit(NULL, grab_file_str(NULL,
argv[1] ? argv[1] : "/usr/share/dict/words"),
"\n", STR_NO_EMPTY);
strset_init(&set);
*
* if (argc > 2)
* err(1, "Takes 0 or 1 arguments");
- * file = grab_file(NULL, argv[1]);
+ * file = grab_file_str(NULL, argv[1]);
* if (!file)
* err(1, "Could not read file %s", argv[1]);
* if (strlen(file)+1 != tal_count(file))
* if (argc > 2)
* errx(1, "Takes 0 or 1 arguments");
* // Grab lines in file.
- * textfile = grab_file(NULL, argv[1]);
+ * textfile = grab_file_str(NULL, argv[1]);
* if (!textfile)
* err(1, "Failed reading %s", argv[1]);
* lines = tal_strsplit(textfile, textfile, "\n", STR_EMPTY_OK);
*
* int main(int argc, char *argv[])
* {
- * const char *graph = grab_file(NULL, argv[1], NULL), *errmsg;
+ * const char *graph = grab_file_str(NULL, argv[1], NULL), *errmsg;
* printf("digraph %s {\n", argv[1] ? argv[1] : "stdin");
* errmsg = ungraph(NULL, graph, add_node, add_edge, NULL);
* if (errmsg)
}
/* Copy it to a file with proper .c suffix. */
- info = grab_file(score, m->info_file->fullname);
+ info = grab_file_str(score, m->info_file->fullname);
if (!info) {
score_file_error(score, m->info_file, 0,
"could not be read: %s", strerror(errno));
err(1, "Writing to _info.new to insert documentation");
}
- oldcontents = grab_file(m, m->info_file->fullname);
+ oldcontents = grab_file_str(m, m->info_file->fullname);
if (!oldcontents) {
unlink_noerr("_info.new");
err(1, "Reading %s", m->info_file->fullname);
apostrophe = strchr(filename, '\'');
*apostrophe = '\0';
if (lines_matter) {
- file = grab_file(score, filename);
+ file = grab_file_str(score, filename);
if (!file) {
score->error = tal_fmt(score,
"Reading %s",
continue;
}
- output = grab_file(i, i->valgrind_log);
+ output = grab_file_str(i, i->valgrind_log);
/* No valgrind errors? */
if (!output || output[0] == '\0') {
err = NULL;
int fd;
/* Copy it to a file with proper .c suffix. */
- info = grab_file(ctx, tal_fmt(ctx, "%s/_info", dir));
+ info = grab_file_str(ctx, tal_fmt(ctx, "%s/_info", dir));
if (!info)
return NULL;
bool correct_style = false;
fname = path_join(ctx, dir, "_info");
- raw = grab_file(fname, fname);
+ raw = grab_file_str(fname, fname);
if (!raw)
errx(1, "Could not open %s", fname);
struct list_head *list;
struct doc_section *d;
- file = grab_file(NULL, argv[i]);
+ file = grab_file_str(NULL, argv[i]);
if (!file)
err(1, "Reading file %s", argv[i]);
lines = tal_strsplit(file, file, "\n", STR_EMPTY_OK);
const char *get_ccan_file_contents(struct ccan_file *f)
{
if (!f->contents) {
- f->contents = grab_file(f, f->fullname);
+ f->contents = grab_file_str(f, f->fullname);
if (!f->contents)
err(1, "Reading file %s", f->fullname);
- f->contents_size = tal_count(f->contents) - 1;
+ f->contents_size = tal_count(f->contents);
}
return f->contents;
}
hdr = tal_fmt(dir, "%s.h",
path_join(NULL, dir, take(path_basename(NULL, dir))));
- contents = grab_file(dir, hdr);
+ contents = grab_file_str(dir, hdr);
if (!contents)
err(1, "Reading %s", hdr);
int fd;
verbose("Rewriting %s\n", filename);
- file = grab_file(filename, filename);
+ file = grab_file_str(filename, filename);
if (!file)
err(1, "Reading file %s", filename);
char *replname = path_join(depdir, depdir, ".namespacize");
char *file, **line;
- file = grab_file(replname, replname);
+ file = grab_file_str(replname, replname);
if (!file) {
if (errno != ENOENT)
err(1, "Opening %s", replname);
unsigned int i;
char *config_header;
- config_header = grab_file(NULL, fname);
+ config_header = grab_file_str(NULL, fname);
if (!config_header) {
tal_free(fname);
}
/* Try copy and delete: not atomic! */
- contents = grab_file(NULL, oldname);
+ contents = grab_file_str(NULL, oldname);
if (!contents) {
if (tools_verbose)
printf("read failed: %s\n", strerror(errno));