Either works:
$ fort --mode=print < cert.cer
$ fort --mode=print - < cert.cer
Progress for #122.
validate_config(void)
{
if (rpki_config.mode == PRINT_FILE)
- return (rpki_config.payload == NULL)
- ? pr_op_err("Missing file name.")
- : 0;
+ return 0;
if (rpki_config.payload != NULL)
return pr_op_err("I don't know what '%s' is.",
json_t *json = NULL;
int error = 0;
- file = fopen(filename, "rb");
- if (file == NULL)
- return pr_op_err("Cannot open file: %s", strerror(errno));
+ if (filename == NULL || strcmp(filename, "-") == 0) {
+ file = stdin;
+ } else {
+ file = fopen(filename, "rb");
+ if (file == NULL)
+ return pr_op_err("Cannot open file: %s", strerror(errno));
+ }
switch (guess_file_type(file)) {
case FT_UNK:
break;
}
- fclose(file);
+ if (file != stdin)
+ fclose(file);
if (error)
return error;
if (json == NULL)