/* Reverse the values of the gen whose table number is given in p0. */ double m_reversegen(float p[], int n_args, double pp[]) { int i, j, slot, size; double *srctable, *desttable; slot = (int) p[0]; srctable = floc(slot); if (srctable == NULL) return die("reversegen", "No function table defined for slot %d.", slot); size = fsize(slot); desttable = new_table(size); if (desttable == NULL) return die("reversegen", "No memory for new function table."); if (!install_gen(slot, size, desttable)) return die("reversegen", "No more function tables available."); for (i = 0, j = size - 1; i < size; i++, j--) desttable[i] = srctable[j]; return (double) size; }
//============================================================================= // ファイルからメモリへの簡易読み込み //============================================================================= // input // szFile : ファイル名 // saDest : 出力先 // dwSize : 読み込むサイズ。ファイルサイズがこれに満たなければエラー // 0(省略時)の時はとりあえず全部読み込んでおく // bError : ファイルサイズがdwSizeに足りない時の挙動 // true:エラーを返す false:その分だけ読み込む(エラーにしない) // // return // 読み込み成功したかどうか // //============================================================================= bool File2Memory(const char* szFile, smart_array< char >& saDest, DWORD dwSize, bool bError) { DWORD filesize = fsize(szFile); if(filesize==0) return false; // ファイルサイズ取得失敗 else if(dwSize>0 && filesize<dwSize){ if(bError) return false; // ファイルサイズが小さすぎ else dwSize = filesize; } else if(dwSize==0 || dwSize>filesize) dwSize = filesize; // 引数省略時とかはファイルを全部読み込む FILE* fp = fopen(szFile, "rb"); if(!fp) return false; // ファイル開けない saDest.Reset(new char[dwSize], dwSize); // ファイル読み込み fread(saDest.GetPtr(), saDest.GetSize(), 1, fp); fclose(fp); return true; }
/* * Pipe the message through the command. * Old message is on stdin of command; * New message collected from stdout. * Sh -c must return 0 to accept the new message. */ void mespipe(FILE *fp, char *cmd) { FILE *nf; int fd; sig_t sigint = signal(SIGINT, SIG_IGN); char *sh, tempname[PATHSIZE]; snprintf(tempname, sizeof(tempname), "%s/mail.ReXXXXXXXXXX", tmpdir); if ((fd = mkstemp(tempname)) == -1 || (nf = Fdopen(fd, "w+")) == NULL) { warn("%s", tempname); goto out; } rm(tempname); /* * stdin = current message. * stdout = new message. */ if ((sh = value("SHELL")) == NULL) sh = _PATH_CSHELL; if (run_command(sh, 0, fileno(fp), fileno(nf), "-c", cmd, NULL) < 0) { Fclose(nf); goto out; } if (fsize(nf) == 0) { fprintf(stderr, "No bytes from \"%s\" !?\n", cmd); Fclose(nf); goto out; } /* * Take new files. */ fseeko(nf, (off_t)0, SEEK_END); collf = nf; Fclose(fp); out: signal(SIGINT, sigint); }
/* Invert the values of the gen whose table number is given in p0. The y-axis center of symmetry is a point halfway between the min and max table values; inversion is performed around this center of symmetry. */ double m_invertgen(float p[], int n_args, double pp[]) { int i, slot, size; double min, max, center, *srctable, *desttable; slot = (int) p[0]; srctable = floc(slot); if (srctable == NULL) return die("invertgen", "No function table defined for slot %d.", slot); size = fsize(slot); desttable = new_table(size); if (desttable == NULL) return die("invertgen", "No memory for new function table."); if (!install_gen(slot, size, desttable)) return die("invertgen", "No more function tables available."); /* determine central y-axis value */ min = DBL_MAX; max = -DBL_MAX; for (i = 0; i < size; i++) { if (srctable[i] < min) min = srctable[i]; if (srctable[i] > max) max = srctable[i]; } center = min + ((max - min) / 2.0); //advise("invertgen", "min: %f, max: %f, center: %f", min, max, center); /* invert values around center */ for (i = 0; i < size; i++) { double diff = srctable[i] - center; desttable[i] = center - diff; } return (double) size; }
/* Quantize the values of the gen whose table number is given in p0 to the quantum given in p1. */ double m_quantizegen(float p[], int n_args, double pp[]) { int i, slot, size; double quantum, *srctable, *desttable; slot = (int) p[0]; srctable = floc(slot); if (srctable == NULL) return die("quantizegen", "No function table defined for slot %d.", slot); size = fsize(slot); quantum = p[1]; if (quantum <= 0.0) return die("quantizegen", "Quantum must be greater than zero."); desttable = new_table(size); if (desttable == NULL) return die("quantizegen", "No memory for new function table."); if (!install_gen(slot, size, desttable)) return die("quantizegen", "No more function tables available."); /* It'd be nice to let the C library do the rounding, but rintf rounds to the nearest even integer, and round and roundf don't even work on my Slackware 8.1 system. Screw it, we'll roll our own. -JGG */ for (i = 0; i < size; i++) { double quotient = fabs(srctable[i] / quantum); int floor = (int) quotient; double remainder = quotient - (double) floor; if (remainder >= 0.5) /* round to nearest */ floor++; if (srctable[i] < 0.0) desttable[i] = -floor * quantum; else desttable[i] = floor * quantum; } return (double) size; }
/* Add a constant, given in p1, to the values of the gen whose table number is given in p0. Note that no rescaling of the resulting table is done, so that values outside [-1, 1] are possible. */ double m_offsetgen(float p[], int n_args, double pp[]) { int i, slot, size; double *srctable, *desttable, offset; slot = (int) p[0]; srctable = floc(slot); if (srctable == NULL) return die("offsetgen", "No function table defined for slot %d.", slot); size = fsize(slot); offset = p[1]; desttable = new_table(size); if (desttable == NULL) return die("offsetgen", "No memory for new function table."); if (!install_gen(slot, size, desttable)) return die("offsetgen", "No more function tables available."); for (i = 0; i < size; i++) desttable[i] = srctable[i] + offset; return (double) size; }
bool CameraMetaData::addCamera( Camera* cam ) { string id = getId(cam); if (cameras.end() != cameras.find(id)) { writeLog(DEBUG_PRIO_WARNING, "CameraMetaData: Duplicate entry found for camera: %s %s, Skipping!\n", cam->make.c_str(), cam->model.c_str()); delete(cam); return false; } else { cameras[id] = cam; } if (string::npos != cam->mode.find("chdk")) { if (cam->hints.find("filesize") == cam->hints.end()) { writeLog(DEBUG_PRIO_WARNING, "CameraMetaData: CHDK camera: %s %s, no \"filesize\" hint set!\n", cam->make.c_str(), cam->model.c_str()); } else { uint32 size; stringstream fsize(cam->hints.find("filesize")->second); fsize >> size; chdkCameras[size] = cam; // writeLog(DEBUG_PRIO_WARNING, "CHDK camera: %s %s size:%u\n", cam->make.c_str(), cam->model.c_str(), size); } } return true; }
static void zynqmpimage_pmufw(struct zynqmp_header *zynqhdr, const char *filename) { uint32_t size; /* Setup PMU fw size */ zynqhdr->pfw_image_length = fsize(fpmu); zynqhdr->total_pfw_image_length = zynqhdr->pfw_image_length; zynqhdr->image_size -= zynqhdr->pfw_image_length; zynqhdr->image_stored_size -= zynqhdr->total_pfw_image_length; /* Read the whole PMUFW to the header */ size = fread(&zynqhdr->__reserved4[66], 1, zynqhdr->pfw_image_length, fpmu); if (size != zynqhdr->pfw_image_length) { fprintf(stderr, "Cannot read PMUFW file: %s\n", filename); fclose(fpmu); exit(1); } fclose(fpmu); }
std::vector<int64_t> DiskIOThread::get_all_sizes(std::string _basename){ DIR *dir; struct dirent *fent; dir = opendir(datapath.c_str()); if(dir == NULL) return std::vector<int64_t>(); int num_files = 0; while((fent = readdir(dir)) != NULL){ int cmp = strncmp(fent->d_name, _basename.c_str(), _basename.size()); if(cmp == 0) ++num_files; } closedir(dir); std::vector<int64_t> fsize(num_files); int i; for(i = 0; i < num_files; ++i){ struct stat fstat; int fstat_suc = stat(build_filename(datapath, _basename, i).c_str(), &fstat); if(fstat_suc < 0) return std::vector<int64_t>(); int64_t fs = fstat.st_size; fsize[i] = fs; } return fsize; }
char *read_buf (FILE *f) { long s = fsize(f); char *buf; #ifndef HAVE_MMAP if (! (buf = (char*) malloc(s + 1))) return NULL; #endif #ifdef HAVE_MMAP buf = (char*) mmap(0, s, PROT_READ, MAP_SHARED, f->_fileno, 0); if (buf == MAP_FAILED) { perror("Unable map file to memory\n"); exit(1); } #else fread((void*)buf, s, 1, f); buf[s] = '\0'; #endif return buf; }
/* ------------------------------------------------------------- post_init -- */ int FOLLOWBUTTER :: post_init(double p[], int n_args) { type = getFiltType(true); if (type == FiltInvalid) return die(instname(), "Filter type must be \"lowpass\", \"highpass\", " "\"bandpass\", or \"bandreject\"."); for (int i = 0; i < nfilts; i++) filt[i] = new Butter(SR); if (type == BandPass || type == BandReject) { if (n_args < 13) { // no p12 filter bandwidth PField, must use gen table double *function = floc(2); if (function == NULL) return die(instname(), "Either use the filter bandwidth pfield " "(p12) or make an old-style gen function in slot 2."); int len = fsize(2); bwtable = new TableL(SR, getdur(), function, len); } } return 0; }
int REVMIX::init(double p[], int n_args) { nargs = n_args; float outskip = p[0]; float inskip = p[1]; float dur = p[2]; inchan = n_args > 4 ? (int) p[4] : 0; // default is chan 0 if (inskip == 0) return die("REVMIX", "Input start time must be greater than zero."); if (dur > inskip) { rtcmix_warn("REVMIX", "Duration must be greater than input start time. " "Adjusting..."); dur = inskip; } if (rtsetoutput(outskip, dur, this) == -1) return DONT_SCHEDULE; if (rtsetinput(inskip, this) == -1) return DONT_SCHEDULE; // no input if (inchan >= inputChannels()) return die("REVMIX", "You asked for channel %d of a %d-channel file.", inchan, inputChannels()); amparray = floc(1); if (amparray) { int amplen = fsize(1); tableset(SR, dur, amplen, amptabs); } skip = (int) (SR / (float) resetval); return nSamps(); }
int TRANS3 :: init(double p[], int n_args) { nargs = n_args; if (nargs < 5) return die("TRANS3", "Usage: TRANS3(start, inskip, dur, amp, trans[, inchan, pan])"); const float outskip = p[0]; const float inskip = p[1]; float dur = p[2]; if (dur < 0.0) dur = -dur - inskip; inchan = (nargs > 5) ? (int) p[5] : 0; if (rtsetoutput(outskip, dur, this) == -1) return DONT_SCHEDULE; if (rtsetinput(inskip, this) == -1) return DONT_SCHEDULE; if (inchan >= inputChannels()) { return die("TRANS3", "You asked for channel %d of a %d-channel file.", inchan, inputChannels()); } // to trigger first read in run() inframe = RTBUFSAMPS; oneover_cpsoct10 = 1.0 / cpsoct(10.0); amptable = floc(1); if (amptable) { int amplen = fsize(1); tableset(SR, dur, amplen, amptabs); } return nSamps(); }
int DELAY::init(double p[], int n_args) { float outskip = p[0]; float inskip = p[1]; float dur = p[2]; float deltime = p[4]; float ringdur = p[6]; inchan = n_args > 7 ? (int) p[7] : 0; if (rtsetinput(inskip, this) == -1) return DONT_SCHEDULE; // no input if (inchan >= inputChannels()) return die("DELAY", "You asked for channel %d of a %d-channel file.", inchan, inputChannels()); if (rtsetoutput(outskip, dur + ringdur, this) == -1) return DONT_SCHEDULE; insamps = (int) (dur * SR + 0.5); if (deltime <= 0.0) return die("DELAY", "Invalid delay time (%g)", deltime); long defaultDelay = MAX(100L, long(deltime * SR + 0.5)); delay = new Odelayi(defaultDelay); // This is how we check for memory failure. if (delay->length() == 0) return die("DELAY", "Can't allocate delay line memory."); amptable = floc(1); if (amptable) { int amplen = fsize(1); tableset(SR, dur, amplen, amptabs); } return nSamps(); }
static void WriteIndexToFile(Access* index, const wxString filename) { if (wxFileName::FileExists(filename)) { Console.Warning(L"WARNING: Won't write index - file name exists (please delete it manually): '%s'", WX_STR(filename)); return; } std::ofstream outfile(PX_wfilename(filename), std::ofstream::binary); outfile.write(GZIP_ID, GZIP_ID_LEN); Point* tmp = index->list; index->list = 0; // current pointer is useless on disk, normalize it as 0. outfile.write((char*)index, sizeof(Access)); index->list = tmp; outfile.write((char*)index->list, sizeof(Point) * index->have); outfile.close(); // Verify if (fsize(filename) != (s64)GZIP_ID_LEN + sizeof(Access) + sizeof(Point) * index->have) { Console.Warning(L"Warning: Can't write index file to disk: '%s'", WX_STR(filename)); } else { Console.WriteLn(Color_Green, L"OK: Gzip quick access index file saved to disk: '%s'", WX_STR(filename)); } }
int init_allocator(ALLOC * a, int fd, int oflag) { a->fd = fd; if ((a->lru = calloc(LRU_NSLOT, sizeof(struct lru_node *))) == NULL) { xerrno = FATAL_NOMEM; return -1; } a->lru_head = a->lru_tail = NULL; a->lru_size = 0; bzero(a->flt, FLT_LEN); if ((oflag & O_TRUNC) || fsize(fd) == 0) { if (fshrink(fd, 0) == -1) return -1; if (alloc(fd, 0, FLT_LEN) == -1) return -1; if (writeat(fd, a->flt, FLT_LEN, 0) != FLT_LEN) return -1; return 0; } /* open an existing allocator */ if (readat(fd, a->flt, FLT_LEN, 0) != FLT_LEN) return -1; return 0; }
int main(int argc, char* argv[]) { int i, msinfo = 0; if (argc > 1) { for(i = 1 ; i < argc ; i++) { msinfo = msinfo + (fsize(argv[i]) / AUDIO_BLOCK_SIZE) + 2; if (i < argc - 1) // pas la dernière piste msinfo = msinfo + TAO_OFFSET; } msinfo = msinfo + MSINFO_OFFSET; if (msinfo == 0) { textColor(LIGHT_RED); printf("error: audio session is empty !"); textColor(LIGHT_GRAY); return 1; } else printf("%d", msinfo); } else print_usage(argv[0]); return 0; }
int START::init(double p[], int n_args) { float outskip = p[0]; float dur = p[1]; float pitch = p[2]; float fdecay = p[3]; float nydecay = p[4]; float amp = p[5]; int squish = (int)p[6]; spread = p[7]; deleteflag = (int)p[8]; if (rtsetoutput(outskip, dur, this) == -1) return DONT_SCHEDULE; strumq1 = new StrumQueue; strumq1->ref(); curstrumq[0] = strumq1; float freq = cpspch(pitch); sset(SR, freq, fdecay, nydecay, strumq1); randfill(amp, squish, strumq1); amptable = floc(1); if (amptable) { int amplen = fsize(1); tableset(SR, dur, amplen, amptabs); } else { rtcmix_advise("START", "Setting phrase curve to all 1's."); aamp = 1.0; } skip = (int)(SR / (float)resetval); return nSamps(); }
int main(void) { FILE *f = tmpfile(); assert(f != NULL); int fd = fileno(f); ALLOC allocator; ALLOC *a = &allocator; assert(init_allocator(a, fd, 0) != 0); assert(init_allocator(a, fd, O_CREAT) == 0); assert(fsize(fd) == FLT_LEN); BTree bt; handle_t root = CreateBTree(&bt, a, 1, 4, cmpInt); int i; for(i = 1; i <= 100000; i++) { SetKey(&bt, &i, i); //output(&bt); //getchar(); } return 0; for(i = 1; i <= 10000; i++) { DeleteKey(&bt, &i, 100000-i+1); } return 0; }
int put_request(struct net_t *n, struct list_t *userName, char *fileName, char *saveLoc) { int filesize; FILE *f; char buf[RCVBUFSIZE]; char *inBuf; int dataSize = 0; struct link_t *templink; struct command_t * cmd; char *filedata; // Setup packet header buf[0] = CMD_PUT; buf[1] = STAT_OK; dataSize += 2; // Add all usernames and filename to packet templink = userName->head; while(templink != NULL){ strncpy(buf + dataSize, templink->item, strlen(templink->item)); dataSize += (strlen(templink->item)); if(templink != userName->tail) { buf[dataSize] = ','; dataSize ++; } templink = templink->next; } buf[dataSize] = ':'; dataSize ++; strncpy(buf + dataSize, fileName, strlen(fileName)); dataSize += (strlen(fileName)); // Sending request packet to the server net_send_tcp(n->sock, buf, dataSize); // Recieve reply from server inBuf = net_recv_tcp(n->sock); // Make sure that packet type is CMD_PUT if(inBuf[0] != CMD_PUT) { printf("Error: Recieved unexpected packet type\n"); return -1; } // Check for errors in the packet status if(inBuf[1] == STAT_BAD_PERM) { printf("Error: Improper permissions, now quitting\n"); return -1; }else if(inBuf[1] == STAT_MALF_REQ) { printf("Error: Malformed request, now quitting\n"); return -1; }else if(inBuf[1] == STAT_NOS_FILE) { printf("Error: No such file, now quitting\n"); return -1; }else if(inBuf[1] == STAT_NOS_USER) { printf("Error: No such user, now quitting\n"); return -1; }else if(inBuf[1] == STAT_UNK_STAT) { printf("Error: Unknown responce from server, now quitting\n"); return -1; }else if(inBuf[1] == STAT_ERROR) { printf("Error: General error has occured, now quitting\n"); return -1; }else if(inBuf[1] != STAT_OK) { printf("Error: An unknown error has occured %d, now quiting\n",inBuf[1]); return -1; } // Set the packet type int size = 0; buf[0] = CMD_PUT; buf[1] = STAT_OK; size+=2; // Make sure file exists if(fcheck_for_file(fileName) < 0) { printf("Error: bad filename: %s\n",fileName); return -1; } // Open file???? WHY???? f = fopen(fileName, "rb"); if(f == NULL) { printf("Error: Could not open file\n"); return -1; } // Get file size and store it in packet filesize = fsize(fileName); *(int*)(buf+size) = htonl(filesize); size += 4; if(filesize <= 0) { fprintf(stderr,"Error: bad file size, %d", filesize); return -1; } // Send packet with STAT_OK and file size net_send_tcp(n->sock, buf, size); // Recieve a reply from the server inBuf = net_recv_tcp(n->sock); cmd = command_parse(inBuf); // Make sure it is a CMD_GET type if(cmd->type != CMD_PUT) { fprintf(stderr,"Error: Unexpected packet type\n"); return -1; } // Make sure the client status is STAT_OK if(cmd->status != STAT_OK) { fprintf(stderr,"Error: Unexpected packet status, %d\n",cmd->status); return -1; } // Reset buf and size; memset(buf, 0, RCVBUFSIZE); size = 0; // Setup packet header buf[0] = CMD_GET; buf[1] = STAT_MF; size += 2; // Read in and store all the file data filedata = (char *)malloc(filesize); if(fread(filedata, 1, filesize, f) != filesize) { fprintf(stderr,"Error: Could not read all the data in file\n"); return -1; } // Actually send the file!! //TODO: make the blocksize a config file option net_send_fragments_tcp(n->sock, filedata, filesize, 400); return 0; }
void Snippet(char* x0) { printf("%s\n","Phrase,Year,MatchCount,VolumeCount"); int32_t x5 = 0; int32_t x2 = open(x0,0); int32_t x3 = fsize(x2); char* x4 = mmap(0, x3, PROT_READ, MAP_FILE | MAP_SHARED, x2, 0); for (;;) { int32_t x6 = x5; bool x7 = x6 < x3; if (!x7) break; int32_t x9 = x5; for (;;) { int32_t x10 = x5; char x11 = x4[x10]; bool x12 = x11 != '\t'; if (!x12) break; x5 += 1; } int32_t x17 = x5; x5 += 1; int32_t x21 = x5; for (;;) { int32_t x22 = x5; char x23 = x4[x22]; bool x24 = x23 != '\t'; if (!x24) break; x5 += 1; } int32_t x29 = x5; x5 += 1; int32_t x33 = x5; for (;;) { int32_t x34 = x5; char x35 = x4[x34]; bool x36 = x35 != '\t'; if (!x36) break; x5 += 1; } int32_t x41 = x5; x5 += 1; int32_t x45 = x5; for (;;) { int32_t x46 = x5; char x47 = x4[x46]; bool x48 = x47 != '\n'; if (!x48) break; x5 += 1; } int32_t x53 = x5; x5 += 1; char* x20 = x4+x9; int32_t x57 = printll(x20); printf(","); char* x32 = x4+x21; int32_t x59 = printll(x32); printf(","); char* x44 = x4+x33; int32_t x61 = printll(x44); printf(","); char* x56 = x4+x45; int32_t x63 = printll(x56); printf("%s\n",""); } }
void Snippet(char* x0) { printf("%s\n","Phrase,Year,MatchCount,VolumeCount"); int32_t x5 = 0; int32_t x2 = open(x0,0); int32_t x3 = fsize(x2); char* x4 = mmap(0, x3, PROT_READ, MAP_FILE | MAP_SHARED, x2, 0); for (;;) { int32_t x6 = x5; bool x7 = x6 < x3; if (!x7) break; int32_t x9 = x5; for (;;) { int32_t x10 = x5; char x11 = x4[x10]; bool x12 = x11 != '\t'; if (!x12) break; x5 += 1; } int32_t x17 = x5; x5 += 1; int32_t x21 = x5; for (;;) { int32_t x22 = x5; char x23 = x4[x22]; bool x24 = x23 != '\t'; if (!x24) break; x5 += 1; } int32_t x29 = x5; x5 += 1; int32_t x33 = x5; for (;;) { int32_t x34 = x5; char x35 = x4[x34]; bool x36 = x35 != '\t'; if (!x36) break; x5 += 1; } int32_t x41 = x5; x5 += 1; int32_t x45 = x5; for (;;) { int32_t x46 = x5; char x47 = x4[x46]; bool x48 = x47 != '\n'; if (!x48) break; x5 += 1; } int32_t x53 = x5; x5 += 1; int32_t x18 = x17 - x9; bool x58 = x18 == 12; bool x73; if (x58) { int32_t x59 = 0; char* x20 = x4+x9; for (;;) { int32_t x60 = x59; bool x61 = x60 < x18; char x62 = x20[x60]; char x63 = "Auswanderung"[x60]; bool x64 = x62 == x63; bool x65 = x61 && x64; if (!x65) break; x59 += 1; } int32_t x70 = x59; bool x71 = x70 == x18; x73 = x71; } else { x73 = false; } if (x73) { char* x20 = x4+x9; int32_t x74 = printll(x20); printf(","); char* x32 = x4+x21; int32_t x76 = printll(x32); printf(","); char* x44 = x4+x33; int32_t x78 = printll(x44); printf(","); char* x56 = x4+x45; int32_t x80 = printll(x56); printf("%s\n",""); } else { } } }
int WIGGLE::init(double p[], int n_args) { const float outskip = p[0]; const float dur = p[1]; depth_type = (n_args > 4) ? getDepthType(p[4]) : NoModOsc; filter_type = (n_args > 5) ? getFiltType(p[5]) : NoFilter; float ringdur; if (filter_type == NoFilter) { nfilts = 0; ringdur = 0.0f; } else { if (filter_type != LowPass && filter_type != HighPass) return die("WIGGLE", "Filter type (p5) must be 0, 1, or 2."); nfilts = (n_args > 6) ? int(p[6]) : 1; if (nfilts < 1 || nfilts > MAXFILTS) return die("WIGGLE", "Steepness (p6) must be an integer between 1 and %d.", MAXFILTS); if (n_args > 7) do_balance = bool(p[7]); if (do_balance) { balancer = new Balance(SR); balancer->setWindowSize(BALANCE_WINDOW_SIZE); } ringdur = 0.1f; } if (rtsetoutput(outskip, dur + ringdur, this) == -1) return DONT_SCHEDULE; if (outputChannels() < 1 || outputChannels() > 2) return die("WIGGLE", "Output must be mono or stereo."); for (int i = 0; i < nfilts; i++) filt[i] = new Butter(SR); double *array = floc(AMP_FUNC); if (array) { int len = fsize(AMP_FUNC); amp_table = new TableL(SR, dur, array, len); } int len; if (n_args > 8) carwave_array = (double *) getPFieldTable(8, &len); if (carwave_array == NULL) { carwave_array = floc(CAR_WAVE_FUNC); if (carwave_array == NULL) return die("WIGGLE", "Either use the carrier wavetable pfield (p8), " "or make an old-style gen function in slot %d.", CAR_WAVE_FUNC); len = fsize(CAR_WAVE_FUNC); } carrier = new OscilL(SR, 0.0, carwave_array, len); array = floc(CAR_GLISS_FUNC); if (array) { len = fsize(CAR_GLISS_FUNC); cargliss_table = new TableN(SR, dur, array, len); } if (depth_type != NoModOsc) { if (n_args > 9) modwave_array = (double *) getPFieldTable(9, &len); if (modwave_array == NULL) { modwave_array = floc(MOD_WAVE_FUNC); if (modwave_array == NULL) return die("WIGGLE", "Either use the modulator wavetable pfield " "(p9), or make an old-style gen function " "in slot %d.", MOD_WAVE_FUNC); len = fsize(MOD_WAVE_FUNC); } modulator = new OscilL(SR, 0.0, modwave_array, len); array = floc(MOD_FREQ_FUNC); if (array) { len = fsize(MOD_FREQ_FUNC); modfreq_table = new TableL(SR, dur, array, len); } else if (n_args < 11) // no p10 mod freq return die("WIGGLE", "Either use the modulator frequency pfield " "(p10), or make an old-style gen function in " "slot %d.", MOD_FREQ_FUNC); array = floc(MOD_DEPTH_FUNC); if (array) { len = fsize(MOD_DEPTH_FUNC); moddepth_table = new TableL(SR, dur, array, len); } else if (n_args < 12) // no p11 mod depth return die("WIGGLE", "Either use the modulator depth pfield " "(p11), or make an old-style gen function in " "slot %d.", MOD_DEPTH_FUNC); } if (filter_type != NoFilter) { array = floc(FILTER_CF_FUNC); if (array) { len = fsize(FILTER_CF_FUNC); filtcf_table = new TableL(SR, dur, array, len); } else if (n_args < 13) // no p12 filter cf return die("WIGGLE", "Either use the filter cutoff frequency pfield " "(p12), or make an old-style gen function in " "slot %d.", FILTER_CF_FUNC); } if (outputChannels() == 2) { array = floc(PAN_FUNC); if (array) { len = fsize(PAN_FUNC); pan_table = new TableL(SR, dur, array, len); } else if (n_args < 14) // no p13 pan return die("WIGGLE", "Either use the pan pfield (p13), or make an " "old-style gen function in slot %d.", PAN_FUNC); } cpsoct10 = cpsoct(10.0); return nSamps(); }
FILE * collect(struct header *hp, int printheaders) { FILE *fbuf; int lc, cc, escape, eofcount, fd, c, t; char linebuf[LINESIZE], tempname[PATHSIZE], *cp, getsub; sigset_t nset; int longline, lastlong, rc; /* So we don't make 2 or more lines out of a long input line. */ collf = NULL; /* * Start catching signals from here, but we're still die on interrupts * until we're in the main loop. */ (void)sigemptyset(&nset); (void)sigaddset(&nset, SIGINT); (void)sigaddset(&nset, SIGHUP); (void)sigprocmask(SIG_BLOCK, &nset, NULL); if ((saveint = signal(SIGINT, SIG_IGN)) != SIG_IGN) (void)signal(SIGINT, collint); if ((savehup = signal(SIGHUP, SIG_IGN)) != SIG_IGN) (void)signal(SIGHUP, collhup); savetstp = signal(SIGTSTP, collstop); savettou = signal(SIGTTOU, collstop); savettin = signal(SIGTTIN, collstop); if (setjmp(collabort) || setjmp(colljmp)) { (void)rm(tempname); goto err; } (void)sigprocmask(SIG_UNBLOCK, &nset, NULL); noreset++; (void)snprintf(tempname, sizeof(tempname), "%s/mail.RsXXXXXXXXXX", tmpdir); if ((fd = mkstemp(tempname)) == -1 || (collf = Fdopen(fd, "w+")) == NULL) { warn("%s", tempname); goto err; } (void)rm(tempname); /* * If we are going to prompt for a subject, * refrain from printing a newline after * the headers (since some people mind). */ t = GTO|GSUBJECT|GCC|GNL; getsub = 0; if (hp->h_subject == NULL && value("interactive") != NULL && (value("ask") != NULL || value("asksub") != NULL)) t &= ~GNL, getsub++; if (printheaders) { puthead(hp, stdout, t); (void)fflush(stdout); } if ((cp = value("escape")) != NULL) escape = *cp; else escape = ESCAPE; eofcount = 0; hadintr = 0; lastlong = 0; longline = 0; if (!setjmp(colljmp)) { if (getsub) grabh(hp, GSUBJECT); } else { /* * Come here for printing the after-signal message. * Duplicate messages won't be printed because * the write is aborted if we get a SIGTTOU. */ cont: if (hadintr) { (void)fflush(stdout); fprintf(stderr, "\n(Interrupt -- one more to kill letter)\n"); } else { printf("(continue)\n"); (void)fflush(stdout); } } for (;;) { colljmp_p = 1; c = readline(stdin, linebuf, LINESIZE); colljmp_p = 0; if (c < 0) { if (value("interactive") != NULL && value("ignoreeof") != NULL && ++eofcount < 25) { printf("Use \".\" to terminate letter\n"); continue; } break; } lastlong = longline; longline = c == LINESIZE - 1; eofcount = 0; hadintr = 0; if (linebuf[0] == '.' && linebuf[1] == '\0' && value("interactive") != NULL && !lastlong && (value("dot") != NULL || value("ignoreeof") != NULL)) break; if (linebuf[0] != escape || value("interactive") == NULL || lastlong) { if (putline(collf, linebuf, !longline) < 0) goto err; continue; } c = linebuf[1]; switch (c) { default: /* * On double escape, just send the single one. * Otherwise, it's an error. */ if (c == escape) { if (putline(collf, &linebuf[1], !longline) < 0) goto err; else break; } printf("Unknown tilde escape.\n"); break; case 'C': /* * Dump core. */ core(); break; case '!': /* * Shell escape, send the balance of the * line to sh -c. */ shell(&linebuf[2]); break; case ':': case '_': /* * Escape to command mode, but be nice! */ execute(&linebuf[2], 1); goto cont; case '.': /* * Simulate end of file on input. */ goto out; case 'q': /* * Force a quit of sending mail. * Act like an interrupt happened. */ hadintr++; collint(SIGINT); exit(1); case 'x': /* * Exit, do not save in dead.letter. */ goto err; case 'h': /* * Grab a bunch of headers. */ grabh(hp, GTO|GSUBJECT|GCC|GBCC); goto cont; case 't': /* * Add to the To list. */ hp->h_to = cat(hp->h_to, extract(&linebuf[2], GTO)); break; case 's': /* * Set the Subject line. */ cp = &linebuf[2]; while (isspace((unsigned char)*cp)) cp++; hp->h_subject = savestr(cp); break; case 'R': /* * Set the Reply-To line. */ cp = &linebuf[2]; while (isspace((unsigned char)*cp)) cp++; hp->h_replyto = savestr(cp); break; case 'c': /* * Add to the CC list. */ hp->h_cc = cat(hp->h_cc, extract(&linebuf[2], GCC)); break; case 'b': /* * Add to the BCC list. */ hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC)); break; case 'i': case 'A': case 'a': /* * Insert named variable in message. */ switch(c) { case 'i': cp = &linebuf[2]; while(isspace((unsigned char)*cp)) cp++; break; case 'a': cp = "sign"; break; case 'A': cp = "Sign"; break; default: goto err; } if(*cp != '\0' && (cp = value(cp)) != NULL) { printf("%s\n", cp); if(putline(collf, cp, 1) < 0) goto err; } break; case 'd': /* * Read in the dead letter file. */ if (strlcpy(linebuf + 2, getdeadletter(), sizeof(linebuf) - 2) >= sizeof(linebuf) - 2) { printf("Line buffer overflow\n"); break; } /* FALLTHROUGH */ case 'r': case '<': /* * Invoke a file: * Search for the file name, * then open it and copy the contents to collf. */ cp = &linebuf[2]; while (isspace((unsigned char)*cp)) cp++; if (*cp == '\0') { printf("Interpolate what file?\n"); break; } cp = expand(cp); if (cp == NULL) break; if (*cp == '!') { /* * Insert stdout of command. */ char *sh; int nullfd, tempfd, rc; char tempname2[PATHSIZE]; if ((nullfd = open(_PATH_DEVNULL, O_RDONLY, 0)) == -1) { warn(_PATH_DEVNULL); break; } (void)snprintf(tempname2, sizeof(tempname2), "%s/mail.ReXXXXXXXXXX", tmpdir); if ((tempfd = mkstemp(tempname2)) == -1 || (fbuf = Fdopen(tempfd, "w+")) == NULL) { warn("%s", tempname2); break; } (void)unlink(tempname2); if ((sh = value("SHELL")) == NULL) sh = _PATH_CSHELL; rc = run_command(sh, 0, nullfd, fileno(fbuf), "-c", cp+1, NULL); close(nullfd); if (rc < 0) { (void)Fclose(fbuf); break; } if (fsize(fbuf) == 0) { fprintf(stderr, "No bytes from command \"%s\"\n", cp+1); (void)Fclose(fbuf); break; } rewind(fbuf); } else if (isdir(cp)) { printf("%s: Directory\n", cp); break; } else if ((fbuf = Fopen(cp, "r")) == NULL) { warn("%s", cp); break; } printf("\"%s\" ", cp); (void)fflush(stdout); lc = 0; cc = 0; while ((rc = readline(fbuf, linebuf, LINESIZE)) >= 0) { if (rc != LINESIZE - 1) lc++; if ((t = putline(collf, linebuf, rc != LINESIZE - 1)) < 0) { (void)Fclose(fbuf); goto err; } cc += t; } (void)Fclose(fbuf); printf("%d/%d\n", lc, cc); break; case 'w': /* * Write the message on a file. */ cp = &linebuf[2]; while (*cp == ' ' || *cp == '\t') cp++; if (*cp == '\0') { fprintf(stderr, "Write what file!?\n"); break; } if ((cp = expand(cp)) == NULL) break; rewind(collf); exwrite(cp, collf, 1); break; case 'm': case 'M': case 'f': case 'F': /* * Interpolate the named messages, if we * are in receiving mail mode. Does the * standard list processing garbage. * If ~f is given, we don't shift over. */ if (forward(linebuf + 2, collf, tempname, c) < 0) goto err; goto cont; case '?': if ((fbuf = Fopen(_PATH_TILDE, "r")) == NULL) { warn("%s", _PATH_TILDE); break; } while ((t = getc(fbuf)) != EOF) (void)putchar(t); (void)Fclose(fbuf); break; case 'p': /* * Print out the current state of the * message without altering anything. */ rewind(collf); printf("-------\nMessage contains:\n"); puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL); while ((t = getc(collf)) != EOF) (void)putchar(t); goto cont; case '|': /* * Pipe message through command. * Collect output as new message. */ rewind(collf); mespipe(collf, &linebuf[2]); goto cont; case 'v': case 'e': /* * Edit the current message. * 'e' means to use EDITOR * 'v' means to use VISUAL */ rewind(collf); mesedit(collf, c); goto cont; } } goto out; err: if (collf != NULL) { (void)Fclose(collf); collf = NULL; } out: if (collf != NULL) rewind(collf); noreset--; (void)sigprocmask(SIG_BLOCK, &nset, NULL); (void)signal(SIGINT, saveint); (void)signal(SIGHUP, savehup); (void)signal(SIGTSTP, savetstp); (void)signal(SIGTTOU, savettou); (void)signal(SIGTTIN, savettin); (void)sigprocmask(SIG_UNBLOCK, &nset, NULL); return (collf); }
struct message * smime_decrypt(struct message *m, const char *to, const char *cc, int signcall) { NSSCMSDecoderContext *ctx; NSSCMSMessage *msg; FILE *op, *hp, *bp; char *buf = NULL; size_t bufsize = 0, buflen, count; char *cp; struct str in, out; FILE *yp; long size; int i, nlevels; int binary = 0; if ((yp = setinput(&mb, m, NEED_BODY)) == NULL) return NULL; if (nss_init() != OKAY) return NULL; if ((op = Ftemp(&cp, "Rp", "w+", 0600, 1)) == NULL) { perror("tempfile"); return NULL; } rm(cp); Ftfree(&cp); if ((ctx = NSS_CMSDecoder_Start(NULL, decoder_cb, op, password_cb, "Pass phrase:", NULL, NULL)) == NULL) { fprintf(stderr, "Cannot start decoder.\n"); return NULL; } size = m->m_size; if ((smime_split(yp, &hp, &bp, size, 1)) == STOP) return NULL; count = fsize(bp); while (fgetline(&buf, &bufsize, &count, &buflen, bp, 0) != NULL) { if (buf[0] == '\n') break; if ((cp = thisfield(buf, "content-transfer-encoding")) != NULL) if (ascncasecmp(cp, "binary", 7) == 0) binary = 1; } while (fgetline(&buf, &bufsize, &count, &buflen, bp, 0) != NULL) { if (binary) NSS_CMSDecoder_Update(ctx, buf, buflen); else { in.s = buf; in.l = buflen; mime_fromb64_b(&in, &out, 0, bp); NSS_CMSDecoder_Update(ctx, out.s, out.l); free(out.s); } } free(buf); if ((msg = NSS_CMSDecoder_Finish(ctx)) == NULL) { fprintf(stderr, "Failed to decode message.\n"); Fclose(hp); Fclose(bp); return NULL; } nlevels = NSS_CMSMessage_ContentLevelCount(msg); for (i = 0; i < nlevels; i++) { NSSCMSContentInfo *content; SECOidTag tag; content = NSS_CMSMessage_ContentLevel(msg, i); tag = NSS_CMSContentInfo_GetContentTypeTag(content); if (tag == SEC_OID_PKCS7_DATA) { const char *fld = "X-Encryption-Cipher"; SECOidTag alg; int keysize; alg = NSS_CMSContentInfo_GetContentEncAlgTag(content); keysize = NSS_CMSContentInfo_GetBulkKeySize(content); fseek(hp, 0L, SEEK_END); switch (alg) { case 0: if (signcall) { NSS_CMSMessage_Destroy(msg); Fclose(hp); Fclose(bp); setinput(&mb, m, NEED_BODY); return (struct message *)-1; } fprintf(hp, "%s: none\n", fld); break; case SEC_OID_RC2_CBC: fprintf(hp, "%s: RC2, %d bits\n", fld, keysize); break; case SEC_OID_DES_CBC: fprintf(hp, "%s: DES, 56 bits\n", fld); break; case SEC_OID_DES_EDE3_CBC: fprintf(hp, "%s: 3DES, 112/168 bits\n", fld); break; case SEC_OID_FORTEZZA_SKIPJACK: fprintf(hp, "%s: Fortezza\n", fld); break; default: fprintf(hp, "%s: unknown type %lu\n", fld, (unsigned long)alg); } fflush(hp); rewind(hp); } } NSS_CMSMessage_Destroy(msg); fflush(op); rewind(op); Fclose(bp); return smime_decrypt_assemble(m, hp, op); }
long file_size(const char *path) { FILE * file; if (!(file = fopen(path, "rb"))) return -1; return fsize(file); }
void Snippet(char* x0) { printf("%s\n","Name,Value,Flag,Name"); char** x2 = (char**)malloc(256 * sizeof(char*)); int32_t* x3 = (int32_t*)malloc(256 * sizeof(int32_t)); int32_t x4 = 0; int32_t x5 = 0; int32_t* x6 = (int32_t*)malloc(256 * sizeof(int32_t)); for(int x8=0; x8 < 256; x8++) { x6[x8] = -1; } char** x12 = (char**)malloc(65536 * sizeof(char*)); int32_t* x13 = (int32_t*)malloc(65536 * sizeof(int32_t)); int32_t* x14 = (int32_t*)malloc(65536 * sizeof(int32_t)); char** x15 = (char**)malloc(65536 * sizeof(char*)); int32_t* x16 = (int32_t*)malloc(65536 * sizeof(int32_t)); int32_t x17 = 0; int32_t x18 = 0; int32_t* x19 = (int32_t*)malloc(65536 * sizeof(int32_t)); int32_t* x20 = (int32_t*)malloc(256 * sizeof(int32_t)); int32_t x24 = 0; int32_t x21 = open("src/data/t.csv",0); int32_t x22 = fsize(x21); char* x23 = mmap(0, x22, PROT_READ, MAP_FILE | MAP_SHARED, x21, 0); for (;;) { int32_t x25 = x24; char x26 = x23[x25]; bool x27 = x26 != ','; if (!x27) break; x24 += 1; } int32_t x32 = x24; x24 += 1; int32_t x35 = x24; int32_t x36 = 0; for (;;) { int32_t x37 = x24; char x38 = x23[x37]; bool x39 = x38 != ','; if (!x39) break; int32_t x41 = x36; int32_t x43 = x24; int32_t x42 = x41 * 10; char x44 = x23[x43]; char x45 = x44 - '0'; int32_t x46 = x42 + x45; x36 = x46; x24 += 1; } x24 += 1; int32_t x52 = x36; int32_t x53 = x24; for (;;) { int32_t x54 = x24; char x55 = x23[x54]; bool x56 = x55 != '\n'; if (!x56) break; x24 += 1; } int32_t x61 = x24; x24 += 1; for (;;) { int32_t x65 = x24; bool x66 = x65 < x22; if (!x66) break; int32_t x68 = x24; for (;;) { int32_t x69 = x24; char x70 = x23[x69]; bool x71 = x70 != ','; if (!x71) break; x24 += 1; } int32_t x76 = x24; x24 += 1; int32_t x80 = x24; int32_t x81 = 0; for (;;) { int32_t x82 = x24; char x83 = x23[x82]; bool x84 = x83 != ','; if (!x84) break; int32_t x86 = x81; int32_t x88 = x24; int32_t x87 = x86 * 10; char x89 = x23[x88]; char x90 = x89 - '0'; int32_t x91 = x87 + x90; x81 = x91; x24 += 1; } x24 += 1; int32_t x97 = x81; int32_t x98 = x24; for (;;) { int32_t x99 = x24; char x100 = x23[x99]; bool x101 = x100 != '\n'; if (!x101) break; x24 += 1; } int32_t x106 = x24; x24 += 1; int32_t x110 = x18; char* x79 = x23+x68; x12[x110] = x79; int32_t x77 = x76 - x68; x13[x110] = x77; x14[x110] = x97; char* x109 = x23+x98; x15[x110] = x109; int32_t x107 = x106 - x98; x16[x110] = x107; x18 += 1; int64_t x117 = hash(x79,x77); int32_t x118 = (int32_t)x117; int32_t x119 = x118 & 255; //#hash_lookup // generated code for hash lookup int32_t x120 = x119; for (;;) { int32_t x121 = x120; int32_t x122 = x6[x121]; bool x124 = x122 == -1; bool x146; if (x124) { x146 = false; } else { char* x125 = x2[x122]; int32_t x126 = x3[x122]; bool x128 = x126 == x77; bool x143; if (x128) { int32_t x129 = 0; for (;;) { int32_t x130 = x129; bool x131 = x130 < x126; bool x135; if (x131) { char x132 = x125[x130]; char x133 = x79[x130]; bool x134 = x132 == x133; x135 = x134; } else { x135 = false; } if (!x135) break; x129 += 1; } int32_t x140 = x129; bool x141 = x140 == x126; x143 = x141; } else { x143 = false; } bool x144 = !x143; x146 = x144; } if (!x146) break; int32_t x148 = x120; int32_t x149 = x148 + 1; int32_t x150 = x149 & 255; x120 = x150; } int32_t x154 = x120; int32_t x155 = x6[x154]; bool x156 = x155 == -1; int32_t x164; if (x156) { int32_t x157 = x5; x2[x157] = x79; x3[x157] = x77; x5 += 1; x6[x154] = x157; x20[x157] = 0; x164 = x157; } else { x164 = x155; } int32_t x166 = x164; //#hash_lookup int32_t x167 = x20[x166]; int32_t x168 = x166 * 256; int32_t x169 = x168 + x167; x19[x169] = x110; int32_t x171 = x167 + 1; x20[x166] = x171; } close(x21); int32_t x176 = 0; for (;;) { int32_t x177 = x176; char x178 = x23[x177]; bool x179 = x178 != ','; if (!x179) break; x176 += 1; } int32_t x184 = x176; x176 += 1; int32_t x186 = x176; int32_t x187 = 0; for (;;) { int32_t x188 = x176; char x189 = x23[x188]; bool x190 = x189 != ','; if (!x190) break; int32_t x192 = x187; int32_t x194 = x176; int32_t x193 = x192 * 10; char x195 = x23[x194]; char x196 = x195 - '0'; int32_t x197 = x193 + x196; x187 = x197; x176 += 1; } x176 += 1; int32_t x203 = x187; int32_t x204 = x176; for (;;) { int32_t x205 = x176; char x206 = x23[x205]; bool x207 = x206 != '\n'; if (!x207) break; x176 += 1; } int32_t x212 = x176; x176 += 1; for (;;) { int32_t x216 = x176; bool x217 = x216 < x22; if (!x217) break; int32_t x219 = x176; for (;;) { int32_t x220 = x176; char x221 = x23[x220]; bool x222 = x221 != ','; if (!x222) break; x176 += 1; } int32_t x227 = x176; x176 += 1; int32_t x231 = x176; int32_t x232 = 0; for (;;) { int32_t x233 = x176; char x234 = x23[x233]; bool x235 = x234 != ','; if (!x235) break; int32_t x237 = x232; int32_t x239 = x176; int32_t x238 = x237 * 10; char x240 = x23[x239]; char x241 = x240 - '0'; int32_t x242 = x238 + x241; x232 = x242; x176 += 1; } x176 += 1; int32_t x248 = x232; int32_t x249 = x176; for (;;) { int32_t x250 = x176; char x251 = x23[x250]; bool x252 = x251 != '\n'; if (!x252) break; x176 += 1; } int32_t x257 = x176; x176 += 1; int32_t x228 = x227 - x219; char* x230 = x23+x219; int64_t x261 = hash(x230,x228); int32_t x262 = (int32_t)x261; int32_t x263 = x262 & 255; //#hash_lookup // generated code for hash lookup int32_t x264 = x263; for (;;) { int32_t x265 = x264; int32_t x266 = x6[x265]; bool x268 = x266 == -1; bool x290; if (x268) { x290 = false; } else { char* x269 = x2[x266]; int32_t x270 = x3[x266]; bool x272 = x270 == x228; bool x287; if (x272) { int32_t x273 = 0; for (;;) { int32_t x274 = x273; bool x275 = x274 < x270; bool x279; if (x275) { char x276 = x269[x274]; char x277 = x230[x274]; bool x278 = x276 == x277; x279 = x278; } else { x279 = false; } if (!x279) break; x273 += 1; } int32_t x284 = x273; bool x285 = x284 == x270; x287 = x285; } else { x287 = false; } bool x288 = !x287; x290 = x288; } if (!x290) break; int32_t x292 = x264; int32_t x293 = x292 + 1; int32_t x294 = x293 & 255; x264 = x294; } int32_t x298 = x264; int32_t x299 = x6[x298]; int32_t x301 = x299; //#hash_lookup bool x303 = x301 == -1; if (x303) { } else { int32_t x304 = x20[x301]; int32_t x305 = x301 * 256; int32_t x306 = x305 + x304; for(int x308=x305; x308 < x306; x308++) { int32_t x309 = x19[x308]; char* x310 = x12[x309]; int32_t x311 = x13[x309]; int32_t x312 = x14[x309]; char* x313 = x15[x309]; int32_t x314 = x16[x309]; int32_t x315 = printll(x310); printf(","); printf("%d",x312); printf(","); int32_t x319 = printll(x313); printf(","); int32_t x321 = printll(x230); printf("%s\n",""); } } } close(x21); }
void Snippet(char* x0) { printf("%s\n","Name,Value"); char** x2 = (char**)malloc(256 * sizeof(char*)); int32_t* x3 = (int32_t*)malloc(256 * sizeof(int32_t)); int32_t x4 = 0; int32_t x5 = 0; int32_t* x6 = (int32_t*)malloc(256 * sizeof(int32_t)); for(int x8=0; x8 < 256; x8++) { x6[x8] = -1; } int32_t* x12 = (int32_t*)malloc(256 * sizeof(int32_t)); int32_t x13 = 0; int32_t x17 = 0; int32_t x14 = open("src/data/t.csv",0); int32_t x15 = fsize(x14); char* x16 = mmap(0, x15, PROT_READ, MAP_FILE | MAP_SHARED, x14, 0); for (;;) { int32_t x18 = x17; char x19 = x16[x18]; bool x20 = x19 != ','; if (!x20) break; x17 += 1; } int32_t x25 = x17; x17 += 1; int32_t x28 = x17; int32_t x29 = 0; for (;;) { int32_t x30 = x17; char x31 = x16[x30]; bool x32 = x31 != ','; if (!x32) break; int32_t x34 = x29; int32_t x36 = x17; int32_t x35 = x34 * 10; char x37 = x16[x36]; char x38 = x37 - '0'; int32_t x39 = x35 + x38; x29 = x39; x17 += 1; } x17 += 1; int32_t x45 = x29; int32_t x46 = x17; for (;;) { int32_t x47 = x17; char x48 = x16[x47]; bool x49 = x48 != '\n'; if (!x49) break; x17 += 1; } int32_t x54 = x17; x17 += 1; for (;;) { int32_t x58 = x17; bool x59 = x58 < x15; if (!x59) break; int32_t x61 = x17; for (;;) { int32_t x62 = x17; char x63 = x16[x62]; bool x64 = x63 != ','; if (!x64) break; x17 += 1; } int32_t x69 = x17; x17 += 1; int32_t x73 = x17; int32_t x74 = 0; for (;;) { int32_t x75 = x17; char x76 = x16[x75]; bool x77 = x76 != ','; if (!x77) break; int32_t x79 = x74; int32_t x81 = x17; int32_t x80 = x79 * 10; char x82 = x16[x81]; char x83 = x82 - '0'; int32_t x84 = x80 + x83; x74 = x84; x17 += 1; } x17 += 1; int32_t x90 = x74; int32_t x91 = x17; for (;;) { int32_t x92 = x17; char x93 = x16[x92]; bool x94 = x93 != '\n'; if (!x94) break; x17 += 1; } int32_t x99 = x17; x17 += 1; int32_t x70 = x69 - x61; char* x72 = x16+x61; int64_t x103 = hash(x72,x70); int32_t x104 = (int32_t)x103; int32_t x105 = x104 & 255; //#hash_lookup // generated code for hash lookup int32_t x106 = x105; for (;;) { int32_t x107 = x106; int32_t x108 = x6[x107]; bool x110 = x108 == -1; bool x132; if (x110) { x132 = false; } else { char* x111 = x2[x108]; int32_t x112 = x3[x108]; bool x114 = x112 == x70; bool x129; if (x114) { int32_t x115 = 0; for (;;) { int32_t x116 = x115; bool x117 = x116 < x112; bool x121; if (x117) { char x118 = x111[x116]; char x119 = x72[x116]; bool x120 = x118 == x119; x121 = x120; } else { x121 = false; } if (!x121) break; x115 += 1; } int32_t x126 = x115; bool x127 = x126 == x112; x129 = x127; } else { x129 = false; } bool x130 = !x129; x132 = x130; } if (!x132) break; int32_t x134 = x106; int32_t x135 = x134 + 1; int32_t x136 = x135 & 255; x106 = x136; } int32_t x140 = x106; int32_t x141 = x6[x140]; bool x142 = x141 == -1; int32_t x150; if (x142) { int32_t x143 = x5; x2[x143] = x72; x3[x143] = x70; x5 += 1; x6[x140] = x143; x12[x143] = 0; x150 = x143; } else { x150 = x141; } int32_t x152 = x150; //#hash_lookup int32_t x153 = x12[x152]; int32_t x154 = x153 + x90; x12[x152] = x154; } int32_t x159 = x5; for(int x161=0; x161 < x159; x161++) { char* x162 = x2[x161]; int32_t x163 = x3[x161]; int32_t x164 = x12[x161]; int32_t x165 = printll(x162); printf(","); printf("%d",x164); printf("%s\n",""); } }
int main(int argc, char *argv[]){ FILE *fh; HANDLE disk; int len_r = 0; DWORD len_w = 0; char *image_path; char *disk_path; int offset = 0; int size = 0; if (argc >= 4){ image_path = argv[1]; disk_path = argv[2]; offset = atoi(argv[3]); printf("Image: %s\n", image_path); fh = fopen(image_path, "rb"); if (fh) { if (argc >= 5) { size = atoi(argv[4]); } else { size = fsize(fh); } char* image = (char*)malloc(size); len_r = fread(image, sizeof(char), size, fh); fclose(fh); printf("Read: %d bytes\n", len_r); printf("Disk: %s\n", disk_path); disk = CreateFileA(disk_path, FILE_ALL_ACCESS, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL); //fh = fopen(disk_path, "wb"); if (disk != INVALID_HANDLE_VALUE){ //len = fwrite(image, sizeof(char), len, fh); DWORD seek = SetFilePointer(disk, offset, NULL, FILE_BEGIN); if (seek == INVALID_SET_FILE_POINTER) { printf("Failed to set seek pointer\n"); } else { int written = 0; while (size > 0) { int write = (size >= 512 ? 512 : size); if (WriteFile(disk, image + written, write, &len_w, NULL) == TRUE){ //printf("Write: %d bytes\n", len_w); } else { printf("Error writing image"); } size -= len_w; written += len_w; } } CloseHandle(disk); //fclose(fh); } else { printf("Could not open Disk!\n"); } } else { printf("Could not open Image!\n"); } } else { printf("No image or disk selected. Syntax: disk_write image.bin \\\\.\\disk"); } return 0; }
int TRANSBEND :: init(double p[], int n_args) { float outskip, inskip, dur, transp, interval = 0, total_indur, dur_to_read; float averageInc; int pgen; if (n_args < 5) { die("TRANSBEND", "Wrong number of args."); return(DONT_SCHEDULE); } outskip = p[0]; inskip = p[1]; dur = p[2]; amp = p[3]; pgen = (int) p[4]; inchan = (n_args > 5) ? (int) p[5] : 0; pctleft = (n_args > 6) ? p[6] : 0.5; if (dur < 0.0) dur = -dur - inskip; if (rtsetoutput(outskip, dur, this) == -1) return DONT_SCHEDULE; if (rtsetinput(inskip, this) == -1) return DONT_SCHEDULE; if (inchan >= inputChannels()) { return die("TRANSBEND", "You asked for channel %d of a %d-channel file.", inchan, inputChannels()); } pitchtable = floc(pgen); if (pitchtable) { int plen = fsize(pgen); float isum = 0; for (int loc = 0; loc < plen; loc++) { float pch = pitchtable[loc]; isum += octpch(pch); } interval = isum / plen; #ifdef DEBUG printf("average interval: %g\n", interval); #endif tableset(SR, dur, plen, ptabs); } else { die("TRANSBEND", "Unable to load pitch curve (table %d)!", pgen); return(DONT_SCHEDULE); } averageInc = (double) cpsoct(10.0 + interval) / cpsoct(10.0); #ifdef NOTYET total_indur = (float) m_DUR(NULL, 0); dur_to_read = dur * averageInc; if (inskip + dur_to_read > total_indur) { warn("TRANSBEND", "This note will read off the end of the input file.\n" "You might not get the envelope decay you " "expect from setline.\nReduce output duration."); /* no exit() */ } #endif /* total number of frames to read during life of inst */ in_frames_left = (int) (nSamps() * averageInc + 0.5); /* to trigger first read in run() */ inframe = RTBUFSAMPS; amptable = floc(1); if (amptable) { int amplen = fsize(1); tableset(SR, dur, amplen, tabs); } else rtcmix_advise("TRANSBEND", "Setting phrase curve to all 1's."); skip = (int) (SR / (float) resetval); return nSamps(); }