static INLINE void send_event(part_evtlist_t *evlist, void **val, bool (*match_func)(void **a, void **b)) { elistdata_t eld_p; mempart_evt_t *reg_event = get_first_event(evlist, &eld_p); while (reg_event != NULL) { struct evt_info_s *evt = ®_event->evt_reg; if (reg_event->onlist == &evlist->active) { /* if this event has been deactivated, don't send it */ if (evt->flags & evtflags_DEACTIVATE) { deactivate_event(evlist, (part_evt_t *)reg_event); } /* check for event send conditions */ else if (reg_event->evt_dest.rcvid > 0) { void **compare_val_p = GET_COMPARE_VAL_P(evt); CRASHCHECK(compare_val_p == NULL); /* * if the caller did not provide a match function, or a match * function was provided and it returns TRUE, deliver the event */ if ((match_func == NULL) || (match_func(compare_val_p, val) == bool_t_TRUE)) { int r; struct sigevent se = evt->sig; // make a local copy /* * if the caller has set evtflags_SIGEV_FLAG_SIGINFO, we * can return some useful information */ if (evt->flags & evtflags_SIGEV_FLAG_SIGINFO) { se.sigev_value.sival_ptr = *val; } r = apm_deliver_event(®_event->evt_dest, &se); if (r == EOK) reg_event->undeliverable_count = 0; else if (r == ESRCH) ++reg_event->undeliverable_count; if ((reg_event->undeliverable_count > ORPHAN_RETRY_COUNT) || (!(evt->flags & evtflags_REARM))) { /* remove the event from the list */ deactivate_event(evlist, (part_evt_t *)reg_event); } } } } reg_event = get_next_event(evlist, reg_event, &eld_p); } }
static const gchar * get_media_url (SnapdSnap *snap, gboolean (*match_func)(const gchar *filename)) { GPtrArray *media, *screenshots; guint i; media = snapd_snap_get_media (snap); for (i = 0; i < media->len; i++) { SnapdMedia *m = media->pdata[i]; /* FIXME: In the future there will be a media type for these */ /* Fall back to old specially named screenshots */ if (g_strcmp0 (snapd_media_get_media_type (m), "screenshot") == 0) { const gchar *url; g_autofree gchar *filename = NULL; url = snapd_media_get_url (m); filename = g_path_get_basename (url); if (match_func (filename)) return url; } } /* Fall back to old screenshots */ G_GNUC_BEGIN_IGNORE_DEPRECATIONS screenshots = snapd_snap_get_screenshots (snap); G_GNUC_END_IGNORE_DEPRECATIONS for (i = 0; i < screenshots->len; i++) { SnapdScreenshot *screenshot = screenshots->pdata[i]; const gchar *url; g_autofree gchar *filename = NULL; url = snapd_screenshot_get_url (screenshot); filename = g_path_get_basename (url); if (match_func (filename)) return url; } return NULL; }
krb5_error_code _adcli_krb5_keytab_clear (krb5_context k5, krb5_keytab keytab, krb5_boolean (* match_func) (krb5_context, krb5_keytab_entry *, void *), void *match_data) { krb5_kt_cursor cursor; krb5_keytab_entry entry; krb5_error_code code; code = krb5_kt_start_seq_get (k5, keytab, &cursor); if (code == KRB5_KT_END || code == ENOENT) return 0; else if (code != 0) return code; for (;;) { code = krb5_kt_next_entry (k5, keytab, &entry, &cursor); if (code != 0) break; /* See if we should remove this entry */ if (!match_func (k5, &entry, match_data)) { krb5_free_keytab_entry_contents (k5, &entry); continue; } /* * Here we close the cursor, remove the entry and then * start all over again from the beginning. Dumb but works. */ code = krb5_kt_end_seq_get (k5, keytab, &cursor); return_val_if_fail (code == 0, code); code = krb5_kt_remove_entry (k5, keytab, &entry); krb5_free_keytab_entry_contents (k5, &entry); if (code != 0) return code; code = krb5_kt_start_seq_get (k5, keytab, &cursor); return_val_if_fail (code == 0, code); } if (code == KRB5_KT_END) code = 0; krb5_kt_end_seq_get (k5, keytab, &cursor); return code; }
inline Item* StaticList<Item>::find_first_unsafe( Matches match_func, const void* featuresp ) const { CORE_ASSERT(featuresp != nullptr); for (const Link* linkp = headp; linkp != nullptr; linkp = linkp->nextp) { if (match_func(linkp->itemp, featuresp)) { return linkp->itemp; } } return nullptr; }
/* Search all history actions which match "keyword" with function * match_func(action, keyword). * * @return a list of GtkAction*, to free with: * g_list_free_full (result, (GDestroyNotify) g_object_unref); */ GList * gimp_action_history_search (Gimp *gimp, GimpActionMatchFunc match_func, const gchar *keyword) { GimpGuiConfig *config; GimpUIManager *manager; GList *actions; GList *result = NULL; gint i; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (match_func != NULL, NULL); config = GIMP_GUI_CONFIG (gimp->config); manager = gimp_ui_managers_from_name ("<Image>")->data; for (actions = history.items, i = 0; actions && i < config->action_history_size; actions = g_list_next (actions), i++) { GimpActionHistoryItem *item = actions->data; GtkAction *action; action = gimp_ui_manager_find_action (manager, NULL, item->action_name); if (action == NULL) continue; if (! gtk_action_is_sensitive (action) && ! config->search_show_unavailable) continue; if (match_func (action, keyword, NULL, gimp)) result = g_list_prepend (result, g_object_ref (action)); } return g_list_reverse (result); }
/* Select NIM Device from Device List */ struct nim_device* dev_select_nim_ext(UINT32 sub_type, UINT32 status, device_match_func match_func) { UINT8 i; struct dev_manag_dev *dev_list = NULL; struct nim_device *ret_dev = NULL; ENTER_DEV_MUTEX(); dev_list = &dev_manag_list[0]; for(i=0; i <DEV_MAX_CNT; i++) { if((dev_list[i].hld_type==HLD_DEV_TYPE_NIM)&&(dev_list[i].sub_type==sub_type)&&(dev_list[i].status&status)) { //Check whether NIM Config Info Match or not if((match_func != NULL)&&(TRUE==match_func(dev_list[i].dev_handle))) ret_dev = (struct nim_device*)dev_list[i].dev_handle; else if(match_func == NULL) ret_dev = (struct nim_device*)dev_list[i].dev_handle; break; } } LEAVE_DEV_MUTEX(); return ret_dev; }
inline Item* StaticList<Item>::find_first( Matches match_func, const void* featuresp ) const { CORE_ASSERT(featuresp != nullptr); core::os::SysLock::acquire(); for (const Link* linkp = headp; linkp != nullptr; linkp = linkp->nextp) { core::os::SysLock::release(); if (match_func(*linkp->itemp, featuresp)) { return linkp->itemp; } core::os::SysLock::acquire(); } core::os::SysLock::release(); return nullptr; } // >::find_first
GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline, int level, int nolevel, const char *text, int before, int after, int regexp, int fullword, int case_sensitive) { #ifdef HAVE_REGEX_H regex_t preg; #endif LINE_REC *line, *pre_line; GList *matches; GString *str; int i, match_after, line_matched; char * (*match_func)(const char *, const char *); g_return_val_if_fail(buffer != NULL, NULL); g_return_val_if_fail(text != NULL, NULL); if (regexp) { #ifdef HAVE_REGEX_H int flags = REG_EXTENDED | REG_NOSUB | (case_sensitive ? 0 : REG_ICASE); if (regcomp(&preg, text, flags) != 0) return NULL; #else return NULL; #endif } matches = NULL; match_after = 0; str = g_string_new(NULL); line = startline != NULL ? startline : buffer->first_line; if (fullword) match_func = case_sensitive ? strstr_full : stristr_full; else match_func = case_sensitive ? strstr : stristr; for (; line != NULL; line = line->next) { line_matched = (line->info.level & level) != 0 && (line->info.level & nolevel) == 0; if (*text != '\0') { textbuffer_line2text(line, FALSE, str); if (line_matched) line_matched = #ifdef HAVE_REGEX_H regexp ? regexec(&preg, str->str, 0, NULL, 0) == 0 : #endif match_func(str->str, text) != NULL; } if (line_matched) { /* add the -before lines */ pre_line = line; for (i = 0; i < before; i++) { if (pre_line->prev == NULL || g_list_find(matches, pre_line->prev) != NULL) break; pre_line = pre_line->prev; } for (; pre_line != line; pre_line = pre_line->next) matches = g_list_append(matches, pre_line); match_after = after; } if (line_matched || match_after > 0) { /* matched */ matches = g_list_append(matches, line); if ((!line_matched && --match_after == 0) || (line_matched && match_after == 0 && before > 0)) matches = g_list_append(matches, NULL); } } #ifdef HAVE_REGEX_H if (regexp) regfree(&preg); #endif g_string_free(str, TRUE); return matches; }
GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline, int level, int nolevel, const char *text, int before, int after, int regexp, int fullword, int case_sensitive) { Regex *preg; LINE_REC *line, *pre_line; GList *matches; GString *str; int i, match_after, line_matched; char * (*match_func)(const char *, const char *); g_return_val_if_fail(buffer != NULL, NULL); g_return_val_if_fail(text != NULL, NULL); preg = NULL; if (regexp) { preg = i_regex_new(text, case_sensitive ? 0 : G_REGEX_CASELESS, 0, NULL); if (preg == NULL) return NULL; } matches = NULL; match_after = 0; str = g_string_new(NULL); line = startline != NULL ? startline : buffer->first_line; if (fullword) match_func = case_sensitive ? strstr_full : stristr_full; else match_func = case_sensitive ? strstr : stristr; for (; line != NULL; line = line->next) { line_matched = (line->info.level & level) != 0 && (line->info.level & nolevel) == 0; if (*text != '\0') { textbuffer_line2text(line, FALSE, str); if (line_matched) { line_matched = regexp ? i_regex_match(preg, str->str, 0, NULL) : match_func(str->str, text) != NULL; } } if (line_matched) { /* add the -before lines */ pre_line = line; for (i = 0; i < before; i++) { if (pre_line->prev == NULL || g_list_nth_data(matches, 0) == pre_line->prev || g_list_nth_data(matches, 1) == pre_line->prev) break; pre_line = pre_line->prev; } for (; pre_line != line; pre_line = pre_line->next) matches = g_list_prepend(matches, pre_line); match_after = after; } if (line_matched || match_after > 0) { /* matched */ matches = g_list_prepend(matches, line); if ((!line_matched && --match_after == 0) || (line_matched && match_after == 0 && before > 0)) matches = g_list_prepend(matches, NULL); } } matches = g_list_reverse(matches); if (preg != NULL) i_regex_unref(preg); g_string_free(str, TRUE); return matches; }