/*-----------------------------------------------------------------------------------------------------------------------*/ static FIXMsgDescr* load_message(xmlNode const* msg_node, xmlNode const* root, FIXFieldType* (*ftypes)[FIELD_TYPE_CNT], FIXError** error) { FIXMsgDescr* msg = (FIXMsgDescr*)calloc(1, sizeof(FIXMsgDescr)); msg->name = _strdup(get_attr(msg_node, "name", NULL)); msg->type = _strdup(get_attr(msg_node, "type", NULL)); msg->field_count = count_msg_fields(msg_node, get_first(root, "components")); msg->fields = (FIXFieldDescr*)calloc(msg->field_count, sizeof(FIXFieldDescr)); uint32_t count = 0; if (FIX_FAILED == load_fields(msg->fields, &count, msg_node, get_first(root, "components"), ftypes, error)) { return NULL; } assert(count == msg->field_count); msg->field_index = (FIXFieldDescr**)calloc(FIELD_DESCR_CNT, sizeof(FIXFieldDescr*)); build_index(msg->fields, msg->field_count, msg->field_index); return msg; }
bool DUSet::verify_def(IR_DU_MGR * du) const { CK_USE(du); DU_ITER di = NULL; for (UINT d = get_first(&di); di != NULL; d = get_next(d, &di)) { ASSERT0(du->get_ir(d)->is_stmt()); } return true; }
// Get data element starting from 0 as the most recent const T* get(int i) { if (size == 0) return nullptr; // no data yet else if (i >= size) return get_first(); // get least recent data else if (i <= 0) return get_last(); // get most recent data else { int abs_index = index - 1 - i; if (abs_index < 0) { // wrap to the end abs_index = N + abs_index; if (abs_index >= size) return get_first(); } return data[abs_index]; } }
//获得适合的选项 char get_choice(void) { char ch; printf("%s\n",STR); printf("%s\n",STR1); printf("%s\n",STR2); printf("%s\n:",STR3); ch = get_first(); while(ch != 'a' && ch != 's' && ch != 'm' && ch != 'd' && ch != 'q'){ printf("Please respond with a,s,m,d,or q.\n:"); ch = get_first(); } return ch; }
struct avltree_node *avltree_next(const struct avltree_node *node) { struct avltree_node *parent; if (node->right) return get_first(node->right); while ((parent = get_parent(node)) && parent->right == node) node = parent; return parent; }
bool DUSet::verify_use(IR_DU_MGR * du) const { CK_USE(du); DU_ITER di = NULL; for (UINT u = get_first(&di); di != NULL; u = get_next(u, &di)) { ASSERT0(du->get_ir(u)->is_exp()); } return true; }
/* When the mode changes the current object may get invisible, * get a new visible one */ PUBLIC void * Jdb_kobject_list::get_valid(void *o) { if (!_filter) return o; if (_filter && _filter(static_cast<Kobject*>(o))) return o; return get_first(); }
/*-----------------------------------------------------------------------------------------------------------------------*/ static FIXErrCode load_field_types(FIXFieldType* (*ftypes)[FIELD_TYPE_CNT], xmlNode const* root, FIXError** error) { xmlNode const* field = get_first(get_first(root, "fields"), "field"); while(field) { if (field->type == XML_ELEMENT_NODE && !strcmp((char const*)field->name, "field")) { if (fix_protocol_get_field_type(ftypes, get_attr(field, "name", NULL))) { *error = fix_error_create(FIX_ERROR_FIELD_TYPE_EXISTS, "FIXFieldType '%s' already exists", (char const*)field->name); return FIX_FAILED; } FIXFieldType* fld = (FIXFieldType*)calloc(1, sizeof(FIXFieldType)); fld->tag = atoi(get_attr(field, "number", NULL)); fld->name = _strdup(get_attr(field, "name", NULL)); fld->valueType = str2FIXFieldValueType(get_attr(field, "type", NULL)); xmlNode const* value = get_first(field, "value"); if (value) { fld->values = (FIXFieldValue**)calloc(FIELD_VALUE_CNT, sizeof(FIXFieldValue*)); while(value) { if (value->type == XML_ELEMENT_NODE && !strcmp((char const*)value->name, "value")) { FIXFieldValue* val = (FIXFieldValue*)calloc(1, sizeof(FIXFieldValue)); val->value = strdup(get_attr(value, "enum", NULL)); uint32_t idx = fix_utils_hash_string(val->value, strlen(val->value)) % FIELD_VALUE_CNT; val->next = fld->values[idx]; fld->values[idx] = val; } value = value->next; } } uint32_t idx = fix_utils_hash_string(fld->name, strlen(fld->name)) % FIELD_TYPE_CNT; fld->next = (*ftypes)[idx]; (*ftypes)[idx] = fld; } field = field->next; } return FIX_SUCCESS; }
/* 下一结点 */ static rbtree_node_st *rb_next(const rbtree_node_st *node) { rbtree_node_st *parent; if (node->right) return get_first(node->right); while ((parent = get_parent(node)) && parent->right == node) node = parent; return parent; }
/*-----------------------------------------------------------------------------------------------------------------------*/ static int32_t load_messages(FIXProtocolDescr* prot, FIXFieldType* (*ftypes)[FIELD_TYPE_CNT], xmlNode const* root, FIXError** error) { xmlNode* msg_node = get_first(get_first(root, "messages"), "message"); while(msg_node) { if (msg_node->type == XML_ELEMENT_NODE && !strcmp((char const*)msg_node->name, "message")) { FIXMsgDescr* msg = load_message(msg_node, root, ftypes, error); if (!msg) { return FIX_FAILED; } int32_t idx = fix_utils_hash_string(msg->type, strlen(msg->type)) % MSG_CNT; msg->next = prot->messages[idx]; prot->messages[idx] = msg; } msg_node = msg_node->next; } return FIX_SUCCESS; }
void main(int argc, char *argv[]) { if (argc!=1) { printf("Sorry, I don't take command line arguments.\n"); exit(-1); } else { get_first(); get_matrices(); mul_matrices(); print_out(); } }
// Allocate a new chunk from the pool (might expand the pool) void* allocate(size_t bytes) { assert(bytes == _size, "bad size"); void* p = NULL; { ThreadCritical tc; _num_used++; p = get_first(); if (p == NULL) p = os::malloc(bytes); } if (p == NULL) vm_exit_out_of_memory(bytes, "ChunkPool::allocate"); return p; }
shelf* get_shelf(node* n, char* shelf_name) { list* l = get_list(n); linked_list_node* crnt_llnode; for (crnt_llnode = get_first(l); crnt_llnode != NULL; crnt_llnode = crnt_llnode -> next_node) { shelf* crnt_shelf = crnt_llnode -> ll_content; char* crnt_name = get_shelf_name2(crnt_llnode); if (strcmp(crnt_name, shelf_name) == 0) return crnt_shelf; } return NULL; }
static void some_really_long_function_name(struct device *dev, struct device_driver *drv) { if ((some_variable_name && somefunction(param1, param2, param3))) { asdfghjk = asdfasdfasd.aasdfasd + (asdfasd.asdas * 1234.65); } for (struct something_really_really_excessive *a_long_ptr_name = get_first_item(); a_long_ptr_name != NULL; a_long_ptr_name = get_next_item(a_long_ptr_name)) { } for (a = get_first(); a != NULL; a = get_next(a)) { } for (a_ptr = get_first(); a_ptr != NULL; a_ptr = get_next(a)) { } register_clcmd( "examine", "do_examine", -1, "-Allows a player to examine the health and armor of a teammate" ); register_clcmd( "/examine", "do_examine", -1, "-Allows a player to examine the health and armor of a teammate" ); }
void Grammar::pseudo_non_terminals() { auto current = get_first(unite(non_terminals, terminals), 'Q'); SymbolList temp_non_terms = non_terminals; SymbolList pseudo_non_terms; unsigned int c = 0; for( auto T : terminals ) { SymbolList temp; temp.push_back(T); non_terminals.push_back(current); pseudo_non_terms.push_back(current); production_rules[get_nt_index(current)].push_back(temp); //std::cout << current << " " << production_rules[get_nt_index(current)].back() << " " << production_rules[get_nt_index(current)].size() << '\n'; get_next(current, ++c); } for( auto nT : temp_non_terms ) { std::vector<SymbolList> temp_rules; for( auto rule : production_rules[get_nt_index(nT)] ) { //std::cout << "rule: " << rule << " => "; if( rule.size() == 1 ) { //std::cout << "unchanged\n"; temp_rules.push_back(rule); continue; } for( auto ch : rule ) { //std::cout << "ch: " << ch << '\n'; if( contains_char(terminals, ch) ) { unsigned int i = pseudo_non_terms.size(); while( i --> 0 ) { //std::cout << "while( "<<i<<" --> 0)\n"; auto x = production_rules[get_nt_index(pseudo_non_terms[i])]; //std::cout << production_rules[get_nt_index(pseudo_non_terms[i])][0]; //std::cout << x[0][0] << " =?= " << ch << '\n'; if( ch == x[0][0] ) { //std::cout << " :: TRUE\n"; break; } } auto t = pseudo_non_terms[i]; replace_first_of(rule, ch, t); } } //std::cout << rule << '\n'; temp_rules.push_back(rule); } production_rules[get_nt_index(nT)] = temp_rules; } }
/** * Get next item in the tree, following natural order. */ rbnode_t * erbtree_next(const rbnode_t *node) { rbnode_t *parent; g_assert(node != NULL); if (node->right != NULL) return get_first(node->right); while (NULL != (parent = get_parent(node)) && parent->right == node) node = parent; return parent; }
static inline avl_node_t * avl_tree_next (avl_node_t *node) { avl_node_t *parent; if (node->right) return get_first(node->right); while ((parent = node->parent) && (parent->right == node)) node = parent; return parent; }
char get_choice(void) { char ch = 0; printf("a. add s. subtrackt\n"); printf("m. multiply d. divide\n"); printf("q. quit\n"); while ((ch = get_first()) != 'a' && ch != 's' && ch != 'm' && ch != 'd' && ch != 'q') { printf("Not valid.\n"); printf("Enter option(a,s,m,d, or q):"); } return ch; }
void InitME1() { auto pattern = hook::pattern("8B 35 ? ? ? ? 57 8B 3D ? ? ? ? 89 74 24 20 89 7C"); if (pattern.empty()) return; static auto nWidth = std::ref(**pattern.get_first<uint32_t*>(2)); static auto nHeight = std::ref(**pattern.get_first<uint32_t*>(9)); pattern = hook::pattern("D9 44 24 24 D9 1C 24 E8 ? ? ? ? B9 10 00 00 00 8B F0 8D BC 24 F0 00 00 00 F3 A5"); struct FOVHook { void operator()(injector::reg_pack& regs) { float f = *(float*)(regs.esp + 0x24); f *= 100.0f; f = AdjustFOV(f, static_cast<float>(nWidth) / static_cast<float>(nHeight)); f /= 100.0f; _asm {fld dword ptr[f]} _asm {fstp dword ptr[f]} *(float*)(regs.esp + 0x00) = f; } }; injector::MakeInline<FOVHook>(pattern.get_first(0), pattern.get_first(7)); }
struct FwAvlNode* fwAvlPrev(struct FwAvlNode* node) { struct FwAvlNode* parent; struct FwAvlNode* tmp; if(node->left != NULL) { tmp = get_first(node->left); } else { tmp = node; while( ((parent = get_parent(tmp)) != NULL) && (parent->left == tmp) ) tmp = parent; } return tmp; }
struct FwAvlNode* fwAvlNext(struct FwAvlNode* node) { struct FwAvlNode* parent = NULL; struct FwAvlNode* tmp; if(node->right != NULL) { return get_first(node->right); } else { tmp = node; while( ((parent = get_parent(tmp)) != NULL) && (parent->right == tmp) ) tmp = parent; } return parent; }
int main(void) { int table_size; int first; int increment; /* loop until sentinel is reached */ table_size = get_table_size(); while (table_size != 0) { first = get_first(); increment = get_increment(); show_table(table_size, first, increment); table_size = get_table_size(); } return 0; }
struct splaytree_node *splaytree_insert(struct splaytree_node *node, struct splaytree *tree) { struct splaytree_node *root = tree->root; int res; if (!root) { INIT_NODE(node); tree->root = node; tree->first = node; tree->last = node; return NULL; } res = do_splay(node, tree); if (res == 0) return tree->root; root = tree->root; if (res < 0) { struct splaytree_node *left = get_left(root); set_left(left, node); set_right(root, node); if (left) set_next(node, get_last(left)); else tree->first = node; set_prev(node, root); } else { struct splaytree_node *right = get_right(root); set_right(right, node); set_left(root, node); if (right) set_prev(node, get_first(right)); else tree->last = node; set_next(node, root); } tree->root = node; return NULL; }
void end_select(t_select *sel, int info) { t_arg *args; env_sw(); args = get_first(sel->first, sel->nb_arg); if (info == W_RET) { while (sel->nb_arg--) { if (args->selected == 1) { ft_putstr(args->name); ft_putchar(' '); } args = args->next; } } exit(EXIT_SUCCESS); }
Status BTIndexPage::deleteKey (const void *key, AttrType key_type, RID& curRid) { PageId pageno; Keytype curkey; Status st; st = get_first(curRid, (void*)&curkey, pageno); assert(st == OK); while (keyCompare(key, (void*)&curkey, key_type) > 0) { st = get_next(curRid, (void*)&curkey, pageno); if (st != OK) break; } if (keyCompare(key, (void*)&curkey, key_type) != 0) curRid.slotNo--; // we want to delete the previous key st = deleteRecord(curRid); assert(st == OK); return OK; }
static void sort_hint_2(t_hint *hint, int *i) { int var; int first; int last; first = get_first(hint->lst_data); last = get_last(hint->lst_data); var = ((t_pile*)(((t_list*)(*(hint->lst_a)))->content))->val; if (var < first) { p_local(hint->lst_a, hint->lst_b, hint->mark); r_local(hint->lst_b, hint->mark); (*i)++; } else if (var >= last) { p_local(hint->lst_a, hint->lst_b, hint->mark); (*i)++; } }
//---------------------------------------------------------------------------- // CTmTimerList::getFirst // Purpose : Get the time of the first entry on the timer list. // The CTmTime returned is the wakeup time(since EPOC) - TMSTARTTIME. //---------------------------------------------------------------------------- CTmTime CTmTimerList::getFirst() { CTmTime lv_time(0); CTmTimerEvent *lp_event = (CTmTimerEvent *) get_first(); if (lp_event) lv_time.set(curr_key()); get_end(); // Avoiding tracing here for efficiency if (lp_event) { TMTIME_TRACE(5, XATM_TraceTimer, ("CTmTimerList::getFirst : EXIT event %p, inputTime %d, returnTime " PFLL ".\n", (void *) lp_event, lp_event->wakeupInterval(), lv_time.get())); } else { TMTIME_TRACE(5, XATM_TraceTimer, ("CTmTimerList::getFirst : EXIT event list empty, returnTime " PFLL ".\n", lv_time.get())); } return lv_time; } // CTmTimerList::getFirst
int main() { char ch; do { switch (menu()) { case 1: func001(); break; case 2: func002(); break; case 3: func003(); break; case 4: func004(); break; default:break; } do{ printf("Do you want to continue to operate?(y/n)"); ch = get_first(); } while (ch != 'y' && ch != 'Y' && ch != 'n' && ch != 'N'); } while (ch == 'y' || ch == 'Y'); return 0; }
int main() { FILE *fin = fopen("friday.in", "r"); FILE *fout = fopen("friday.out", "w"); int result[7]; int sum, day; int N, i, j, k; fscanf(fin, "%d", &N); fclose(fin); memset(result, 0, sizeof(result)); int year; for (year = 1900; year < 1900 + N; ++year) { int first = get_first(year); for (j = 1; j < 13; ++j) { sum = 0; for ( k = 0; k < j; ++k) { if (k == 2 && is_leap(year)) sum += 29; else sum += month[k]; } day = (sum + 12 + first) % 7; result[day]++; } } for (i = 6; i < 12; ++i) fprintf(fout, "%d ", result[i % 7]); fprintf(fout, "%d\n", result[5]); fclose(fout); return 0; }
void splaytree_remove(struct splaytree_node *node, struct splaytree *tree) { struct splaytree_node *right, *left, *prev; do_splay(node, tree); assert(tree->root == node); /* 'node' must be present */ right = get_right(node); left = get_left(node); if (!left) { tree->root = right; tree->first = splaytree_next(node); prev = NULL; } else { tree->root = left; do_splay(node, tree); set_right(right, tree->root); prev = tree->root; } if (right) set_prev(prev, get_first(right)); else tree->last = prev; }