Skip to content

Commit a69b75c

Browse files
wcawijngaardsk0ekk0ek
authored andcommitted
Read zone from stdin.
1 parent 9aa57dc commit a69b75c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/zone.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,19 @@ static int32_t open_file(
289289
const char *includer = "";
290290
if (file != &parser->first)
291291
includer = parser->file->path;
292-
if ((code = resolve_path(includer, file->name, &file->path)))
292+
if(strcmp(file->name, "-") == 0) {
293+
if(!(file->path = strdup(file->name)))
294+
return ZONE_OUT_OF_MEMORY;
295+
} else if ((code = resolve_path(includer, file->name, &file->path)))
293296
return (void)close_file(parser, file), code;
294297

295-
if ((file->handle = fopen(file->path, "rb")))
298+
if(strcmp(file->path, "-") == 0) {
299+
file->handle = stdin;
296300
return 0;
301+
} else {
302+
if ((file->handle = fopen(file->path, "rb")))
303+
return 0;
304+
}
297305

298306
switch (errno) {
299307
case ENOMEM:

0 commit comments

Comments
 (0)