int compare_freq(const void *a, const void *b) { lia_avl_t *c,*d; c=(lia_avl_t *)a; d=(lia_avl_t *)b; return compare_info((*d)->info,(*c)->info); }
lia_avl_t lia_recherche_avl(lia_avl_t racine, type_info *info) { int comp; if (racine==NULL) return NULL; if ((comp=compare_info(racine->info,info))==0) return racine; if (comp>0) return lia_recherche_avl(racine->fg,info); else return lia_recherche_avl(racine->fd,info); }
lia_avl_t lia_insere_avl(lia_avl_t racine, type_info *info, char *si_augm,int avec_reequilibrage,char *mesg) { int comp; if (racine==NULL) { *si_augm=1; return new_tree_mot_node(info); } comp=compare_info(racine->info,info); if (comp==0) { /* message -> le noeud est deja dans l'arbre */ if (VERBOSE) sprintf(mesg,"noeud [%s] deja present",info->key_string); add_type_info(info,racine->info); /* from info1 to info2 */ delete_type_info(info); *si_augm=0; } else if (comp>0) { /* sur le fils gauche */ racine->fg=lia_insere_avl(racine->fg,info,si_augm,avec_reequilibrage,mesg); if (*si_augm) { if (racine->dq<0) *si_augm=0; racine->dq++; } /* eventuelle rotation */ if ((avec_reequilibrage)&&(racine->dq==2)) { lia_reequilibre_droite(racine,mesg,si_augm); *si_augm=0; } } else { /* sur le fils droit */ racine->fd=lia_insere_avl(racine->fd,info,si_augm,avec_reequilibrage,mesg); if (*si_augm) { if (racine->dq>0) *si_augm=0; racine->dq--; } /* eventuelle rotation */ if ((avec_reequilibrage)&&(racine->dq==-2)) { lia_reequilibre_gauche(racine,mesg,si_augm); *si_augm=0; } } return racine; }
static BOOL CALLBACK find_best_locale_proc(HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam) { locale_search_t *res = (locale_search_t *)lParam; const LCID lcid = MAKELCID(LangID, SORT_DEFAULT); char buff[MAX_ELEM_LEN]; unsigned int flags = 0; if(PRIMARYLANGID(LangID) == LANG_NEUTRAL) return CONTINUE_LOOKING; /* Check Language */ if (compare_info(lcid,LOCALE_SISO639LANGNAME,buff,res->search_language) || compare_info(lcid,LOCALE_SABBREVLANGNAME,buff,res->search_language) || compare_info(lcid,LOCALE_SENGLANGUAGE,buff,res->search_language)) { TRACE(":Found language: %s->%s\n", res->search_language, buff); flags |= FOUND_LANGUAGE; memcpy(res->found_language,res->search_language,MAX_ELEM_LEN); } else if (res->match_flags & FOUND_LANGUAGE) { return CONTINUE_LOOKING; } /* Check Country */ if (compare_info(lcid,LOCALE_SISO3166CTRYNAME,buff,res->search_country) || compare_info(lcid,LOCALE_SABBREVCTRYNAME,buff,res->search_country) || compare_info(lcid,LOCALE_SENGCOUNTRY,buff,res->search_country)) { TRACE("Found country:%s->%s\n", res->search_country, buff); flags |= FOUND_COUNTRY; memcpy(res->found_country,res->search_country,MAX_ELEM_LEN); } else if (res->match_flags & FOUND_COUNTRY) { return CONTINUE_LOOKING; } /* Check codepage */ if (compare_info(lcid,LOCALE_IDEFAULTCODEPAGE,buff,res->search_codepage) || (compare_info(lcid,LOCALE_IDEFAULTANSICODEPAGE,buff,res->search_codepage))) { TRACE("Found codepage:%s->%s\n", res->search_codepage, buff); flags |= FOUND_CODEPAGE; memcpy(res->found_codepage,res->search_codepage,MAX_ELEM_LEN); } else if (res->match_flags & FOUND_CODEPAGE) { return CONTINUE_LOOKING; } if (flags > res->match_flags) { /* Found a better match than previously */ res->match_flags = flags; res->found_lang_id = LangID; } if ((flags & (FOUND_LANGUAGE | FOUND_COUNTRY | FOUND_CODEPAGE)) == (FOUND_LANGUAGE | FOUND_COUNTRY | FOUND_CODEPAGE)) { TRACE(":found exact locale match\n"); return STOP_LOOKING; } return CONTINUE_LOOKING; }