void ProcessFile(void (*funct)(UNCH *n, FILE *f), UNCH *e, UNCH *fln){ UNCH s[100], s2[100]; s2[0] = 0; makefilename(s, fln,e); if(dtdfilename != 0)makefilename(s2, dtdfilename,e); FILE *f = fopen((char *)s, "r"); if (f != 0) funct(s, f); else if(s2[0] != 0){ f = fopen((char *)s2, "r"); if (f) funct(s2, f); } else { /*RES OLD MSG 586 Neither %0 file "%1" or "%2" was found. SGML2TDB will stop. */ ResFile->MsgData(e); ResFile->MsgData(s); ResFile->MsgData(s2); ResFile->PutResError( /*RES REM INS*/ 586); exit(100); } };
int c0x_mkdirname(char *path, size_t max, const char *dir, const char *sub) { #if DEBUGS printf("$ mkdirname(path=%08p, max=%u, dir=%08p='%.9999s',\n" "$ sub=%08p='%.9999s')\n", path, max, dir, (dir != NULL ? dir : ""), sub, (sub != NULL ? sub : "")); #endif /* Construct a directory pathname */ return (makefilename(path, max, dir, sub)); }
int c0x_mkfilename(char *path, size_t max, const char *dir, const char *file) { #if DEBUGS printf("$ mkfilename(path=%08p, max=%u, dir=%08p='%.9999s',\n" "$ file=%08p='%.9999s')\n", path, max, dir, (dir != NULL ? dir : ""), file, (file != NULL ? file : "")); #endif /* Construct a file pathname */ return (makefilename(path, max, dir, file)); }
void readsetupfiles(UNCH * fln){ initialalpData(); globalvars = new varnamestype; localvars = new varnamestype; ProcessFile(processalpfile, ".alp", fln); BuildAlphabetXlate(AlphaLines, DiacRetLines,DiacNonLines, ContinuText, WordSepSeq); ProcessFile(processepmfile, ".epm", fln); delete globalvars; delete localvars; UNCH s[100]; makefilename(s, fln,(UNCH *)".tdb"); StartTDBFile(s, TitleText, RefTemText); makemytagstk(); PgmSetup(); startdynamicdata(vtype); initpgm->Execute(); delete initpgm; };
//#pragma argsused short PD_style _ASK_Distinct( OpndType *lpOpnd, short ParaNum, short *OpndTop, \ short *CurState ) { dFIELDWHENACTION *p; char buf[256]; dFIELD *field; extern WSToMT FromToStru fFrTo; extern char tmpPath[MAXPATH]; //asqlana.c if( *CurState == 0 ) { short i; if( fFrTo.distinctBh != NULL ) { *OpndTop -= ParaNum; /* maintain the opnd stack */ return 0; } if( xIsOpndField( &lpOpnd[0] ) == 0 ) { i = (short)xGetOpndLong( &lpOpnd[0] ); if( i < 1 ) { return 1; } } else { i = -1; } sprintf(buf, "DT%03X%03X.NDX", (fFrTo.insideInt)++, intOfThread&0xFFF); makefilename(buf, tmpPath, buf); if( i < 1 ) { p = (dFIELDWHENACTION *)lpOpnd[0].oval; field=getFieldInfo(p->pSourceDfile, p->wSourceid); fFrTo.distinctBh=BppTreeBuild(buf, (short)(field->fieldlen)); } else { fFrTo.distinctBh=BppTreeBuild(buf, i); } } else if( *CurState > 0 ) { if( xIsOpndField( &lpOpnd[0] ) == 0 ) { char *sz = xGetOpndString( &lpOpnd[1] ); strZcpy(buf, sz, 256); } else { p = (dFIELDWHENACTION *)lpOpnd[0].oval; get_fld(p->pSourceDfile, p->wSourceid, buf); } if( IndexSeek(fFrTo.distinctBh, buf) == LONG_MIN ) { IndexRecIns(fFrTo.distinctBh, buf, LONG_MAX); } else { return 2; } } else { /*sprintf(buf, "DIST_%03X.NDX", intOfThread&0xFFF); makefilename(buf, tmpPath, buf); */ strcpy(buf, fFrTo.distinctBh->ndxName); IndexDispose(fFrTo.distinctBh); fFrTo.distinctBh = NULL; unlink(buf); } return 0; } //end of _ASK_Distinct()
/* asqlBlobPut() * *************************************************************************/ _declspec(dllexport) long asqlBlobPut(TS_CLIENT_CURSOR *tscc, LPCSTR lpszUser, \ LPCSTR lpszUserDir,\ void *df, \ long recNo, \ LPSTR fieldName, \ EXCHNG_BUF_INFO *exbuf ) { TS_COM_PROPS tscp; unsigned short iw; char buf[4096]; char szCn[128]; // int i; memset(&tscp, 0, sizeof(TS_COM_PROPS)); while( tscc != NULL ) { if( tscc->p == (void *)df ) goto agdr_dfTrueR; tscc = tscc->pNext; } df = NULL; agdr_dfTrueR: tscp.packetType = 'R'; tscp.msgType = 'E'; tscp.len = 0; if( df == NULL || recNo <= 0 ) { tscp.lp = -1; memcpy(buf, &tscp, sizeof(TS_COM_PROPS)); SrvWriteExchngBuf(exbuf, buf, sizeof(TS_COM_PROPS)); return -1; } iw = GetFldid((dFILE *)df, fieldName); if( iw == 0xFFFF ) { tscp.lp = -4; memcpy(buf, &tscp, sizeof(TS_COM_PROPS)); SrvWriteExchngBuf(exbuf, buf, sizeof(TS_COM_PROPS)); return -4; } if( lServerAsRunning ) { /*i = 32; GetComputerName(szCn, &i); i = MAXPATH; if( GetUserHomeDir(szCn, lpszUser, buf, &i) != 0 ) { tscp.packetType = 'R'; tscp.msgType = 'E'; tscp.len = 4096-sizeof(TS_COM_PROPS); tscp.lp = 0; memcpy(buf, &tscp, sizeof(TS_COM_PROPS)); strcpy(&buf[sizeof(TS_COM_PROPS)], "ERR:4 INF:No Thread service"); SrvWriteExchngBuf(exbuf, buf, 4096); return 4; }*/ strZcpy(buf, lpszUserDir, MAXPATH); beSurePath(buf); sprintf(szCn, "%s.DTM", fieldName); makefilename(buf, buf, szCn); } else { sprintf(buf, "%s.DTM", fieldName); } wmtDbfLock((dFILE *)df); //((dFILE *)df)->rec_p = recNo; dseek((dFILE *)df, recNo-1, dSEEK_SET); if( get1rec((dFILE *)df) == NULL ) { wmtDbfUnLock((dFILE *)df); tscp.lp = -4; memcpy(buf, &tscp, sizeof(TS_COM_PROPS)); SrvWriteExchngBuf(exbuf, buf, 4096); return -4; } if( (tscp.lp=dbtFromFile((dFILE *)df, iw, buf)) >= 0 ) { tscp.msgType = 'D'; } wmtDbfUnLock((dFILE *)df); memcpy(buf, &tscp, sizeof(TS_COM_PROPS)); SrvWriteExchngBuf(exbuf, buf, tscp.len+sizeof(TS_COM_PROPS)); return 0; } //end of asqlBlobPut()
int main (int argc, char * argv[]) { int i, trim_len_fw, trim_len_rev; //struct reads_info ** ri_left; //struct reads_info ** ri_right; // int cnt_reads_left; // int cnt_reads_right; int read_size; char * out[4]; FILE * fd[4]; int ass; double uncalled_forward, uncalled_reverse; struct user_args sw; struct emp_freq * ef; struct block_t fwd_block; struct block_t rev_block; char two_piece; int elms; if (!decode_switches (argc, argv, &sw)) { /* TODO: Validate reads names */ usage (); return (EXIT_FAILURE); } ef = (struct emp_freq *)malloc (sizeof(struct emp_freq)); ef->freqa = ef->freqc = ef->freqg = ef->freqt = ef->total = ef->pa = ef->pc = ef->pg = ef->pt = ef->q = 0.25; init_scores(sw->phred_base, ef); /* read the two fastq files containing the left-end and right-end reads */ //ri_left = read_fastq(sw.fastq_left, &cnt_reads_left); //ri_right = read_fastq(sw.fastq_right, &cnt_reads_right); //if (!validate_input (cnt_reads_left, cnt_reads_right)) // { // return (EXIT_FAILURE); // } // read_size = strlen (ri_left[0]->data); /* TODO: THIS IS WRONG!!!! TO GET EMPIRICAL FREQUENCIES WE NEED TO READ THE WHOLE FILE :-( */ //ef = get_emp_freq (cnt_reads_right, read_size, fwd_block.reads, rev_block.reads); /* reverse the right ends */ /* allocate memory for the assembled results */ /* ai = (struct asm_info *) malloc (cnt_reads_left * sizeof(struct asm_info)); for (i = 0; i < cnt_reads_left; ++i) { ai[i].data = (char *) malloc ((2 * read_size + 1) * sizeof(char)); ai[i].quality_score = (char *) malloc ((2 * read_size + 1) * sizeof(char)); } */ init_fastq_reader (sw.fastq_left, sw.fastq_right, sw.memory, &fwd_block, &rev_block); /* construct output file names */ out[0] = makefilename (sw.outfile, ".assembled.fastq"); out[1] = makefilename (sw.outfile, ".unassembled.forward.fastq"); out[2] = makefilename (sw.outfile, ".unassembled.reverse.fastq"); out[3] = makefilename (sw.outfile, ".discarded.fastq"); fd[0] = fopen (out[0], "w"); fd[1] = fopen (out[1], "w"); fd[2] = fopen (out[2], "w"); fd[3] = fopen (out[3], "w"); while (1) { elms = get_next_reads (&fwd_block, &rev_block); if (!elms) break; read_size = strlen (fwd_block.reads[0]->data); // printf ("%d elms (Seq)\n", elms); //#pragma omp parallel shared(fwd_block.reads, rev_block.reads, ai) private(i, ass, uncalled, kassian_result) #pragma omp parallel private(i, ass) { /* flags[i] = 1 (assembled) 0 (discarded) 2 (unassembled) */ #pragma omp for schedule (guided) for (i = 0; i < elms; ++ i) { mstrrev (rev_block.reads[i]->data); mstrcpl (rev_block.reads[i]->data); mstrrev (rev_block.reads[i]->qscore); if (sw.emp_freqs == 0) { ass = assembly (fwd_block.reads[i], rev_block.reads[i], &sw); *(fwd_block.reads[i]->qscore - 1) = ass; } else { ass = assembly_ef (fwd_block.reads[i], rev_block.reads[i], ef, &sw); *(fwd_block.reads[i]->qscore - 1) = ass; } } } for ( i = 0; i < elms; ++ i) { two_piece = *(fwd_block.reads[i]->data - 1); *(fwd_block.reads[i]->data - 1) = 0; if (*(fwd_block.reads[i]->qscore - 1) == 1) /* assembled */ { *(fwd_block.reads[i]->qscore - 1) = 0; fprintf (fd[0], "%s\n", fwd_block.reads[i]->header); if (!two_piece) { fprintf (fd[0], "%s\n", fwd_block.reads[i]->data); } else { fprintf (fd[0], "%s", fwd_block.reads[i]->data); fprintf (fd[0], "%s\n", rev_block.reads[i]->data); } fprintf (fd[0], "+\n"); if (!two_piece) { fprintf (fd[0], "%s\n", fwd_block.reads[i]->qscore); } else { fprintf (fd[0], "%s", fwd_block.reads[i]->qscore); fprintf (fd[0], "%s\n", rev_block.reads[i]->qscore); } } else /* not assembled */ { *(fwd_block.reads[i]->qscore - 1) = 0; trim_len_fw = trim (fwd_block.reads[i], &sw, read_size, &uncalled_forward); trim_len_rev = trim_cpl (rev_block.reads[i], &sw, read_size, &uncalled_reverse); if (trim_len_fw < sw.min_trim_len || trim_len_rev < sw.min_trim_len || uncalled_forward >= sw.max_uncalled || uncalled_reverse >= sw.max_uncalled) { /* discarded reads*/ /* Maybe consider printing the untrimmed sequences */ fprintf (fd[3], "%s\n", fwd_block.reads[i]->header); fprintf (fd[3], "%s\n+\n%s\n", fwd_block.reads[i]->data, fwd_block.reads[i]->qscore); fprintf (fd[3], "%s\n", rev_block.reads[i]->header); fprintf (fd[3], "%s\n+\n%s\n", rev_block.reads[i]->data, rev_block.reads[i]->qscore); /* printing the reverse compliment of the original sequence */ } else /* unassembled reads*/ { fprintf (fd[1], "%s\n", fwd_block.reads[i]->header); fprintf (fd[2], "%s\n", rev_block.reads[i]->header); fprintf (fd[1], "%s\n+\n%s\n", fwd_block.reads[i]->data, fwd_block.reads[i]->qscore); fprintf (fd[2], "%s\n+\n%s\n", rev_block.reads[i]->data, rev_block.reads[i]->qscore); /* printing the reverse compliment of the original sequence */ } } } } free (ef); free (out[0]); free (out[1]); free (out[2]); free (out[3]); destroy_reader (); /* TODO: Fix those file closings */ fclose (fd[0]); fclose (fd[1]); fclose (fd[2]); fclose (fd[3]); return (0); }
int main(int argc, char *argv[]) { char *dev; // The device to sniff on char errbuf[PCAP_ERRBUF_SIZE]; // Error string if any operation fails struct bpf_program fp; // The compiled filter (not used) char filter_exp[] = "port 23"; // The filter expression (not used) bpf_u_int32 mask; // Our subnet mask bpf_u_int32 net; // Our network ID struct pfring_pkthdr header; // The header that pfring gives us u_char *packet; // The actual packet int flags,num_pkts=0; // Flags to pass for opening pfring instance, number of packets captured memset(&header,0,sizeof(header)); signal(SIGINT,sigproc); dev = argv[1]; // Set the device manually to arg[1] printf("\nCapture device: %s\n", dev); makefilename(); flags = PF_RING_PROMISC; if((handle = pfring_open(dev, 1520, flags)) == NULL) { //MAX_CAPLEN instead of 1520 printf("pfring_open error"); return(-1); } else { pfring_set_application_name(handle, "packetcapture"); } pfring_enable_ring(handle); dumper = pcap_dump_open(pcap_open_dead(DLT_EN10MB, 16384), filename); //16384 is MTU if(dumper == NULL) { printf("Unable to create dump file %s\n", filename); return(-1); } while(1) { if(pfring_recv(handle, &packet, 0, &header, 1 ) > 0) { //wait for packet, blocking call if(num_pkts>=PACKETS_PER_FILE) { num_pkts = 0; pcap_dump_close(dumper); filenumber++; makefilename(); dumper = pcap_dump_open(pcap_open_dead(DLT_EN10MB, 16384), filename); if(dumper == NULL) { printf("Unable to create dump file %s\n", filename); exit(1); } } pcap_dump((u_char*)dumper, (struct pcap_pkthdr*)&header, packet); fprintf(stdout, "."); fflush(stdout); num_pkts++; } } pcap_dump_close(dumper); pfring_close(handle); return 0; }