void ui_find(int next) { int item = -1; static char findstr[MAX_FIELD_LEN]; int search_fields[] = {NAME, EMAIL, NICK, -1}; clear_statusline(); if(next) { if(!*findstr) return; } else { char *s; s = ui_readline("/", findstr, MAX_FIELD_LEN - 1, 0); refresh_screen(); if(s == NULL) { return; /* user cancelled (ctrl-G) */ } else { strncpy(findstr, s, MAX_FIELD_LEN); free(s); } } if( (item = find_item(findstr, list_get_curitem() + !!next, search_fields)) < 0 && (item = find_item(findstr, 0, search_fields)) >= 0) statusline_addstr(_("Search hit bottom, continuing at top")); if(item >= 0) { list_set_curitem(item); refresh_list(); } }
void do_flashall(void) { char *fname; void *data; unsigned sz; queue_info_dump(); fb_queue_query_save("product", cur_product, sizeof(cur_product)); fname = find_item("info", product); if (fname == 0) die("cannot find android-info.txt"); data = load_file(fname, &sz); if (data == 0) die("could not load android-info.txt"); setup_requirements(data, sz); fname = find_item("boot", product); data = load_file(fname, &sz); if (data == 0) die("could not load boot.img"); do_send_signature(fname); fb_queue_flash("boot", data, sz); fname = find_item("recovery", product); data = load_file(fname, &sz); if (data != 0) { do_send_signature(fname); fb_queue_flash("recovery", data, sz); } fname = find_item("system", product); data = load_file(fname, &sz); if (data == 0) die("could not load system.img"); do_send_signature(fname); fb_queue_flash("system", data, sz); }
void do_flashall(usb_handle *usb, int erase_first) { queue_info_dump(); fb_queue_query_save("product", cur_product, sizeof(cur_product)); char* fname = find_item("info", product); if (fname == 0) die("cannot find android-info.txt"); unsigned sz; void* data = load_file(fname, &sz); if (data == 0) die("could not load android-info.txt: %s", strerror(errno)); setup_requirements(reinterpret_cast<char*>(data), sz); for (size_t i = 0; i < ARRAY_SIZE(images); i++) { fname = find_item(images[i].part_name, product); fastboot_buffer buf; if (load_buf(usb, fname, &buf)) { if (images[i].is_optional) continue; die("could not load %s\n", images[i].img_name); } do_send_signature(fname); if (erase_first && needs_erase(usb, images[i].part_name)) { fb_queue_erase(images[i].part_name); } flash_buf(images[i].part_name, &buf); } }
void Mixer::sm_active ( bool b ) { sm_blinker->value( b ); sm_blinker->tooltip( nsm->session_manager_name() ); if ( b ) { find_item( menubar, "&Project/&Open" )->deactivate(); find_item( menubar, "&Project/&New" )->deactivate(); } }
static IconLoaderItem* get_or_create_item(Items& items, const char* name, IconSizes sz, IconContext ctx, IconTheme* theme, Fl_Widget* widg, bool scale_icon) { IconLoaderItem* item = find_item(items, name, sz); if(!item) { item = new IconLoaderItem; item->name = name; item->path = theme->find_icon(name, sz, ctx); item->size = sz; item->size_wh = 0; item->context = ctx; item->widget = widg; /* see if we are going to look scaled version */ if(scale_icon) item->size_wh = (int)sz; /* register it */ items.push_back(item); } return item; }
z_status zp_parser::parse_item(void*& p_item, ctext item_entry_name ) { //ZTF; z_status status; const zp_factory* ie=find_item(item_entry_name); if(ie==0) return zs_no_entry_for_item; void* obj=ie->create_obj(); context_set_root(obj,ie,0); reset_results(); status=_process_template(zp_mode_parse_input); if(status==zs_matched) { ZT("==========ITEM[%s] MATCHED, CREATING=====\n",item_entry_name); index_reset(); context_get_current_template_parser().index_reset(); reset_results(); status=_process_template(zp_mode_parse_create); p_item=obj; } return status; }
t_size find_or_add_guid(const GUID & guid) { t_size index = find_item(guid); if (index == pfc_infinite) index = add_item(guid); return index; }
void l_earth_station(void) { pob o; print1("The tendrilled mass reaches out for you from the muddy ooze."); if (find_item(&o,OB_SALT_WATER,-1)) print2("A splash of salt water does nothing to dissuade the vines."); morewait(); print1("Enter the overgrown mire? [yn] "); if (ynq1()=='y') { if (Player.hp == 1) p_death("being eaten alive"); else Player.hp = 1; dataprint(); print1("You are being dragged into the muck. Suckers bite you...."); print2("You're about to be entangled.... Leave the mud? [yn] "); if (ynq2()=='y') print2("Phew! That was close!"); else { Player.str -= (15+random_range(15)); if (Player.str > 0) { print1("That's odd, the vine withdraws...."); print2("A spatter of dirt sprays into the void nearby."); Level->site[Player.x][Player.y].locchar = FLOOR; Level->site[Player.x][Player.y].p_locf = L_NO_OP; stationcheck(); } else { print2("The tendril has destroyed your strength!"); p_death("the Essence of Earth"); } } } else print2("You step back from the ominous vegetation."); }
void find_path(const std::string& from, const std::string& to) { auto first = std::find_if(words.begin(), words.end(), [&from](const std::shared_ptr<Item>& item)->bool { return dict[item->word_id] == from; }); if (first == words.end()) { std::cout << "missing " << from << std::endl; return; } auto second = std::find_if(words.begin(), words.end(), [&to](const std::shared_ptr<Item>& item)->bool { return dict[item->word_id] == to; }); if (second == words.end()){ std::cout << "missing " << to << std::endl; return; } auto l = *first; auto r = *second; visited_t visited; array_t path; std::size_t lenmax = 11; find_item(lenmax, l, r, path, visited); std::cout << "hit_reached " << hit_reached << std::endl; }
void output_manager::set_value(const char *outname, int32_t value) { output_item *item = find_item(outname); int32_t oldval; /* if no item of that name, create a new one and send the item's state */ if (item == nullptr) { item = create_new_item(outname, value); oldval = value + 1; } else { /* set the new value */ oldval = item->value; item->value = value; } /* if the value is different, signal the notifier */ if (oldval != value) { if (OUTPUT_VERBOSE) machine().logerror("Output %s = %d (was %d)\n", outname, value, oldval); /* call the local notifiers first */ for (auto notify : item->notifylist) (*notify.m_notifier)(outname, value, notify.m_param); /* call the global notifiers next */ for (auto notify : m_global_notifylist) (*notify.m_notifier)(outname, value, notify.m_param); } }
/* delete a symbol from the map (if it is in there) */ static void index_delete(t_index *x, t_symbol *s, int argc, t_atom*argv) { int idx=-1; ZEXY_USEVAR(s); if(argc!=1){ error("index :: delete what ?"); return; } else { if(argv->a_type==A_FLOAT){ idx=atom_getint(argv)-1; } else if (argv->a_type==A_SYMBOL){ idx=find_item(atom_getsymbol(argv),x->names, x->maxentries); } else { error("index :: delete what ?"); return; } } if ( idx >= 0 && idx < x->maxentries) { x->names[idx]=0; x->entries--; outlet_float(x->x_obj.ob_outlet, 0.0); } else { z_verbose(1, "index :: couldn't find element"); outlet_float(x->x_obj.ob_outlet, -1.0); } }
static void ecal_objects_removed (ECalView *ecalview, GList *uids, DatesNavigatorModel * nav) { ECal *ecal = e_cal_view_get_client (ecalview); GtkTreeIter iter; GtkListStore * store = GTK_LIST_STORE (gtk_tree_model_filter_get_model ( GTK_TREE_MODEL_FILTER (nav))); for (; uids; uids = uids->next) { gchar *uri_uid; #ifdef HAVE_CID_TYPE ECalComponentId *id = uids->data; uri_uid = g_strconcat (e_cal_get_uri (ecal), id->uid, NULL); #else uri_uid = g_strconcat (e_cal_get_uri (ecal), uids->data, NULL); #endif if (find_item (store, uri_uid, &iter)) gtk_list_store_remove (store, &iter); g_free (uri_uid); } }
void search(void) { int i, stock_number; printf("Stock number: "); scanf("%d", &stock_number); i = find_item(stock_number); if (i >= 0) { printf("Stock No: %d\n", catalog[i].stock_number); printf("Price: %.2f\n", catalog[i].price); printf("Item Type: "); switch (catalog[i].item_type) { case 0: puts("Book"); printf("Title: %s\n", catalog[i].item.book.title); printf("Author: %s\n", catalog[i].item.book.author); printf("Pages: %d\n", catalog[i].item.book.num_pages); break; case 1: puts("Mug"); printf("Design: %s\n", catalog[i].item.mug.design); break; case 2: puts("Shirt"); printf("Design: %s\n", catalog[i].item.shirt.design); printf("Colors: %d\n", catalog[i].item.shirt.colors); printf("Sizes: %d\n", catalog[i].item.shirt.sizes); break; } } else { puts("No such item."); } }
void output_set_value(const char *outname, INT32 value) { output_item *item = find_item(outname); INT32 oldval; /* if no item of that name, create a new one and send the item's state */ if (item == NULL) { item = create_new_item(outname, value); oldval = value + 1; } else { /* set the new value */ oldval = item->value; item->value = value; } /* if the value is different, signal the notifier */ if (oldval != value) { /* call the local notifiers first */ for (output_notify *notify = item->notifylist.first(); notify != NULL; notify = notify->next()) (*notify->m_notifier)(outname, value, notify->m_param); /* call the global notifiers next */ for (output_notify *notify = global_notifylist.first(); notify != NULL; notify = notify->next()) (*notify->m_notifier)(outname, value, notify->m_param); } }
static HRESULT WINAPI PropertyBag_Read(IPropertyBag2 *iface, ULONG cProperties, PROPBAG2 *pPropBag, IErrorLog *pErrLog, VARIANT *pvarValue, HRESULT *phrError) { HRESULT res = S_OK; ULONG i; PropertyBag *This = impl_from_IPropertyBag2(iface); TRACE("(%p,%u,%p,%p,%p,%p)\n", iface, cProperties, pPropBag, pErrLog, pvarValue, phrError); for (i=0; i < cProperties; i++) { LONG idx; if (pPropBag[i].dwHint && pPropBag[i].dwHint <= This->prop_count) idx = pPropBag[i].dwHint-1; else idx = find_item(This, pPropBag[i].pstrName); if (idx > -1) { VariantInit(pvarValue+i); res = VariantCopy(pvarValue+i, This->values+idx); if (FAILED(res)) break; phrError[i] = res; } else { res = E_FAIL; break; } } return res; }
int custom_get_string(const char *module, const char *key, char *value, const char *default_value) { ItemNode *node; pthread_mutex_lock(&parseMutex); if (!initDone) { if (parse_file("/system/etc/custom.conf")) initDone = 1; else { pthread_mutex_unlock(&parseMutex); goto find_fail; } } pthread_mutex_unlock(&parseMutex); node = find_item(module, key); if (!node) goto find_fail; strcpy(value, node->value); return strlen(node->value); find_fail: if (default_value) { strcpy(value, default_value); return strlen(default_value); } return -1; }
void find_item(std::size_t& lenmax, const array_t::value_type& from, const array_t::value_type& to, array_t& path = array_t(), visited_t& visited = visited_t()) { if (path.size() > lenmax) return; path.push_back(from); if (from->word_id == to->word_id) { lenmax = path.size() - 2; dump(path); return; } visited.insert(std::make_pair(from->word_id, 1)); for (auto& s : from->similar) { auto hit = visited.find(s->word_id); if (hit != visited.end() && hit->second > 12535000) { hit_reached++; continue; } if (hit != visited.end()) hit->second++; // исключить зацикливание if (std::find(path.begin(), path.end(), s) != path.end()) continue; array_t another; another = path; find_item(lenmax, s, to, another, visited); } }
void output_manager::set_value(const char *outname, INT32 value) { output_item *item = find_item(outname); INT32 oldval; /* if no item of that name, create a new one and send the item's state */ if (item == nullptr) { item = create_new_item(outname, value); oldval = value + 1; } else { /* set the new value */ oldval = item->value; item->value = value; } /* if the value is different, signal the notifier */ if (oldval != value) { /* call the local notifiers first */ for (auto notify : item->notifylist) (*notify.m_notifier)(outname, value, notify.m_param); /* call the global notifiers next */ for (auto notify : m_global_notifylist) (*notify.m_notifier)(outname, value, notify.m_param); } }
char *VLlookup(char *name) { struct var *itemp; if ((itemp = find_item(name, 0)) != NULL) return itemp->str + 1 + strlen(name); return ""; }
INT32 output_get_value(const char *outname) { output_item *item = find_item(outname); /* if no item, value is 0 */ if (item == NULL) return 0; return item->value; }
// 解除 void unset(const CALLBACK_ID id) { Item *item = find_item(id); if (item != NULL) { item->id = 0; item->entry = NULL; item->arg = NULL; } }
UINT32 output_name_to_id(const char *outname) { output_item *item = find_item(outname); /* if no item, ID is 0 */ if (item == NULL) return 0; return item->id; }
/* look up a symbol in the map */ static void index_symbol(t_index *x, t_symbol *s) { int element; if ( (element = find_item(s, x->names, x->maxentries)+1) ) outlet_float(x->x_obj.ob_outlet, (t_float)element); else if (x->auto_mode) /* not yet stored: add automatically */ index_add(x, s, 0); else outlet_float(x->x_obj.ob_outlet, 0.f); /* not yet stored but do not add */ }
INT32 output_manager::get_value(const char *outname) { output_item *item = find_item(outname); /* if no item, value is 0 */ if (item == nullptr) return 0; return item->value; }
UINT32 output_manager::name_to_id(const char *outname) { output_item *item = find_item(outname); /* if no item, ID is 0 */ if (item == nullptr) return 0; return item->id; }
virtual CubitBoolean move_to(OutType* item) { typename TreeType::iterator iter = find_item(item); if(iter != mTree->end()) { mIter = iter; return CUBIT_TRUE; } return CUBIT_FALSE; }
json_t *C_monitoring__remove(json_t *arg) { json_t *id = json_object_get(arg, "id"); if (!id) return NULL; item_t *item = find_item(id); if (!item) return NULL; item_free(item); return json_true(); }
static void ecal_objects_changed (ECalView * cview, GList *objects, DatesNavigatorModel * nav) { ECal *ecal = e_cal_view_get_client (cview); GtkListStore * store = GTK_LIST_STORE (gtk_tree_model_filter_get_model ( GTK_TREE_MODEL_FILTER (nav))); for (; objects; objects = objects->next) { const char *uid = icalcomponent_get_uid (objects->data); gchar *uri_uid; GtkTreeIter iter; const gchar * summary; gchar * s = NULL; gchar time[100]; gchar * folded = NULL; if (!uid) continue; uri_uid = g_strconcat (e_cal_get_uri (ecal), uid, NULL); if (!find_item (store, uri_uid, &iter)) gtk_list_store_append (store, &iter); summary = icalcomponent_get_summary (objects->data); if (summary) folded = g_utf8_casefold (summary, -1); /* use only first 15 chars of the summary */ if (summary && g_utf8_strlen (summary, -1) > 15) { s = g_strdup (summary); gchar * p = g_utf8_offset_to_pointer (s, 15); *p = 0; summary = s; } event_time (objects->data, (gchar*)&time, sizeof(time), nav->priv->format); gtk_list_store_set (store, &iter, DN_Name, summary, DN_Time, time, DN_Uid, uri_uid, DN_NameFolded, folded, -1); g_free (uri_uid); g_free (s); g_free (folded); } }
char * VLlookup(char * name) /* * returns value of var or empty string if not there */ { struct var * itemp; if ((itemp = find_item(name, 0)) != NULL) return itemp->str + 1 + strlen(name); return ""; }
int main() { int res = EXIT_SUCCESS; ews::set_up(); try { const auto env = ews::test::environment(); auto service = ews::service(env.server_uri, env.domain, env.username, env.password); // First create a draft message ews::distinguished_folder_id drafts = ews::standard_folder::drafts; auto message = ews::message(); message.set_subject("This is an e-mail message for our Contains query"); std::vector<ews::mailbox> recipients; recipients.push_back(ews::mailbox("*****@*****.**")); message.set_to_recipients(recipients); auto item_id = service.create_item(message, ews::message_disposition::save_only); // Then search for it auto search_expression = ews::contains(ews::item_property_path::subject, "ess", ews::containment_mode::substring, ews::containment_comparison::ignore_case); auto item_ids = service.find_item(drafts, search_expression); if (item_ids.empty()) { std::cout << "No messages found!\n"; } else { for (const auto& id : item_ids) { auto msg = service.get_message(id); std::cout << msg.get_subject() << std::endl; } } } catch (std::exception& exc) { std::cout << exc.what() << std::endl; res = EXIT_FAILURE; } ews::tear_down(); return res; }