int get_texture_index(char *name) { List *l; l = scan_list(texture_list, name, find_list_name); if (l == NULL) return -1; else return ((Texture_node *) l->next->node)->index; }
static struct hash_entry *get_hash_entry(struct hash_table *tbl, const char *key) { struct list_link *head; struct hash_entry *entry; unsigned int hash; hash = hash_string(key) % tbl->ht_size; head = &tbl->ht_lists[hash]; entry = scan_list(head, key); return entry; }
int main() { printf("device initiallation!\n"); pNode DevNode=(pNode)malloc(sizeof(deviceNode)); pNode cur; DevNode = device_init(); printf("scan all of the devices!\n"); /*scan the list*/ scan_list(DevNode); printf("-----------------------add a node to the node list-----------------------------------\n"); /*insert a new node to the list*/ pNode newNode = (pNode)malloc(sizeof(deviceNode)); newNode->dev_name="led"; newNode->dev_driver="led_driver"; insert_node(DevNode,2,newNode); scan_list(DevNode); printf("-----------------------add a node to the node list-----------------------------------\n"); //#if 0 pNode newNode1 = (pNode)malloc(sizeof(deviceNode)); newNode1->dev_name="ledd"; newNode1->dev_driver="ledd_driver"; insert_node(DevNode,7,newNode1); scan_list(DevNode); //#endif printf("----------------------delete a node from the node list---------------------------\n"); delete_node(DevNode,3); scan_list(DevNode); return 0; }
// // playlist // tiz::playlist::playlist (const uri_lst_t &uri_list /* = uri_lst_t () */, const bool shuffle /* = false */) : uri_list_ (uri_list), current_index_ (0), loop_playback_ (false), sub_list_indexes_ (), current_sub_list_ (-1), shuffle_ (shuffle), extension_list_ (), single_format_ (Unknown) { const int list_size = uri_list_.size (); if (list_size) { TIZ_LOG (TIZ_PRIORITY_TRACE, "first uri [%s]", uri_list_[0].c_str ()); TIZ_LOG (TIZ_PRIORITY_TRACE, "last list [%s]", uri_list_[uri_list_.size () - 1].c_str ()); } scan_list (); }
void do_scan(CHAR_DATA *ch, char *argument) { extern char *const dir_name[]; char arg1[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH]; ROOM_INDEX_DATA *scan_room; EXIT_DATA *pExit; sh_int door, depth, outlet; argument = one_argument(argument, arg1); if (IS_AFFECTED(ch,AFF_BLIND)) { send_to_char("Maybe it would help if you could see?\n\r",ch); return; } if (arg1[0] == '\0') { act("$n looks all around.", ch, NULL, NULL, TO_ROOM); send_to_char("Looking around you see:\n\r", ch); scan_list(ch->in_room, ch, 0, -1); for (door=0;door<6;door++) { outlet = door; if ( ( ch->alignment < 0 ) && (pExit = ch ->in_room->exit[door+6]) != NULL) outlet += 6; if ((pExit = ch ->in_room->exit[outlet]) != NULL) scan_list(pExit->u1.to_room, ch, 1, outlet); } return; } else if (!str_cmp(arg1, "n") || !str_cmp(arg1, "north")) door = 0; else if (!str_cmp(arg1, "e") || !str_cmp(arg1, "east")) door = 1; else if (!str_cmp(arg1, "s") || !str_cmp(arg1, "south")) door = 2; else if (!str_cmp(arg1, "w") || !str_cmp(arg1, "west")) door = 3; else if (!str_cmp(arg1, "u") || !str_cmp(arg1, "up" )) door = 4; else if (!str_cmp(arg1, "d") || !str_cmp(arg1, "down")) door = 5; else { send_to_char("Which way do you want to scan?\n\r", ch); return; } act("You peer intently $T.", ch, NULL, dir_name[door], TO_CHAR); act("$n peers intently $T.", ch, NULL, dir_name[door], TO_ROOM); sprintf(buf, "Looking %s you see:\n\r", dir_name[door]); scan_room = ch->in_room; for (depth = 1; depth < 4; depth++) { outlet = door; if (scan_room == NULL) return; if ( ( ch->alignment < 0 ) && ((pExit = scan_room->exit[outlet+6]) != NULL)) { scan_room = pExit->u1.to_room; scan_list(pExit->u1.to_room, ch, depth, outlet+6); } else if ((pExit = scan_room->exit[outlet]) != NULL) { scan_room = pExit->u1.to_room; scan_list(pExit->u1.to_room, ch, depth, outlet); } } return; }
void scan_seq( char *seq, size_t seq_len, uint *count_array ) { /* Martin A. Hansen, September 2008 */ /* Run a sliding window over a given sequence. The window */ /* consists of a list where new blocks of 4 nucleotides */ /* are pushed onto one end while at the same time old */ /* blocks are popped from the other end. The number of */ /* in the list is determined by the maximum seperator. */ /* Everytime we have a full window, the window is scanned */ /* for motifs. */ bitblock *block = NULL; size_t b_count = 0; ushort n_count = 0; size_t i = 0; uchar bin = 0; bool first_node = TRUE; node_sl *new_node = NULL; node_sl *old_node = NULL; list_sl *list = list_sl_new(); for ( i = 0; seq[ i ]; i++ ) { bin <<= BITS_IN_NT; switch( seq[ i ] ) { case 'A': case 'a': add_A( bin ); break; case 'T': case 't': add_T( bin ); break; case 'C': case 'c': add_C( bin ); break; case 'G': case 'g': add_G( bin ); break; default: n_count = BLOCK_SIZE_NT; break; } if ( i > BLOCK_SIZE_NT - 2 ) { b_count++; block = bitblock_new(); block->bin = bin; if ( n_count > 0 ) { block->hasN = TRUE; n_count--; } new_node = node_sl_new(); new_node->val = block; if ( first_node ) { list_sl_add_beg( &list, &new_node ); } else { list_sl_add_after( &old_node, &new_node ); } old_node = new_node; first_node = FALSE; if ( b_count > BLOCK_SPACE_MAX + BLOCK_SIZE_NT ) { // bitblock_list_print( list ); /* DEBUG */ scan_list( list, count_array ); mem_free( &list->first->val ); list_sl_remove_beg( &list ); } } } /* if the list is shorter than BLOCK_SPACE_MAX + BLOCK_SIZE_NT */ if ( b_count <= BLOCK_SPACE_MAX + BLOCK_SIZE_NT ) { // bitblock_list_print( list ); /* DEBUG */ scan_list( list, count_array ); } list_sl_destroy( &list ); }
int main(int argc, char **argv) { GPtrArray *protos = NULL, *handoffs = NULL; GError *err = NULL; guint i; GString *s; const char *outfile; guint count_protos, count_handoffs; if (argc < 3) { fprintf(stderr, "Usage: %s <outfile> <infiles...>\n", argv[0]); exit(1); } protos = g_ptr_array_new_full(ARRAY_RESERVED_SIZE, g_free); handoffs = g_ptr_array_new_full(ARRAY_RESERVED_SIZE, g_free); protos_regex = g_regex_new("void\\s+(proto_register_[[:alnum:]_]+)\\s*\\(\\s*void\\s*\\)\\s*{", G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY, &err); if (err) { fprintf(stderr, "GRegex: %s\n", err->message); exit(1); } handoffs_regex = g_regex_new("void\\s+(proto_reg_handoff_[[:alnum:]_]+)\\s*\\(\\s*void\\s*\\)\\s*{", G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY, &err); if (err) { fprintf(stderr, "GRegex: %s\n", err->message); exit(1); } outfile = argv[1]; for (int arg = 2; arg < argc; arg++) { if (argv[arg][0] == '@') { scan_list(&argv[arg][1], protos, handoffs); } else { scan_file(argv[arg], protos, handoffs); } } if (protos->len == 0) { fprintf(stderr, "No protocol registrations found.\n"); exit(1); } g_ptr_array_sort(protos, compare_symbols); g_ptr_array_sort(handoffs, compare_symbols); s = g_string_sized_new(STRING_RESERVED_SIZE); g_string_append(s, "/*\n" " * Do not modify this file. Changes will be overwritten.\n" " *\n" " * Generated automatically by the \"dissectors.c\" target using\n" " * \"make-dissectors\".\n" " */\n" "\n" "#include <dissectors.h>\n" "\n"); g_string_append_printf(s, "const gulong dissector_reg_proto_count = %d;\n" "const gulong dissector_reg_handoff_count = %d;\n" "\n", protos->len, handoffs->len); for (i = 0; i < protos->len; i++) { g_string_append_printf(s, "void %s(void);\n", (char *)protos->pdata[i]); } g_string_append(s, "\n" "dissector_reg_t dissector_reg_proto[] = {\n"); for (i = 0; i < protos->len; i++) { g_string_append_printf(s, " { \"%s\", %s },\n", (char *)protos->pdata[i], (char *)protos->pdata[i]); } g_string_append(s, " { NULL, NULL }\n" "};\n" "\n"); for (i = 0; i < handoffs->len; i++) { g_string_append_printf(s, "void %s(void);\n", (char *)handoffs->pdata[i]); } g_string_append(s, "\n" "dissector_reg_t dissector_reg_handoff[] = {\n"); for (i = 0; i < handoffs->len; i++) { g_string_append_printf(s, " { \"%s\", %s },\n", (char *)handoffs->pdata[i], (char *)handoffs->pdata[i]); } g_string_append(s, " { NULL, NULL }\n" "};\n"); if (!g_file_set_contents(outfile, s->str, s->len, &err)) { fprintf(stderr, "%s: %s\n", outfile, err->message); exit(1); } count_protos = protos->len; count_handoffs = handoffs->len; g_string_free(s, TRUE); g_regex_unref(protos_regex); g_regex_unref(handoffs_regex); g_ptr_array_free(protos, TRUE); g_ptr_array_free(handoffs, TRUE); printf("Found %u registrations and %u handoffs.\n", count_protos, count_handoffs); }