int list_equals_cmp(ADTList list1, ADTList list2, int (*cmp)(void *, void *)) { int list1_size = list_size(list1); if (list1_size == list_size(list2)) { for (int i = 0; i < list1_size; i++) if (cmp(list_at(list1, i), list_at(list2, i)) == 0) return 0; return 1; } return 0; }
int list_equals(ADTList list1, ADTList list2) { int list1_size = list_size(list1); if (list1_size == list_size(list2)) { for (int i = 0; i < list1_size; i++) if (list_at(list1, i) != list_at(list2, i)) return 0; return 1; } return 0; }
int verify_ros_header(subscriber* sub, char* header, int hsize) { char *msgtype, *md5sum,*topic,*ptr,*key,*val; char field[MAX_BUFF]; int size; ptr = header; msgtype = NULL; md5sum = NULL; topic = NULL; list l; while((!msgtype || !md5sum || !topic) && ptr < header + hsize) { memset(field ,0,MAX_BUFF); // read field size size = (int)(*ptr); ptr += 4; memcpy(field, ptr ,size); ptr += size; //LOG("Found field:%s\n",field); l = split(field,"="); if(list_size(l) != 2) {list_free(&l); continue;} key = list_at(l,0)->value.s; val = list_at(l,1)->value.s; if(strcmp(key,"topic")== 0) topic = val; else if(strcmp(key,"md5sum")== 0) md5sum = val; else if(strcmp(key,"type") ==0) msgtype = val; list_free(&l); } // check for type, md5 and topic if(!msgtype || !md5sum || !topic) { LOG("%s","Some fields is missing\n"); return 0; } if(strcmp(topic, sub->topic) != 0) { LOG("Wrong topic, expect [%s] but receive [%s]\n", sub->topic, topic); return 0; } if(strcmp(msgtype, sub->type)!=0 && strcmp(msgtype,"*") != 0) { LOG("Wrong message type, expect [%s] but receive [%s]\n", sub->type, msgtype); return 0; } if(strcmp(md5sum, md5sum_of(msgtype)) != 0 && strcmp(md5sum,"*") != 0) { LOG("Wrong md5sum signature, receive [%s] for type [%s]\n", md5sum, msgtype); return 0; } return hash(msgtype, HASHSIZE); }
// drop a elements from the beginning and b from the end of l void cropList(V p, V l, I a, I b) { L lv=L(l); if (lv->r > 1) { I nl=lv->l-a-b; T t=lv->t; I s=t_sizeof(t); P v=MALLOC(s*next_pow_2(nl)); DO(i,nl) valcpy(v+s*i, LIST_PTR_ATS(lv,i+a,s), t); del(l); setL(p, wrapArray(t, nl, v)); } else { if (a>0) { DO(j,a) del(list_at(lv,a)); } if (b>0) { DO(j,b) del(list_at(lv,lv->l-b+j)); } lv->o = (lv->o+a) % lv->c; lv->l -= a+b; mv_P(p, l); } }
void requestTopic(rpc_value_t params, int n, int client) { if(n != 3){ rpc_bad_request(client);return;} char* topic = list_at(params,1)->value.s; if(! topic){rpc_bad_request(client);return;} publisher* pub = (publisher*) dvalue(xml_prc_server.node->publishers,topic); if(!pub) { LOG("Unknow topic: %s\n", topic); rpc_bad_request(client); return; } // send response list l = list_init(); list l1 = list_init(); list l2 = list_init(); list_put_s(&l2,"TCPROS"); list_put_s(&l2,pub->uri); list_put_i(&l2,pub->port); list_put_i(&l1,1); list_put_s(&l1,__s("ready on %s:%d",pub->uri, pub->port)); list_put_array(&l1,l2); list_put_array(&l,l1); char* data = gen_rpc_response(l); char* xml_resp = __s(RESPONSE_PATTERN, strlen(data), SERVER_STRING,data); send(client,xml_resp, strlen(xml_resp),0); list_free(&l); }
int irc_names(void *data) { char *params[1]; struct irc_msgdata *ircdata = (struct irc_msgdata *) data; struct ircchan *chan; struct ircuser *source = irc_user_byid(ircdata->globdata, ircdata->msgdata->fd); char *chanlist = NULL; int i; if (irc_parse_paramlist(ircdata->msg, params, 1) == 1) chanlist = params[0]; for (i = 0; i < list_count(ircdata->globdata->chan_list); i++) { chan = list_at(ircdata->globdata->chan_list, i); if ((!(chan->mode & (chan_priv | chan_secret)) || irc_user_inchannel(chan, source) == OK) /* No mostramos canales ni secretos ni privados si el usuario no estĆ” en ellos */ && (chanlist == NULL || strnstr(chanlist, chan->name, MAX_IRC_MSG) != NULL)) /* Si el usuario ha especificado un canal, mostrar sĆ³lo esos */ { irc_send_names_messages(chan, ircdata); } } irc_send_numericreply(ircdata, RPL_ENDOFNAMES, NULL); return OK; }
int irc_list(void *data) { struct irc_msgdata *ircdata = (struct irc_msgdata *) data; struct ircchan *chan; struct ircuser *source = irc_user_byid(ircdata->globdata, ircdata->msgdata->fd); char *chanlist = NULL; char *params[1]; char chandata[50]; int i; if (irc_parse_paramlist(ircdata->msg, params, 1) == 1) chanlist = params[0]; irc_send_numericreply(ircdata, RPL_LISTSTART, NULL); for (i = 0; i < list_count(ircdata->globdata->chan_list); i++) { chan = list_at(ircdata->globdata->chan_list, i); if ((!(chan->mode & (chan_priv | chan_secret)) || irc_user_inchannel(chan, source) == OK) /* No mostramos canales ni secretos ni privados si el usuario no estĆ” en ellos */ && (chanlist == NULL || strnstr(chanlist, chan->name, MAX_IRC_MSG) == 0)) /* Si el usuario ha especificado un canal, mostrar sĆ³lo esos */ { snprintf(chandata, 50, "%s %d", chan->name, list_count(chan->users)); irc_send_numericreply_withtext(ircdata, RPL_LIST, chandata, chan->topic); } } irc_send_numericreply(ircdata, RPL_LISTEND, NULL); return OK; }
ADT list_take(List* self, int p_index) { if ( list_at(self, p_index) ) { return list_take_current(self); } return NULL; }
int createServerUserGetFriends(int sock,int clienttype,list_t* list){ client_header_2_t* header = createClientHeader(COMMAND_OTHER_MESSAGE,MESSAGE_TYPE_USER_GET_FRIEND,clienttype); cJSON* json = cJSON_CreateArray(); list_node_t *node = NULL; if(list != NULL){ int i = 0; for(i=0;i<list->len;i++) { node = list_at(list,i); user_info_t* uinfo = (user_info_t*)node->val; cJSON* info = cJSON_CreateObject(); cJSON_AddStringToObject(info,"username",uinfo->username); cJSON_AddStringToObject(info,"userid",uinfo->userid); cJSON* arr = cJSON_CreateArray(); int j = 0; if(uinfo->drivces != NULL){ for(j=0;j<uinfo->drivces->len;j++){ cJSON* strjson = cJSON_CreateString(list_at(uinfo->drivces,j)->val); cJSON_AddItemToArray(arr,strjson); } } cJSON_AddItemToObject(info,"drivces",arr); cJSON_AddItemToArray(json,info); } } char* str = cJSON_Print(json); printf("%s,%d",str,strlen(str)); int total = sizeof(server_header_2_t)+sizeof(uint16_t)+strlen(str); void* bufs = malloc(total); void* buf = bufs; header->total = total; memcpy(buf,header,sizeof(server_header_2_t)); buf += sizeof(server_header_2_t); *(uint16_t*)buf = htons(strlen(str)); buf += sizeof(uint16_t); memcpy(buf,str,strlen(str)); int ret =send(sock,bufs,total,0); free(bufs); cJSON_Delete(json); //free(str); return ret; }
void extract_url(subscriber* sub, list l) { if(!l || list_size(l) == 0) { pthread_mutex_lock (&node_mux); sub->uri = NULL; sub->port = 0; sub->status = TOPIC_REFRESH; pthread_mutex_unlock(&node_mux); return; } char* url = list_at(l,0)->value.s; l = split(url,"/"); //printf("list size %d\n",list_size(l)); url = list_at(l,1)->value.s; l = split(url,":"); pthread_mutex_lock (&node_mux); sub->uri = list_at(l,0)->value.s; sub->port = list_at(l,1)->value.i; sub->status = TOPIC_REFRESH; pthread_mutex_unlock (&node_mux); }
void listcpy(L d, L s, I i) { s->r--; if (s->l) { d->l += s->l; if (s->r && s->t&COMP_t) { // Increase reference count of source's children I ss=t_sizeof(s->t); DO(j,s->l) (**(I**)(LIST_PTR_ATS(s,j,ss)))++; } if (PURE(d->t)==PURE(s->t)) listcpy1(d,s,i); else { DO(j,s->l) LIST_AT(d,i+j) = cpy1(list_at(s,j)); } } if (!s->r) { FREEL(s); } }
void publisherUpdate(rpc_value_t params, int n, int client) { //LOG("Number params %d\n", n); //LOG("parms: %s\n",as_string(params)); char* topic = list_at(params,1)->value.s; char* url; list l; if(topic == NULL) { rpc_bad_request(client); return; } subscriber* sub = (subscriber*)dvalue(xml_prc_server.node->subscribers,topic); if(sub == NULL) { rpc_bad_request(client); return; } l = list_at(params,2)->value.array; extract_url(sub, l); rpc_dummy_response(client); }
int list_find(list* ls, comparator comp, void * element) { int i; int size = list_count(ls); void* current = NULL; for(i = 0; i < size; i++) { current = list_at(ls, i); if((*comp)(current, element) == 0) return i; } return -1; }
static void _send_who_msgs_channel(struct irc_msgdata *data, struct ircchan *chan, struct ircuser *sender) { struct ircuser *user; int i; for (i = 0; i < list_count(chan->users); i++) { user = list_at(chan->users, i); if (irc_users_have_common_chans(user, sender)) continue; if (!(user->mode & user_invisible)) _send_who_msg(data, user); } }
int irc_nick(void *data) { int retval; struct irc_msgdata *ircdata = (struct irc_msgdata *) data; char *new_nick[1], *old_nick; int i; struct ircuser *user = irc_user_byid(ircdata->globdata, ircdata->msgdata->fd); if (user) old_nick = strdup(user->nick); if (!irc_parse_paramlist(ircdata->msg, new_nick, 1)) { irc_send_numericreply(ircdata, ERR_UNKNOWNCOMMAND, NULL); return ERR; } retval = irc_set_usernick(ircdata->globdata, ircdata->msgdata->fd, new_nick[0]); if (retval != OK) { if (retval == ERR_NOTFOUND) irc_send_numericreply(ircdata, ERR_ERRONEUSNICKNAME, NULL); else if (retval == ERR_NICKCOLLISION) irc_send_numericreply(ircdata, ERR_NICKCOLLISION, NULL); else slog(LOG_ERR, "Error desconocido %d al cambiar nick del usuario a %s", retval, new_nick[0]); free(old_nick); return OK; } if (strlen(old_nick) == 0) irc_send_welcome_message(ircdata); /* Si no tenĆa un nick le mandamos bienvenida */ else irc_send_response(ircdata, ":%s NICK %s", old_nick, user->nick); for (i = 0; i < list_count(user->channels); ++i) irc_channel_broadcast(list_at(user->channels, i), ircdata->msg_tosend, user, ":%s NICK %s", old_nick, user->nick); free(old_nick); return OK; }
int createServerUserFindUser(int sock,int clienttype,user_info_t* userinfo){ client_header_2_t* header = createClientHeader(COMMAND_OTHER_MESSAGE,MESSAGE_TYPE_USER_LOGIN,clienttype); cJSON* json = cJSON_CreateObject(); if(userinfo != NULL){ cJSON_AddStringToObject(json,"username",userinfo->username); cJSON_AddStringToObject(json,"userid",userinfo->userid); cJSON_AddNumberToObject(json,"isSuccess",1); cJSON* arr = cJSON_CreateArray(); if(userinfo->drivces){ list_node_t* node = NULL; int i = 0; for(i=0;i<userinfo->drivces->len;i++) { node = list_at(userinfo->drivces,i); printf("pop list=%s\n",node->val); cJSON_AddItemToArray(arr,cJSON_CreateString(node->val)); } } cJSON_AddItemToObject(json,"driveces",arr); } else{ cJSON_AddNumberToObject(json,"isSuccess",0); } char* str = cJSON_Print(json); printf("%s,%d",str,strlen(str)); int total = sizeof(server_header_2_t)+sizeof(uint16_t)+strlen(str); void* bufs = malloc(total); void* buf = bufs; header->total = total; memcpy(buf,header,sizeof(server_header_2_t)); buf += sizeof(server_header_2_t); *(uint16_t*)buf = htons(strlen(str)); buf += sizeof(uint16_t); memcpy(buf,str,strlen(str)); int ret =send(sock,bufs,total,0); free(bufs); cJSON_Delete(json); //free(str); return ret; }
int irc_who(void *data) { char *params[1]; struct irc_msgdata *ircdata = (struct irc_msgdata *) data; struct ircchan *chan; struct ircuser *source = irc_user_byid(ircdata->globdata, ircdata->msgdata->fd); struct ircuser *user; char *channame = NULL; int i; if (irc_parse_paramlist(ircdata->msg, params, 1) == 1) channame = params[0]; if (!channame) { for (i = 0; i < list_count(ircdata->globdata->chan_list); i++) { chan = list_at(ircdata->globdata->chan_list, i); _send_who_msgs_channel(ircdata, chan, source); } } else { chan = irc_channel_byname(ircdata->globdata, channame); if (chan) _send_who_msgs_channel(ircdata, chan, NULL); else { user = irc_user_bynick(ircdata->globdata, channame); if (user) _send_who_msg(ircdata, user); } } irc_send_numericreply(ircdata, RPL_ENDOFWHO, NULL); return OK; }
void sendMessage(char* clientMessageid,int delytime, char* message, int messagetype, list_t* sendtoList){ send_message_t* ms = malloc(sizeof(send_message_t)); ms->message = malloc(strlen(message)); strcpy(ms->message,message); strcpy(ms->messageid,clientMessageid); ms->messagetype = messagetype; ms->delytime = delytime; ms->sendto = list_new(); ms->sendto->free = free; int i = 0; for(i=0;i<sendtoList->len;i++){ list_node_t* node = list_at(sendtoList,i); char* str = malloc(strlen(node->val)); list_lpush(ms->sendto,list_node_new(str)); } list_lpush(sendlist,list_node_new(ms)); pthread_cond_signal(&queue_send); pthread_mutex_unlock(&send_lock); }
static void test_list_at() { // Setup list_t *list = list_new(); list_node_t *a = list_node_new("a"); list_node_t *b = list_node_new("b"); list_node_t *c = list_node_new("c"); // a b c list_rpush(list, a); list_rpush(list, b); list_rpush(list, c); // Assertions assert(a == list_at(list, 0)); assert(b == list_at(list, 1)); assert(c == list_at(list, 2)); assert(NULL == list_at(list, 3)); assert(c == list_at(list, -1)); assert(b == list_at(list, -2)); assert(a == list_at(list, -3)); assert(NULL == list_at(list, -4)); }
int test_run (void) { SCL_list_t list; SCL_iterator_t iterator; void* data; int stat; int i; printf ("Create list: "); fflush (stdout); list = list_new(); printf ("(%p = list_new()) != NULL ... ", list); fflush (stdout); printf ("%s\n", ((list!=NULL) ? "PASS" : "FAIL")); printf ("Push data in back list.\n"); for (i=0 ; i<LIST_SIZE ; i++) { stat = list_push_back (list, (void*)g_data[i]); printf ( "([%d,%s] = list_push_back (list, data[%d]) .... %s\n", stat, scl_statstr(stat), i, ((stat==SCL_OK) ? "PASS" : "FAIL") ); } printf ( "%2ld = list_count (list) .......................... %s\n", list_count(list), ((list_count(list)==LIST_SIZE) ? "PASS" : "FAIL") ); printf ("Foreach on list.\n"); for (i=0 ; i<LIST_SIZE ; i++) g_flag[i] = 0; list_foreach (list, cbfn, g_context); printf ("REVERSE the list.\n"); list_reverse (list); printf ("Iterate through the list.\n"); iterator = list_begin (list); for (i=0 ; i<LIST_SIZE ; i++) g_flag[i] = 0; while (iterator != NULL) { data_flag (list_data_get(iterator)); iterator = list_next (iterator); } printf ("Iterate back through the list.\n"); iterator = list_end (list); for (i=0 ; i<LIST_SIZE ; i++) g_flag[i] = 0; while (iterator != NULL) { data_flag (list_data_get(iterator)); iterator = list_prev (iterator); } printf ("REVERSE the list.\n"); list_reverse (list); printf ("Accesses on list.\n"); for (i=0 ; i<LIST_SIZE ; i++) { data = list_access (list, i); printf ( "list_access(list,%d) == %08X ................. %s\n", i, (unsigned long)data, (((unsigned long)data==g_data[i]) ? "PASS" : "FAIL") ); } printf ("Accesses on list via iterator.\n"); for (i=0 ; i<LIST_SIZE ; i++) { iterator = list_at (list, i); printf ( "list_at(list,%d) => %08X ..................... %s\n", i, (unsigned long)list_data_get(iterator), (((unsigned long)list_data_get(iterator)==g_data[i]) ? "PASS" : "FAIL") ); } printf ("Erase list.\n"); list_erase (list); printf ( "%2ld = list_count (list) .......................... %s\n", list_count(list), ((list_count(list)==0) ? "PASS" : "FAIL") ); printf ("Delete list.\n"); list_del (list); printf ("\n"); return 0; }
Bool prima_one_loop_round( Bool wait, Bool careOfApplication) { XEvent ev, next_event; fd_set read_set, write_set, excpt_set; struct timeval timeout; int r, i, queued_events; PTimerSysData timer; if ( guts. applicationClose) return false; if (( queued_events = XEventsQueued( DISP, QueuedAlready))) { goto FetchAndProcess; } read_set = guts.read_set; write_set = guts.write_set; excpt_set = guts.excpt_set; if ( guts. oldest) { gettimeofday( &timeout, nil); if ( guts. oldest-> when. tv_sec < timeout. tv_sec || ( guts. oldest-> when. tv_sec == timeout. tv_sec && guts. oldest-> when. tv_usec <= timeout. tv_usec)) { timer = guts. oldest; apc_timer_start( timer-> who); if ( timer-> who == CURSOR_TIMER) { prima_cursor_tick(); } else if ( timer-> who == MENU_TIMER) { apc_timer_stop( MENU_TIMER); if ( guts. currentMenu) { XEvent ev; ev. type = MenuTimerMessage; prima_handle_menu_event( &ev, M(guts. currentMenu)-> w-> w, guts. currentMenu); } } else if ( timer-> who == MENU_UNFOCUS_TIMER) { prima_end_menu(); } else { prima_simple_message( timer-> who, cmTimer, false); } gettimeofday( &timeout, nil); } if ( guts. oldest && wait) { if ( guts. oldest-> when. tv_sec < timeout. tv_sec) { timeout. tv_sec = 0; timeout. tv_usec = 0; } else { timeout. tv_sec = guts. oldest-> when. tv_sec - timeout. tv_sec; if ( guts. oldest-> when. tv_usec < timeout. tv_usec) { if ( timeout. tv_sec == 0) { timeout. tv_sec = 0; timeout. tv_usec = 0; } else { timeout. tv_sec--; timeout. tv_usec = 1000000 - (timeout. tv_usec - guts. oldest-> when. tv_usec); } } else { timeout. tv_usec = guts. oldest-> when. tv_usec - timeout. tv_usec; } } if ( timeout. tv_sec > 0 || timeout. tv_usec > 200000) { timeout. tv_sec = 0; timeout. tv_usec = 200000; } } else { timeout. tv_sec = 0; if ( wait) timeout. tv_usec = 200000; else timeout. tv_usec = 0; } } else { timeout. tv_sec = 0; if ( wait) timeout. tv_usec = 200000; else timeout. tv_usec = 0; } if (( r = select( guts.max_fd+1, &read_set, &write_set, &excpt_set, &timeout)) > 0 && FD_ISSET( guts.connection, &read_set)) { if (( queued_events = XEventsQueued( DISP, QueuedAfterFlush)) <= 0) { /* just like tcl/perl tk do, to avoid an infinite loop */ RETSIGTYPE oldHandler = signal( SIGPIPE, SIG_IGN); XNoOp( DISP); XFlush( DISP); (void) signal( SIGPIPE, oldHandler); } FetchAndProcess: if ( queued_events && ( application || !careOfApplication)) { XNextEvent( DISP, &ev); XCHECKPOINT; queued_events--; while ( queued_events > 0) { if (!application && careOfApplication) return false; XNextEvent( DISP, &next_event); XCHECKPOINT; prima_handle_event( &ev, &next_event); guts. total_events++; queued_events = XEventsQueued( DISP, QueuedAlready); memcpy( &ev, &next_event, sizeof( XEvent)); } if (!application && careOfApplication) return false; guts. total_events++; prima_handle_event( &ev, nil); } XNoOp( DISP); XFlush( DISP); } else if ( r < 0) { list_first_that( guts.files, (void*)purge_invalid_watchers, nil); } else { if ( r > 0) { for ( i = 0; i < guts.files->count; i++) { PFile f = (PFile)list_at( guts.files,i); if ( FD_ISSET( f->fd, &read_set) && (f->eventMask & feRead)) { prima_simple_message((Handle)f, cmFileRead, false); break; } else if ( FD_ISSET( f->fd, &write_set) && (f->eventMask & feWrite)) { prima_simple_message((Handle)f, cmFileWrite, false); break; } else if ( FD_ISSET( f->fd, &excpt_set) && (f->eventMask & feException)) { prima_simple_message((Handle)f, cmFileException, false); break; } } } else { XNoOp( DISP); XFlush( DISP); } } send_pending_events(); perform_pending_paints(); kill_zombies(); return application != nilHandle; }
void *list_pop_back(ADTList list) { void *value = list_at(list, -1); if (list->head) list_remove_at(list, -1); return value; }
void *list_pop_front(ADTList list) { void *value = list_at(list, 0); if (list->head) list_remove_at(list, 0); return value; }
std::string lazy_entry::list_string_value_at(int i) const { lazy_entry const* e = list_at(i); if (e == 0 || e->type() != lazy_entry::string_t) return std::string(); return e->string_value(); }
pascal_string lazy_entry::list_pstr_at(int i) const { lazy_entry const* e = list_at(i); if (e == 0 || e->type() != lazy_entry::string_t) return pascal_string(0, 0); return e->string_pstr(); }
int test_run (void) { SCL_list_t list; SCL_iterator_t iterator; void* data; int stat; int i; printf ("Create list: "); fflush (stdout); list = list_new(); printf ("(%p = list_new()) != NULL ....... ", list); fflush (stdout); printf ("%s\n", ((list!=NULL) ? "PASS" : "FAIL")); printf ("Push data in back list.\n"); for (i=0 ; i<LIST1_SIZE ; i++) { stat = list_push_back (list, (void*)g_data1[i]); printf ( "([%d,%s] = list_push_back (list, data[%d]) .... %s\n", stat, scl_statstr(stat), i, ((stat==SCL_OK) ? "PASS" : "FAIL") ); } printf ( "%2ld = list_count (list) .......................... %s\n", list_count(list), ((list_count(list)==LIST1_SIZE) ? "PASS" : "FAIL") ); printf ("Foreach on list.\n"); for (i=0 ; i<LIST1_SIZE ; i++) g_flag1[i] = 0; list_foreach (list, cbfn1, NULL); printf ("Insert data in list before 2 using iterator.\n"); iterator = list_at (list, 2); printf ("%p = list_at (list, 2);\n", iterator); stat = list_insert_before (list, iterator, (void*)0x0101); printf ( "[%d,%s] = list_insert_before (list, iterator=>%p, %08X);\n", stat, scl_statstr(stat), iterator, 0x0101 ); printf ("Insert data in list after 3 using iterator.\n"); iterator = list_at (list, 3); printf ("%p = list_at (list, 3);\n", iterator); stat = list_insert_after (list, iterator, (void*)0xAAAAAAAA); printf ( "[%d,%s] = list_insert_after (list, iterator=>%p, %08X);\n", stat, scl_statstr(stat), iterator, 0xAAAAAAAA ); printf ( "%2ld = list_count (list) .......................... %s\n", list_count(list), ((list_count(list)==LIST2_SIZE) ? "PASS" : "FAIL") ); printf ("Foreach on list.\n"); for (i=0 ; i<LIST2_SIZE ; i++) g_flag2[i] = 0; list_foreach (list, cbfn2, NULL); printf ("REVERSE the list.\n"); list_reverse (list); printf ( "%2ld = list_count (list) .......................... %s\n", list_count(list), ((list_count(list)==LIST3_SIZE) ? "PASS" : "FAIL") ); printf ("Foreach on list.\n"); for (i=0 ; i<LIST3_SIZE ; i++) g_flag3[i] = 0; list_foreach (list, cbfn3, NULL); printf ("Erase list.\n"); list_erase (list); printf ( "%2ld = list_count (list) .......................... %s\n", list_count(list), ((list_count(list)==0) ? "PASS" : "FAIL") ); printf ("Delete list.\n"); list_del (list); printf ("\n"); return 0; }
boost::int64_t lazy_entry::list_int_value_at(int i, boost::int64_t default_val) const { lazy_entry const* e = list_at(i); if (e == 0 || e->type() != lazy_entry::int_t) return default_val; return e->int_value(); }