Index: trunk/src_plugins/export_vfs_mc/export_vfs_mc.c =================================================================== --- trunk/src_plugins/export_vfs_mc/export_vfs_mc.c (revision 23993) +++ trunk/src_plugins/export_vfs_mc/export_vfs_mc.c (revision 23994) @@ -30,6 +30,8 @@ #define NUM_OPTIONS (sizeof(export_vfs_mc_options)/sizeof(export_vfs_mc_options[0])) +PCB_REGISTER_ATTRIBUTES(export_vfs_mc_options, export_vfs_mc_cookie) + static pcb_hid_attr_val_t export_vfs_mc_values[NUM_OPTIONS]; static pcb_hid_attribute_t *export_vfs_mc_get_export_options(int *n) @@ -39,6 +41,17 @@ return export_vfs_mc_options; } +static void mc_list_cb(void *ctx, const char *path, int isdir) +{ + const char *attrs = isdir ? "drwxr-xr-x" : "-rw-r--r--"; + printf("%s 1 pcb-rnd pcb-rnd 0 01/01/01 01:01 %s\n", attrs, path); +} + +static void mc_list(void) +{ + pcb_vfs_list(PCB, mc_list_cb, NULL); +} + static void export_vfs_mc_do_export(pcb_hid_attr_val_t * options) { const char *cmd; @@ -52,7 +65,11 @@ } cmd = options[HA_export_vfs_mc_cmd].str_value; - TODO("Process cmd here"); + if (strcmp(cmd, "list") == 0) mc_list(); + else { + fprintf(stderr, "Unknown vfs_mc command: '%s'\n", cmd); + exit(1); + } } static int export_vfs_mc_usage(const char *topic) @@ -76,6 +93,7 @@ void pplg_uninit_export_vfs_mc(void) { + pcb_hid_remove_attributes_by_cookie(export_vfs_mc_cookie); } int pplg_init_export_vfs_mc(void) @@ -87,7 +105,7 @@ pcb_hid_nogui_init(&export_vfs_mc_hid); export_vfs_mc_hid.struct_size = sizeof(pcb_hid_t); - export_vfs_mc_hid.name = "export_vfs_mc"; + export_vfs_mc_hid.name = "vfs_mc"; export_vfs_mc_hid.description = "Handler of mc VFS calls, serving board data"; export_vfs_mc_hid.exporter = 1; export_vfs_mc_hid.hide_from_gui = 1; Index: trunk/src_plugins/lib_vfs/lib_vfs.c =================================================================== --- trunk/src_plugins/lib_vfs/lib_vfs.c (revision 23993) +++ trunk/src_plugins/lib_vfs/lib_vfs.c (revision 23994) @@ -30,7 +30,38 @@ #include "data.h" #include "plugins.h" +#include "lib_vfs.h" +static void vfs_list_layers(pcb_board_t *pcb, pcb_vfs_list_cb cb, void *ctx) +{ + gds_t path; + pcb_layer_id_t lid; + size_t orig_used; + + cb(ctx, "data/layers", 1); + gds_init(&path); + gds_append_str(&path, "data/layers/"); + orig_used = path.used; + for(lid = 0; lid < pcb->Data->LayerN; lid++) { + path.used = orig_used; + pcb_append_printf(&path, "%ld", lid); + cb(ctx, path.array, 1); + } + gds_uninit(&path); +} + +int pcb_vfs_list(pcb_board_t *pcb, pcb_vfs_list_cb cb, void *ctx) +{ + cb(ctx, "data", 1); + vfs_list_layers(pcb, cb, ctx); + cb(ctx, "data/layer_groups", 1); + cb(ctx, "route_styles", 1); + cb(ctx, "netlist", 1); + + return 0; +} + + int pplg_check_ver_lib_vfs(int ver_needed) { return 0; } void pplg_uninit_lib_vfs(void) Index: trunk/src_plugins/lib_vfs/lib_vfs.h =================================================================== --- trunk/src_plugins/lib_vfs/lib_vfs.h (revision 23993) +++ trunk/src_plugins/lib_vfs/lib_vfs.h (revision 23994) @@ -24,3 +24,9 @@ * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") */ +#include "board.h" + +typedef void (*pcb_vfs_list_cb)(void *ctx, const char *path, int isdir); + +int pcb_vfs_list(pcb_board_t *pcb, pcb_vfs_list_cb cb, void *ctx); +