コード例 #1
0
static void
convert_cat(String *cap, char *s, Config *c, int maxlen)
{
  int res;

  if (config_get_boolean(c, "/enfle/plugins/ui/normal/filename_code_conversion", &res)) {
    char **froms = config_get_list(c, "/enfle/plugins/ui/normal/filename_code_from", &res);
    char *to = config_get_str(c, "/enfle/plugins/ui/normal/filename_code_to");
    char *from;
    int i = 0;

    if (res && to) {
      while ((from = froms[i++])) {
	char *tmp;

	//debug_message_fnc("%s->%s: %s\n", from, to, s);
	if ((res = converter_convert(s, &tmp, strlen(s), from, to)) < 0)
	  continue;
	if (maxlen)
	  string_ncat(cap, tmp, maxlen);
	else
	  string_cat(cap, tmp);
	free(tmp);
	return;
      }
    }
  }

  if (maxlen > 0)
    string_ncat(cap, s, maxlen);
  else
    string_cat(cap, s);
}
コード例 #2
0
ファイル: plugins.c プロジェクト: acieroid/tetristar
void plugins_load_all()
{
  GSList *plugins_to_load;
  plugins_to_load = config_get_list("plugins", NULL);;
  g_slist_foreach(plugins_to_load,
                  (GFunc) tetris_plugin_file_load, NULL);
  g_slist_free_full(plugins_to_load, (GDestroyNotify) g_free);
}
コード例 #3
0
ファイル: dosage.c プロジェクト: kgururaj/bcftools
/* 
    Called once at startup, allows to initialize local variables.
    Return 1 to suppress VCF/BCF header from printing, 0 for standard
    VCF/BCF output and -1 on critical errors.
*/
int init(const char *opts, bcf_hdr_t *in, bcf_hdr_t *out)
{
    int i, id;

    in_hdr = in;
    tags = config_get_list(opts ? opts : "tags=PL,GL,GT","tags", &ntags);
    for (i=0; i<ntags; i++)
    {
        if ( !strcmp("PL",tags[i]) )
        {
            id = bcf_hdr_id2int(in_hdr,BCF_DT_ID,"PL");
            if ( bcf_hdr_idinfo_exists(in_hdr,BCF_HL_FMT,id) ) 
            {
                pl_type = bcf_hdr_id2type(in_hdr,BCF_HL_FMT,id);
                if ( pl_type!=BCF_HT_INT && pl_type!=BCF_HT_REAL ) 
                {
                    fprintf(stderr,"Expected numeric type of FORMAT/PL\n");
                    return -1;
                }
                handlers = (dosage_f*) realloc(handlers,(nhandlers+1)*sizeof(*handlers));
                handlers[nhandlers++] = calc_dosage_PL;
            }
        }
        else if ( !strcmp("GL",tags[i]) )
        {
            id = bcf_hdr_id2int(in_hdr,BCF_DT_ID,"GL");
            if ( bcf_hdr_idinfo_exists(in_hdr,BCF_HL_FMT,id) )
            {
                gl_type = bcf_hdr_id2type(in_hdr,BCF_HL_FMT,id);
                if ( gl_type!=BCF_HT_INT && gl_type!=BCF_HT_REAL ) 
                {
                    fprintf(stderr,"Expected numeric type of FORMAT/GL\n");
                    return -1;
                }
                handlers = (dosage_f*) realloc(handlers,(nhandlers+1)*sizeof(*handlers));
                handlers[nhandlers++] = calc_dosage_GL;
            }
        }
        else if ( !strcmp("GT",tags[i]) )
        {
            handlers = (dosage_f*) realloc(handlers,(nhandlers+1)*sizeof(*handlers));
            handlers[nhandlers++] = calc_dosage_GT;
        }
        else 
        {
            fprintf(stderr,"No handler for tag \"%s\"\n", tags[i]);
            return -1;
        }
    }
    free(tags[0]);
    free(tags);

    printf("#[1]CHROM\t[2]POS\t[3]REF\t[4]ALT");
    for (i=0; i<bcf_hdr_nsamples(in_hdr); i++) printf("\t[%d]%s", i+5,in_hdr->samples[i]);
    printf("\n");

    return 1;
}