bool redis_hash::hmget(const char* key, const std::vector<const char*>& names, std::vector<string>* result /* = NULL */) { hash_slot(key); build("HMGET", key, names); return get_strings(result) >= 0 ? true : false; }
int sock_get_strings(int purpose, char ** vals, int num) { if (accept_if_needed(purpose) != -1) return get_strings(purpose_table[purpose], vals, num); return -1; }
int redis_zset::zrange_get(const char* cmd, const char* key, int start, int stop, std::vector<string>* result) { const char* argv[4]; size_t lens[4]; argv[0] = cmd; lens[0] = strlen(cmd); argv[1] = key; lens[1] = strlen(key); char start_s[INTLEN], stop_s[INTLEN]; safe_snprintf(start_s, sizeof(start_s), "%d", start); safe_snprintf(stop_s, sizeof(stop_s), "%d", stop); argv[2] = start_s; lens[2] = strlen(start_s); argv[3] = stop_s; lens[3] = strlen(stop_s); hash_slot(key); build_request(4, argv, lens); return get_strings(result); }
int redis_zset::zrangebylex(const char* key, const char* min, const char* max, std::vector<string>* out, const int* offset /* = NULL */, const int* count /* = NULL */) { const char* argv[7]; size_t lens[7]; size_t argc = 4; argv[0] = "ZRANGEBYLEX"; lens[0] = sizeof("ZRANGEBYLEX") - 1; argv[1] = key; lens[1] = strlen(key); argv[2] = min; lens[2] = strlen(min); argv[3] = max; lens[3] = strlen(max); if (offset != NULL && count != NULL) { argv[4] = min; lens[4] = strlen(min); argc++; argv[5] = max; lens[5] = strlen(max); argc++; } hash_slot(key); build_request(argc, argv, lens); return get_strings(out); }
int main(int ac, char *av[]) { int i, j, k=-1, c, err=0, oclose=0; char *ifile=NULL, rdtok[MAXLABLEN], rdfile[MAXLABLEN]; FILE *fp, *ofp=stdout; TreePtr gtree=NULL, ttree=NULL; AlPtr align=NULL, zalign; SPConf peval=init_peval(); extern char *optarg; extern int optind; while ((c = getopt(ac, av, "p:a:F:v?")) != -1) switch (c) { case 'v': peval->verbose = 1; break; case 'p': peval->params=optarg; break; case 'F': ofp=myfopen(optarg,"w"); oclose=1; break; case '?': default: err++; } if (err || ac != optind+3) { fprintf(stderr, USAGE, av[0]); exit(1); } if (peval->params != NULL) config_peval(peval,&rdfile[0],&rdtok[0]); strcpy(peval->gfile,av[optind]); strcpy(peval->tfile,av[optind+1]); fp=myfopen(av[optind],"r"); while (fgets(rdfile,MAXLABLEN,fp) != NULL) { i=0; while (ws(rdfile[i])) i++; if (rdfile[i]=='\n') continue; gtree=load_tree(&rdfile[0],&rdtok[0],&i,NULL,NULL,peval,1,gtree,0,'g'); } fclose(fp); i=0; fp=myfopen(av[optind+1],"r"); while (fgets(rdfile,MAXLABLEN,fp) != NULL) { i=0; while (ws(rdfile[i])) i++; if (rdfile[i]=='\n') continue; ttree=load_tree(&rdfile[0],&rdtok[0],&i,NULL,NULL,peval,0,ttree,0,'t'); } fclose(fp); fp=myfopen(av[optind+2],"r"); align=get_rawalign(fp,&rdfile[0],&rdtok[0]); fclose(fp); get_strings(gtree,ttree,align, &rdtok[0],0); show_align(ofp,align,peval); if (oclose) fclose(ofp); }
static void _get_picker_strings(QSP_ARG_DECL Screen_Obj *sop, int n_cyl ) { int *count_tbl; int i, j, n_max; const char **string_arr; int n; // set by get_strings? SET_SOB_SELECTOR_TBL(sop, (const char ***)getbuf( n_cyl * sizeof(char **) )); SET_SOB_N_CYLINDERS(sop, n_cyl ); count_tbl = getbuf( n_cyl * sizeof(int) ); SET_SOB_COUNT_TBL(sop,count_tbl); n_max=0; for(i=0;i<n_cyl;i++){ const char **selectors; n=get_strings(sop,&string_arr); if( n < 0 ) return; // BUG clean up! else if( n > 0 ){ SET_SOB_N_SELECTORS_AT_IDX(sop, i, n); selectors = (const char **)getbuf( n * sizeof(char **) ); SET_SOB_SELECTORS_AT_IDX(sop, i, selectors ); for(j=0;j<n;j++){ SET_SOB_SELECTOR_AT_IDX(sop,i,j,string_arr[j]); } givbuf(string_arr); if( n > n_max ) n_max = n; } else { assert(string_arr == NULL); } } }
bool redis_hash::hmget(const char* key, const char* names[], const size_t lens[], size_t argc, std::vector<string>* result /* = NULL */) { hash_slot(key); build("HMGET", key, names, lens, argc); return get_strings(result) >= 0 ? true : false; }
bool redis_hash::hkeys(const char* key, std::vector<string>& names) { const char* keys[1]; keys[0] = key; hash_slot(key); build("HKEYS", NULL, keys, 1); return get_strings(names) < 0 ? false : true; }
bool redis_hash::hgetall(const char* key, std::map<string, string>& result) { const char* keys[1]; keys[0] = key; hash_slot(key); build("HGETALL", NULL, keys, 1); return get_strings(result) < 0 ? false : true; }
bool redis_hash::hgetall(const char* key, std::vector<const char*>& names, std::vector<const char*>& values) { const char* keys[1]; keys[0] = key; hash_slot(key); build("HGETALL", NULL, keys, 1); return get_strings(names, values) < 0 ? false : true; }
t_aa_names *get_aa_names(void) { /* Read the database in aminoacids.dat */ t_aa_names *aan; snew(aan,1); aan->n = get_strings("aminoacids.dat",&(aan->aa)); /* qsort(aan->aa,aan->n,sizeof(aan->aa[0]),strcmp);*/ return aan; }
int redis_key::keys_pattern(const char* pattern, std::vector<string>* out) { const char* argv[2]; size_t lens[2]; argv[0] = "KEYS"; lens[0] = sizeof("KEYS") - 1; argv[1] = pattern; lens[1] = strlen(pattern); build_request(2, argv, lens); return get_strings(out); }
static gmx_bool *bPhobics(int nres,char *resnm[]) { int i,nb; char **cb; gmx_bool *bb; nb=get_strings("phbres.dat",&cb); snew(bb,nres); for(i=0; (i<nres); i++) { if (search_str(nb,cb,resnm[i]) != -1) bb[i]=TRUE; } return bb; }
static void read_dict() { int index; for (index = 0; (string = get_strings()); ++index) { if (string[0] == '\0') continue; strings = (char**) realloc(strings, (index+1)*sizeof(*strings)); if (strings == NULL) { bail_out(EXIT_FAILURE, "realloc(3) failed"); } strings[index] = string; } /* Take a note of how many entries we have yet. */ dict_size = index; }
void PluginMessages::unreg (SmartPointer<Client> client, Vector<Byte> data) { auto channels=get_strings(data); lock.Write([&] () mutable { auto iter=clients.find(client); if (iter==clients.end()) return; for (auto & channel : channels) iter->second.erase(channel); }); }
bool *bPhobics(t_atoms *atoms) { int i,nb; char **cb; bool *bb; nb=get_strings("phbres.dat",&cb); snew(bb,atoms->nres); for(i=0; (i<atoms->nres); i++) { if (search_str(nb,cb,*atoms->resname[i]) != -1) bb[i]=TRUE; } return bb; }
bool redis_string::mget(std::vector<string>* out, const char* first_key, ...) { std::vector<const char*> keys; keys.push_back(first_key); va_list ap; va_start(ap, first_key); const char* key; while ((key = va_arg(ap, const char*)) != NULL) keys.push_back(key); va_end(ap); build("MGET", NULL, keys); return get_strings(out) >= 0 ? true : false; }
int Context::get_strings_and_reopen() { // Get device strings (closes device) int ret=get_strings(); if (ret < 0) { d->open = 0; return ret; } // Reattach device ret = ftdi_usb_open_dev(d->ftdi, d->dev); d->open = (ret >= 0); return ret; }
/* * The main function */ int main (int argc, char *argv[]) { swf_extractor * swf; int error = SWF_ENoError; int num_string, num_url, i; char ** strings, ** urls; /* Check the argument count. */ if (argc < 2) { /* Bad arguments. */ usage(argv[0]); return -1; } swf = load_swf (argv[1], &error); if (error!=SWF_ENoError) { fprintf (stderr, "Error creating parser : %s\n", swf_error_code_to_string (error)); return error; } num_string = get_number_strings (swf); num_url = get_number_urls (swf); strings = get_strings (swf); urls = get_urls (swf); printf ("Number of strings is %d\n", num_string); for (i=0; i<num_string; i++) { printf ("\t ... %s\n",strings[i]); } printf ("\n\n"); printf ("Number of urls is %d\n", num_url); for (i=0; i<num_url; i++) { printf ("\t ... %s\n",urls[i]); } destroy_swf (swf); return error; }
static gmx_bool *bPhobics(t_atoms *atoms) { int i, nb; char **cb; gmx_bool *bb; nb = get_strings("phbres.dat", &cb); snew(bb, atoms->nres); for (i = 0; (i < atoms->nres); i++) { if (-1 != search_str(nb, cb, *atoms->resinfo[i].name) ) { bb[i] = TRUE; } } return bb; }
int redis_zset::zrangebyscore_get(const char* cmd, const char* key, const char* min, const char* max, std::vector<string>* out, const int* offset /* = NULL */, const int* count /* = NULL */) { const char* argv[8]; size_t lens[8]; size_t argc = 4; argv[0] = cmd; lens[0] = strlen(cmd); argv[1] = key; lens[1] = strlen(key); argv[2] = min; lens[2] = strlen(min); argv[3] = max; lens[3] = strlen(max); char offset_s[INTLEN], count_s[INTLEN]; if (offset && count) { safe_snprintf(offset_s, sizeof(offset_s), "%d", *offset); safe_snprintf(count_s, sizeof(count_s), "%d", *count); argv[4] = "LIMIT"; lens[4] = sizeof("LIMIT") - 1; argv[5] = offset_s; lens[5] = strlen(offset_s); argv[6] = count_s; lens[6] = strlen(count_s); argc += 3; } hash_slot(key); build_request(argc, argv, lens); return get_strings(out); }
bool redis_list::lrange(const char* key, int start, int end, std::vector<string>* result) { const char* argv[4]; size_t lens[4]; argv[0] = "LRANGE"; lens[0] = sizeof("LRANGE") - 1; argv[1] = key; lens[1] = strlen(key); char start_s[LONG_LEN], end_s[LONG_LEN]; safe_snprintf(start_s, sizeof(start_s), "%d", start); safe_snprintf(end_s, sizeof(end_s), "%d", end); argv[2] = start_s; lens[2] = strlen(start_s); argv[3] = end_s; lens[3] = strlen(end_s); build_request(4, argv, lens); return get_strings(result) < 0 ? false : true; }
int redis_command::get_strings(std::vector<string>& out) { return get_strings(&out); }
int main (int argc, char** argv) { get_strings(argv[0]); }
int sporth_oscmorph4(sporth_stack *stack, void *ud) { plumber_data *pd = ud; SPFLOAT out; sporth_oscmorph *oscmorph; switch(pd->mode) { case PLUMBER_CREATE: #ifdef DEBUG_MODE fprintf(stderr, "oscmorph: Creating\n"); #endif oscmorph = malloc(sizeof(sporth_oscmorph)); sp_oscmorph_create(&oscmorph->data); oscmorph->nft = 4; oscmorph->ft = malloc(sizeof(sp_ftbl *) * 4); oscmorph->ftname = malloc(sizeof(char *) * 4); plumber_add_ugen(pd, SPORTH_OSCMORPH4, oscmorph); if(sporth_check_args(stack, "ffffssss") != SPORTH_OK) { fprintf(stderr,"Not enough arguments for oscmorph\n"); stack->error++; return PLUMBER_NOTOK; } get_strings(stack, oscmorph); pop_args(stack, oscmorph); if(search_for_ft(pd, oscmorph) == PLUMBER_NOTOK) { stack->error++; return PLUMBER_NOTOK; } sporth_stack_push_float(stack, 0); free_strings(oscmorph); break; case PLUMBER_INIT: #ifdef DEBUG_MODE fprintf(stderr, "oscmorph: Initialising\n"); #endif oscmorph = pd->last->ud; get_strings(stack, oscmorph); pop_args(stack, oscmorph); sp_oscmorph_init(pd->sp, oscmorph->data, oscmorph->ft, oscmorph->nft, oscmorph->phase); sporth_stack_push_float(stack, 0); free_strings(oscmorph); break; case PLUMBER_COMPUTE: oscmorph = pd->last->ud; pop_args(stack, oscmorph); set_args(oscmorph); sp_oscmorph_compute(pd->sp, oscmorph->data, NULL, &out); sporth_stack_push_float(stack, out); break; case PLUMBER_DESTROY: oscmorph = pd->last->ud; free(oscmorph->ftname); free(oscmorph->ft); sp_oscmorph_destroy(&oscmorph->data); free(oscmorph); break; default: fprintf(stderr, "oscmorph: Unknown mode!\n"); break; } return PLUMBER_OK; }
int main( int nArgs, const char * const args[] ) { if( nArgs != 2 ) { printf("%s: <image>\n", args[0] ); return 1; } const char * infile = args[1]; std::vector<uint8_t> fbuf; { std::ifstream f( infile, std::ios::binary | std::ios::ate ); if( !f.is_open() ) { printf("Unable to open %s\n",infile); return 2; } fbuf.resize( f.tellg() ); f.seekg(0); f.read( (char*)&fbuf[0], fbuf.size() ); if( f.gcount() != fbuf.size() ) { printf("Unable to fully read %s\n",infile); return 3; } } printf( "Scanning binary for strings...\n" ); stable str_table = get_strings( fbuf ); printf( "Total strings found: %d\n", str_table.size() ); printf( "Scanning binary for pointers...\n" ); ptable ptr_table = get_pointers( fbuf ); printf( "Total pointers found: %d\n", ptr_table.size() ); // signal.signal(signal.SIGINT, high_scores) MutexType mutex; //protects next few variables unsigned top_score = 0; scorecard scores; #ifdef _OPENMP #pragma omp parallel for #endif for( offset_t base = 0; base < 0xf0000000UL; base += 0x1000 ) { #ifndef _OPENMP //Turn off status display when using OpenMP //otherwise the numbers will be scrabled if( base % 0x10000 == 0 ) printf( "Trying base address 0x%x\n", base ); #endif unsigned score = 0; for(ptable::iterator iter = ptr_table.begin(); iter != ptr_table.end(); ++iter) { offset_t ptr = iter->first; if( ptr < base ) continue; if( ptr >= (base + fbuf.size()) ) continue; unsigned offset = ptr - base; if( str_table.find(offset) != str_table.end() ) score += iter->second; } if( score ) { mutex.Lock(); scores.push_back( std::make_pair( score, base ) ); if( score > top_score ) { top_score = score; printf( "New highest score, 0x%x: %d\n", base, score ); } mutex.Unlock(); } } std::sort(scores.begin(),scores.end() ); high_scores( scores ); }
bool redis_string::mget(const std::vector<const char*>& keys, std::vector<string>* out /* = NULL */) { build("MGET", NULL, keys); return get_strings(out) >= 0 ? true : false; }
int redis_command::get_strings(std::list<string>& out) { return get_strings(&out); }
bool redis_string::mget(const char* keys[], const size_t keys_len[], size_t argc, std::vector<string>* out /* = NULL */) { build("MGET", NULL, keys, keys_len, argc); return get_strings(out) >= 0 ? true : false; }
int main() { void display_help(); void get_strings(); char *search_strings(); void copy_strings(); void display_results(); char str1[32], str2[4], str3[8], str4[1024]; char *ptr1, *ptr2, *ptr3; char *start_ptr, *match_ptr, *copy_ptr; int match_ctr; ptr1 = ptr2 = ptr3 = NULL; start_ptr = match_ptr = copy_ptr = NULL; match_ctr = 0; display_help(); get_strings( str1, str2, str3 ); ptr1 = str1; ptr2 = str2; ptr3 = str3; start_ptr = str1; copy_ptr = str4; // TO DO: while( *start_ptr != '\0' ) while( start_ptr <= ( str1 + strlen( str1 ) ) ) { if( debug_flag == 1 ) printf( "\n START ptr = %c", *start_ptr ); match_ptr = search_strings( str1, str2, start_ptr ); if( match_ptr ) { match_ctr ++; if( debug_flag == 1 ) printf( "\n if - MATCH ctr %d: need to start copy/replace", match_ctr ); // RESULT STRING: copy from archive string start location to match location copy_strings( start_ptr, match_ptr, str4, copy_ptr ); copy_ptr += match_ptr - start_ptr; // RESULT STRING: copy entire replacement string, i.e. replace query string copy_strings( ptr3, ptr3 + strlen( str3 ), str4, copy_ptr ); if( debug_flag == 1 ) printf( "\n MATCH: RESULT STR4: %s", str4 ); start_ptr = match_ptr + strlen(str2); copy_ptr += strlen( str3 ); if( debug_flag == 1 ) printf( "\n continue searching from %c", *start_ptr ); } else { if( debug_flag == 1 ) printf("\n else - match ctr = %d", match_ctr); if( match_ctr != 0) { // RESULT STRING: copy from archive string last match location until end if( debug_flag == 1 ) printf( "\n NO MATCH: copy from last match start ptr %c until end", *start_ptr ); copy_strings( start_ptr, str1 + strlen( str1 ), str4, copy_ptr ); if( debug_flag == 1 ) printf( "\n NO MATCH: RESULT STR4: %s", str4 ); break; } else { strcpy( str4, "The archive string does not contain the query string." ); break; } start_ptr ++; } } display_results( str1, str2, str3, str4 ); return 0; } // end main()