bool Gobby::FindDialog::find_range_once(const GtkTextIter* from, const GtkTextIter* to, SearchDirection direction, GtkTextIter* match_start, GtkTextIter* match_end) { GtkTextSearchFlags flags = GtkTextSearchFlags(0); if(!m_check_case->get_active() ) flags = GTK_TEXT_SEARCH_CASE_INSENSITIVE; TextSearchFunc search_func = (direction == SEARCH_FORWARD ? gtk_text_iter_forward_search : gtk_text_iter_backward_search); Glib::ustring find_str = m_entry_find->get_text(); gboolean result = search_func( from, find_str.c_str(), flags, match_start, match_end, to != NULL ? to : NULL ); return result; }
BOOL found_func(char * libname,char * ut_funcname,SYM * declared_func) { /* ** Search for function in bmap file and record register usage ** and library base offset in symbol table entry for function. */ make_bmap_name(libname); if (search_func(bmapname,ut_funcname,declared_func)) { /* store library name */ declared_func->libname = (char *)sym_alloc(MAXIDSIZE+8); if (declared_func->libname == NULL) { puts("Can't allocate memory for library name in symbol table!"); early_exit=TRUE; kill_all_lists(); cleanup(); } else { /* found the function */ strcpy(declared_func->libname,libname); return(TRUE); } } /* didn't find the function */ return(FALSE); }
int is_silenced_function(void) { char *func; func = get_function(); if (!func) return 0; if (search_func(silenced_funcs, func)) return 1; return 0; }
const bfd_target * bfd_search_for_target (int (*search_func) (const bfd_target *, void *), void *data) { const bfd_target * const *target; for (target = bfd_target_vector; *target != NULL; target ++) if (search_func (*target, data)) return *target; return NULL; }
static GdmLoginExtension * gdm_extension_list_foreach_extension (GdmExtensionList *extension_list, GdmExtensionListForeachFunc search_func, gpointer data) { GList *node; for (node = extension_list->priv->extensions; node != NULL; node = node->next) { GdmLoginExtension *extension; extension = node->data; if (search_func (extension_list, extension, data)) { return g_object_ref (extension); } } return NULL; }
int is_no_inline_function(const char *function) { if (search_func(no_inline_funcs, (char *)function)) return 1; return 0; }
void TestApp::start() { struct timeval tmv; int status; fd_set READ_SET; fd_set READ_SET_COPY; //outfile_client<<"inside seleact"<<endl; cout<<"inside select function"<<endl; int max_sock; if(UDP_private > sockfd_client) { max_sock=UDP_private; } else { max_sock=sockfd_client; } int total_timer_events; FD_ZERO(&READ_SET); // Change while condition to reflect what is required for Project 1 // ex: Routing table stabalization. while (1) { //if (total_timer_events >5) //exit(1); timersManager_->NextTimerTime(&tmv); if (tmv.tv_sec == 0 && tmv.tv_usec == 0) { //outfile_client<<"timer finished .... calling the function"<<endl; // The timer at the head on the queue has expired timersManager_->ExecuteNextTimer(); continue; } if (tmv.tv_sec == MAXVALUE && tmv.tv_usec == 0){ // There are no timers in the event queue break; } /* The select call here will wait for tv seconds before expiring * You need to modifiy it to listen to multiple sockets and add code for * packet processing. Refer to the select man pages or "Unix Network * Programming" by R. Stevens Pg 156. */ FD_SET(UDP_private,&READ_SET); FD_SET(sockfd_client,&READ_SET); status = select(max_sock+1,&READ_SET,NULL,NULL,&tmv); if (status<0) {perror("select");} else if (status == 0){ //outfile_client<<"select timed out ..... again calling the timers function"<<endl; // Timer expired, Hence process it timersManager_->ExecuteNextTimer(); // Execute all timers that have expired. timersManager_->NextTimerTime(&tmv); while(tmv.tv_sec == 0 && tmv.tv_usec == 0){ // Timer at the head of the queue has expired timersManager_->ExecuteNextTimer(); timersManager_->NextTimerTime(&tmv); } } else if (status > 0){ // The socket has received data. // Perform packet processing. //for(int i=1;i<33;i++) // { // outfile_client<<"client"<<hex<<MY_TOKEN<<"#"<<i<<":"<<hex<<FT[i].NODE_TOKEN<<"->"<<dec<<FT[i].udp_port<<endl; // } //outfile_client<<"PREDECESSOR: "<<PREDECESSOR<<endl; //outfile_client<<"DOUBLE_SUCC: "<<DOUBLE_SUCC<<"port: "<<DOUBLE_SUCC_PORT<<endl; //outfile_client<<"data on socket ---------------"<<endl; /////////////////////// // got msg on UDP port /////////////////////// //cout<<"CLIENT:"<<CLIENT_NAME<<"->"<<" got from port"<<endl; if(FD_ISSET(UDP_private,&READ_SET)) { int num_read1; outfile_client<<endl; //ioctl(UDP_private,FIONREAD,&num_read1); //if(num_read1< MARSHALLING_UDP obj; obj.RECEIVE(UDP_private); } if(FD_ISSET(sockfd_client,&READ_SET)) { int num_read; ioctl(sockfd_client,FIONREAD,&num_read); if(num_read<=0) { continue; } //recv_tcp(); int numbytes_client; char RECV[100],RECV1[100]; if ((numbytes_client = recv(sockfd_client, RECV, sizeof RECV, 0)) == -1) { perror("recv_TCP_client"); exit(1); } //outfile_client<<"received msg from manager:"<<RECV<<endl; inst.instruction=strtok(RECV,"-"); inst.DATA=strtok(NULL,"\0"); //outfile_client<<"received msg :"<<inst.instruction<<endl; //outfile_client<<"received data :"<<inst.DATA<<endl; uint32_t data_hash= nonce_name_hash((uint32_t)(htonl(atoi(NONCE))),inst.DATA); char DUMMY_store[]="store"; char DUMMY_search[]="search"; char DUMMY_end_client[]="end_client"; char DUMMY_kill_client[]="kill_client"; int YES; uint32_t numbers[]={0,1,2,3}; uint32_t temp; //cout<<"data hash is "<<hex<<data_hash<<endl; if (strcmp((char *)inst.instruction,DUMMY_store)==0 ) { if(STAGE.compare("7")==0) { for (int i=0;i<4;i++) { data_hash= (numbers[i]<<30) | (0x3fffffff & data_hash ); cout<< "DATA_HASH VALUE IS ------->"<<hex<<data_hash<<endl; //DATA_HASH=data_hash; // setting the global value of DATA_HASH store_func(data_hash); } } else { store_func(data_hash); } } else if(strcmp((char *)inst.instruction,DUMMY_search)==0 ) { cout<<"&&&&&&&&&&&&&&&&&&& in SEARCH"<<endl; uint32_t min1,min2,temp,temporary; min1=0xffffffff; uint32_t diff[4]; map <uint32_t,uint32_t> mapping; global_search_counter=0; if(STAGE.compare("7")==0) { for (int i=0;i<4;i++) { temp= (numbers[i]<<30) | (0x3fffffff & data_hash ); //cout<< "DATA_HASH VALUE IS ------->"<<hex<<data_hash<<endl; //DATA_HASH=data_hash; // setting the global value of DATA_HASH diff[i] = calculate((uint64_t)temp,(uint64_t)MY_TOKEN,0); mapping[diff[i]]= temp; cout << diff[i] <<"->"<<hex<<mapping[diff[i]]<<endl; } for (int j=0;j<4;j++) // sorting the differences { for (int k=j+1;k<4;k++) { if (diff[k]< diff[j] ) { temporary= diff[j]; diff[j]=diff[k]; diff[k]=temporary; } } } for (int g=0;g<4;g++) { cout<<"diff is: "<<diff[g]<<endl; } cout<< "nearest 2 are : "<< hex<<mapping[diff[0]]<<", "<<hex<<mapping[diff[1]]<<endl; search_func(mapping[diff[0]]); search_func(mapping[diff[1]]); } else { search_func(data_hash); } } else if(strcmp((char *)inst.instruction,DUMMY_kill_client)==0 ) { cout<<"CLIENT: "<<CLIENT_NAME<<"-> killing my self ---- got the kill signal from manager"<<endl; //outfile_client<<endl; exit(1); } } } //end data on socket }// end while 1 return; }
static void translate(Dwarf_Debug dbg, const char* addrstr) { Dwarf_Die die, ret_die; Dwarf_Line *lbuf; Dwarf_Error de; Dwarf_Half tag; Dwarf_Unsigned lopc, hipc, addr, lineno, plineno; Dwarf_Signed lcount; Dwarf_Addr lineaddr, plineaddr; char *funcname; char *file, *file0, *pfile; char demangled[1024]; int i, ret; addr = strtoull(addrstr, NULL, 16); addr += section_base; lineno = 0; file = unknown; die = NULL; lbuf = NULL; lcount = 0; while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL, NULL, &de)) == DW_DLV_OK) { die = NULL; while (dwarf_siblingof(dbg, die, &ret_die, &de) == DW_DLV_OK) { if (die != NULL) dwarf_dealloc(dbg, die, DW_DLA_DIE); die = ret_die; if (dwarf_tag(die, &tag, &de) != DW_DLV_OK) { warnx("dwarf_tag failed: %s", dwarf_errmsg(de)); goto next_cu; } /* XXX: What about DW_TAG_partial_unit? */ if (tag == DW_TAG_compile_unit) break; } if (ret_die == NULL) { warnx("could not find DW_TAG_compile_unit die"); goto next_cu; } if (!dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) && !dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc, &de)) { /* * Check if the address falls into the PC range of * this CU. */ if (handle_high_pc(die, lopc, &hipc) != DW_DLV_OK) goto next_cu; if (addr < lopc || addr >= hipc) goto next_cu; } switch (dwarf_srclines(die, &lbuf, &lcount, &de)) { case DW_DLV_OK: break; case DW_DLV_NO_ENTRY: /* If a CU lacks debug info, just skip it. */ goto next_cu; default: warnx("dwarf_srclines: %s", dwarf_errmsg(de)); goto out; } plineaddr = ~0ULL; plineno = 0; pfile = unknown; for (i = 0; i < lcount; i++) { if (dwarf_lineaddr(lbuf[i], &lineaddr, &de)) { warnx("dwarf_lineaddr: %s", dwarf_errmsg(de)); goto out; } if (dwarf_lineno(lbuf[i], &lineno, &de)) { warnx("dwarf_lineno: %s", dwarf_errmsg(de)); goto out; } if (dwarf_linesrc(lbuf[i], &file0, &de)) { warnx("dwarf_linesrc: %s", dwarf_errmsg(de)); } else file = file0; if (addr == lineaddr) goto out; else if (addr < lineaddr && addr > plineaddr) { lineno = plineno; file = pfile; goto out; } plineaddr = lineaddr; plineno = lineno; pfile = file; } next_cu: if (die != NULL) { dwarf_dealloc(dbg, die, DW_DLA_DIE); die = NULL; } } out: funcname = NULL; if (ret == DW_DLV_OK && func) { search_func(dbg, die, addr, &funcname); die = NULL; } if (func) { if (funcname == NULL) if ((funcname = strdup(unknown)) == NULL) err(EXIT_FAILURE, "strdup"); if (demangle && !elftc_demangle(funcname, demangled, sizeof(demangled), 0)) printf("%s\n", demangled); else printf("%s\n", funcname); free(funcname); } (void) printf("%s:%ju\n", base ? basename(file) : file, lineno); if (die != NULL) dwarf_dealloc(dbg, die, DW_DLA_DIE); /* * Reset internal CU pointer, so we will start from the first CU * next round. */ while (ret != DW_DLV_NO_ENTRY) { if (ret == DW_DLV_ERROR) errx(EXIT_FAILURE, "dwarf_next_cu_header: %s", dwarf_errmsg(de)); ret = dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL, NULL, &de); } }
static void search_func(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Addr addr, char **rlt_func) { Dwarf_Die ret_die, spec_die; Dwarf_Error de; Dwarf_Half tag; Dwarf_Unsigned lopc, hipc; Dwarf_Off ref; Dwarf_Attribute sub_at, spec_at; char *func0; const char *func1; int ret; if (*rlt_func != NULL) goto done; if (dwarf_tag(die, &tag, &de)) { warnx("dwarf_tag: %s", dwarf_errmsg(de)); goto cont_search; } if (tag == DW_TAG_subprogram) { if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) || dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc, &de)) goto cont_search; if (handle_high_pc(die, lopc, &hipc) != DW_DLV_OK) goto cont_search; if (addr < lopc || addr >= hipc) goto cont_search; /* Found it! */ if ((*rlt_func = strdup(unknown)) == NULL) err(EXIT_FAILURE, "strdup"); ret = dwarf_attr(die, DW_AT_name, &sub_at, &de); if (ret == DW_DLV_ERROR) goto done; if (ret == DW_DLV_OK) { if (dwarf_formstring(sub_at, &func0, &de) == DW_DLV_OK) { free(*rlt_func); if ((*rlt_func = strdup(func0)) == NULL) err(EXIT_FAILURE, "strdup"); } goto done; } /* * If DW_AT_name is not present, but DW_AT_specification is * present, then probably the actual name is in the DIE * referenced by DW_AT_specification. */ if (dwarf_attr(die, DW_AT_specification, &spec_at, &de)) goto done; if (dwarf_global_formref(spec_at, &ref, &de)) goto done; if (dwarf_offdie(dbg, ref, &spec_die, &de)) goto done; if (dwarf_attrval_string(spec_die, DW_AT_name, &func1, &de) == DW_DLV_OK) { free(*rlt_func); if ((*rlt_func = strdup(func1)) == NULL) err(EXIT_FAILURE, "strdup"); } goto done; } cont_search: /* Search children. */ ret = dwarf_child(die, &ret_die, &de); if (ret == DW_DLV_ERROR) errx(EXIT_FAILURE, "dwarf_child: %s", dwarf_errmsg(de)); else if (ret == DW_DLV_OK) search_func(dbg, ret_die, addr, rlt_func); /* Search sibling. */ ret = dwarf_siblingof(dbg, die, &ret_die, &de); if (ret == DW_DLV_ERROR) errx(EXIT_FAILURE, "dwarf_siblingof: %s", dwarf_errmsg(de)); else if (ret == DW_DLV_OK) search_func(dbg, ret_die, addr, rlt_func); done: dwarf_dealloc(dbg, die, DW_DLA_DIE); }