orderbook_order_t * find_sell_order(option_order_t *order){ uint32_t low_oid = 0; orderbook_order_t * o = NULL; for(int i =0; i < NUM_ORDERS; ++i){ option_order_t *potential = &(ORDERBOOK[i].contract); int ms = 1; if(potential != NULL && potential->symbol[0] != 0x0){ ms = match_symbol(potential, order); } if(potential != NULL && ms == 0 && potential->price <= order->price && potential->qty > 0 && potential->qty >= order->qty){ if(low_oid == 0){ low_oid = ORDERBOOK[i].order_id; o = &(ORDERBOOK[i]); }else if(ORDERBOOK[i].order_id < low_oid ){ low_oid = ORDERBOOK[i].order_id; o = &(ORDERBOOK[i]); } } } return o; }
static void select_id(expression_type parent_type, struct selection *selection, const freesasa_structure *structure, const char *id) { int count = 0, match, i; assert(id); for (i = 0; i < selection->size; ++i) { match = 0; switch(parent_type) { case E_NAME: match = match_name(structure, id, i); break; case E_SYMBOL: match = match_symbol(structure, id, i); break; case E_RESN: match = match_resn(structure, id, i); break; case E_RESI: match = match_resi(structure, id, i); break; case E_CHAIN: match = match_chain(structure, id, i); break; default: assert(0); break; } if (match) selection->atom[i] = 1; count += match; } if (count == 0) freesasa_warn("Found no matches to %s '%s', typo?", e_str(parent_type),id); }
void find_comments_and_literals(char * orig_buffer, char * buffer, items * Items, int add_literals, int add_comments, int add_backslashes) { int i, n, end; n = strlen(buffer); for (i = 0; i < n;) { switch (buffer[i]) { case '\"': end = match_symbol(buffer, i, '\"'); assert(end > 0); if (add_literals) add_item(Items, i, end - 1, STRING); i = end; break; case '\'': end = match_symbol(buffer, i, '\''); assert(end > 0); if (add_literals) add_item(Items, i, end - 1, LITERAL); i = end; break; case '/': if (buffer[i + 1] == '*') { if (flag_nested_comments) { end = match_bracket(orig_buffer, buffer, n, i, "/*", "*/"); if (end < 0) { printf("No matching closing comment\n"); exit(-1); } if (add_comments) add_item(Items, i, end + 1, COMMENT); i = end + 2; } else { end = matchComment(buffer, i, Items); assert(end > 0); if (add_comments) add_item(Items, i, end - 1, COMMENT); i = end; } } else i++; break; case '\\': if (add_backslashes) add_item(Items, i, i + 1, ESCSEQ); i += 2; break; default: i++; break; } if (i < 0) { printf("Internal error detected\n"); exit(-1); } } }