Rval mod(Rval l, Rval r) { Rval ret; ret.type = do_types(l, r); ret().ullongv = l().ullongv % r().ullongv; return ret; }
Rval quotient(Rval l, Rval r) { Rval ret; ret.type = do_types(l, r); ret().ullongv = l().ullongv / r().ullongv; return ret; }
Rval product(Rval l, Rval r) { Rval ret; ret.type = do_types(l, r); ret().ullongv = l().ullongv * r().ullongv; return ret; }
Rval difference(Rval l, Rval r) { Rval ret; ret.type = do_types(l, r); ret().ullongv = l().ullongv - r().ullongv; return ret; }
Rval lesseq (Rval l, Rval r) { Rval ret; ret.type = bool_t; do_types(l, r); ret().boolv = (l().ullongv <= r().ullongv); return ret; }
Rval greater (Rval l, Rval r) { Rval ret; ret.type = bool_t; do_types(l, r); ret().boolv = (l().ullongv > r().ullongv); return ret; }
Rval nequal (Rval l, Rval r) { Rval ret; ret.type = bool_t; do_types(l, r); ret().boolv = (l().ullongv != r().ullongv); return ret; }
//-----------------------------------Rval binary Rval sum(Rval l, Rval r) { Rval ret; ret.type = do_types(l, r); ret().ullongv = l().ullongv + r().ullongv; return ret; }
int do_file_sorting(dataptr dz) { int exit_status; int n; int a_srate = 0; double sum; int infilecnt = dz->all_words-1; int fileno = 0, namestoresize = 0; char *filename = dz->wordstor[infilecnt]; /* name of input list file */ char *monofile=NULL, *stereofile = NULL, *analfile = NULL, *quadfile = NULL; char *pitchfile = NULL, *transfile = NULL, *formantfile = NULL; char *envfile = NULL, *otherfile = NULL, *namestore = NULL; int *posstore = NULL; int *lcnt = NULL; char ***lstore = NULL; double *lenstore = NULL; double *sortlens = NULL; char *file48 = ENDOFSTR, *file44 = ENDOFSTR, *file32 = ENDOFSTR; char *file24 = ENDOFSTR, *file22 = ENDOFSTR, *file16 = ENDOFSTR; int is_file48=FALSE, is_file44=FALSE, is_file32=FALSE, is_file24=FALSE, is_file22=FALSE, is_file16=FALSE; int is_mono_list=FALSE, is_stereo_list=FALSE,is_quad_list=FALSE, is_anal_list=FALSE,is_pitch_list=FALSE; int is_trans_list=FALSE, is_fmnt_list=FALSE, is_env_list=FALSE, is_other_list=FALSE; FILE *fp48 = NULL, *fp44 = NULL, *fp32 = NULL, *fp24 = NULL, *fp22 = NULL, *fp16 = NULL, *fpm = NULL, *fps = NULL, *fpa = NULL, *fpp = NULL, *fpt = NULL, *fpf = NULL, *fpe = NULL, *fpo = NULL, *fpq = NULL; char *p; int done_errmsg = 0; switch(dz->mode) { case(BY_DURATION): case(BY_LOG_DUR): if((lcnt = (int *)malloc((dz->iparam[SORT_LENCNT]+1) * sizeof(int)))==NULL) { sprintf(errstr,"INSUFFICIENT MEMORY for lcnt store.\n"); return(MEMORY_ERROR); } if((sortlens = (double *)malloc(dz->iparam[SORT_LENCNT] * sizeof(double)))==NULL) { sprintf(errstr,"INSUFFICIENT MEMORY for lens store.\n"); return(MEMORY_ERROR); } sum = dz->param[SORT_SMALL]; for(n=0;n<dz->iparam[SORT_LENCNT];n++) { lcnt[n] = 0; sortlens[n] = sum; if(dz->mode==BY_LOG_DUR) sum *= dz->param[SORT_STEP]; else sum += dz->param[SORT_STEP]; } lcnt[dz->iparam[SORT_LENCNT]] = 0; sortlens[dz->iparam[SORT_LENCNT]-1] = dz->param[SORT_LARGE]; dz->iparam[SORT_LENCNT]++; /* fall thro */ case(IN_DUR_ORDER): if((lstore = (char ***)malloc((dz->iparam[SORT_LENCNT]+1) * sizeof(char **)))==NULL) { sprintf(errstr,"INSUFFICIENT MEMORY for length store.\n"); return(MEMORY_ERROR); } for(n=0;n<dz->iparam[SORT_LENCNT]+1;n++) { // AVOID realloc if((lstore[n] = (char **)malloc(infilecnt * sizeof(char *)))==NULL) { sprintf(errstr,"INSUFFICIENT MEMORY for length store %d.\n",n+1); return(MEMORY_ERROR); } } break; } strip_extension(filename); if(sloom && (dz->mode == BY_FILETYPE || dz->mode == BY_SRATE)) { p = filename + strlen(filename) - 1; /* Strip trailing zero from generic tempfilename */ *p = ENDOFSTR; } for(n=0;n<infilecnt;n++) { if(!strcmp(dz->wordstor[infilecnt],dz->wordstor[n])) { sprintf(errstr,"The name of the listfile cannot be included in the listing!!\n"); return(DATA_ERROR); } } // AVOID realloc for(n=0;n<infilecnt;n++) namestoresize += strlen(dz->wordstor[n]) + 1; if((namestore = (char *)malloc(namestoresize * sizeof(char)))==NULL) { sprintf(errstr,"INSUFFICIENT MEMORY for name store.\n"); return(MEMORY_ERROR); } namestoresize = 0; for(n=0;n<infilecnt;n++) { if((dz->ifd[0] = sndopenEx(dz->wordstor[n],0,CDP_OPEN_RDONLY)) < 0) { if(dz->mode!=BY_FILETYPE) { if(!done_errmsg) { sprintf(errstr,"Some files are NOT soundfiles.\n"); print_outmessage_flush(errstr); done_errmsg = 1; } } dz->ifd[0] = -1; continue; } else if((dz->mode!=BY_FILETYPE) && filename_extension_is_not_sound(dz->wordstor[n])) { if(!done_errmsg) { sprintf(errstr,"Some files are NOT soundfiles.\n"); print_outmessage_flush(errstr); done_errmsg = 1; } continue; } switch(dz->mode) { case(BY_SRATE): if((exit_status = do_srates(filename,dz->wordstor[n],&file48,&file44,&file32,&file24,&file22,&file16, &is_file48,&is_file44,&is_file32,&is_file24,&is_file22,&is_file16, &fp48,&fp44,&fp32,&fp24,&fp22,&fp16,dz))<0) return(exit_status); break; case(BY_DURATION): case(BY_LOG_DUR): if((exit_status = do_lenths(filename,dz->wordstor[n],&namestore,lstore,&namestoresize,lcnt,sortlens,dz))<0) return(exit_status); break; case(IN_DUR_ORDER): if((exit_status = do_order (filename,dz->wordstor[n],&namestore,&lenstore,&posstore,&lstore,&fileno,&namestoresize,dz))<0) return(exit_status); break; case(BY_FILETYPE): if((exit_status = do_types(filename,dz->wordstor[n], &monofile,&stereofile,&quadfile,&analfile,&pitchfile,&transfile,&formantfile,&envfile,&otherfile, &is_mono_list,&is_stereo_list,&is_quad_list,&is_anal_list, &is_pitch_list,&is_trans_list,&is_fmnt_list,&is_env_list,&is_other_list, &fpm,&fps,&fpa,&fpp,&fpt,&fpf,&fpe,&fpo,&fpq,dz))<0) return(exit_status); break; case(FIND_ROGUES): do_rogues(dz->wordstor[n],&a_srate,dz); break; } if(dz->ifd[0]!=-1 && sndcloseEx(dz->ifd[0])<0) fprintf(stdout,"WARNING: Failed to close sndfile %s.\n",dz->wordstor[n]); dz->ifd[0] = -1; } switch(dz->mode) { case(BY_LOG_DUR): case(BY_DURATION): if((exit_status = output_lenths(filename,&otherfile,lstore,sortlens,lcnt,dz))<0) return(exit_status); break; case(BY_SRATE): output_srates(is_file48,is_file44,is_file32,is_file24,is_file22,is_file16, file48, file44,file32,file24,file22,file16); break; case(IN_DUR_ORDER): if((exit_status = output_order(filename,&otherfile,posstore,lenstore,lstore,fileno,dz))<0) return(exit_status); break; case(BY_FILETYPE): output_types(filename,is_mono_list,is_stereo_list,is_quad_list, is_anal_list,is_pitch_list,is_trans_list,is_fmnt_list,is_env_list, is_other_list,monofile,stereofile,quadfile,analfile,pitchfile, transfile,formantfile,envfile,otherfile); break; } fflush(stdout); return(FINISHED); }