/* Find the options for InterMezzo in "options", saving them into the * passed pointers. If the pointer is null, the option is discarded. * Copy out all non-InterMezzo options into cache_data (to be passed * to the read_super operation of the cache). The return value will * be a pointer to the end of the cache_data. */ static char *presto_options(struct super_block *sb, char *options, char *cache_data, char **cache_type, char **fileset, char **channel) { char *this_char; char *cache_data_end = cache_data; /* set the defaults */ if (strcmp(sb->s_type->name, "intermezzo") == 0) opt_set_default(cache_type, "ext3"); else opt_set_default(cache_type, "tmpfs"); if (!options || !cache_data) return cache_data_end; CDEBUG(D_SUPER, "parsing options\n"); for (this_char = strtok (options, ","); this_char != NULL; this_char = strtok (NULL, ",")) { char *opt; CDEBUG(D_SUPER, "this_char %s\n", this_char); if ( (opt = opt_read("fileset", this_char)) ) { opt_store(fileset, opt); continue; } if ( (opt = opt_read("cache_type", this_char)) ) { opt_store(cache_type, opt); continue; } if ( (opt = opt_read("channel", this_char)) ) { opt_store(channel, opt); continue; } cache_data_end += sprintf(cache_data_end, "%s%s", cache_data_end != cache_data ? ",":"", this_char); } return cache_data_end; }
int main(int argc, const char *argv[]) { opt_t *o; setlocale(LC_ALL, ""); o = opt_read(argc, argv); if(o->info) sub_info(o); else sub_convert(o); opt_free(o); return 0; }
int ft_printf(const char *fmt, ...) { va_list args; t_fmt *begin_list; t_fmt *list; int count; t_opt *opt; char *format; format = ft_strdup(fmt); count = 0; list = 0; list = fmt_init(list); begin_list = list; va_start(args, fmt); if (!(opt = (t_opt*)ft_memalloc(sizeof(t_opt)))) return (-1); while (*format) { opt_init(opt); while (*format != '%' && *format) { ft_putchar(*format); format++; count++; } if (*format == '%') { format++; if (!*format) return (count); if (*format == '%') { ft_putchar('%'); count++; } else { format = opt_read(opt, (char*)format); // ft_putendl(format); //juste pour le debug // print_opt(opt); //ici il faut appeler une fct de conv if (*format == 'p') { *format = 'x'; opt->hash = 1; } if (!(list = find_list(begin_list, *format))) { if (*format) { ft_putchar(*format); count++; } } else count += (int)list->fct(va_arg(args, void*), opt); } format++; } }