static int ea_filter(char FAR *name, int skip_ln) { char tmp_name[CCHMAXPATH]; far_strcpy((char FAR *)tmp_name, name); if(skip_ln&&!stricmp(tmp_name, longname_ea)) return(0); if(include_eas&&!flist_find(&flist_ea, tmp_name)) return(0); if(exclude_eas&&flist_find(&flist_xea, tmp_name)) return(0); return(1); }
static void init_bf_2(void) { int i; long ptr; save_bf_vars(); /* copy corners values for conversion */ calc_lengths(); /* allocate all the memory at once within the same segment (DOS) */ #if defined(BIG_FAR) || defined(BIG_ANSI_C) bnroot = (bf_t)MK_FP(extraseg,ENDVID); /* ENDVID is to avoid videotable */ #else /* BASED or NEAR */ bnroot = (bf_t)ENDVID; /* ENDVID is to avoid videotable */ #endif #ifdef BIG_BASED bignum_seg = (_segment)extraseg; #endif /* at present time one call would suffice, but this logic allows mulytiple kinds of alternate math eg long double */ if((i = find_alternate_math(fractype, BIGNUM)) > -1) bf_math = alternatemath[i].math; else if((i = find_alternate_math(fractype, BIGFLT)) > -1) bf_math = alternatemath[i].math; else bf_math = 1; /* maybe called from cmdfiles.c and fractype not set */ floatflag=1; /* Now split up the memory among the pointers */ /* internal pointers */ ptr = 0; bntmp1 = bnroot+ptr; ptr += rlength; bntmp2 = bnroot+ptr; ptr += rlength; bntmp3 = bnroot+ptr; ptr += rlength; bntmp4 = bnroot+ptr; ptr += rlength; bntmp5 = bnroot+ptr; ptr += rlength; bntmp6 = bnroot+ptr; ptr += rlength; bftmp1 = bnroot+ptr; ptr += rbflength+2; bftmp2 = bnroot+ptr; ptr += rbflength+2; bftmp3 = bnroot+ptr; ptr += rbflength+2; bftmp4 = bnroot+ptr; ptr += rbflength+2; bftmp5 = bnroot+ptr; ptr += rbflength+2; bftmp6 = bnroot+ptr; ptr += rbflength+2; bftmpcpy1 = bnroot+ptr; ptr += (rbflength+2)*2; bftmpcpy2 = bnroot+ptr; ptr += (rbflength+2)*2; bntmpcpy1 = bnroot+ptr; ptr += (rlength*2); bntmpcpy2 = bnroot+ptr; ptr += (rlength*2); if (bf_math == BIGNUM) { bnxmin = bnroot+ptr; ptr += bnlength; bnxmax = bnroot+ptr; ptr += bnlength; bnymin = bnroot+ptr; ptr += bnlength; bnymax = bnroot+ptr; ptr += bnlength; bnx3rd = bnroot+ptr; ptr += bnlength; bny3rd = bnroot+ptr; ptr += bnlength; bnxdel = bnroot+ptr; ptr += bnlength; bnydel = bnroot+ptr; ptr += bnlength; bnxdel2 = bnroot+ptr; ptr += bnlength; bnydel2 = bnroot+ptr; ptr += bnlength; bnold.x = bnroot+ptr; ptr += rlength; bnold.y = bnroot+ptr; ptr += rlength; bnnew.x = bnroot+ptr; ptr += rlength; bnnew.y = bnroot+ptr; ptr += rlength; bnsaved.x = bnroot+ptr; ptr += bnlength; bnsaved.y = bnroot+ptr; ptr += bnlength; bnclosenuff= bnroot+ptr; ptr += bnlength; bnparm.x = bnroot+ptr; ptr += bnlength; bnparm.y = bnroot+ptr; ptr += bnlength; bntmpsqrx = bnroot+ptr; ptr += rlength; bntmpsqry = bnroot+ptr; ptr += rlength; bntmp = bnroot+ptr; ptr += rlength; } if (bf_math == BIGFLT) { bfxdel = bnroot+ptr; ptr += bflength+2; bfydel = bnroot+ptr; ptr += bflength+2; bfxdel2 = bnroot+ptr; ptr += bflength+2; bfydel2 = bnroot+ptr; ptr += bflength+2; bfold.x = bnroot+ptr; ptr += rbflength+2; bfold.y = bnroot+ptr; ptr += rbflength+2; bfnew.x = bnroot+ptr; ptr += rbflength+2; bfnew.y = bnroot+ptr; ptr += rbflength+2; bfsaved.x = bnroot+ptr; ptr += bflength+2; bfsaved.y = bnroot+ptr; ptr += bflength+2; bfclosenuff= bnroot+ptr; ptr += bflength+2; bfparm.x = bnroot+ptr; ptr += bflength+2; bfparm.y = bnroot+ptr; ptr += bflength+2; bftmpsqrx = bnroot+ptr; ptr += rbflength+2; bftmpsqry = bnroot+ptr; ptr += rbflength+2; big_pi = bnroot+ptr; ptr += bflength+2; bftmp = bnroot+ptr; ptr += rbflength+2; } bf10tmp = bnroot+ptr; ptr += bfdecimals+4; /* ptr needs to be 16-bit aligned on some systems */ ptr = (ptr+1)&~1; stack_ptr = bnroot + ptr; startstack = ptr; /* max stack offset from bnroot */ maxstack = (long)0x10000l-(bflength+2)*22-ENDVID; /* sanity check */ /* leave room for NUMVARS variables allocated from stack */ /* also leave room for the safe area at top of segment */ if(ptr + NUMVARS*(bflength+2) > (long)0x10000l -(bflength+2)*22-ENDVID) { char msg[80]; char nmsg[80]; static FCODE fmsg[] = {"Requested precision of %d too high, aborting"}; far_strcpy(nmsg,fmsg); sprintf(msg,nmsg,decimals); stopmsg(0,msg); goodbye(); } /* room for 6 corners + 6 save corners + 10 params at top of extraseg */ /* this area is safe - use for variables that are used outside fractal*/ /* generation - e.g. zoom box variables */ ptr = ((long)0x10000l-(bflength+2)*22-ENDVID); bfxmin = bnroot+ptr; ptr += bflength+2; bfxmax = bnroot+ptr; ptr += bflength+2; bfymin = bnroot+ptr; ptr += bflength+2; bfymax = bnroot+ptr; ptr += bflength+2; bfx3rd = bnroot+ptr; ptr += bflength+2; bfy3rd = bnroot+ptr; ptr += bflength+2; for(i=0;i<10;i++) { bfparms[i] = bnroot+ptr; ptr += bflength+2; } bfsxmin = bnroot+ptr; ptr += bflength+2; bfsxmax = bnroot+ptr; ptr += bflength+2; bfsymin = bnroot+ptr; ptr += bflength+2; bfsymax = bnroot+ptr; ptr += bflength+2; bfsx3rd = bnroot+ptr; ptr += bflength+2; bfsy3rd = bnroot+ptr; ptr += bflength+2; /* end safe vars */ /* good citizens initialize variables */ if(bf_save_len) /* leave save area */ far_memset(bnroot+(bf_save_len+2)*22,0,(unsigned)(startstack-(bf_save_len+2)*22)); else /* first time through - nothing saved */ { /* high variables */ far_memset(bnroot+((long)0x10000l-(bflength+2)*22-ENDVID),0,(bflength+2)*22); /* low variables */ far_memset(bnroot,0,(unsigned)startstack); } restore_bf_vars(); /* Initialize the value of pi. Needed for trig functions. */ /* init_big_pi(); */ /* call to init_big_pi() has been moved to fractal setup routine */ /* so as to use only when necessary. */ }
int get_video_mode(struct fractal_info *info,struct ext_blk_3 *blk_3_info) { static FCODE o_hdg2[]={"key...name......................err...xdot..ydot.clr.comment.................."}; static FCODE o_warning[]={"\nWARNING: non-standard aspect ratio; loading will change your <v>iew settings"}; static FCODE o_select_msg[]={"\ Select a video mode. Use the cursor keypad to move the pointer.\n\ Press ENTER for selected mode, or use a video mode function key.\n\ Press F1 for help, "}; char far *hdg2, far *warning, far *select_msg, far *ptr; struct vidinf vid[MAXVIDEOMODES]; int i,j; int gotrealmode; double ftemp,ftemp2; unsigned tmpflags; int tmpxdots,tmpydots; float tmpreduce; #ifndef XFRACT char *nameptr; int *attributes; int oldhelpmode; #endif VIDEOINFO *vident; /* save overlayed strings to extraseg memory */ ptr = (char far *)MK_FP(extraseg,ENDVID); /* ENDVID is to avoid videotable */ hdg2 = ptr; ptr += sizeof(o_hdg2); warning = ptr; ptr += sizeof(o_warning); select_msg = ptr; far_strcpy(hdg2,o_hdg2); far_strcpy(warning,o_warning); far_strcpy(select_msg,o_select_msg); initmode = -1; load_fractint_cfg(0); /* get fractint.cfg into *vidtbl (== extraseg) */ /* try to change any VESA entries to fit the loaded image size */ if (virtual && video_vram && initmode == -1) { unsigned long vram = (unsigned long)video_vram << 16, need = (unsigned long)info->xdots * info->ydots; if (need <= vram) { char over[25]; /* overwrite comments with original resolutions */ int bppx; /* bytesperpixel multiplier */ for (i = 0; i < vidtbllen; ++i) { vident = &vidtbl[i]; if (vident->dotmode%100 == 28 && vident->colors >= 256 && (info->xdots > vident->xdots || info->ydots > vident->ydots) && vram >= (unsigned long) (info->xdots < vident->xdots ? vident->xdots : info->xdots) * (info->ydots < vident->ydots ? vident->ydots : info->ydots) * ((bppx = vident->dotmode/1000) < 2 ? ++bppx : bppx)) { sprintf(over,"<-VIRTUAL! at %4u x %4u",vident->xdots,vident->ydots); far_strcpy((char far *)vident->comment,(char far *)over); if (info->xdots > vident->xdots) vident->xdots = info->xdots; if (info->ydots > vident->ydots) vident->ydots = info->ydots; } /* change entry to force VESA virtual scanline setup */ } } } /* try to find exact match for vid mode */ for (i = 0; i < vidtbllen; ++i) { vident = &vidtbl[i]; if (info->xdots == vident->xdots && info->ydots == vident->ydots && filecolors == vident->colors && info->videomodeax == vident->videomodeax && info->videomodebx == vident->videomodebx && info->videomodecx == vident->videomodecx && info->videomodedx == vident->videomodedx && info->dotmode%100 == vident->dotmode%100) { initmode = i; break; } } /* exit in makepar mode if no exact match of video mode in file */ if(*s_makepar == '\0' && initmode == -1) return(0); if (initmode == -1) /* try to find very good match for vid mode */ for (i = 0; i < vidtbllen; ++i) { vident = &vidtbl[i]; if (info->xdots == vident->xdots && info->ydots == vident->ydots && filecolors == vident->colors) { initmode = i; break; } } /* setup table entry for each vid mode, flagged for how well it matches */ for (i = 0; i < vidtbllen; ++i) { far_memcpy((char far *)&videoentry,(char far *)&vidtbl[i], sizeof(videoentry)); tmpflags = VI_EXACT; if (videoentry.keynum == 0) tmpflags |= VI_NOKEY; if (info->xdots > videoentry.xdots || info->ydots > videoentry.ydots) tmpflags |= VI_SSMALL; else if (info->xdots < videoentry.xdots || info->ydots < videoentry.ydots) tmpflags |= VI_SBIG; if (filexdots > videoentry.xdots || fileydots > videoentry.ydots) tmpflags |= VI_VSMALL; else if (filexdots < videoentry.xdots || fileydots < videoentry.ydots) tmpflags |= VI_VBIG; if (filecolors > videoentry.colors) tmpflags |= VI_CSMALL; if (filecolors < videoentry.colors) tmpflags |= VI_CBIG; if (i == initmode) tmpflags -= VI_EXACT; if (videoentry.dotmode%100 == 11) { tmpflags |= VI_DISK2; if ((tmpflags & (VI_SBIG+VI_SSMALL+VI_VBIG+VI_VSMALL)) != 0) tmpflags |= VI_DISK1; } if (fileaspectratio != 0 && videoentry.dotmode%100 != 11 && (tmpflags & VI_VSMALL) == 0) { ftemp = vid_aspect(filexdots,fileydots); if ( ftemp < fileaspectratio * 0.98 || ftemp > fileaspectratio * 1.02) tmpflags |= VI_ASPECT; } vid[i].entnum = i; vid[i].flags = tmpflags; } if (fastrestore && !askvideo) initmode = adapter; #ifndef XFRACT gotrealmode = 0; if ((initmode < 0 || (askvideo && !initbatch)) && *s_makepar != '\0') { /* no exact match or (askvideo=yes and batch=no), and not in makepar mode, talk to user */ qsort(vid,vidtbllen,sizeof(vid[0]),vidcompare); /* sort modes */ attributes = (int *)&dstack[1000]; for (i = 0; i < vidtbllen; ++i) attributes[i] = 1; vidptr = &vid[0]; /* for format_item */ /* format heading */ if (info->info_id[0] == 'G') strcpy(temp1," Non-fractal GIF"); else { nameptr = curfractalspecific->name; if (*nameptr == '*') ++nameptr; if (display3d) nameptr = "3D Transform"; if ((!strcmp(nameptr,"formula")) || (!strcmp(nameptr,"lsystem")) || (!strncmp(nameptr,"ifs",3))) /* for ifs and ifs3d */ sprintf(temp1,"Type: %s -> %s",nameptr,blk_3_info->form_name); else sprintf(temp1,"Type: %s",nameptr); } sprintf((char *)dstack,"File: %-44s %d x %d x %d\n%-52s", readname,filexdots,fileydots,filecolors,temp1); if (info->info_id[0] != 'G') { if (save_system) strcat((char *)dstack,"WinFract "); sprintf(temp1,"v%d.%01d",save_release/100,(save_release%100)/10); if (save_release%100) { i = strlen(temp1); temp1[i] = (char)((save_release%10) + '0'); temp1[i+1] = 0; } if (save_system == 0 && save_release <= 1410) strcat(temp1," or earlier"); strcat((char *)dstack,temp1); } strcat((char *)dstack,"\n"); if (info->info_id[0] != 'G' && save_system == 0) if (initmode < 0) strcat((char *)dstack,"Saved in unknown video mode."); else { format_vid_inf(initmode,"",temp1); strcat((char *)dstack,temp1); } if (fileaspectratio != 0 && fileaspectratio != screenaspect) far_strcat((char *)dstack,warning); strcat((char *)dstack,"\n"); /* set up instructions */ far_strcpy(temp1,select_msg); if (info->info_id[0] != 'G') strcat(temp1,"TAB for fractal information, "); strcat(temp1,"ESCAPE to back out."); oldhelpmode = helpmode; helpmode = HELPLOADFILE; i = fullscreen_choice(0,(char *)dstack,hdg2,temp1,vidtbllen,NULL,attributes, 1,13,78,0,format_item,NULL,NULL,check_modekey); helpmode = oldhelpmode; if (i == -1) return(-1); if (i < 0) { /* returned -100 - videotable entry number */ initmode = -100 - i; gotrealmode = 1; } else initmode = vid[i].entnum; } #else initmode = 0; j = vidtbl[0].keynum; gotrealmode = 0; #endif if (gotrealmode == 0) { /* translate from temp table to permanent */ if ((j = vidtbl[i=initmode].keynum) != 0) { for (initmode = 0; initmode < MAXVIDEOTABLE-1; ++initmode) if (videotable[initmode].keynum == j) break; if (initmode >= MAXVIDEOTABLE-1) j = 0; } if (j == 0) /* mode has no key, add to reserved slot at end */ far_memcpy((char far *)&videotable[initmode=MAXVIDEOTABLE-1], (char far *)&vidtbl[i],sizeof(*vidtbl)); } /* ok, we're going to return with a video mode */ far_memcpy((char far *)&videoentry,(char far *)&videotable[initmode], sizeof(videoentry)); if (viewwindow && filexdots == videoentry.xdots && fileydots == videoentry.ydots) { /* pull image into a view window */ if (calc_status != 4) /* if not complete */ calc_status = 0; /* can't resume anyway */ if (viewxdots) { viewreduction = videoentry.xdots / viewxdots; viewxdots = viewydots = 0; /* easier to use auto reduction */ } viewreduction = (float)((int)(viewreduction + 0.5)); /* need integer value */ skipxdots = skipydots = (short)(viewreduction - 1); return(0); } skipxdots = skipydots = 0; /* set for no reduction */ if (videoentry.xdots < filexdots || videoentry.ydots < fileydots) { /* set up to load only every nth pixel to make image fit */ if (calc_status != 4) /* if not complete */ calc_status = 0; /* can't resume anyway */ skipxdots = skipydots = 1; while (skipxdots * videoentry.xdots < filexdots) ++skipxdots; while (skipydots * videoentry.ydots < fileydots) ++skipydots; i = j = 0; for(;;) { tmpxdots = (filexdots + skipxdots - 1) / skipxdots; tmpydots = (fileydots + skipydots - 1) / skipydots; if (fileaspectratio == 0 || videoentry.dotmode%100 == 11) break; /* reduce further if that improves aspect */ if ((ftemp = vid_aspect(tmpxdots,tmpydots)) > fileaspectratio) { if (j) break; /* already reduced x, don't reduce y */ ftemp2 = vid_aspect(tmpxdots,(fileydots+skipydots)/(skipydots+1)); if (ftemp2 < fileaspectratio && ftemp/fileaspectratio *0.9 <= fileaspectratio/ftemp2) break; /* further y reduction is worse */ ++skipydots; ++i; } else { if (i) break; /* already reduced y, don't reduce x */ ftemp2 = vid_aspect((filexdots+skipxdots)/(skipxdots+1),tmpydots); if (ftemp2 > fileaspectratio && fileaspectratio/ftemp *0.9 <= ftemp2/fileaspectratio) break; /* further x reduction is worse */ ++skipxdots; ++j; } } filexdots = tmpxdots; fileydots = tmpydots; --skipxdots; --skipydots; } if ((finalaspectratio = fileaspectratio) == 0) /* assume display correct */ finalaspectratio = (float)vid_aspect(filexdots,fileydots); if (finalaspectratio >= screenaspect-0.02 && finalaspectratio <= screenaspect+0.02) finalaspectratio = screenaspect; i = (int)(finalaspectratio * 1000.0 + 0.5); finalaspectratio = (float)(i/1000.0); /* chop precision to 3 decimals */ /* setup view window stuff */ viewwindow = viewxdots = viewydots = 0; if (filexdots != videoentry.xdots || fileydots != videoentry.ydots) { /* image not exactly same size as screen */ viewwindow = 1; ftemp = finalaspectratio * (double)videoentry.ydots / (double)videoentry.xdots / screenaspect; if (finalaspectratio <= screenaspect) { i = (int)((double)videoentry.xdots / (double)filexdots * 20.0 + 0.5); tmpreduce = (float)(i/20.0); /* chop precision to nearest .05 */ i = (int)((double)videoentry.xdots / tmpreduce + 0.5); j = (int)((double)i * ftemp + 0.5); } else { i = (int)((double)videoentry.ydots / (double)fileydots * 20.0 + 0.5); tmpreduce = (float)(i/20.0); /* chop precision to nearest .05 */ j = (int)((double)videoentry.ydots / tmpreduce + 0.5); i = (int)((double)j / ftemp + 0.5); } if (i != filexdots || j != fileydots) { /* too bad, must be explicit */ viewxdots = filexdots; viewydots = fileydots; } else viewreduction = tmpreduce; /* ok, this works */ } if (*s_makepar && !fastrestore && !initbatch && (fabs(finalaspectratio - screenaspect) > .00001 || viewxdots != 0)) { static FCODE msg[] = {"\ Warning: <V>iew parameters are being set to non-standard values.\n\ Remember to reset them when finished with this image!"}; stopmsg(4,msg); } return(0); }
int resolve_longname(char *dest, char *name) { #ifdef HAVE_EAS unsigned char *tmp_name; int entry, l_sel, rc; #if TARGET==OS2 #ifdef __32BIT__ EAOP2 eaop; PGEA2LIST pgeal; PFEA2LIST pfeal; #else EAOP eaop; PGEALIST pgeal; PFEALIST pfeal; #endif #elif TARGET==WIN32 struct nt_sid *sid=NULL; unsigned char *streambuf=NULL; unsigned long stream_len, rem_len, fetch; FEALIST feal; PFEALIST pfeal; #endif char FAR *valptr; unsigned int st_len; if(name[0]=='\0'||name[0]==PATHSEP_DEFAULT&&name[1]=='\0'||name[1]==':'&&name[2]=='\0') { strcpy(dest, name); return(0); } tmp_name=(char *)malloc_msg(FILENAME_MAX); l_sel=entry=split_name(name, tmp_name, NULL); if(entry>0) { tmp_name[entry-1]='\0'; resolve_longname(dest, tmp_name); entry=strlen(dest); dest[entry]=PATHSEP_DEFAULT; dest[entry+1]='\0'; } else dest[0]='\0'; #if TARGET==OS2 #ifdef __32BIT__ pgeal=(PGEA2LIST)farmalloc_msg(sizeof(GEA2LIST)+sizeof(longname_ea)); pfeal=(PFEA2LIST)farmalloc_msg(sizeof(FEA2LIST)+sizeof(longname_ea)+FILENAME_MAX); #else pgeal=(PGEALIST)farmalloc_msg(sizeof(GEALIST)+sizeof(longname_ea)); pfeal=(PFEALIST)farmalloc_msg(sizeof(FEALIST)+sizeof(longname_ea)+FILENAME_MAX); #endif far_strcpy(pgeal->list[0].szName, (char FAR *)longname_ea); #elif TARGET==WIN32 pfeal=(PFEALIST)farmalloc_msg(sizeof(FEALIST)+sizeof(longname_ea)+FILENAME_MAX); #endif #if TARGET==OS2 #ifdef __32BIT__ pgeal->list[0].oNextEntryOffset=0; #endif pgeal->list[0].cbName=sizeof(longname_ea)-1; #ifdef __32BIT__ pgeal->cbList=sizeof(GEA2LIST)+sizeof(longname_ea)-1; pfeal->cbList=sizeof(FEA2LIST)+sizeof(longname_ea)+FILENAME_MAX-1-entry; eaop.fpGEA2List=pgeal; eaop.fpFEA2List=pfeal; #else pgeal->cbList=sizeof(GEALIST)+sizeof(longname_ea)-1; pfeal->cbList=sizeof(FEALIST)+sizeof(longname_ea)+FILENAME_MAX-1-entry; eaop.fpGEAList=pgeal; eaop.fpFEAList=pfeal; #endif #ifdef __32BIT__ if(DosQueryPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop))) #else if(DosQPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop), 0L)) #endif rc=0; else { rc=1; #ifdef __32BIT__ valptr=(char FAR *)pfeal+sizeof(FEA2LIST)+pfeal->list[0].cbName; #else valptr=(char FAR *)pfeal+sizeof(FEALIST)+pfeal->list[0].cbName+1; #endif } #elif TARGET==WIN32 rc=0; if((sid=open_streams(name, 0))!=NULL&& (stream_len=seek_stream_id(BACKUP_EA_DATA, sid))>0) { valptr=streambuf=(char *)farmalloc_msg(256); pfeal=(PFEALIST)&feal; while(read_stream((char *)pfeal, sizeof(FEALIST), sid)==sizeof(FEALIST)&& read_stream(streambuf, pfeal->list[0].cbName+1, sid)==pfeal->list[0].cbName+1) { rem_len=pfeal->cbList-sizeof(FEALIST)-pfeal->list[0].cbName-1; if(!stricmp(streambuf, longname_ea)) { if(pfeal->list[0].cbValue<256) { read_stream(streambuf, pfeal->list[0].cbValue, sid); rc=1; break; } } else { if(pfeal->cbList==0) break; /* Advance to the next EA entry */ while(rem_len>0) { fetch=min(256, rem_len); read_stream(streambuf, fetch, sid); rem_len-=fetch; } } } } #endif if(rc) { if((st_len=pfeal->list[0].cbValue)==0) rc=0; else { far_memmove((char FAR *)tmp_name, valptr, st_len); tmp_name[st_len]='\0'; if(tmp_name[0]==0xFD&&tmp_name[1]==0xFF) { strcpy(tmp_name, (char *)tmp_name+4); st_len-=4; } if(st_len==0||st_len+entry>=FILENAME_MAX) rc=0; else { while(st_len-->0) { if(tmp_name[st_len]<' '||strchr(forbidden_chars, tmp_name[st_len])!=NULL) { rc=0; break; } } } } } if(!rc) { if(strlen(name)+entry+l_sel>=FILENAME_MAX) error(M_MAXPATH_EXCEEDED, FILENAME_MAX, name); strcat(dest, name+l_sel); } else strcat(dest, (char *)tmp_name); #if TARGET==OS2 farfree(pgeal); farfree(pfeal); #elif TARGET==WIN32 if(streambuf!=NULL) farfree(streambuf); if(sid!=NULL) close_streams(sid); #endif free(tmp_name); return(rc); #else return(0); #endif }
int query_ea(char FAR **dest, char *name, int skip_ln) { #ifdef HAVE_EAS ULONG count, j; #if TARGET==OS2 #ifdef __32BIT__ EAOP2 eaop; PGEA2LIST pgeal; PFEA2LIST pfeal; APIRET rc; PDENA2 pdena; FILESTATUS4 fs; #else EAOP eaop; PGEALIST pgeal; PFEALIST pfeal; USHORT rc; PDENA1 pdena; FILESTATUS2 fs; #endif #elif TARGET==WIN32 struct nt_sid *sid; unsigned char *streambuf; unsigned long stream_len; PFEALIST pfeal; #endif int rcode=0; char FAR *dptr, FAR *nptr; #if TARGET==OS2 pdena=farmalloc_msg(sizeof(*pdena)+CCHMAXPATHCOMP); #ifdef __32BIT__ pgeal=(PGEA2LIST)farmalloc_msg(sizeof(GEA2LIST)+CCHMAXPATHCOMP); if(DosQueryPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs))) return(-1); #else pgeal=(PGEALIST)farmalloc_msg(sizeof(GEALIST)+CCHMAXPATHCOMP); if(DosQPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs), 0L)) return(-1); #endif if(fs.cbList<4) fs.cbList=4; /* Fix for Ext2FS */ /* Allocate enough space to hold EA block */ #ifdef __32BIT__ *dest=(char FAR *)farmalloc_msg((int)fs.cbList*2); /* SDK does recommend it */ #else *dest=(char FAR *)farmalloc_msg((int)fs.cbList-2); #endif #elif TARGET==WIN32 if((sid=open_streams(name, 0))==NULL) return(-1); stream_len=seek_stream_id(BACKUP_EA_DATA, sid); if(stream_len==0||stream_len>65535) { close_streams(sid); *dest=(char FAR *)farmalloc_msg(2); dptr=*dest; mput_word(0, dptr); return(0); } /* It's a plain FEALIST, so doesn't require much caution */ streambuf=(char FAR *)farmalloc_msg((int)stream_len); *dest=(char FAR *)farmalloc_msg((int)stream_len); if((stream_len=read_stream(streambuf, stream_len, sid))==0) { close_streams(sid); dptr=*dest; mput_word(0, dptr); free(streambuf); return(0); } #endif /* Initialize storage */ dptr=*dest; mput_word(0, dptr); dptr+=2; j=0L; while(1) { #if TARGET==OS2 count=1L; #ifdef __32BIT__ if(DosEnumAttribute(ENUMEA_REFTYPE_PATH, (PVOID)name, ++j, (PVOID)pdena, sizeof(*pdena)+CCHMAXPATHCOMP, &count, ENUMEA_LEVEL_NO_VALUE)) break; #else if(DosEnumAttribute(ENUMEA_REFTYPE_PATH, (PVOID)name, ++j, (PVOID)pdena, sizeof(*pdena)+CCHMAXPATHCOMP, &count, ENUMEA_LEVEL_NO_VALUE, 0L)) break; #endif if(count==0L) break; /* EA (pdena->szName) consumes (pdena->cbValue) bytes */ #ifdef __32BIT__ eaop.fpGEA2List=pgeal; #else eaop.fpGEAList=pgeal; #endif far_strcpy(pgeal->list[0].szName, pdena->szName); pgeal->list[0].cbName=pdena->cbName; #ifdef __32BIT__ pgeal->list[0].oNextEntryOffset=0; pgeal->cbList=sizeof(GEA2LIST)+pdena->cbName; eaop.fpGEA2List=pgeal; pfeal=(PFEA2LIST)farmalloc_msg(sizeof(FEA2LIST)+pdena->cbName+pdena->cbValue+1); pfeal->cbList=sizeof(FEA2LIST)+pdena->cbName+pdena->cbValue+1; eaop.fpFEA2List=pfeal; if((rc=DosQueryPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop)))!=0) { farfree(pfeal); rcode=-1; break; } nptr=(char FAR *)&(pfeal->list[0])+sizeof(FEA2)-1; #else pgeal->cbList=sizeof(GEALIST)+pdena->cbName; eaop.fpGEAList=pgeal; pfeal=(PFEALIST)farmalloc_msg(sizeof(FEALIST)+pdena->cbName+pdena->cbValue+1); pfeal->cbList=sizeof(FEALIST)+pdena->cbName+pdena->cbValue+1; eaop.fpFEAList=pfeal; if((rc=DosQPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop), 0L))!=0) { farfree(pfeal); rcode=-1; break; } nptr=(char FAR *)&(pfeal->list[0])+sizeof(FEA); #endif #elif TARGET==WIN32 /* Win32 provides us with a FEALIST at our disposal. */ pfeal=(PFEALIST)streambuf; nptr=(char FAR *)&(pfeal->list[0])+sizeof(FEA); #endif #if SFX_LEVEL>=ARJ if(ea_filter(nptr, skip_ln)&&((pfeal->list[0].fEA&FEA_NEEDEA)||!crit_eas)) #endif { mput_word(mget_word(*dest)+1, *dest); mput_byte(pfeal->list[0].fEA, dptr++); mput_byte(pfeal->list[0].cbName, dptr++); mput_word(pfeal->list[0].cbValue, dptr); dptr+=2; far_memmove(dptr, nptr, (int)pfeal->list[0].cbName); dptr+=pfeal->list[0].cbName; far_memmove(dptr, nptr+pfeal->list[0].cbName+1, pfeal->list[0].cbValue); dptr+=pfeal->list[0].cbValue; } #if TARGET==OS2 farfree(pfeal); #elif TARGET==WIN32 if(pfeal->cbList==0) /* Indicates the last EA */ break; streambuf+=pfeal->cbList; #endif } #if TARGET==OS2 farfree(pdena); farfree(pgeal); #endif #if TARGET==WIN32 close_streams(sid); #endif return(rcode); #else return(-1); #endif }
int discard_ea(char *name) { #if TARGET==OS2 ULONG count; #ifdef __32BIT__ APIRET rc; char FAR *real_pfeal; PFEA2LIST pfeal; EAOP2 eaop; PDENA2 pdena; #else USHORT rc; PFEALIST pfeal; EAOP eaop; PDENA1 pdena; #endif int rcode=0; #ifdef __32BIT__ pdena=(PDENA2)farmalloc_msg(sizeof(*pdena)+CCHMAXPATHCOMP); real_pfeal=(char FAR *)farmalloc_msg(sizeof(*pdena)+CCHMAXPATHCOMP); pfeal=(PFEA2LIST)align_dword(real_pfeal); #else pdena=(PDENA1)farmalloc_msg(sizeof(*pdena)+CCHMAXPATHCOMP); pfeal=(PFEALIST)farmalloc_msg(sizeof(*pdena)+CCHMAXPATHCOMP); #endif while(1) { count=1L; #ifdef __32BIT__ if(DosEnumAttribute(ENUMEA_REFTYPE_PATH, (PVOID)name, 1L, (PVOID)pdena, sizeof(*pdena)+CCHMAXPATHCOMP, &count, ENUMEA_LEVEL_NO_VALUE)) #else if(DosEnumAttribute(ENUMEA_REFTYPE_PATH, (PVOID)name, 1L, (PVOID)pdena, sizeof(*pdena)+CCHMAXPATHCOMP, &count, ENUMEA_LEVEL_NO_VALUE, 0L)) #endif break; if(count==0L) break; /* EA (pdena->szName) consumes (pdena->cbValue) bytes */ #ifdef __32BIT__ eaop.fpFEA2List=pfeal; pfeal->list[0].oNextEntryOffset=0; #else eaop.fpFEAList=pfeal; #endif pfeal->list[0].fEA=0; pfeal->list[0].cbName=far_strlen(pdena->szName); pfeal->list[0].cbValue=0; #ifdef __32BIT__ far_strcpy((char FAR *)&(pfeal->list[0])+sizeof(FEA2)-1, pdena->szName); pfeal->cbList=(unsigned long)sizeof(FEA2LIST)+pfeal->list[0].cbName; if((rc=DosSetPathInfo(name, FIL_QUERYEASIZE, (PBYTE)&eaop, sizeof(eaop), 0))!=0) { rcode=-1; break; } #else far_strcpy((char FAR *)&(pfeal->list[0])+sizeof(FEA), pdena->szName); pfeal->cbList=(unsigned long)sizeof(FEALIST)+pfeal->list[0].cbName+1; if((rc=DosSetPathInfo(name, FIL_QUERYEASIZE, (PBYTE)&eaop, sizeof(eaop), 0, 0L))!=0) { rcode=-1; break; } #endif } farfree(pdena); #ifndef TILED farfree(real_pfeal); #endif return(rcode); #elif TARGET==WIN32 /* There seems to be no easy way to not purge EAs using the backup APIs! */ return(0); #else return(-1); #endif }
static int query_action_proc(int def, int qtype, char *query) { char reply_text[INPUT_LENGTH]; int sel, key, ukey; char *sel_ptr, *rt_ptr; int rt_len; if(query!=NULL) msg_cprintf(H_PROMPT, (FMSG *)strform, query); #if SFX_LEVEL>=ARJ if(qtype!=QUERY_CRITICAL&&queries_assume_no[qtype]) { msg_cprintf(H_OPER, M_NO); msg_cprintf(0, (FMSG *)lf); return(0); } if(qtype!=QUERY_CRITICAL&&queries_assume_yes[qtype]) { msg_cprintf(H_OPER, M_YES); msg_cprintf(0, (FMSG *)lf); return(1); } #endif if(kbd_cleanup_on_input) fetch_keystrokes(); #if SFX_LEVEL>=ARJ if(accept_shortcut_keys) { while(1) { do { while(1) { key=uni_getch(); /* If possible default action selected */ if(def!=0&&key==LF) { msg_cprintf(0, (FMSG *)lf); if(def==1) return(1); if(def==2) return(0); } ukey=toupper(key); far_strcpy(strcpy_buf, M_REPLIES); sel_ptr=strchr(strcpy_buf, ukey); sel=sel_ptr-strcpy_buf; if(ukey!=0&&sel_ptr!=NULL&&(qtype!=QUERY_CRITICAL||sel<=REPLY_QUIT)) break; fetch_keystrokes(); nputc(BEL); } nputc(key); msg_cprintf(0, (FMSG *)lf); } while(sel>MAX_REPLY); switch(sel) { case REPLY_YES: return(1); case REPLY_NO: return(0); case REPLY_QUIT: exit(ARJ_ERL_WARNING); case REPLY_ALL: if(qtype!=QUERY_CRITICAL) queries_assume_yes[qtype]=1; return(1); case REPLY_SKIP: if(qtype!=QUERY_CRITICAL) queries_assume_no[qtype]=1; return(0); case REPLY_GLOBAL: yes_on_all_queries=1; return(1); case REPLY_COMMAND: query_cmd(); if(query!=NULL) msg_cprintf(H_PROMPT, (FMSG *)strform, query); } } /* There is no way down here */ } #endif /* Use an editable field */ while(1) { read_line(reply_text, INPUT_LENGTH); for(rt_ptr=reply_text; rt_ptr[0]==' '; rt_ptr++); if((rt_len=strlen(rt_ptr))>0) { strupper(rt_ptr); if(!msg_strncmp(rt_ptr, reply_help, rt_len)) { far_strcpy(strcpy_buf, (qtype==QUERY_CRITICAL)?M_REPLIES_HELP:M_ALL_REPLIES_HELP); msg_cprintf(0, (FMSG *)strcpy_buf); continue; } else if(!msg_strncmp(rt_ptr, M_NO, rt_len)) return(0); else if(!msg_strncmp(rt_ptr, M_YES, rt_len)) return(1); else if(!msg_strncmp(rt_ptr, M_QUIT, rt_len)) exit(1); else if(qtype!=QUERY_CRITICAL) { #if SFX_LEVEL>=ARJ if(!msg_strncmp(rt_ptr, M_ALWAYS, rt_len)) { if(qtype!=QUERY_CRITICAL) queries_assume_yes[qtype]=1; return(1); } if(!msg_strncmp(rt_ptr, M_SKIP, rt_len)) { if(qtype!=QUERY_CRITICAL) queries_assume_no[qtype]=1; return(0); } #endif if(!msg_strncmp(rt_ptr, M_GLOBAL, rt_len)) { yes_on_all_queries=1; return(1); } #if SFX_LEVEL>=ARJ if(!msg_strncmp(rt_ptr, M_COMMAND, rt_len)) { query_cmd(); if(query!=NULL) msg_cprintf(H_PROMPT, (FMSG *)strform, query); continue; } #endif } } else { if(def==1) return(1); if(def==2) return(0); } fetch_keystrokes(); nputc(BEL); msg_cprintf(0, M_REPLIES_HELP); } }