// get text from master address entry, check if prefix matches radio buttons, // modify and write back if needed static void master_check_master_addr_prefix(void) { const gchar *pos; const gchar *master_addr; gchar *master_tmp_addr; master_addr= gtk_entry_get_text(GTK_ENTRY (GTK_COMBO(master_addr_combo)->entry)); // Replace up to :// with master type selected from radio buttons if (g_ascii_strncasecmp(master_addr, master_prefixes[current_master_query_type], strlen(master_prefixes[current_master_query_type]))) { pos = lowcasestrstr(master_addr,"://"); if (!pos) { pos = master_addr; } else { // +"://" pos+=3; } // Add lan://255.255.255.255 if user picks LAN and has not already entered an address if (current_master_query_type==MASTER_LAN && (strlen(master_addr) <= (size_t)(pos - master_addr))) { char *txt = g_strdup_printf("%s%s", master_prefixes[current_master_query_type], "255.255.255.255"); gtk_entry_set_text( GTK_ENTRY(GTK_COMBO(master_addr_combo)->entry), txt); g_free(txt); } // Otherwise, just change the master type (xxx://) else { master_tmp_addr = g_strconcat(master_prefixes[current_master_query_type], pos, NULL); gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(master_addr_combo)->entry), master_tmp_addr); g_free(master_tmp_addr); } } }
int player_filter (struct server *s) { /* The 'vars' is ignored in this function, however, since we need it for applying the server filter, we will put it in the arguments. */ GSList *list; GSList *plist; struct player_pattern *pp; struct player *p; s->flags &= ~PLAYER_GROUP_MASK; if (!s->players) return FALSE; for (plist = s->players; plist; plist = plist->next) { p = (struct player *) plist->data; p->flags &= ~PLAYER_GROUP_MASK; } if (!players) return FALSE; for (list = players; list; list = list->next) { pp = (struct player_pattern *) list->data; for (plist = s->players; plist; plist = plist->next) { p = (struct player *) plist->data; if (pp->data && !pp->error) { if ((pp->mode == PATTERN_MODE_STRING && g_strcasecmp (p->name, pp->data) == 0) || (pp->mode == PATTERN_MODE_SUBSTR && lowcasestrstr (p->name, pp->data)) || (pp->mode == PATTERN_MODE_REGEXP && regexec ((regex_t *) pp->data, p->name, 0, NULL, 0) == 0)) { p->flags |= pp->groups; s->flags |= pp->groups; } } } } return ((s->flags & PLAYER_GROUP_MASK) != 0)? TRUE : FALSE; }