2 * Copyright (C) 2006,2007 Gabor Juhos
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
15 #include <unistd.h> /* for unlink() */
17 #include <getopt.h> /* for getopt() */
21 #include <endian.h> /* for __BYTE_ORDER */
23 #if defined(__CYGWIN__)
24 # include <byteswap.h>
27 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
28 # define HOST_TO_LE16(x) (x)
29 # define HOST_TO_LE32(x) (x)
31 # define HOST_TO_LE16(x) bswap_16(x)
32 # define HOST_TO_LE32(x) bswap_32(x)
37 #define MAX_FW_BLOCKS 32
38 #define MAX_ARG_COUNT 32
39 #define MAX_ARG_LEN 1024
40 #define FILE_BUF_LEN (16*1024)
44 uint32_t blocklen; /* length of the block */
47 char *name; /* name of the file */
48 uint32_t size; /* length of the file */
49 uint32_t crc; /* crc value of the file */
52 #define BLOCK_FLAG_HAVEHDR 0x0001
55 char *model; /* model number*/
56 char *name; /* model name*/
57 char *desc; /* description */
58 uint16_t vid; /* vendor id */
59 uint16_t did; /* device id */
60 uint16_t svid; /* sub vendor id */
61 uint16_t sdid; /* sub device id */
62 uint32_t flash_size; /* size of flash */
65 #define BOARD(_vid, _did, _svid, _sdid, _flash, _mod, _name, _desc) { \
66 .model = _mod, .name = _name, .desc = _desc, \
67 .vid = _vid, .did = _did, .svid = _svid, .sdid = _sdid, \
68 .flash_size = (_flash << 20) }
70 #define CPX_BOARD(_did, _flash, _mod, _name, _desc) \
71 BOARD(VENID_COMPEX, _did, VENID_COMPEX, _did, _flash, _mod, _name, _desc)
76 uint32_t flash_size = 0;
77 int fw_num_partitions = 0;
78 int fw_num_blocks = 0;
81 struct mylo_fw_header fw_header;
82 struct mylo_partition fw_partitions[MYLO_MAX_PARTITIONS];
83 struct fw_block fw_blocks[MAX_FW_BLOCKS];
85 struct cpx_board boards[] = {
86 CPX_BOARD(DEVID_COMPEX_NP18A, 4,
87 "NP18A", "Compex NetPassage 18A",
88 "Dualband Wireless A+G Internet Gateway"),
89 CPX_BOARD(DEVID_COMPEX_NP26G8M, 2,
90 "NP26G8M", "Compex NetPassage 26G (8M)",
91 "Wireless-G Broadband Multimedia Gateway"),
92 CPX_BOARD(DEVID_COMPEX_NP26G16M, 4,
93 "NP26G16M", "Compex NetPassage 26G (16M)",
94 "Wireless-G Broadband Multimedia Gateway"),
95 CPX_BOARD(DEVID_COMPEX_NP27G, 4,
96 "NP27G", "Compex NetPassage 27G",
97 "Wireless-G 54Mbps eXtended Range Router"),
98 CPX_BOARD(DEVID_COMPEX_NP28G, 4,
99 "NP28G", "Compex NetPassage 28G",
100 "Wireless 108Mbps Super-G XR Multimedia Router with 4 USB Ports"),
101 CPX_BOARD(DEVID_COMPEX_NP28GHS, 4,
102 "NP28GHS", "Compex NetPassage 28G (HotSpot)",
104 CPX_BOARD(DEVID_COMPEX_WP18, 4,
105 "WP18", "Compex NetPassage WP18",
106 "Wireless-G 54Mbps A+G Dualband Access Point"),
107 CPX_BOARD(DEVID_COMPEX_WP54G, 4,
108 "WP54G", "Compex WP54G",
109 "Wireless-G 54Mbps XR Access Point"),
110 CPX_BOARD(DEVID_COMPEX_WP54Gv1C, 2,
111 "WP54Gv1C", "Compex WP54G rev.1C",
112 "Wireless-G 54Mbps XR Access Point"),
113 CPX_BOARD(DEVID_COMPEX_WP54AG, 4,
114 "WP54AG", "Compex WP54AG",
115 "Wireless-AG 54Mbps XR Access Point"),
116 CPX_BOARD(DEVID_COMPEX_WPP54G, 4,
117 "WPP54G", "Compex WPP54G",
118 "Outdoor Access Point"),
119 CPX_BOARD(DEVID_COMPEX_WPP54AG, 4,
120 "WPP54AG", "Compex WPP54AG",
121 "Outdoor Access Point"),
126 errmsgv(int syserr, const char *fmt, va_list arg_ptr)
131 fprintf(stderr, "[%s] Error: ", progname);
132 vfprintf(stderr, fmt, arg_ptr);
134 fprintf(stderr, ": %s", strerror(save));
136 fprintf(stderr, "\n");
140 errmsg(int syserr, const char *fmt, ...)
143 va_start(arg_ptr, fmt);
144 errmsgv(syserr, fmt, arg_ptr);
149 dbgmsg(int level, const char *fmt, ...)
152 if (verblevel >= level) {
154 va_start(arg_ptr, fmt);
155 vfprintf(stderr, fmt, arg_ptr);
156 fprintf(stderr, "\n");
165 FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
166 struct cpx_board *board;
168 fprintf(stream, "Usage: %s [OPTION...] <file>\n", progname);
171 " <file> write output to the <file>\n"
174 " -B <board> create firmware for the board specified with <board>.\n"
175 " This option set vendor id, device id, subvendor id,\n"
176 " subdevice id, and flash size options to the right value.\n"
177 " valid <board> values:\n");
178 for (board = boards; board->model != NULL; board++){
181 board->model, board->name);
184 " -i <vid>:<did>[:<svid>[:<sdid>]]\n"
185 " create firmware for board with vendor id <vid>, device\n"
186 " id <did>, subvendor id <svid> and subdevice id <sdid>.\n"
187 " -r <rev> set board revision to <rev>.\n"
188 " -s <size> set flash size to <size>\n"
189 " -b <addr>:<len>[:[<flags>]:<file>]\n"
190 " define block at <addr> with length of <len>.\n"
191 " valid <flag> values:\n"
192 " h : add crc header before the file data.\n"
193 " -p <addr>:<len>[:<flags>[:<param>[:<file>]]]\n"
194 " add partition at <addr>, with size of <len> to the\n"
195 " partition table, set partition flags to <flags> and\n"
196 " partition parameter to <param>. If the <file> is specified\n"
197 " content of the file is also added to the firmware image.\n"
198 " valid <flag> values:\n"
199 " a: this is the active partition. The bootloader loads\n"
200 " the firmware from this partition.\n"
201 " h: the partition data have a header.\n"
202 " p: the bootloader loads data from this partition to\n"
203 " the RAM before decompress it.\n"
204 " -h show this screen\n"
211 * Code to compute the CRC-32 table. Borrowed from
212 * gzip-1.0.3/makecrc.c.
215 static uint32_t crc_32_tab[256];
220 /* Not copyrighted 1990 Mark Adler */
222 uint32_t c; /* crc shift register */
223 uint32_t e; /* polynomial exclusive-or pattern */
224 int i; /* counter for all possible eight bit values */
225 int k; /* byte being shifted into crc apparatus */
227 /* terms of polynomial defining this crc (except x^32): */
228 static const int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
230 /* Make exclusive-or pattern from polynomial */
232 for (i = 0; i < sizeof(p)/sizeof(int); i++)
233 e |= 1L << (31 - p[i]);
237 for (i = 1; i < 256; i++) {
239 for (k = i | 256; k != 1; k >>= 1) {
240 c = c & 1 ? (c >> 1) ^ e : c >> 1;
250 update_crc(uint8_t *p, uint32_t len, uint32_t *crc)
254 t = *crc ^ 0xFFFFFFFFUL;
256 t = crc_32_tab[(t ^ *p++) & 0xff] ^ (t >> 8);
258 *crc = t ^ 0xFFFFFFFFUL;
263 get_crc(uint8_t *p, uint32_t len)
268 update_crc(p ,len , &crc);
274 str2u32(char *arg, uint32_t *val)
280 t = strtoul(arg, &err, 0);
281 if (errno || (err==arg) || ((err != NULL) && *err)) {
291 str2u16(char *arg, uint16_t *val)
297 t = strtoul(arg, &err, 0);
298 if (errno || (err==arg) || ((err != NULL) && *err) || (t >= 0x10000)) {
308 find_board(char *model){
309 struct cpx_board *board;
310 struct cpx_board *tmp;
313 for (tmp = boards; tmp->model != NULL; tmp++){
314 if (strcmp(model, tmp->model) == 0) {
325 get_file_crc(struct fw_block *ff)
328 uint8_t buf[FILE_BUF_LEN];
329 uint32_t readlen = sizeof(buf);
333 if ((ff->flags & BLOCK_FLAG_HAVEHDR) == 0) {
339 f = fopen(ff->name,"r");
341 errmsg(1,"unable to open file %s", ff->name);
352 fread(buf, readlen, 1, f);
354 errmsg(1,"unable to read from file %s", ff->name);
358 update_crc(buf, readlen, &ff->crc);
378 for (i = 0; i < fw_num_blocks; i++) {
380 if ((b->addr + b->blocklen) > flash_size) {
381 errmsg(0, "block at 0x%08X is too big", b->addr);
387 if (stat(b->name, &st) < 0) {
388 errmsg(0, "stat failed on %s",b->name);
391 if (b->blocklen == 0) {
392 b->blocklen = flash_size - b->addr;
394 if (st.st_size > b->blocklen) {
395 errmsg(0,"file %s is too big",b->name);
399 b->size = st.st_size;
407 process_partitions(void)
409 struct mylo_partition *part;
412 for (i = 0; i < fw_num_partitions; i++) {
413 part = &fw_partitions[i];
415 if (part->addr > flash_size) {
416 errmsg(0, "invalid partition at 0x%08X", part->addr);
420 if ((part->addr + part->size) > flash_size) {
421 errmsg(0, "partition at 0x%08X is too big", part->addr);
431 * routines to write data to the output file
434 write_out_data(FILE *outfile, uint8_t *data, size_t len, uint32_t *crc)
438 fwrite(data, len, 1, outfile);
440 errmsg(1,"unable to write output file");
445 update_crc(data, len, crc);
453 write_out_desc(FILE *outfile, struct mylo_fw_blockdesc *desc, uint32_t *crc)
455 return write_out_data(outfile, (uint8_t *)desc,
461 write_out_file(FILE *outfile, struct fw_block *block, uint32_t *crc)
463 char buff[FILE_BUF_LEN];
464 size_t buflen = sizeof(buff);
470 if (block->name == NULL) {
474 if ((block->flags & BLOCK_FLAG_HAVEHDR) != 0) {
475 struct mylo_partition_header ph;
477 if (get_file_crc(block) != 0)
480 ph.crc = HOST_TO_LE32(block->crc);
481 ph.len = HOST_TO_LE32(block->size);
483 if (write_out_data(outfile, (uint8_t *)&ph, sizeof(ph), crc) != 0)
487 f = fopen(block->name,"r");
489 errmsg(1,"unable to open file: %s", block->name);
498 // read data from source file
500 fread(buff, buflen, 1, f);
502 errmsg(1,"unable to read from file: %s",block->name);
506 if (write_out_data(outfile, buff, buflen, crc) != 0)
514 dbgmsg(1,"file %s written out", block->name);
520 write_out_header(FILE *outfile, uint32_t *crc)
522 struct mylo_fw_header hdr;
524 memset(&hdr, 0, sizeof(hdr));
526 hdr.magic = HOST_TO_LE32(MYLO_MAGIC_FIRMWARE);
527 hdr.crc = HOST_TO_LE32(fw_header.crc);
528 hdr.vid = HOST_TO_LE16(fw_header.vid);
529 hdr.did = HOST_TO_LE16(fw_header.did);
530 hdr.svid = HOST_TO_LE16(fw_header.svid);
531 hdr.sdid = HOST_TO_LE16(fw_header.sdid);
532 hdr.rev = HOST_TO_LE32(fw_header.rev);
533 hdr.fwhi = HOST_TO_LE32(fw_header.fwhi);
534 hdr.fwlo = HOST_TO_LE32(fw_header.fwlo);
535 hdr.flags = HOST_TO_LE32(fw_header.flags);
537 if (fseek(outfile, 0, SEEK_SET) != 0) {
538 errmsg(1,"fseek failed on output file");
542 return write_out_data(outfile, (uint8_t *)&hdr, sizeof(hdr), crc);
547 write_out_partitions(FILE *outfile, uint32_t *crc)
549 struct mylo_partition_table p;
550 struct mylo_partition *p1, *p2;
553 if (fw_num_partitions == 0)
556 memset(&p, 0, sizeof(p));
558 p.magic = HOST_TO_LE32(MYLO_MAGIC_PARTITIONS);
559 for (i = 0; i < fw_num_partitions; i++) {
560 p1 = &p.partitions[i];
561 p2 = &fw_partitions[i];
562 p1->flags = HOST_TO_LE16(p2->flags);
563 p1->type = HOST_TO_LE16(PARTITION_TYPE_USED);
564 p1->addr = HOST_TO_LE32(p2->addr);
565 p1->size = HOST_TO_LE32(p2->size);
566 p1->param = HOST_TO_LE32(p2->param);
569 return write_out_data(outfile, (uint8_t *)&p, sizeof(p), crc);
574 write_out_blocks(FILE *outfile, uint32_t *crc)
576 struct mylo_fw_blockdesc desc;
581 * if at least one partition specified, write out block descriptor
582 * for the partition table
584 if (fw_num_partitions > 0) {
586 desc.type = HOST_TO_LE32(FW_DESC_TYPE_USED);
587 desc.addr = HOST_TO_LE32(0x10000);
588 desc.dlen = HOST_TO_LE32(sizeof(struct mylo_partition_table));
589 desc.blen = HOST_TO_LE32(0x10000);
591 if (write_out_desc(outfile, &desc, crc) != 0)
596 * write out block descriptors for each files
598 for (i = 0; i < fw_num_blocks; i++) {
600 desc.type = HOST_TO_LE32(FW_DESC_TYPE_USED);
601 desc.addr = HOST_TO_LE32(b->addr);
602 desc.blen = HOST_TO_LE32(b->blocklen);
603 if ((b->flags & BLOCK_FLAG_HAVEHDR) != 0) {
604 desc.dlen = HOST_TO_LE32(b->size +
605 sizeof(struct mylo_partition_header));
607 desc.dlen = HOST_TO_LE32(b->size);
609 if (write_out_desc(outfile, &desc, crc) != 0)
614 * write out the null block descriptor
616 memset(&desc, 0, sizeof(desc));
617 if (write_out_desc(outfile, &desc, crc) != 0)
620 if (write_out_partitions(outfile, crc) != 0)
624 * write out data for each blocks
626 for (i = 0; i < fw_num_blocks; i++) {
628 if (write_out_file(outfile, b, crc) != 0)
640 parse_arg(char *arg, char *buf, char *argv[])
649 /* invalid argument string */
659 if (argl >= MAX_ARG_LEN) {
660 /* argument is too long */
661 argl = MAX_ARG_LEN-1;
664 memset(argv, 0, MAX_ARG_COUNT * sizeof(void *));
665 memcpy(buf, arg, argl);
668 for (i = 0; i < MAX_ARG_COUNT; i++) {
669 tok = strsep(ap, ":");
674 else if (tok[0] == '\0') {
687 required_arg(char c, char *arg)
689 if ((optarg != NULL) && (*arg == '-')){
690 errmsg(0,"option %c requires an argument\n", c);
699 is_empty_arg(char *arg)
710 parse_opt_flags(char ch, char *arg)
712 if (required_arg(ch, arg)) {
716 if (str2u32(arg, &fw_header.flags) != 0) {
717 errmsg(0,"invalid firmware flags: %s", arg);
721 dbgmsg(1, "firmware flags set to %X bytes", fw_header.flags);
731 parse_opt_size(char ch, char *arg)
733 if (required_arg(ch, arg)) {
737 if (str2u32(arg, &flash_size) != 0) {
738 errmsg(0,"invalid flash size: %s", arg);
742 dbgmsg(1, "flash size set to %d bytes", flash_size);
752 parse_opt_id(char ch, char *arg)
754 char buf[MAX_ARG_LEN];
755 char *argv[MAX_ARG_COUNT];
759 if (required_arg(ch, arg)) {
763 argc = parse_arg(arg, buf, argv);
765 /* processing vendor ID*/
767 if (is_empty_arg(p)) {
768 errmsg(0,"vendor id is missing from -%c %s",ch, arg);
770 } else if (str2u16(p, &fw_header.vid) != 0) {
771 errmsg(0,"invalid vendor id: %s", p);
775 dbgmsg(1, "vendor id is set to 0x%04X", fw_header.vid);
777 /* processing device ID*/
779 if (is_empty_arg(p)) {
780 errmsg(0,"device id is missing from -%c %s",ch, arg);
782 } else if (str2u16(p, &fw_header.did) != 0) {
783 errmsg(0,"invalid device id: %s", p);
787 dbgmsg(1, "device id is set to 0x%04X", fw_header.did);
789 /* processing sub vendor ID*/
791 if (is_empty_arg(p)) {
792 fw_header.svid = fw_header.vid;
793 } else if (str2u16(p, &fw_header.svid) != 0) {
794 errmsg(0,"invalid sub vendor id: %s", p);
798 dbgmsg(1, "sub vendor id is set to 0x%04X", fw_header.svid);
800 /* processing device ID*/
802 if (is_empty_arg(p)) {
803 fw_header.sdid = fw_header.did;
804 } else if (str2u16(p, &fw_header.sdid) != 0) {
805 errmsg(0,"invalid sub device id: %s", p);
809 dbgmsg(1, "sub device id is set to 0x%04X", fw_header.sdid);
811 /* processing revision */
813 if (is_empty_arg(p)) {
815 } else if (str2u32(arg, &fw_header.rev) != 0) {
816 errmsg(0,"invalid revision number: %s", p);
820 dbgmsg(1, "board revision is set to 0x%08X", fw_header.rev);
830 parse_opt_block(char ch, char *arg)
832 char buf[MAX_ARG_LEN];
833 char *argv[MAX_ARG_COUNT];
838 if (required_arg(ch, arg)) {
842 if (fw_num_blocks >= MAX_FW_BLOCKS) {
843 errmsg(0,"too many blocks specified");
847 argc = parse_arg(arg, buf, argv);
848 dbgmsg(1,"processing block option %s, count %d", arg, argc);
850 b = &fw_blocks[fw_num_blocks++];
852 /* processing block address */
854 if (is_empty_arg(p)) {
855 errmsg(0,"no block address specified in %s", arg);
857 } else if (str2u32(p, &b->addr) != 0) {
858 errmsg(0,"invalid block address: %s", p);
862 /* processing block length */
864 if (is_empty_arg(p)) {
865 errmsg(0,"no block length specified in %s", arg);
867 } else if (str2u32(p, &b->blocklen) != 0) {
868 errmsg(0,"invalid block length: %s", p);
873 dbgmsg(1,"empty block %s", arg);
877 /* processing flags */
879 if (is_empty_arg(p) == 0) {
880 for ( ; *p != '\0'; p++) {
883 b->flags |= BLOCK_FLAG_HAVEHDR;
886 errmsg(0, "invalid block flag \"%c\"", *p);
892 /* processing file name */
894 if (is_empty_arg(p)) {
895 errmsg(0,"file name missing in %s", arg);
900 if (b->name == NULL) {
901 errmsg(0,"not enough memory");
915 parse_opt_partition(char ch, char *arg)
917 char buf[MAX_ARG_LEN];
918 char *argv[MAX_ARG_COUNT];
922 struct mylo_partition *part;
924 if (required_arg(ch, arg)) {
928 if (fw_num_partitions >= MYLO_MAX_PARTITIONS) {
929 errmsg(0, "too many partitions specified");
933 part = &fw_partitions[fw_num_partitions++];
935 argc = parse_arg(arg, buf, argv);
937 /* processing partition address */
939 if (is_empty_arg(p)) {
940 errmsg(0,"partition address missing in -%c %s",ch, arg);
942 } else if (str2u32(p, &part->addr) != 0) {
943 errmsg(0,"invalid partition address: %s", p);
947 /* processing partition size */
949 if (is_empty_arg(p)) {
950 errmsg(0,"partition size missing in -%c %s",ch, arg);
952 } else if (str2u32(p, &part->size) != 0) {
953 errmsg(0,"invalid partition size: %s", p);
957 /* processing partition flags */
959 if (is_empty_arg(p) == 0) {
960 for ( ; *p != '\0'; p++) {
963 part->flags |= PARTITION_FLAG_ACTIVE;
966 part->flags |= PARTITION_FLAG_PRELOAD;
969 part->flags |= PARTITION_FLAG_HAVEHDR;
972 errmsg(0, "invalid partition flag \"%c\"", *p);
978 /* processing partition parameter */
980 if (is_empty_arg(p)) {
981 /* set default partition parameter */
983 } else if (str2u32(p, &part->param) != 0) {
984 errmsg(0,"invalid partition parameter: %s", p);
989 if (part->size == 0) {
990 part->size = flash_size - part->addr;
993 /* processing file parameter */
995 if (is_empty_arg(p) == 0) {
998 if (fw_num_blocks == MAX_FW_BLOCKS) {
999 errmsg(0,"too many blocks specified", p);
1002 b = &fw_blocks[fw_num_blocks++];
1003 b->name = strdup(p);
1004 b->addr = part->addr;
1005 b->blocklen = part->size;
1006 if (part->flags & PARTITION_FLAG_HAVEHDR) {
1007 b->flags |= BLOCK_FLAG_HAVEHDR;
1020 parse_opt_board(char ch, char *arg)
1022 struct cpx_board *board;
1024 if (required_arg(ch, arg)) {
1028 board = find_board(arg);
1030 errmsg(0,"invalid/unknown board specified: %s", arg);
1034 fw_header.vid = board->vid;
1035 fw_header.did = board->did;
1036 fw_header.svid = board->svid;
1037 fw_header.sdid = board->sdid;
1039 flash_size = board->flash_size;
1049 parse_opt_rev(char ch, char *arg)
1051 if (required_arg(ch, arg)) {
1055 if (str2u32(arg, &fw_header.rev) != 0) {
1056 errmsg(0,"invalid revision number: %s", arg);
1068 main(int argc, char *argv[])
1070 int optinvalid = 0; /* flag for invalid option */
1072 int res = EXIT_FAILURE;
1077 progname=basename(argv[0]);
1079 memset(&fw_header, 0, sizeof(fw_header));
1081 /* init header defaults */
1082 fw_header.vid = VENID_COMPEX;
1083 fw_header.did = DEVID_COMPEX_WP54G;
1084 fw_header.svid = VENID_COMPEX;
1085 fw_header.sdid = DEVID_COMPEX_WP54G;
1086 fw_header.fwhi = 0x20000;
1087 fw_header.fwlo = 0x20000;
1088 fw_header.flags = 0;
1090 opterr = 0; /* could not print standard getopt error messages */
1091 while ((c = getopt(argc, argv, "b:B:f:hi:p:r:s:v")) != -1) {
1095 optinvalid = parse_opt_block(c,optarg);
1098 optinvalid = parse_opt_board(c,optarg);
1101 optinvalid = parse_opt_flags(c,optarg);
1104 usage(EXIT_SUCCESS);
1107 optinvalid = parse_opt_id(c,optarg);
1110 optinvalid = parse_opt_partition(c,optarg);
1113 optinvalid = parse_opt_rev(c,optarg);
1116 optinvalid = parse_opt_size(c,optarg);
1125 if (optinvalid != 0 ){
1126 errmsg(0, "invalid option: -%c", optopt);
1131 if (optind == argc) {
1132 errmsg(0, "no output file specified");
1136 ofname = argv[optind++];
1138 if (optind < argc) {
1139 errmsg(0, "invalid option: %s", argv[optind]);
1143 if (flash_size == 0) {
1144 errmsg(0, "no flash size specified");
1148 if (process_files() != 0) {
1152 if (process_partitions() != 0) {
1156 outfile = fopen(ofname, "w");
1157 if (outfile == NULL) {
1158 errmsg(1, "could not open \"%s\" for writing", ofname);
1165 if (write_out_header(outfile, &crc) != 0)
1168 if (write_out_blocks(outfile, &crc) != 0)
1171 fw_header.crc = crc;
1172 if (write_out_header(outfile, NULL) != 0)
1175 dbgmsg(1,"Firmware file %s completed.", ofname);
1182 if (res != EXIT_SUCCESS) {