char * printSequence (void *space, CharSequence *s, Uint cols) { Uint i, c, k, pos=0, l=0, width=0; char *buf, *buf2; stringset_t *entries; entries=initStringset(space); for (i=0; i < s->length; i++) { /*buf = ALLOCMEMORY(space, NULL, char, 32); buf = my_itoa(s->sequence[i], buf, 10);*/ addString(space, entries, s->sequence[i], strlen(s->sequence[i])); if(SETSTRLEN(entries, i) > width) width = SETSTRLEN(entries, i); } /*add spacer*/ width++; c = cols / (width+1); l = (s->descrlen+2)+(s->namelen+2)+(s->length*(width+1))+((entries->noofstrings/c)*(5+1+1)); buf = ALLOCMEMORY(space, NULL, char, l); memset(&buf[pos++], '>', 1); memmove(&buf[pos], s->url, s->urllen); pos+=s->urllen; memset(&buf[pos++], '\n', 1); memset(&buf[pos++], '>', 1); memmove(&buf[pos], s->alphabetname, s->namelen); pos+=s->namelen; memset(&buf[pos++], '\n', 1); for (i=0; i < entries->noofstrings; i++) { if((i%c) == 0) { memset(&buf[pos++], '\n', 1); buf2 = ALLOCMEMORY(space, NULL, char, 5); buf2 = my_itoa(i, buf2, 10); memset(&buf[pos], ' ', 5-strlen(buf2)); pos += 5-strlen(buf2); memmove(&buf[pos], buf2, strlen(buf2)); pos += strlen(buf2); memset(&buf[pos++], '\t', 1); FREEMEMORY(space, buf2); } k = (width-SETSTRLEN(entries,i)); memset(&buf[pos], ' ', k); pos += k; memmove(&buf[pos], SETSTR(entries, i), SETSTRLEN(entries, i)); pos += SETSTRLEN(entries, i); }
static void checkallbut( int z ) { int i; for ( i = 1; i < 16; i++ ) { int level, up, hipri, mask, req; if ( z == i ) continue; SETSTR( i, z, lstr ); SETSTR( i, z, mstr ); SETSTR( i, z, ustr ); HAL_INTERRUPT_QUERY_INFO( i, level, up, hipri, mask, req); l = level; u = up; m = mask; j = i; #if 0 // for manual testing really... if ( level != levels[i] ) CYG_TEST_INFO( lstr ); if ( up != ups[i] ) CYG_TEST_INFO( ustr ); if ( mask != masks[i] ) CYG_TEST_INFO( mstr ); if ( (level != levels[i] ) | ( up != ups[i] ) | ( mask != masks[i] ) ) { CYG_TEST_INFO( "Re-reading" ); HAL_INTERRUPT_QUERY_INFO( i, level, up, hipri, mask, req); } #endif CYG_TEST_CHECK( level == levels[i], lstr ); CYG_TEST_CHECK( up == ups[i], ustr ); CYG_TEST_CHECK( mask == masks[i], mstr ); } }
void Control::changeStatus(int status, std::string info, int net) { if (net && (net != kZmieniacz::net)) { sCtrl->changeStatus(net, info, status); return; } sCtrl->changeStatus(info, status); int lastSt = (status != -1) ? status : GETINT(cfg::lastSt); if (lastSt != GETINT(cfg::lastSt) || info != GETSTRA(cfg::lastStInfo)) PlugStatusChange(lastSt, info.c_str()); if (status != -1) { SETINT(cfg::lastSt, status); Helpers::chgBtn(ui::tb::tb, ui::tb::btnOk, 0, 0, this->stIcon(status), -1); } SETSTR(cfg::lastStInfo, info.c_str()); this->refreshCombo(info); }
int main(int argc, char** argv) { Uint noofvecs, i; Sint optindex, c; vector_t info; #ifdef MEMMAN_H Spacetable spacetab; #endif void *space = NULL; char *url = NULL; char *outpath = NULL; char *pveclistfile = NULL; char *alphabetfile = NULL; char *vecext="vec"; char *seqext="seq"; struct prob_vec *p_vec; IntSequence *sequence; FAlphabet *alphabet; stringset_t *tok; stringset_t **fn; #ifdef MEMMAN_H initmemoryblocks(&spacetab, 1000); space = &spacetab; #endif while(1) { c=getopt_long(argc, argv, "f:a:o:", long_options, &optindex); if (c==-1) break; switch(c) { case 'f': pveclistfile = optarg; break; case 'a': alphabetfile = optarg; break; case 'o': outpath = optarg; break; default: usage(argv[0]); exit (EXIT_FAILURE); } } if (pveclistfile==NULL || alphabetfile == NULL) { usage(argv[0]); exit (EXIT_FAILURE); } fn=readcsv(space, pveclistfile, ".", &noofvecs); alphabet = loadCSValphabet(space, alphabetfile); sortMapdomain(space, alphabet); for(i=0; i<noofvecs; i++) { INITVECTOR(&info); SETSTR(fn[i],0) = concatdelim(space, SETSTR(fn[i],0), vecext, SETSTRLEN(fn[i],0), 3, '.'); p_vec = prob_vec_read (SETSTR(fn[i],0)); if (p_vec->mship == NULL) prob_vec_expand(p_vec); sequence = encode_prob_vec(space, alphabet, p_vec, 0, 0, cantorchar, &info); sequence->info = (Uint*) info.elements; sequence->namelen= strlen(alphabetfile); COPYSTR(space, sequence->alphabetname, alphabetfile, strlen(alphabetfile)); /*this is a potential security risk*/ if (p_vec->compnd_len > 0) { sequence->descrlen = p_vec->compnd_len-1; COPYSTR(space, sequence->description, p_vec->compnd, p_vec->compnd_len-1); } else { sequence->descrlen = 14; COPYSTR(space, sequence->description, "descriptor n/a", 14); } sequence->urllen = SETSTRLEN(fn[i],0); COPYSTR(space, sequence->url, SETSTR(fn[i],0), SETSTRLEN(fn[i],0)); SETSTR(fn[i],0) = concatdelim(space, SETSTR(fn[i],0), seqext, SETSTRLEN(fn[i],0), 3, '.'); SETSTRLEN(fn[i],0) += 4; if (outpath) { tok = tokensToStringset(space, "/", SETSTR(fn[i],0), SETSTRLEN(fn[i],0)); COPYSTR(space, url, outpath, strlen(outpath)); url = concat(space, url, SETSTR(tok, tok->noofstrings-1), strlen(url), SETSTRLEN(tok, tok->noofstrings-1)); saveSequence(sequence, url); destructStringset(space, tok); FREEMEMORY(space, url); url = NULL; } else { saveSequence(sequence, SETSTR(fn[i],0)); } destructSequence (space, sequence); prob_vec_destroy (p_vec); destructStringset (space, fn[i]); progressBarVT("probability vectors converted", noofvecs-1, i, 25); } printf("\nexit.\n"); FREEMEMORY(space, fn); destructAlphabet(space, alphabet); return EXIT_SUCCESS; }
static LGrab * lgrab_new( const char *device ) { LGrab *lg = IM_NEW( NULL, LGrab ); int i; if( !lg ) return( NULL ); lg->device = NULL; lg->capture_buffer = NULL; lg->capture_size = 0; lg->fd = -1; lg->c_channel = -1; lg->c_width = -1; lg->c_height = -1; lg->c_ngrabs = 1; SETSTR( lg->device, device ); if( !lg->device || (lg->fd = open( lg->device, O_RDWR )) == -1 ) { im_error( "lgrab_new", _( "cannot open video device \"%s\"" ), lg->device ); lgrab_destroy( lg ); return( NULL ); } if( lgrab_ioctl( lg, VIDIOCGCAP, &lg->capability ) ) { im_error( "lgrab_new", "%s", _( "cannot get video capability" ) ); lgrab_destroy( lg ); return( NULL ); } /* Check that it can capture to memory. */ if( !(lg->capability.type & VID_TYPE_CAPTURE) ) { im_error( "lgrab_new", "%s", _( "card cannot capture to memory" ) ); lgrab_destroy( lg ); return( NULL ); } /* Read channel info. */ for( i = 0; i < IM_MIN( lg->capability.channels, IM_MAXCHANNELS ); i++ ) { lg->channel[i].channel = i; if( lgrab_ioctl( lg, VIDIOCGCHAN, &lg->channel[i] ) ) { lgrab_destroy( lg ); return( NULL ); } } /* Get other props. */ if( lgrab_ioctl( lg, VIDIOCGWIN, &lg->window) || lgrab_ioctl( lg, VIDIOCGPICT, &lg->picture) ) { lgrab_destroy( lg ); return( NULL ); } /* Set 24 bit mode. */ lg->picture.depth = 24; lg->picture.palette = VIDEO_PALETTE_RGB24; if( lgrab_ioctl( lg, VIDIOCSPICT, &lg->picture ) ) { lgrab_destroy( lg ); return( NULL ); } return( lg ); }
int main (int argc, char** argv) { Sint optindex, c; unsigned char depictsw=0; unsigned char wurst=1; unsigned char gnuplot=0; Uint i, j, noofseqs=0, nooffreqs=0, noofqueries=0; Uint noofhits=100; Uint substrlen = 10; Uint minseeds = 5; Uint maxmatches = 10000; char *seq, *vec, *bin; imbissinfo *imbiss; void *space = NULL; double *scores = NULL; int swscores[2]={3,-2}; char *pveclistfile=NULL; char *alphabetfile=NULL; char *inputfile=NULL; char *batchfile = NULL; char *subfile=NULL; char *reportfile = NULL; int (*handler) (void *, Matchtype *, IntSequence **, Uint, Uint, void *) = allscores; double (*filter) (void *, Matchtype *, IntSequence *, IntSequence *, Uint *, Uint, Uint, void *) = swconstfilter; Matchtype* (*select) (void *, Matchtype *, Uint k, IntSequence *, IntSequence **, void *) = selectSW; stringset_t **fn, **freq, *queryurl, **queries=NULL; Suffixarray *arr = NULL; IntSequence **sequences = NULL; IntSequence *input = NULL; FAlphabet *alphabet = NULL; PairSint *matches=NULL; Uint percent=0; time_t startsuf, endsuf; double difsuf, difmatch, difrank; #ifdef MEMMAN_H Spacetable spacetab; initmemoryblocks(&spacetab, 100000); space = &spacetab; #endif while(1) { c=getopt_long(argc, argv, "SAghFGBLM:D:r:m:x:n:p:b:s:a:q:l:c:dvw", long_options, &optindex); if (c==-1) break; switch(c) { case 'r': reportfile=optarg; break; case 'v': verbose_flag=1; break; case 'd': depictsw = 1; break; case 's': pveclistfile = optarg; break; case 'a': alphabetfile = optarg; break; case 'q': inputfile = optarg; noofqueries = 1; break; case 'l': substrlen = atoi(optarg); break; case 'c': minseeds = atoi(optarg); break; case 'b': batchfile = optarg; break; case 'p': percent = atoi(optarg); break; case 'x': subfile = optarg; break; case 'n': noofhits = atoi(optarg); break; case 'w': wurst = 0; break; case 'B': filter = scorefilter; select = selectBlastScore; break; case 'S': filter = scorefilter; select = selectScore; break; case 'A': filter = swconstfilter; select = selectSW; break; case 'F': filter = scorefilter; select = selectScoreSWconst; break; case 'G': filter = scorefilter; select = selectBlastScoreSWconst; break; case 'M': swscores[0]=atoi(optarg); break; case 'L': handler = latexscores; break; case 'D': swscores[1]=atoi(optarg); break; case 'g': gnuplot = 1; break; case 'm': maxmatches=atoi(optarg); break; case 'h': default: usage(argv[0]); exit (EXIT_FAILURE); } } if (pveclistfile==NULL || (inputfile == NULL && batchfile==NULL) || alphabetfile == NULL) { usage(argv[0]); exit (EXIT_FAILURE); } imbiss = ALLOCMEMORY(space, NULL, imbissinfo, 1); imbiss->reportfile = reportfile; imbiss->swscores = swscores; imbiss->noofhits = noofhits; imbiss->minseeds = minseeds; imbiss->wurst = wurst; /*read batch file*/ if (batchfile) { queries = readcsv(space, batchfile, "", &noofqueries); } /*read substitution matrix*/ if (subfile) { freq=readcsv(space, subfile,",", &nooffreqs); scores = ALLOCMEMORY(space, NULL, double, ((nooffreqs-1)*(nooffreqs-1)) ); for(i=1; i < nooffreqs; i++) { for(j=1; j < nooffreqs; j++) { if(strcmp(SETSTR(freq[i],j),"inf")==0){ MATRIX2D(scores, nooffreqs-1, i, j)=0; }else{ MATRIX2D(scores, nooffreqs-1, i, j)=atof(SETSTR(freq[i],j)); } } } } /*read alphabet*/ if (alphabetfile != NULL) { alphabet = loadCSValphabet(space, alphabetfile); sortMapdomain(space, alphabet); } /*load sequence database*/ fn=readcsv(space, pveclistfile, "", &noofseqs); sequences = ALLOCMEMORY(space, NULL, IntSequence *, noofseqs); for(i=0; i < noofseqs; i++) { sequences[i] = loadSequence(space, SETSTR(fn[i],0)); } for (i=0; i < noofseqs; i++) { destructStringset(space, fn[i]); } FREEMEMORY(space, fn); /*construct the suffix array*/ time (&startsuf); arr = constructSufArr(space, sequences, noofseqs, NULL); constructLcp(space, arr); time (&endsuf); difsuf = difftime (endsuf, startsuf); /*do search*/ for (i=0; i < noofqueries; i++) { /*get query form batchfile*/ if (queries) { inputfile = SETSTR(queries[i],0); } /*typically only used with batchfile*/ if (percent != 0) { substrlen = ((double)((double)input->length/100)*(double) percent); } input = loadSequence(space, inputfile); //seq = printSequence (space, input, 60); printf(">IMBISS order delivered\n"); //printf("%s\n",seq); printf("%s\n", input->url); //FREEMEMORY(space, seq); time (&startsuf); matches=sufSubstring(space, arr, input->sequence, input->length, substrlen); time (&endsuf); difmatch = difftime (endsuf, startsuf); /*get prob vector url for salami/wurst*/ //printf("%.*s\n", 5, input->url + 58); vec = malloc(sizeof(char)*66); sprintf(vec, "/smallfiles/public/no_backup/bm/pdb_all_vec_6mer_struct/%5s.vec\0", input->url+56); bin = malloc(sizeof(char)*54); sprintf(bin, "/smallfiles/public/no_backup/bm/pdb_all_bin/%5s.bin\0", input->url+56); queryurl = initStringset(space); addString(space, queryurl, bin, strlen(bin)); addString(space, queryurl, vec, strlen(vec)); getimbissblast(space, input, sequences, noofseqs, alphabet, imbiss); imbiss->query = queryurl; imbiss->substrlen = substrlen; imbiss->alphabet = alphabet; /*if a substition file was given ...*/ if (subfile) { imbiss->sub = createsubmatrix(scores, imbiss->score, nooffreqs-1); } /*match 'n' report*/ time (&startsuf); imbiss->consensus = ALLOCMEMORY(space, NULL, Uint, (input->length-substrlen)); memset(imbiss->consensus, 0, (sizeof(Uint)*(input->length-substrlen))); rankSufmatch(space, arr, matches, input->length-substrlen, maxmatches, substrlen, sequences, noofseqs, filter, select, handler, input, imbiss, scores, depictsw); if (gnuplot) { consensus (space, imbiss->consensus, input->length-substrlen, input, substrlen, imbiss); } time (&endsuf); difrank = difftime (endsuf, startsuf); printf ("Building the suffixtree has taken %f seconds.\n", difsuf); printf ("Match the suffixtree has taken %f seconds.\n", difmatch); printf ("Rank the suffixtree has taken %f seconds.\n", difrank); /*partial cleanup*/ //destructStringset(space, queryurl); destructSequence(space, input); if(subfile) { FREEMEMORY(space, imbiss->sub); } FREEMEMORY(space, imbiss->consensus); FREEMEMORY(space, imbiss->score); FREEMEMORY(space, matches); free(bin); free(vec); } /*final cleanup*/ for (i=0; i < noofseqs; i++) { destructSequence(space, sequences[i]); } FREEMEMORY(space, sequences); destructSufArr(space, arr); #ifdef MEMMAN_H activeblocks(space); #endif printf("Goodbye.\n"); return EXIT_SUCCESS; }
long UUEXPORT UUVBSaveClipboard( HWND owner, // Owner window handle VBSTRP clipfile) // Clipboard file { FILE *cf; LPSTR cfn; HANDLE cdata; DWORD csize; size_t bsize; long rc; char createf; char _huge *cp, _huge *eob; char wrk[256]; if (!IsClipboardFormatAvailable(CF_TEXT)) return(0); // No text on clipboard cfn = VBDerefHlstrLen(clipfile, &bsize); // Grab the current clipboard filename if (bsize >= sizeof(wrk)) return(0); // Path name is too long if (bsize == 0) { // Need to create a new clipboard filename if (GetTempFileName(0, "uud", 0, wrk) == 0) return(0); // Couldn't create temp name?? SETSTR(clipfile, wrk); // Set the caller's clipboard file name createf = TRUE; } else { // Existing clipboard string memcpy(wrk, cfn, bsize); // Copy the path name wrk[bsize] = EOS; // Terminate string createf = FALSE; } if ((cf = fopen(wrk, (createf) ? "wb" : "ab")) == NULL) return(0); // Couldn't create/append temp if (OpenClipboard(owner) == FALSE) { fclose(cf); return(0); // Couldn't grab clipboard } if ((cdata = GetClipboardData(CF_TEXT)) == NULL || // Couldn't get handle (cp = GlobalLock(cdata)) == NULL) { // Couldn't lock it CloseClipboard(); // Let go of clipboard fclose(cf); return(0); } csize = GlobalSize(cdata); // Read the size of the clipboard while (csize > 0) { bsize = (csize > 8192) ? 8192 : (int) csize; // Size of this block if ((eob = memchr(cp, 0, bsize)) != NULL) { csize = eob - cp; // Found the end of the buffer... bsize = (int) csize; } if (fwrite(cp, 1, bsize, cf) != bsize) { // Error writing rc = 0; goto emex; } csize -= bsize; cp += bsize; } rc = ftell(cf); // OK---we'll return the new file size emex: fclose(cf); GlobalUnlock(cdata); if (rc != 0) EmptyClipboard(); // Operation was OK, clear clipboard CloseClipboard(); return(rc); }