Index: io_tedax.c =================================================================== --- io_tedax.c (revision 32376) +++ io_tedax.c (revision 32377) @@ -75,7 +75,7 @@ static const char pcb_acts_Savetedax[] = "SaveTedax(netlist|board-footprints|stackup|layer|board|drc|etest, filename)\n" "SaveTedax(drc_query, filename, [rule_name])" - "SaveTedax(route_req, filename)"; + "SaveTedax(route_req, filename, [confkey=value, confkey=value, ...])"; static const char pcb_acth_Savetedax[] = "Saves the specific type of data in a tEDAx file."; static fgw_error_t pcb_act_Savetedax(fgw_arg_t *res, int argc, fgw_arg_t *argv) { @@ -126,7 +126,7 @@ } if (rnd_strcasecmp(type, "route_req") == 0) { - RND_ACT_IRES(tedax_route_req_save(PCB, fname)); + RND_ACT_IRES(tedax_route_req_save(PCB, fname, argc-3, argv+3)); return 0; } Index: parse.c =================================================================== --- parse.c (revision 32376) +++ parse.c (revision 32377) @@ -125,13 +125,13 @@ return argc; } -void tedax_fprint_escape(FILE *f, const char *val) +void tedax_fnprint_escape(FILE *f, const char *val, int len) { if ((val == NULL) || (*val == '\0')) { fputc('-', f); return; } - for(; *val != '\0'; val++) { + for(; (*val != '\0') && (len > 0); val++,len--) { switch(*val) { case '\\': fputc('\\', f); fputc('\\', f); break; case '\n': fputc('\\', f); fputc('n', f); break; @@ -144,6 +144,11 @@ } } +void tedax_fprint_escape(FILE *f, const char *val) +{ + tedax_fnprint_escape(f, val, 510); +} + #define APPEND(c) \ do { \ if (dstlen == 0) { \ Index: parse.h =================================================================== --- parse.h (revision 32376) +++ parse.h (revision 32377) @@ -25,5 +25,6 @@ /* print val with special chars escaped. Prints a single dash if val is NULL or empty. */ void tedax_fprint_escape(FILE *f, const char *val); +void tedax_fnprint_escape(FILE *f, const char *val, int len); int tedax_strncpy_escape(char *dst, int dstlen, const char *val); Index: trouter.c =================================================================== --- trouter.c (revision 32376) +++ trouter.c (revision 32377) @@ -48,6 +48,7 @@ #include "obj_pstk.h" #include #include +#include #include "plug_io.h" #include "conf_core.h" @@ -88,8 +89,37 @@ return 0; } -int tedax_route_req_fsave(pcb_board_t *pcb, FILE *f) +static void write_conf(FILE *f, int argc, fgw_arg_t *argv) { + int n; + + for(n = 0; n < argc; n++) { + const char *key, *sep; + if (fgw_arg_conv(&rnd_fgw, &argv[n], FGW_STR) != 0) { + rnd_message(RND_MSG_ERROR, "Error: route_req: confkey #%d can not be converted to string and is ignored\n", n); + continue; + } + key = argv[n].val.str; + sep = strchr(key, '='); + if (sep == NULL) { + rnd_message(RND_MSG_ERROR, "Error: route_req: confkey %s: no '=' and no value\n", key); + continue; + } + if (strlen(key) > 500) { + rnd_message(RND_MSG_ERROR, "Error: route_req: confkey %s: value too long\n", key); + continue; + } + sep++; + fprintf(f, " conf "); + tedax_fnprint_escape(f, key, sep-key-1); + fprintf(f, " "); + tedax_fprint_escape(f, sep); + fprintf(f, "\n"); + } +} + +int tedax_route_req_fsave(pcb_board_t *pcb, FILE *f, int cfg_argc, fgw_arg_t *cfg_argv) +{ rnd_layergrp_id_t gid; int res = -1; tedax_stackup_t ctx; @@ -123,6 +153,8 @@ tedax_fprint_escape(f, pcb->hidlib.name); fputc('\n', f); + write_conf(f, cfg_argc, cfg_argv); + rnd_fprintf(f, " stackup %s\n", stackupid); if (tedax_global_via_fwrite(pcb, pcb->Data, f, &nmap) != 0) @@ -141,7 +173,7 @@ } -int tedax_route_req_save(pcb_board_t *pcb, const char *fn) +int tedax_route_req_save(pcb_board_t *pcb, const char *fn, int cfg_argc, fgw_arg_t *cfg_argv) { int res; FILE *f; @@ -152,7 +184,7 @@ return -1; } fprintf(f, "tEDAx v1\n"); - res = tedax_route_req_fsave(pcb, f); + res = tedax_route_req_fsave(pcb, f, cfg_argc, cfg_argv); fclose(f); return res; } Index: trouter.h =================================================================== --- trouter.h (revision 32376) +++ trouter.h (revision 32377) @@ -1,7 +1,7 @@ #include "board.h" -int tedax_route_req_save(pcb_board_t *pcb, const char *fn); -int tedax_route_req_fsave(pcb_board_t *pcb, FILE *f); +int tedax_route_req_save(pcb_board_t *pcb, const char *fn, int cfg_argc, fgw_arg_t *cfg_argv); +int tedax_route_req_fsave(pcb_board_t *pcb, FILE *f, int cfg_argc, fgw_arg_t *cfg_argv); int tedax_route_res_fload(FILE *fn, const char *blk_id, int silent); int tedax_route_res_load(const char *fname, const char *blk_id, int silent);