Index: ar_extern.c =================================================================== --- ar_extern.c (revision 32356) +++ ar_extern.c (revision 32357) @@ -29,8 +29,7 @@ #include "config.h" #include -#include -#include +#include #include "board.h" #include "data.h" @@ -52,7 +51,8 @@ typedef struct { const char *name; int (*route)(pcb_board_t *pcb, ext_route_scope_t scope, const char *method, int argc, fgw_arg_t *argv); - rnd_hid_attribute_t *(*list_conf)(const char *method); + int (*list_methods)(rnd_hidlib_t *hl, vts0_t *dst); + rnd_hid_attribute_t *(*list_conf)(rnd_hidlib_t *hl, const char *method); } ext_router_t; #include "e_route-rnd.c" @@ -73,10 +73,23 @@ static void extroute_gui(pcb_board_t *pcb) { const ext_router_t **r; + vts0_t methods = {0}; + printf("GUI!\n"); for(r = routers; *r != NULL; r++) { - (*r)->list_conf(NULL); + int n; + + printf(" router=%s\n", (*r)->name); + methods.used = 0; + (*r)->list_methods(&pcb->hidlib, &methods); + for(n = 0; n < methods.used; n+=2) { + printf(" method=%s (%s)\n", methods.array[n], methods.array[n+1]); + (*r)->list_conf(&pcb->hidlib, methods.array[n]); + free(methods.array[n]); + free(methods.array[n+1]); + } } + vts0_uninit(&methods); } static const char pcb_acts_extroute[] = "extroute(board|selected, router, [confkey=value, ...])"; Index: e_route-rnd.c =================================================================== --- e_route-rnd.c (revision 32356) +++ e_route-rnd.c (revision 32357) @@ -26,9 +26,12 @@ * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") */ +TODO("this should be in config") +static const char *exe = "route-rnd"; + static int rtrnd_route(pcb_board_t *pcb, ext_route_scope_t scope, const char *method, int argc, fgw_arg_t *argv) { - const char *exe = "route-rnd", *route_req = "rtrnd.1.tdx", *route_res = "rtrnd.2.tdx"; + const char *route_req = "rtrnd.1.tdx", *route_res = "rtrnd.2.tdx"; rnd_hidlib_t *hl = &pcb->hidlib; char *cmd; int r; @@ -60,8 +63,42 @@ return 0; } -static rnd_hid_attribute_t *rtrnd_list_conf(const char *method) +static int rtrnd_list_methods(rnd_hidlib_t *hl, vts0_t *dst) { + FILE *f; + char *cmd, line[1024]; + + printf("fos\n"); + + cmd = rnd_strdup_printf("%s -M", exe); + f = rnd_popen(hl, cmd, "r"); + free(cmd); + if (f == NULL) + return -1; + + while(fgets(line, sizeof(line), f) != NULL) { + char *name, *desc; + name = line; + while(isspace(*name)) name++; + if (*name == '\0') continue; + desc = strchr(name, '\t'); + if (desc != NULL) { + *desc = '\0'; + desc++; + } + else + desc = "n/a"; + vts0_append(dst, rnd_strdup(name)); + vts0_append(dst, rnd_strdup(desc)); + } + + fclose(f); + return 0; +} + + +static rnd_hid_attribute_t *rtrnd_list_conf(rnd_hidlib_t *hl, const char *method) +{ return NULL; } @@ -68,5 +105,6 @@ static const ext_router_t route_rnd = { "route-rnd", rtrnd_route, + rtrnd_list_methods, rtrnd_list_conf };