GList * parse_result_page(GlyrQuery * query, GlyrMemCache * to_parse) { GList * result_list = NULL; gchar * node = to_parse->data; while(continue_search(g_list_length(result_list),query) && (node = strstr(node,LYR_NODE))) { node += (sizeof LYR_NODE); gchar * lyr = get_search_value(node,LYR_BEGIN,LYR_ENDIN); gchar * beautiness_test = beautify_string(lyr); if(beautiness_test != NULL && beautiness_test[0]) { if(lyr != NULL && strstr(lyr,BAD_STRING) == NULL && strstr(lyr,EXTERNAL_LINKS) == NULL) { GlyrMemCache * result = DL_init(); result->data = lyr; result->size = strlen(result->data); result->dsrc = g_strdup(to_parse->dsrc); result_list = g_list_prepend(result_list,result); } } else { g_free(lyr); } g_free(beautiness_test); } return result_list; }
static GlyrMemCache * parse_page(GlyrMemCache * dl, cb_object * capo) { GlyrMemCache * result = NULL; if(dl != NULL) { gchar * begin = strstr(dl->data,LYR_BEGIN); if(begin != NULL) { begin += (sizeof LYR_BEGIN) - 1; gchar * end = strstr(begin,LYR_ENDIN); if(end != NULL) { *(end) = 0; gchar * no_br_tags = strreplace(begin,"<br />",NULL); if(no_br_tags != NULL) { result = DL_init(); result->data = beautify_string(no_br_tags); result->size = (result->data) ? strlen(result->data) : 0; result->dsrc = g_strdup(dl->dsrc); g_free(no_br_tags); } } } } return result; }
static GList * lyrics_lyricsreg_parse (cb_object * capo) { GList * result_list = NULL; gchar * start = strstr (capo->cache->data, INFO_BEGIN); if (start != NULL) { start += (sizeof INFO_BEGIN) - 1; gchar * end = strstr (start,INFO_ENDIN); if (end != NULL) { * (end) = 0; gchar * no_br_tags = strreplace (start,"<br />",NULL); if (no_br_tags != NULL) { GlyrMemCache * tmp = DL_init(); tmp->data = beautify_string (no_br_tags); tmp->size = tmp->data ? strlen (tmp->data) : 0; g_free (no_br_tags); if (tmp->data != NULL) { result_list = g_list_prepend (result_list,tmp); } } } } return result_list; }
static GList * factory (GlyrQuery * s, GList * list, gboolean * stop_me, GList ** result_list) { /* Fix up tabs, escape chars etc. */ for (GList * elem = list; elem; elem = elem->next) { GlyrMemCache * item = elem->data; if (item != NULL) { gchar * temp = beautify_string (item->data); g_free (item->data); item->data = temp; item->size = (item->data) ? strlen (item->data) : 0; } } /* Let the rest do by the norma generic finalizer */ return generic_txt_finalizer (s,list,stop_me,GLYR_TYPE_GUITARTABS,result_list); }
static gchar * translate_string (gchar * string) { gchar * result = NULL; if (string != NULL) { gchar * beautiful = beautify_string (string); if (beautiful != NULL) { gchar * downcase = g_utf8_strdown (beautiful,-1); if (downcase != NULL) { result = translate_umlauts (downcase); g_free (downcase); } g_free (beautiful); } } return result; }
GList * parse_result_page (GlyrQuery * query, GlyrMemCache * to_parse) { GList * result_list = NULL; gchar * node = to_parse->data; while (continue_search (g_list_length (result_list),query) && (node = strstr (node,LYR_NODE))) { node += (sizeof LYR_NODE); char *script_tag = strstr(node, LYR_SCRIPT_TAG); char *end_tag = strstr(node, LYR_ENDIN); if(script_tag && script_tag < end_tag) { node = script_tag + sizeof(LYR_SCRIPT_TAG) - 1; } bool is_instrumental = strstr(node, LYR_INSTRUMENTAL) != NULL; gchar * lyr = get_search_value (node,LYR_BEGIN,LYR_ENDIN); gchar * beautiness_test = beautify_string (lyr); if (is_instrumental || (beautiness_test != NULL && beautiness_test[0])) { if (is_instrumental || (lyr != NULL && strstr (lyr,BAD_STRING) == NULL && strstr (lyr,EXTERNAL_LINKS) == NULL)) { GlyrMemCache * result = DL_init(); if(is_instrumental) result->data = g_strdup("Instrumental"); else result->data = lyr; result->size = strlen (result->data); result->dsrc = g_strdup (to_parse->dsrc); result_list = g_list_prepend (result_list,result); } } else { g_free (lyr); } g_free (beautiness_test); } return result_list; }