Пример #1
0
int
main(int argc, char **argv)
{
  int cache_strategy, cache_metric, cache_size, help;
  Eina_List *filters = NULL,
	    *list_iter;
  Filter *f, *last, *load, *sink; 
  char *file = NULL;
  int verbose;
  
  lime_init();

  if (parse_cli(argc, argv, &filters, NULL, &cache_size, &cache_metric, &cache_strategy, &file, NULL, &verbose, &help))
    return EXIT_FAILURE;
  
  if (help) {
    print_help();
    return EXIT_SUCCESS;
  }
  
  print_init_info(NULL, cache_size, cache_metric, cache_strategy, NULL);
  
  lime_cache_set(cache_size, cache_strategy | cache_metric);
  
  if (!strcmp(((Filter*)eina_list_data_get(filters))->fc->shortname, "load")) {
    load = eina_list_data_get(filters);
    if (file)
      lime_setting_string_set(load, "filename", file);
  }
  else {
    if (!file) { 
      printf("ERROR: need file to execute filter chain!\n");
      return EXIT_FAILURE;
    }
    load = lime_filter_new("load");
    lime_setting_string_set(load, "filename", file);
    filters = eina_list_prepend(filters, load);
  }
  

  last = NULL;
  EINA_LIST_FOREACH(filters, list_iter, f) {
    if (last)
      lime_filter_connect(last, f);
    
    last = f;
  }
  
  sink = last;

  lime_render(sink);
  
  cache_stats_print();
  
  lime_shutdown();
  
  return 0;
}
Пример #2
0
//FIXME check if setting does exist, give some debug info if parsing fails!
Eina_List *lime_filter_chain_deserialize(char *str)
{
  int i;
  int checksettings;
  Meta *m;
  Filter *f, *last_f = NULL;
  Eina_List *filters = NULL;
  
  str = strdup(str);
  
  char *last = str + strlen(str);
  char *next = str;
  char *next_comma;
  char *cur = str;
  const char *setting;
  char *tmp;
  while (cur) {
    next = next_single_colon(cur);
    next_comma = strchr(cur, ',');
    if (next || next_comma) {
      if (next && (next < next_comma || !next_comma)) {
        printf("%s with settings\n", cur);
        checksettings = 1;
        *next = '\0';
        f = lime_filter_new(cur);
      }
      else if (next_comma && (next > next_comma || !next)) {
        printf("%s no settings\n", cur);
        checksettings = 0;
        *next_comma = '\0';
        f = lime_filter_new(cur);
        cur = next_comma+1;
        next = NULL;
      }
      else {
        //FIXME  check rethink?
        abort();
      }
    }
    else {
      printf("%s last filter no settings\n", cur);
      checksettings = 0;
      f = lime_filter_new(cur);
      next = NULL;
      cur = NULL;
    }
    
    if (!f) {
      printf("no filter for %s\n", cur);
      return NULL;
    }
    
    if (next && next+1 < last)
      cur = next+1;
    else
      checksettings = 0;
    
    //f = fc->filter_new_f();
    
    if (last_f)
      lime_filter_connect(last_f, f);
    
    last_f = f;
    
    filters = eina_list_append(filters, f);
    
    //settings
    if (cur && checksettings) {
      next = strchr(cur, '=');
      if (strchr(cur, ',') && next > strchr(cur, ','))
        break;
      while (next) {
        *next = '\0';
        
          setting = cur;
          assert(next+1 < last);
          cur = next+1;
  
        if (!ea_count(f->settings)) {
          printf("no settings for %s\n", f->fc->name);
          return NULL;
        }
  
        for(i=0;i<ea_count(f->settings);i++) {
          m = ea_data(f->settings, i);
          if (!strncmp(setting, m->name, strlen(setting))) {
            setting = m->name;
            break;
          }
        }
            
        switch (lime_setting_type_get(f, setting)) {
          case MT_INT :
            lime_setting_int_set(f, setting, atoi(cur));
            break;
          case MT_FLOAT :
            lime_setting_float_set(f, setting, atof(cur));
            break;
	  case MT_STRING :
            tmp = strdup(cur);
            if (next_single_colon(tmp))
              *next_single_colon(tmp) = '\0';
            if (strchr(tmp, ','))
              *strchr(tmp, ',') = '\0';
            lime_setting_string_set(f, setting, string_unescape_colon(tmp));
	    printf("set %s to %s\n", setting, string_unescape_colon(tmp));
            free(tmp);
            break;
          default :
            if (lime_setting_type_get(f, setting) == -1)
              printf("setting %s for filter %s not known (filter implementation changed?)\n", setting, f->fc->name);
            else
              printf("FIXME implement type %s settings parsing\n", mt_type_str(lime_setting_type_get(f, setting)));
        }
          
          next = next_single_colon(cur);
          if (next && next+1 < last && (!strchr(cur, ',') || next < strchr(cur, ','))) {
            cur = next+1;
            next = strchr(cur, '=');
          }
          else
            next = NULL;
        
        
      }
      
      if (cur)
        cur = strchr(cur, ',');
      if (cur)
        cur++;
    }
    
    if (cur >= last)
      cur = NULL;
      
  }
  
  free(str);
  
  return filters;
}