Index: export_vfs_fuse.c =================================================================== --- export_vfs_fuse.c (revision 24068) +++ export_vfs_fuse.c (revision 24069) @@ -23,54 +23,80 @@ const char *export_vfs_fuse_cookie = "export_vfs_fuse HID"; -static pcb_hid_attribute_t export_vfs_fuse_options[] = { - {"cmd", "mc command", - PCB_HATT_STRING, 0, 0, {0, 0, 0}, 0, 0}, -#define HA_export_vfs_fuse_cmd 0 -}; - -#define NUM_OPTIONS (sizeof(export_vfs_fuse_options)/sizeof(export_vfs_fuse_options[0])) - -PCB_REGISTER_ATTRIBUTES(export_vfs_fuse_options, export_vfs_fuse_cookie) - -static pcb_hid_attr_val_t export_vfs_fuse_values[NUM_OPTIONS]; - static pcb_hid_attribute_t *export_vfs_fuse_get_export_options(int *n) { - if (n) - *n = NUM_OPTIONS; - return export_vfs_fuse_options; + return 0; } -static void export_vfs_fuse_do_export(pcb_hid_attr_val_t * options) +static char **fuse_argv; +static int fuse_argc = 0; +static void export_vfs_fuse_do_export(pcb_hid_attr_val_t *options) { - const char *cmd; - int i; - - if (!options) { - export_vfs_fuse_get_export_options(0); - for (i = 0; i < NUM_OPTIONS; i++) - export_vfs_fuse_values[i] = export_vfs_fuse_options[i].default_val; - options = export_vfs_fuse_values; - } - - cmd = options[HA_export_vfs_fuse_cmd].str_value; - TODO("Process cmd here"); + int n; + for(n = 0; n < fuse_argc; n++) + printf("fuse arg [%d] '%s'\n", n, fuse_argv[n]); } static int export_vfs_fuse_usage(const char *topic) { - fprintf(stderr, "\nexport_vfs_fuse exporter command line arguments:\n\n"); - pcb_hid_usage(export_vfs_fuse_options, sizeof(export_vfs_fuse_options) / sizeof(export_vfs_fuse_options[0])); - fprintf(stderr, "\nUsage: pcb-rnd [generic_options] -x export_vfs_fuse [export_vfs_fuse_options] foo.pcb\n\n"); + fprintf(stderr, "\nexport_vfs_fuse exporter command line arguments are plain fuse aguments.\n\n"); + fprintf(stderr, "\nUsage: pcb-rnd [pcb-rnd-options] [-o fuse-options] foo.pcb mountpoint\n\n"); return 0; } +#define arg_append(dst_argc, dst_argv, str) dst_argv[dst_argc++] = str +#define arg_copy_to_fuse(cnt) \ +do { \ + int __i__; \ + for(__i__ = 0; __i__ < (cnt); __i__++,n++) \ + arg_append(fuse_argc, fuse_argv, in_argv[n]); \ + n--; \ +} while(0) + +#define arg_copy_to_pcb(cnt) \ +do { \ + int __i__; \ + for(__i__ = 0; __i__ < (cnt); __i__++,n++) \ + arg_append(fuse_ret_argc, fuse_ret_argv, in_argv[n]); \ + n--; \ +} while(0) + +static char **fuse_ret_argv; +static int fuse_ret_argc = 0; static int export_vfs_fuse_parse_arguments(int *argc, char ***argv) { - pcb_hid_register_attributes(export_vfs_fuse_options, sizeof(export_vfs_fuse_options) / sizeof(export_vfs_fuse_options[0]), export_vfs_fuse_cookie, 0); - return pcb_hid_parse_command_line(argc, argv); + int n, in_argc = *argc; + char **in_argv = *argv; + char *board = NULL, *dir = NULL; + + fuse_argv = malloc(sizeof(char *) * (*argc+1)); + fuse_argc = 0; + fuse_ret_argv = malloc(sizeof(char *) * (*argc+1)); + fuse_ret_argc = 0; + + for(n = 0; n < in_argc; n++) { + if (strcmp(in_argv[n], "-o") == 0) arg_copy_to_fuse(2); + else if (*in_argv[n] == '-') arg_copy_to_pcb(2); + else { + if (board == NULL) board = in_argv[n]; + else if (dir == NULL) dir = in_argv[n]; + else { + fprintf(stderr, "export_vfs_fuse: excess unrecognized argument: '%s'\n", in_argv[n]); + exit(1); + } + } + } + + arg_append(fuse_ret_argc, fuse_ret_argv, board); + arg_append(fuse_argc, fuse_argv, dir); + + fuse_argv[fuse_argc] = NULL; + fuse_ret_argv[fuse_ret_argc] = NULL; + + argc = &fuse_ret_argc; + *argv = fuse_ret_argv; + return 0; } pcb_hid_t export_vfs_fuse_hid; @@ -80,6 +106,10 @@ void pplg_uninit_export_vfs_fuse(void) { pcb_hid_remove_attributes_by_cookie(export_vfs_fuse_cookie); + free(fuse_argv); + fuse_argv = NULL; + free(fuse_ret_argv); + fuse_ret_argv = NULL; } int pplg_init_export_vfs_fuse(void)