void populate_each_function(
  struct Value * item_key,
  struct Value * index_key,
  struct Tree * ast,
  struct Value * item,
  struct Value * index){
    if(!ast->size && ast->type == 'k'){
        if(string_matches(item_key->data.str, ast->content.data.str)){
            if(item->type == 's'){
              ast->type = item->type;
            } else {
              ast->type = 'n';
            }
            copy_value(&ast->content, item);
        }
        else if(string_matches(index_key->data.str, ast->content.data.str)){
            ast->type = 'n';
            copy_value(&ast->content, index);
        }
    } else if(ast->size > 0){
        for(int i = 0; i < ast->size; i++){
            populate_each_function(item_key, index_key, ast->children[i], item, index);
        }
    }
}
Exemple #2
0
static GList *traverse_xml(const gchar *data, const gchar *url, cb_object *capo)
{
    gchar *beg = (gchar *) data;
    GList *collection = NULL;
    gint item_ctr = 0;

    /* Hop over album title */
    beg = strstr(beg, TIT_BEGIN);

    while(continue_search(item_ctr, capo->s) && (beg = strstr(beg + (sizeof TIT_BEGIN) - 1, TIT_BEGIN)) != NULL) {
        gchar *dy;
        gchar *value = copy_value(beg + (sizeof TIT_BEGIN) - 1, strstr(beg, TIT_ENDIN));
        gchar *durat = copy_value(strstr(beg, DUR_BEGIN) + (sizeof DUR_BEGIN) - 1, (dy = strstr(beg, DUR_ENDIN)));
        if(value != NULL && durat != NULL) {
            GlyrMemCache *cont = DL_init();
            cont->data = value;
            cont->size = strlen(cont->data);
            cont->duration = strtol(durat, NULL, 10) / 1e3;
            cont->dsrc = g_strdup(url);
            collection = g_list_prepend(collection, cont);

            /* free & jump to next */
            item_ctr++;
            g_free(durat);
            beg = dy;
        }
    }
    return collection;
}
int _aix_ntv_bits_to_info(hwd_register_t *bits, char *names,
                               unsigned int *values, int name_len, int count)
{
   int i = 0;
   copy_value(bits->selector, "PowerPC64 event code", &names[i*name_len], &values[i], name_len);
   if (++i == count) return(i);
   copy_value((unsigned int)bits->counter_cmd, "PowerPC64 counter_cmd code", &names[i*name_len], &values[i], name_len);
   return(++i);
}
Exemple #4
0
/**
 * Perform a deep copy on a pair, make a new pair with copies of the branches
 */
Pair* copy_pair(Pair* pair) {
   Pair* new_pair = (Pair*) malloc(sizeof( Pair ));
   memcpy(new_pair, pair, sizeof (Pair));

   new_pair->left = copy_value(*pair->left);
   new_pair->right = copy_value(*pair->right);

   return new_pair;
}
Exemple #5
0
int
_ultra_hwd_ntv_bits_to_info( hwd_register_t * bits, char *names,
							unsigned int *values, int name_len, int count )
{
	int i = 0;
	copy_value( bits->event[0], "US Ctr 0", &names[i * name_len], &values[i],
				name_len );
	if ( ++i == count )
		return ( i );
	copy_value( bits->event[1], "US Ctr 1", &names[i * name_len], &values[i],
				name_len );
	return ( ++i );
}
Exemple #6
0
int
_papi_hwd_ntv_bits_to_info( hwd_register_t * bits, char *names,
							unsigned int *values, int name_len, int count )
{
	int i = 0;
	copy_value( bits->selector, "Available counters", &names[i * name_len],
				&values[i], name_len );
	if ( ++i == count )
		return ( i );
	int j;
	int event_found = 0;
	for ( j = 0; j < 5; j++ ) {
		if ( bits->counter_cmd[j] >= 0 ) {
			event_found = 1;
			break;
		}
	}
	if ( event_found ) {
		copy_value( bits->counter_cmd[j], "Event on first counter",
					&names[i * name_len], &values[i], name_len );
	}
	if ( ++i == count )
		return ( i );

	int group_sets = 0;
	int k;
	for ( k = 0; k < GROUP_INTS; k++ ) {
		if ( bits->group[k] )
			group_sets++;
	}
	char *msg_base = "Available group";
	char *set_id_msg = ", set ";
	char *msg = ( char * ) malloc( 30 );
	int current_group_set = 0;
	for ( k = 0; k < GROUP_INTS; k++ ) {
		if ( bits->group[k] ) {
			if ( group_sets > 1 ) {
				sprintf( msg, "%s%s%d", msg_base, set_id_msg,
						 ++current_group_set );
				copy_value( bits->group[k], msg, &names[i * name_len],
							&values[i], name_len );
			} else {
				copy_value( bits->group[k], msg_base, &names[i * name_len],
							&values[i], name_len );
			}
		}
	}

	return ( ++i );
}
Exemple #7
0
static GList * photos_flickr_parse (cb_object * capo)
{
    gchar * ph_begin = capo->cache->data;
    GList * result_list = NULL;

    while (continue_search (g_list_length (result_list),capo->s) && (ph_begin=strstr (ph_begin,LINE_BEGIN) ) != NULL)
    {
        gchar * ph_end = strstr (ph_begin,LINE_ENDIN);
        if (ph_end != NULL)
        {
            gchar * linebf = copy_value (ph_begin,ph_end);
            if (linebf != NULL)
            {
                gchar * ID = get_search_value (linebf, "id=\"","\"");
                gchar * SC = get_search_value (linebf, "secret=\"","\"");
                gchar * SV = get_search_value (linebf, "server=\"","\"");
                gchar * FR = get_search_value (linebf, "farm=\"","\"");

                GlyrMemCache * cache = DL_init();
                cache->data = g_strdup_printf ("http://farm%s.static.flickr.com/%s/%s_%s.jpg",FR,SV,ID,SC);
                cache->size = strlen (cache->data);
                result_list = g_list_prepend (result_list,cache);

                g_free (ID);
                g_free (SC);
                g_free (SV);
                g_free (FR);

                g_free (linebf);
            }
        }
    }
    return result_list;
}
Exemple #8
0
static GList * ainfo_lyricsreg_parse(cb_object * capo)
{
	GList * result_list = NULL;
	gchar * point_to_start = strstr(capo->cache->data,INFO_BEGIN);
	if(point_to_start != NULL)
	{
		gchar * opt_begin = strstr(point_to_start,OPTN_BEGIN);
		gsize skip_len = (sizeof INFO_BEGIN) - 1;
		if(opt_begin != NULL)
		{
			point_to_start = opt_begin;
			skip_len = (sizeof OPTN_BEGIN) - 1;
		}

		point_to_start += skip_len;
		gchar * end = strstr(point_to_start, INFO_ENDIN);
		if(end != NULL)
		{
			gsize info_len = end - point_to_start;
			if(info_len > 200)
			{
				gchar * info = copy_value(point_to_start, end);
				if(info != NULL)
				{
					GlyrMemCache * result = DL_init();
					result->data = info;
					result->size = info_len; 
					result_list = g_list_prepend(result_list,result);
				}
			}
		}
	}
	return result_list;
}
Exemple #9
0
GList * generic_google_parse (cb_object * capo)
{
    GList * result_list = NULL;
    gchar * find = capo->cache->data;

    while (continue_search (g_list_length (result_list),capo->s) && (find =  strstr (find+1,FIRST_RESULT) ) != NULL)
    {
        gchar * end_of_url = NULL;
        find += strlen (FIRST_RESULT);
        if ( (end_of_url = strstr (find, END_OF_URL) ) != NULL)
        {
            if (google_check_image_size (capo->s,find) == TRUE)
            {
                gchar * url = copy_value (find,end_of_url);
                if (url != NULL)
                {
                    GlyrMemCache * result = DL_init();
                    result->data = url;
                    result->size = end_of_url - find;
                    result_list = g_list_prepend (result_list,result);
                }
            }
        }
    }
    return result_list;
}
Exemple #10
0
static int
conv_string (int argc, RESULT_NODE **argv, void *item, RESULT_NODE *result, THREAD *gsl_thread)
{
    RESULT_NODE *arg     = argc > 0 ? argv [0] : NULL;

    if (! arg)
      {
        strcpy (object_error, "Missing argument: arg");
        return -1;
      }
    if (arg-> value. type == TYPE_UNDEFINED)
      {
        result-> culprit = arg-> culprit;
        arg-> culprit = NULL;
        return 0;
      }

  {
    if (arg-> value. type != TYPE_UNDEFINED)
      {
        string_value (&arg-> value);
        copy_value (&result-> value, &arg-> value);
      }

    return 0;
  }

    return 0;  /*  Just in case  */
}
Exemple #11
0
static GList * review_metallum_parse(cb_object * capo)
{
	GList * result_items = NULL;

	gsize nodelen = strlen(NODE_START);
	gchar * node  = capo->cache->data;
	gint node_ctr = 0;

	while((node = strstr(node+nodelen,NODE_START)) != NULL)
	{
		/* Only take the album url, not the other urls */
		if(++node_ctr % 2 == 0)
		{
			node += nodelen;
			gchar * content_url = copy_value(node,strstr(node,NODE_END));
			if(content_url != NULL)
			{
				gchar * review_url = strreplace(content_url,"/albums/","/reviews/");
				if(review_url != NULL)
				{
					parse_review_site(capo->s, download_single(review_url,capo->s,NULL), &result_items);
					g_free(review_url);
				}
				g_free(content_url);
			}
		}
	}
	return result_items;
}
Exemple #12
0
static GList * lyrics_metallum_parse (cb_object * capo)
{
    GList * result_items = NULL;
    gchar * id_start = strstr (capo->cache->data,ID_START);
    if (id_start != NULL)
    {
        id_start += strlen (ID_START);
        gchar * ID_string = copy_value (id_start,strstr (id_start,ID_END) );
        if (ID_string != NULL)
        {
            gchar * content_url = g_strdup_printf (SUBST_URL,ID_string);
            if (content_url != NULL)
            {
                GlyrMemCache * content_cache = download_single (content_url,capo->s,NULL);
                if (content_cache != NULL && strstr (content_cache->data,BAD_STRING) == NULL)
                {
                    result_items = g_list_prepend (result_items, content_cache);
                }
                g_free (content_url);
            }
            g_free (ID_string);
        }
    }
    return result_items;
}
Exemple #13
0
value cupl_divide(value left, value right)
/* divide two CUPL values */
{
    if (left.rank == 0 && right.rank == 0)
    {
        value	result;

        make_scalar(&result, 0);
        result.elements[0] = left.elements[0] / right.elements[0];
        return(result);
    }
    else if (right.rank == 0)
    {
        value	result;
        int	n;

        result = copy_value(left);
        for (n = 0; n < left.width * left.depth; n++)
            result.elements[n] = left.elements[n] / right.elements[0];
        return(result);
    }
    else
        die("division of rank %d by rank %d value is undefined\n",
            left.rank, right.rank);
}
Exemple #14
0
static GList * photos_lastfm_parse (cb_object * capo)
{
    gchar * root = capo->cache->data;
    GList * result_list = NULL;

    while (continue_search (g_list_length (result_list),capo->s) && (root = strstr (root,SIZE_FO) ) != NULL)
    {
        gchar * begin = root + strlen (SIZE_FO);
        if (size_fits (capo->s,&begin) == TRUE)
        {
            gchar * endin = strstr (begin,URL_ENDIN);
            if (endin != NULL)
            {
                gchar * urlb = copy_value (begin,endin);
                if (urlb != NULL)
                {
                    GlyrMemCache * cache = DL_init();
                    cache->data = urlb;
                    cache->size = strlen (urlb);
                    result_list = g_list_prepend (result_list,cache);
                }
            }
        }
        root += (sizeof SIZE_FO) - 1;
    }
    return result_list;
}
Exemple #15
0
static void parse_lyrics_page (const gchar * url, GList ** result_list, cb_object * capo)
{
    GlyrMemCache * lyrcache = download_single (url,capo->s,"<!-- eBay Relevance Ad -->");
    if (lyrcache != NULL)
    {
        gchar * lyr_begin = strstr (lyrcache->data,LYRIC_BEGIN);
        if (lyr_begin != NULL)
        {
            gchar * lyr_endin = strstr (lyr_begin,"</div>");
            if (lyr_endin != NULL)
            {
                gchar * lyrics = copy_value (lyr_begin,lyr_endin);
                if (lyrics != NULL)
                {
                    GlyrMemCache * result = DL_init();
                    result->data = strreplace (lyrics,"<br />","");
                    result->size = strlen (result->data);
                    result->dsrc = g_strdup (url);
                    *result_list = g_list_prepend (*result_list,result);
                }
                g_free (lyrics);
            }
        }
        DL_free (lyrcache);
    }
}
Exemple #16
0
static gboolean validate_artist(cb_object * capo, gchar * backpointer)
{
	gboolean i_shall_continue = false;
	if(backpointer != NULL)
	{
		char * span = strstr(backpointer,SPAN_BEGIN);
		if(span != NULL)
		{
			gchar * artist_beg = strstr(span,ARTIST_BEG);
			if(artist_beg != NULL)
			{
				artist_beg += (sizeof ARTIST_BEG) - 1;
				gchar * artist_end = strstr(artist_beg,ARTIST_END);
				if(artist_end != NULL)
				{
					gchar * artist_val = copy_value(artist_beg,artist_end);
					if(artist_val != NULL)
					{
						if(levenshtein_strnormcmp(capo->s,artist_val,capo->s->artist) <= capo->s->fuzzyness)
						{
							i_shall_continue = true;
						}
						g_free(artist_val);
					}
				}
			}
		}
	}
	return i_shall_continue;
}
int mp_snmp_subtree_get_value(const mp_snmp_subtree *subtree,
                               const oid *oid_prefix,
                               const size_t oid_prefix_len,
                               const size_t idx,
                               const u_char type,
                               void **target,
                               const size_t target_len) {
    size_t i, j = 0;

    if (!subtree || (subtree->size < 1))
        return 0;

    for (i = 0; i < subtree->size; i++) {
        if (snmp_oidtree_compare(oid_prefix,
                                 oid_prefix_len,
                                 subtree->vars[i]->name,
                                 subtree->vars[i]->name_length) == 0) {
            if (j == idx) {
                return copy_value(subtree->vars[i], type, target_len, target);
            }
            j++;
        }
    }
    return 0;
}
Exemple #18
0
GList * lyrics_lyrixat_parse (cb_object * capo)
{
    /* lyrix.at does not offer any webservice -> use the searchfield to get some results */
    GList * result_list = NULL;
    gchar * search_begin_tag = capo->cache->data;
    gint ctr = 0;

    while (continue_search (g_list_length (result_list),capo->s) && (search_begin_tag = strstr (search_begin_tag+1,SEARCH_START_TAG) ) && MAX_TRIES >= ctr++)
    {
        gchar * url_tag = search_begin_tag;
        url_tag = strstr (url_tag,URL_TAG_BEGIN);
        if (url_tag != NULL)
        {
            gchar * title_tag = strstr (url_tag,URL_TAG_ENDIN);
            if (title_tag)
            {
                gchar * title_end = strstr (title_tag,TITLE_END);
                if (title_end != NULL)
                {
                    gsize tag_end_len = (sizeof URL_TAG_ENDIN) - 1;
                    gchar * title = copy_value (title_tag + tag_end_len,title_end);
                    if (title != NULL)
                    {
                        if (levenshtein_strnormcmp (capo->s,title,capo->s->title) <= capo->s->fuzzyness)
                        {
                            gchar * url_part = copy_value (url_tag+strlen (URL_TAG_BEGIN),title_tag);
                            if (url_part != NULL)
                            {
                                gchar * url = g_strdup_printf ("http://lyrix.at/de%s",url_part);
                                parse_lyrics_page (url,&result_list,capo);
                                g_free (url);
                                g_free (url_part);
                            }
                        }
                        g_free (title);
                    }
                }
            }
        }
    }
    return result_list;
}
Exemple #19
0
value cupl_uminus(value right)
/* apply unary minus */
{
    int	n;
    value	result;

    result = copy_value(right);
    for (n = 0; n < right.width * right.depth; n++)
        result.elements[n] = -result.elements[n];
    return(result);
}
Exemple #20
0
value cupl_abs(value right)
/* apply absolute-value function */
{
    value	result;
    int	n;

    result = copy_value(right);
    for (n = 0; n < right.width * right.depth; n++)
        result.elements[n] = fabs(right.elements[n]);
    return(result);
}
Exemple #21
0
int ruleif_notification_request(const char *what, ...)
{
    va_list  ap;
    char    *argv[16];
    char  ***retval;
    char    *name;
    int      type;
    void    *value;
    int      i;
    int      status;
    int      success = FALSE;

    if (notreq < 0)
        lookup_rules();

    if (notreq >= 0) {
        retval = NULL;

        argv[i=0] = (char *)'s';
        argv[++i] = (char *)what;

        status = rule_eval(notreq, &retval, (void **)argv, (i+1)/2);

        OHM_DEBUG(DBG_RULE, "rule_eval returned %d (retval %p)",status,retval);

        if (status <= 0) {
            if (retval && status < 0)
                rules_dump_result(retval);
        }
        else {
            if (OHM_LOGGED(INFO))
                rules_dump_result(retval);

            if (retval && retval[0] != NULL && retval[1] == NULL) {

                success = TRUE;

                va_start(ap, what);

                while ((name = va_arg(ap, char *)) != NULL) {
                    type  = va_arg(ap, int);
                    value = va_arg(ap, void *);

                    if (!copy_value(name, type, value, retval[0])) {
                        success = FALSE;
                        break;
                    }
                }
                    
                va_end(ap);                    
            }
        }
Exemple #22
0
static struct lp_list *copy_list(struct lp_list *l) {
  int c;
  struct lp_list *result = calloc(1, sizeof(*result));
  memcpy(result, l, sizeof(struct lp_list));
  result->values = calloc(l->values_len, sizeof(result->values[0]));
  memcpy(result->values, l->values, l->values_len * sizeof(int *));
  for(c = 0; c < l->values_len; c++) {
    if(l->values[c]) {
      result->values[c] = copy_value(l->values[c]);
    }
  }
  return result;
}
Exemple #23
0
static GList * ainfo_allmusic_parse(cb_object * capo)
{
	GList * result_list = NULL;

	/* Are we already on the biopage? */
	if(strstr(capo->cache->data, "<!--Begin Biography -->"))
	{
		GlyrMemCache * info_long = find_long_version(capo->s,capo->cache);
		if(info_long != NULL)
		{
			result_list = g_list_prepend(result_list,info_long);
		}
		return result_list;
	}

	gchar * search_begin = NULL;

	/* Hello, anybody there? */
	if((search_begin = strstr(capo->cache->data, SEARCH_TREE_BEGIN)) == NULL)
	{
		return NULL;
	}

	gsize nodelen = (sizeof SEARCH_NODE) - 1;
	gchar * node  = search_begin;
	while(continue_search(g_list_length(result_list),capo->s) && (node = strstr(node + nodelen,SEARCH_NODE)))
	{
		gchar * end_of_url = strstr(node,SEARCH_DELIM);
		if(approve_content(capo->s,end_of_url) == TRUE)
		{
			gchar * url = copy_value(node + nodelen, end_of_url);
			if(url != NULL)
			{
				gchar * biography_url = g_strdup_printf("%s/biography",url);
				GlyrMemCache * dl_cache = download_single(biography_url,capo->s,NULL);
				if(dl_cache != NULL)
				{
					GlyrMemCache * content = parse_bio_page(dl_cache,biography_url);
					if(content != NULL)
					{
						result_list = g_list_prepend(result_list,content);
					}
					DL_free(dl_cache);
				}
				g_free(biography_url);
				g_free(url);
			}
		}
	}
	return result_list;
}
Exemple #24
0
// Compare response, so lyricswiki's search did not fool us
static gboolean lv_cmp_content(const gchar * to_artist, const gchar * to_title, cb_object * capo)
{
    gboolean res = false;
    if(to_artist && to_title && capo)
    {
        gchar * tmp_artist = copy_value(to_artist,strstr(to_artist,"</artist>"));
        if(tmp_artist != NULL)
        {
            gchar * tmp_title = copy_value(to_title, strstr(to_title ,"</song>" ));
            if(tmp_title != NULL)
            {
                /* levenshtein_strnormcmp takes care of those brackets */
                if((levenshtein_strnormcmp(capo->s,capo->s->artist,tmp_artist) <= capo->s->fuzzyness &&
                    levenshtein_strnormcmp(capo->s,capo->s->title, tmp_title)  <= capo->s->fuzzyness ))
                {
                    res = true;
                }
                g_free(tmp_title);
            }
            g_free(tmp_artist);
        }
    }
    return res;
}
Exemple #25
0
static GList * cover_albumart_parse (cb_object * capo)
{
    GList * result_list = NULL;
    gchar * node = strstr (capo->cache->data,NODE_START);
    if (node != NULL)
    {
        /* Decide what size we want */
        gsize size_it = 2;
        if (capo->s->img_max_size < 450 && capo->s->img_max_size != -1 && capo->s->img_min_size < 160)
        {
            size_it = 1;
        }

        /* Go through all nodes */
        while (continue_search (g_list_length (result_list),capo->s) && (node = strstr (node + (sizeof NODE_NEXT) - 1,NODE_NEXT) ) )
        {
            gchar * img_tag = node;
            gchar * img_end = NULL;

            gchar * album_name = get_search_value (node,"title=\"","\"");
            if (levenshtein_strnormcmp (capo->s,album_name,capo->s->album) <= capo->s->fuzzyness)
            {
                for (gsize it = 0; it < size_it; it++, img_tag += (sizeof AMZ) - 1)
                {
                    if ( (img_tag = strstr (img_tag,AMZ) ) == NULL)
                    {
                        break;
                    }
                }

                if ( (img_end  = strstr (img_tag,IMG_FORMAT) ) != NULL)
                {
                    gchar * img_url = copy_value (img_tag,img_end);
                    if (img_url != NULL)
                    {
                        GlyrMemCache * result = DL_init();
                        result->data = g_strdup_printf (AMZ"%s"IMG_FORMAT, img_url);
                        result->size = strlen (result->data);
                        result_list = g_list_prepend (result_list,result);
                        g_free (img_url);
                    }
                }
            }
            g_free (album_name);
        }
    }
    return result_list;
}
Exemple #26
0
value cupl_subtract(value left, value right)
/* subtract two CUPL values */
{
    if (!CONGRUENT(left, right))
        die("subtract failed, operands of different sizes or ranks\n");
    else
    {
        value	result;
        int	n;

        result = copy_value(right);
        for (n = 0; n < left.width * left.depth; n++)
            result.elements[n] = left.elements[n] - right.elements[n];
        return(result);
    }
}
Exemple #27
0
static GList * lyrics_lyrdb_parse (cb_object * capo)
{
    gchar *slash = NULL;
    GList * result_list = NULL;

    if ( (slash = strchr (capo->cache->data,'\\') ) != NULL)
    {
        gchar * uID = copy_value (capo->cache->data,slash);
        if (uID != NULL)
        {
            gchar * lyr_url = g_strdup_printf ("http://webservices.lyrdb.com/getlyr.php?q=%s",uID);
            if (lyr_url != NULL)
            {
                GlyrMemCache * new_cache = download_single (lyr_url,capo->s,NULL);
                if (new_cache != NULL)
                {
                    gsize i = 0;
                    gchar * buffer = g_malloc0 (new_cache->size + 1);
                    for (i = 0; i < new_cache->size; i++)
                    {
                        buffer[i] = (new_cache->data[i] == '\r') ?
                                    ' ' :
                                    new_cache->data[i];
                    }
                    buffer[i] = 0;

                    if (i != 0)
                    {
                        GlyrMemCache * result = DL_init();
                        result->data = buffer;
                        result->size = i;
                        result->dsrc = g_strdup (lyr_url);

                        result_list = g_list_prepend (result_list,result);
                    }

                    DL_free (new_cache);
                }
                g_free (lyr_url);
            }
            g_free (uID);
        }
    }
    return result_list;
}
Exemple #28
0
static GList * lyrics_lyricstime_parse(cb_object * capo)
{
	GList * rList = NULL;
	char * start = capo->cache->data;
	if(start != NULL)
	{
		gchar * div_end = strstr(start,SEARCH_ENDIN);
		gchar * node = capo->cache->data;
		gchar * backpointer = node;
		gsize nlen = (sizeof NODE_BEGIN) - 1;

		while(continue_search(g_list_length(rList),capo->s) && (node = strstr(node+nlen,NODE_BEGIN)) != NULL)
		{
			if(div_end >= node)
				break;

			if(validate_artist(capo,backpointer) == TRUE)
			{
				gchar * end_of_url = strstr(node+nlen,NODE_ENDIN);
				if(end_of_url != NULL)
				{
					gchar * url = copy_value(node+nlen,end_of_url);
					if(url != NULL)
					{
						gchar * full_url = g_strdup_printf("http://www.lyricstime.com%s",url);
						GlyrMemCache * dl_cache = download_single(full_url,capo->s,NULL);
						if(dl_cache)
						{
							GlyrMemCache * parsed_cache = parse_page(dl_cache,capo);
							if(parsed_cache != NULL)
							{
								rList = g_list_prepend(rList,parsed_cache);
							}
							DL_free(dl_cache);
							g_free(full_url);
						}
						g_free(url);
					}
				}
			}
			backpointer = node;
		}
	}
	return rList;
}
Exemple #29
0
/* Wrap around the (a bit more) generic versions */
static GList * tags_musicbrainz_parse (cb_object * capo)
{
    GList * results = NULL;
    gint mbid_marker = 0;
    while (continue_search (g_list_length (results), capo->s) )
    {
        GlyrMemCache  * info = generic_musicbrainz_parse (capo,&mbid_marker,"tags");
        if (info == NULL)
        {
            break;
        }

        gint type_num = please_what_type (capo->s);
        gchar * tag_node = info->data;
        while ( (tag_node = strstr (tag_node + 1,"<tag") ) )
        {
            gchar * tag_begin = strchr (tag_node+1,'>');
            if (!tag_begin)
                continue;

            tag_begin++;
            gchar * tag_endin = strchr (tag_begin,'<');
            if (!tag_endin)
                continue;

            gchar * value = copy_value (tag_begin,tag_endin);
            if (value != NULL)
            {
                if (strlen (value) > 0)
                {
                    GlyrMemCache * tmp = DL_init();
                    tmp->data = value;
                    tmp->size = tag_endin - tag_begin;
                    tmp->type = type_num;
                    tmp->dsrc = g_strdup (info->dsrc);

                    results = g_list_prepend (results,tmp);
                }
            }
        }
        DL_free (info);
    }
    return results;
}
Exemple #30
0
static gboolean check_size (const char * art_root, const char *hw, cb_object * capo)
{
    gchar * begin = strstr (art_root,hw);
    if (begin != NULL)
    {
        gchar * end = strchr (begin,' ');
        gchar * buf = copy_value (begin+strlen (hw),end);
        if (buf != NULL)
        {
            gint atoid = strtol (buf,NULL,10);
            g_free (buf);

            if ( (atoid >= capo->s->img_min_size || capo->s->img_min_size == -1) &&
                    (atoid <= capo->s->img_max_size || capo->s->img_max_size == -1)  )
                return TRUE;
        }
    }
    return FALSE;
}