home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
disks
/
misc
/
afcopy_v4.4
/
sourcecode
/
afcopy_config.c
< prev
next >
Wrap
C/C++ Source or Header
|
1981-06-29
|
35KB
|
904 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/execbase.h>
#include <exec/nodes.h>
#include <dos/dos.h>
#include <dos/dostags.h>
#include <dos/filehandler.h>
#include <libraries/dos.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <libraries/reqtools.h>
#include <libraries/dos.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/reqtools_protos.h>
#include "afcopy_defines.h"
#include "afcopy_protos.h"
#include "afcopy_vars.h"
#include "afcopy_version.h"
static struct NewMenu CfgNewMenu[] = {
NM_TITLE, (STRPTR)"Devs (Left)", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Top 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 5", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 6", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 5", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 6", NULL, 0, 0L, NULL,
NM_TITLE, (STRPTR)"Devs (Right)", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Top 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 5", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 6", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 5", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 6", NULL, 0, 0L, NULL,
NM_TITLE, (STRPTR)"User Gads (Left)", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Top 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 5", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 5", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 5", NULL, 0, 0L, NULL,
NM_TITLE, (STRPTR)"User Gads (Right)", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Top 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Top 5", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Middle 5", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 1", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 2", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 3", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 4", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Bottom 5", NULL, 0, 0L, NULL,
NM_TITLE, (STRPTR)"Misc", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Select Font", NULL, 0, 0L, NULL,
NM_END, NULL, NULL, 0, 0L, NULL };
BOOL LoadConfig(char *configname)
{
FILE *cfgf;
char cfgstr[MAX_PATH_LEN+1];
int loop,loop2,v,r;
BOOL retval=FALSE;
if ((cfgf=fopen(configname,"r"))==NULL)
{
return(FALSE);
}
else
{
if (fscanf(cfgf,"%6s",cfgstr)==1 && strcmp("AFCOPY",cfgstr)==0)
{
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
v=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
r=atoi(cfgstr);
if (v>=4 && r>=0)
{
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
strfcpy(cpath[0],cfgstr,1);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
strfcpy(cpath[1],cfgstr,1);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
strfcpy(defaulticonfile,cfgstr,1);
mfgets(cfgstr,MAX_CANCELCONTMSG_LEN,cfgf); /**/
strfcpy(cancelcontmsg,cfgstr,1);
mfgets(cfgstr,MAX_PATH_LEN,cfgf); /**/
strfcpy(outputcon,cfgstr,1);
for (loop=0;loop<MAX_COMMANDS;loop++)
{
mfgets(cfgstr,MAX_COMMAND_LEN,cfgf); /**/
strfcpy(CommandString[loop],cfgstr,1);
}
for (loop2=0;loop2<2;loop2++)
{
for (loop=0;loop<12;loop++)
{
mfgets(cfgstr,MAX_DEV_GAD_NAME_LEN,cfgf); /**/
strfcpy(devicegadnames[loop2][loop],cfgstr,1);
mfgets(cfgstr,MAX_DEV_GAD_ACTUAL_LEN,cfgf); /**/
strfcpy(devicegadactual[loop2][loop],cfgstr,1);
}
}
for (loop2=0;loop2<2;loop2++)
{
for (loop=0;loop<15;loop++)
{
mfgets(cfgstr,MAX_USER_GAD_NAME_LEN,cfgf); /**/
strfcpy(usergadnames[loop2][loop],cfgstr,1);
mfgets(cfgstr,MAX_USER_GAD_ACTUAL_LEN,cfgf); /**/
strfcpy(usergadactual[loop2][loop],cfgstr,1);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
usergadflags[loop2][loop]=atoi(cfgstr);
}
}
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
deleteverify=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
setprotverify=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
ignorehiddenbit=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
ignoreinserteddisks=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
mixfilesanddraws=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
autooverwrite=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
filecol=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
dircol=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
highlightcol=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
max_copy_buf_size=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
nomessages=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
lines_per_side=atoi(cfgstr);
if (lines_per_side<MIN_LINES_PER_SIDE) lines_per_side=MIN_LINES_PER_SIDE;
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
ignorenodisk=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
useworkbenchscreen=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
scrH=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
scrID=atoi(cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
shufflescreens=atoi(cfgstr);
mfgets(cfgstr,MAX_FONTNAME_LEN,cfgf);
strcpy(ScreenFontAttr.ta_Name,cfgstr);
mfgets(cfgstr,MAX_PATH_LEN,cfgf);
ScreenFontAttr.ta_Flags=atoi(cfgstr);
retval=TRUE;
}
}
else
{
rtEZRequest ("Not An AFCopy File",okmsg,NULL,(struct TagItem *)&reqtags,NULL);
}
fclose(cfgf);
}
return(retval);
}
BOOL SaveConfig(char *configname)
{
FILE *cfgf;
int loop,loop2;
if ((cfgf=fopen(configname,"w"))==NULL)
{
return(FALSE);
}
else
{
fprintf(cfgf,"AFCOPY CONFIG FILE FOR AFCOPY VERSION\n%d\nREVISION\n%d\n",VERSION,REVISION);
fprintf(cfgf,"!%s\n!%s\n!%s\n!%s\n!%s\n",cpath[0],cpath[1],defaulticonfile,cancelcontmsg,outputcon);
for (loop=0;loop<MAX_COMMANDS;loop++)
{
fprintf(cfgf,"!%s\n",CommandString[loop]);
}
for (loop2=0;loop2<2;loop2++)
{
for (loop=0;loop<12;loop++)
{
fprintf(cfgf,"!%s\n!%s\n",devicegadnames[loop2][loop],devicegadactual[loop2][loop]);
}
}
for (loop2=0;loop2<2;loop2++)
{
for (loop=0;loop<15;loop++)
{
fprintf(cfgf,"!%s\n!%s\n%d\n",usergadnames[loop2][loop],usergadactual[loop2][loop],usergadflags[loop2][loop]);
}
}
fprintf(cfgf,"%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%ld\n%d\n%s\n%d\n",
deleteverify,
setprotverify,
ignorehiddenbit,
ignoreinserteddisks,
mixfilesanddraws,
autooverwrite,
filecol,
dircol,
highlightcol,
max_copy_buf_size,
nomessages,
lines_per_side,
ignorenodisk,
useworkbenchscreen,
scrH,
scrID,
shufflescreens,
ScreenFontAttr.ta_Name,
ScreenFontAttr.ta_Flags);
fclose(cfgf);
return(TRUE);
}
}
void setdefaultconfig( void )
{
strcpy( devicegadnames[0][0],"DF0:");
strcpy(devicegadactual[0][0],devicegadnames[0][0]);
strcpy( devicegadnames[0][1],"DF1:");
strcpy(devicegadactual[0][1],devicegadnames[0][1]);
strcpy( devicegadnames[0][2],"DF2:");
strcpy(devicegadactual[0][2],devicegadnames[0][2]);
strcpy( devicegadnames[0][3],"PC0:");
strcpy(devicegadactual[0][3],devicegadnames[0][3]);
strcpy( devicegadnames[0][4],"PC1:");
strcpy(devicegadactual[0][4],devicegadnames[0][4]);
strcpy( devicegadnames[0][5],"RAM:");
strcpy(devicegadactual[0][5],devicegadnames[0][5]);
strcpy( devicegadnames[0][6],"DH0:");
strcpy(devicegadactual[0][6],devicegadnames[0][6]);
strcpy( devicegadnames[0][7],"DH1:");
strcpy(devicegadactual[0][7],devicegadnames[0][7]);
strcpy( devicegadnames[0][8],"DH2:");
strcpy(devicegadactual[0][8],devicegadnames[0][8]);
strcpy( devicegadnames[0][9],"XH0:");
strcpy(devicegadactual[0][9],devicegadnames[0][9]);
strcpy( devicegadnames[0][10],"NET:");
strcpy(devicegadactual[0][10],devicegadnames[0][10]);
strcpy( devicegadnames[0][11],"RAD:");
strcpy(devicegadactual[0][11],devicegadnames[0][11]);
strcpy( devicegadnames[1][0],"DF0:");
strcpy(devicegadactual[1][0],devicegadnames[1][0]);
strcpy( devicegadnames[1][1],"DF1:");
strcpy(devicegadactual[1][1],devicegadnames[1][1]);
strcpy( devicegadnames[1][2],"DF2:");
strcpy(devicegadactual[1][2],devicegadnames[1][2]);
strcpy( devicegadnames[1][3],"PC0:");
strcpy(devicegadactual[1][3],devicegadnames[1][3]);
strcpy( devicegadnames[1][4],"PC1:");
strcpy(devicegadactual[1][4],devicegadnames[1][4]);
strcpy( devicegadnames[1][5],"RAM:"); // dontforget CPATH[] below..
strcpy(devicegadactual[1][5],devicegadnames[1][5]);
strcpy( devicegadnames[1][6],"DH0:");
strcpy(devicegadactual[1][6],devicegadnames[1][6]);
strcpy( devicegadnames[1][7],"DH1:");
strcpy(devicegadactual[1][7],devicegadnames[1][7]);
strcpy( devicegadnames[1][8],"DH2:");
strcpy(devicegadactual[1][8],devicegadnames[1][8]);
strcpy( devicegadnames[1][9],"XH0:");
strcpy(devicegadactual[1][9],devicegadnames[1][9]);
strcpy( devicegadnames[1][10],"NET:");
strcpy(devicegadactual[1][10],devicegadnames[1][10]);
strcpy( devicegadnames[1][11],"RAD:");
strcpy(devicegadactual[1][11],devicegadnames[1][11]);
strcpy(outputcon,"CON:0/11/640/200/AFCopy Command Output/SCREEN @S@/AUTO/CLOSE/WAIT/ALT0/11/100/30");
strcpy(defaulticonfile,"env:sys/def_drawer.info");
strcpy(cancelcontmsg,"Continue|Cancel");
strcpy(ScreenFontAttr.ta_Name,"topaz.font");
strcpy(cpath[0],devicegadnames[1][5]);
strcpy(cpath[1],cpath[0]);
ScreenFontAttr.ta_YSize=8;
ScreenFontAttr.ta_Style=FS_NORMAL;
ScreenFontAttr.ta_Flags=FPB_ROMFONT;
deleteverify=TRUE;
setprotverify=TRUE;
ignorehiddenbit=TRUE;
ignorenodisk=FALSE;
ignoreinserteddisks=TRUE;
mixfilesanddraws=FALSE;
autooverwrite=FALSE;
// set to TRUE as of v4.2a
nomessages=TRUE;
max_copy_buf_size=1572864; /* 1.5MB!!! should be plenty!*/
// as of v4.2 afcopy defaults to custom screen!
lines_per_side=30;
useworkbenchscreen=FALSE;
scrID=PAL_MONITOR_ID | HIRES_KEY;
scrH=260;
dircol=1;
filecol=2;
highlightcol=3;
shufflescreens=FALSE;
strcpy(CommandString[C_View],"PPSHOW \"@<@@F@\"");
strcpy(CommandString[C_Read],"PPMORE \"@<@@F@\"");
// updated for v4.1.
strcpy(CommandString[C_Edit],"TTX \"@<@@F@\" SCREEN @S@");
strcpy(CommandString[C_Hear],"HEAR \"@<@@F@\"");
strcpy(CommandString[C_Execute],"EXECUTE \"@<@@F@\"");
strcpy(CommandString[C_Archive],"LHA");
strcpy(CommandString[C_Unarc],"LHA");
strcpy(batchstring,"@<@@F@");
}
struct Gadget *createModGadgets(struct Gadget **glistptr, void *vi,
UWORD topborder, struct Gadget *gads[],short side,int num)
{
struct NewGadget ng;
struct Gadget *gad;
#ifdef DEBUG
puts("createmodGadgets()");
#endif
gad = CreateContext(glistptr);
ng.ng_LeftEdge = 5;
ng.ng_TopEdge = 1+topborder;
ng.ng_Width = 8;
ng.ng_Height = 10;
ng.ng_TextAttr = &ScreenFontAttr;
ng.ng_VisualInfo = vi;
ng.ng_Flags = PLACETEXT_RIGHT;
ng.ng_GadgetID = G_m_sendfiles;
ng.ng_GadgetText = "Send File Names";
gads[G_m_sendfiles] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,usergadflags[side][num] & UG_SENDFILES,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_m_readc;
ng.ng_GadgetText = "Read Current";
gads[G_m_readc] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,usergadflags[side][num] & UG_READC,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_m_reado;
ng.ng_GadgetText = "Read Opposite";
gads[G_m_reado] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,usergadflags[side][num] & UG_READO,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_m_modify;
ng.ng_GadgetText = "Run Asynch";
gads[G_m_asynch] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,usergadflags[side][num] & UG_ASYNCH,
TAG_END);
ng.ng_LeftEdge = 160;
ng.ng_TopEdge = 1+topborder;
ng.ng_GadgetID = G_m_cdc;
ng.ng_GadgetText = "CD to Current";
gads[G_m_cdc] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,usergadflags[side][num] & UG_CDC,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_m_cdo;
ng.ng_GadgetText = "CD to Opposite";
gads[G_m_cdo] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,usergadflags[side][num] & UG_CDO,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_m_modify;
ng.ng_GadgetText = "Modify Command";
gads[G_m_modify] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,usergadflags[side][num] & UG_MODIFY,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_m_shuffle;
ng.ng_GadgetText = "Shuffle Screen";
gads[G_m_shuffle] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,usergadflags[side][num] & UG_SHUFFLE,
TAG_END);
ng.ng_LeftEdge = 5;
ng.ng_TopEdge += ng.ng_Height+2+14; /* 14 for font...*/
ng.ng_Width = 298;
ng.ng_Height = 14;
ng.ng_Flags = PLACETEXT_ABOVE;
ng.ng_GadgetText = "Gadget Name";
ng.ng_GadgetID = G_m_gadname;
gads[G_m_gadname] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, usergadnames[side][num],
GTST_MaxChars, MAX_USER_GAD_NAME_LEN-1,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2+12;
ng.ng_GadgetText = "Command Name (use @x@ codes)";
ng.ng_GadgetID = G_m_command;
gads[G_m_command] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, usergadactual[side][num],
GTST_MaxChars, MAX_USER_GAD_ACTUAL_LEN-1,
TAG_END);
return(gad);
}
struct Window *OpenModWindow(void)
{
#ifdef DEBUG
puts("OpenModWindow()");
#endif
struct Window *win;
if(win=OpenWindowTags(NULL,
WA_Left,W->LeftEdge+165,
WA_Top,W->TopEdge+50,
WA_Width,310,
WA_Height,128,
WA_AutoAdjust, FALSE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_Activate, TRUE,
WA_CloseGadget, TRUE,
WA_SimpleRefresh, FALSE,
WA_IDCMP, IDCMP_CLOSEWINDOW,
WA_Title,"Modify Gadget!",
WA_PubScreen, mysc,
WA_Gadgets,modglist,
WA_ScreenTitle,screentitle,
TAG_END))
{
GT_RefreshWindow(win, NULL);
}
return(win);
}
BOOL ModGadget(short side, int num) /* returns -1 if failed or cancelled.. */
{
struct IntuiMessage *imsg;
BOOL done=FALSE;
if (createModGadgets(&modglist, vi, topborder,modgads,side,num))
{
if ((modw=OpenModWindow()))
{
do
{
Wait (1 << modw->UserPort->mp_SigBit);
if ((imsg = GT_GetIMsg(modw->UserPort)))
{
if (imsg->Class == IDCMP_CLOSEWINDOW)
{
done=TRUE;
}
GT_ReplyIMsg(imsg);
}
} while (!done);
CloseWindow(modw);
usergadflags[side][num]=0;
if (modgads[G_m_sendfiles] ->Flags & GFLG_SELECTED) usergadflags[side][num]+=UG_SENDFILES;
if (modgads[G_m_readc] ->Flags & GFLG_SELECTED) usergadflags[side][num]+=UG_READC;
if (modgads[G_m_reado] ->Flags & GFLG_SELECTED) usergadflags[side][num]+=UG_READO;
if (modgads[G_m_cdc] ->Flags & GFLG_SELECTED) usergadflags[side][num]+=UG_CDC;
if (modgads[G_m_cdo] ->Flags & GFLG_SELECTED) usergadflags[side][num]+=UG_CDO;
if (modgads[G_m_modify] ->Flags & GFLG_SELECTED) usergadflags[side][num]+=UG_MODIFY;
if (modgads[G_m_asynch] ->Flags & GFLG_SELECTED) usergadflags[side][num]+=UG_ASYNCH;
if (modgads[G_m_shuffle] ->Flags & GFLG_SELECTED) usergadflags[side][num]+=UG_SHUFFLE;
strcpy(usergadnames[side][num],((struct StringInfo *)modgads[G_m_gadname]->SpecialInfo)->Buffer);
strcpy(usergadactual[side][num],((struct StringInfo *)modgads[G_m_command]->SpecialInfo)->Buffer);
}
FreeGadgets(modglist);
}
return(done); /* done will be false if window didnt open or
cadgets weren't created. */
}
struct Gadget *createCfgGadgets(struct Gadget **glistptr, void *vi,
UWORD topborder, struct Gadget *gads[])
{
struct NewGadget ng;
struct Gadget *gad;
#ifdef DEBUG
puts("createCfgGadgets()");
#endif
gad = CreateContext(glistptr);
ng.ng_LeftEdge = 5;
ng.ng_TopEdge = 1+topborder;
ng.ng_Width = 8;
ng.ng_Height = 10;
ng.ng_TextAttr = &ScreenFontAttr;
ng.ng_VisualInfo = vi;
ng.ng_Flags = PLACETEXT_RIGHT;
ng.ng_GadgetID = G_Cdelverify;
ng.ng_GadgetText = "Delete Verify";
gads[G_Cdelverify] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,deleteverify,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_Cignorehiddenbit;
ng.ng_GadgetText = "Ignore Hidden Bit";
gads[G_Cignorehiddenbit] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,ignorehiddenbit,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_Csetprotverify;
ng.ng_GadgetText = "Set Protection Verify";
gads[G_Csetprotverify] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,setprotverify,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_Cignoreinserteddisks;
ng.ng_GadgetText = "Ignore Disk Insert";
gads[G_Cignoreinserteddisks] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,ignoreinserteddisks,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_Cmixfilesanddraws;
ng.ng_GadgetText = "Mix Files and Dirs";
gads[G_Cmixfilesanddraws] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,mixfilesanddraws,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_Cautooverwrite;
ng.ng_GadgetText = "Auto Overwrite";
gads[G_Cautooverwrite] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,autooverwrite,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_Cnomessages;
ng.ng_GadgetText = "No Command Error Msg's";
gads[G_Cnomessages] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,nomessages,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetID = G_Cignorenodisk;
ng.ng_GadgetText = "Ignore No Disk In Drive";
gads[G_Cignorenodisk] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,ignorenodisk,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Shuffle Screens on command";
ng.ng_GadgetID = G_Cshufflescreens;
gads[G_Cshufflescreens] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,shufflescreens,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Use Workbench Screen";
ng.ng_GadgetID = G_Cuseworkbenchscreen;
gads[G_Cuseworkbenchscreen] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,
GTCB_Checked,useworkbenchscreen,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_Height += 2;
ng.ng_Width = CFG_STRGAD_WIDTH;
ng.ng_GadgetText = "Screen Mode";
ng.ng_GadgetID = G_Cpickscreen;
ng.ng_Flags = NG_HIGHLABEL|PLACETEXT_IN;
gads[G_Cpickscreen] = gad = CreateGadget(BUTTON_KIND, gad, &ng,TAG_END);
ng.ng_Flags = PLACETEXT_RIGHT; /* reset this cos changed for screenmode button*/
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_Width = 120;
ng.ng_Height = 20;
ng.ng_GadgetText = "File Colour";
ng.ng_GadgetID = G_Cfilecol;
gads[G_Cfilecol] = gad = CreateGadget(PALETTE_KIND, gad, &ng,
GTPA_Color, filecol,
GTPA_Depth, mysc->RastPort.BitMap->Depth,
GTPA_ColorOffset , 0,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Dir Colour";
ng.ng_GadgetID = G_Cdircol;
gads[G_Cdircol] = gad = CreateGadget(PALETTE_KIND, gad, &ng,
GTPA_Color, dircol,
GTPA_Depth, mysc->RastPort.BitMap->Depth,
GTPA_ColorOffset , 0,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Highlight";
ng.ng_GadgetID = G_Chighlightcol;
gads[G_Chighlightcol] = gad = CreateGadget(PALETTE_KIND, gad, &ng,
GTPA_Color, highlightcol,
GTPA_Depth, mysc->RastPort.BitMap->Depth,
GTPA_ColorOffset , 0,
TAG_END);
ng.ng_LeftEdge = 250;
ng.ng_TopEdge = 1+topborder;
ng.ng_Width = CFG_STRGAD_WIDTH;
ng.ng_Height = 14;
ng.ng_GadgetText = "View";
ng.ng_GadgetID = G_Cview;
gads[G_Cview] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, CommandString[C_View],
GTST_MaxChars, MAX_COMMAND_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Read";
ng.ng_GadgetID = G_Cread;
gads[G_Cread] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, CommandString[C_Read],
GTST_MaxChars, MAX_COMMAND_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Edit";
ng.ng_GadgetID = G_Cedit;
gads[G_Cedit] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, CommandString[C_Edit],
GTST_MaxChars, MAX_COMMAND_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Hear";
ng.ng_GadgetID = G_Chear;
gads[G_Chear] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, CommandString[C_Hear],
GTST_MaxChars, MAX_COMMAND_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Execute";
ng.ng_GadgetID = G_Cexecute;
gads[G_Cexecute] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, CommandString[C_Execute],
GTST_MaxChars, MAX_COMMAND_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Archiver";
ng.ng_GadgetID = G_Carchive;
gads[G_Carchive] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, CommandString[C_Archive],
GTST_MaxChars, MAX_COMMAND_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Un-Archiver";
ng.ng_GadgetID = G_Cunarc;
gads[G_Cunarc] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, CommandString[C_Unarc],
GTST_MaxChars, MAX_COMMAND_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Console Window";
ng.ng_GadgetID = G_Coutputcon;
gads[G_Coutputcon] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, outputcon,
GTST_MaxChars, MAX_PATH_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Draw Icon File";
ng.ng_GadgetID = G_Cdefaulticonfile;
gads[G_Cdefaulticonfile] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, defaulticonfile,
GTST_MaxChars, MAX_PATH_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Requester Message";
ng.ng_GadgetID = G_Ccancelcontmsg;
gads[G_Ccancelcontmsg] = gad = CreateGadget(STRING_KIND, gad, &ng,
GTST_String, cancelcontmsg,
GTST_MaxChars, MAX_CANCELCONTMSG_LEN,
TAG_END);
ng.ng_TopEdge += ng.ng_Height+2;
ng.ng_GadgetText = "Lines per side";
ng.ng_GadgetID = G_Clines;
gads[G_Clines] = gad = CreateGadget(INTEGER_KIND, gad, &ng,
GTIN_Number, lines_per_side,
GTIN_MaxChars, 3,
TAG_END);
return(gad);
}
struct Window *OpenCfgWindow(void)
{
#ifdef DEBUG
puts("OpenCfgWindow()");
#endif
struct Window *win;
if (win=OpenWindowTags(NULL,
WA_Left,W->LeftEdge+CFGLEFT,
WA_Top,W->TopEdge+CFGTOP,
WA_Width,CFGWIDTH,
WA_Height,CFGHEIGHT,
WA_AutoAdjust, FALSE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_Activate, TRUE,
WA_CloseGadget, TRUE,
WA_SimpleRefresh, FALSE,
WA_IDCMP, PALETTEIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_MENUPICK,
WA_Title,"AFCOPY Configuration",
WA_NewLookMenus, TRUE,
WA_PubScreen, mysc,
WA_Gadgets,cfgglist,
WA_ScreenTitle,screentitle,
TAG_END))
{
GT_RefreshWindow(win, NULL);
Move(win->RPort,250,CFGHEIGHT-15);
SetAPen(win->RPort,2); // white
Text(win->RPort,"Use The Menus!",14);
}
return(win);
}
BOOL EditConfig( void )
{
struct IntuiMessage *imsg;
BOOL done=FALSE;
struct Gadget *gad;
if (createCfgGadgets(&cfgglist, vi, topborder,cfggads))
{
if ((cfgw=OpenCfgWindow()))
{
if (CfgMenu = CreateMenus( CfgNewMenu, GTMN_NewLookMenus,TRUE,
TAG_DONE))
{
LayoutMenus(CfgMenu,vi,GTMN_TextAttr, &ScreenFontAttr,
GTMN_NewLookMenus,TRUE,TAG_DONE);
SetMenuStrip(cfgw,CfgMenu);
SetFont(cfgw->RPort,ScreenFont);
SetAPen(cfgw->RPort,2);
do
{
Wait (1 << cfgw->UserPort->mp_SigBit);
if ((imsg = GT_GetIMsg(cfgw->UserPort)))
{
if (imsg->Class == IDCMP_CLOSEWINDOW)
{
done=TRUE;
}
if (imsg->Class == IDCMP_MENUPICK)
{
switch (MENUNUM(imsg->Code))
{
case 0:
case 1:
if (rtGetString (devicegadnames[MENUNUM(imsg->Code)][ITEMNUM(imsg->Code)], MAX_DEV_GAD_NAME_LEN, "Enter Device Gadget Name", NULL,RT_Window,W, TAG_END))
{
rtGetString (devicegadactual[MENUNUM(imsg->Code)][ITEMNUM(imsg->Code)], MAX_DEV_GAD_ACTUAL_LEN, "Enter Actual Device Name", NULL,RT_Window,W, TAG_END);
}
break;
case 2:
case 3:
ModGadget(MENUNUM(imsg->Code)-2,ITEMNUM(imsg->Code));
break;
case 4: /* misc */
switch (ITEMNUM(imsg->Code))
{
case 0: /* pick font! */
do
{
CloseFont(ScreenFont);
PickFont();
} while (GetFont()==0);
break;
}
break;
}
}
if (imsg->Class == IDCMP_GADGETUP)
{
gad = (struct Gadget *)imsg->IAddress;
switch (gad->GadgetID)
{
case G_Cfilecol:
filecol=imsg->Code;
break;
case G_Cdircol:
dircol=imsg->Code;
break;
case G_Chighlightcol:
highlightcol=imsg->Code;
break;
case G_Cpickscreen:
pickscreen();
GT_SetGadgetAttrs(cfggads[G_Cuseworkbenchscreen],cfgw,NULL,
GTCB_Checked,useworkbenchscreen,
TAG_END);
break;
}
}
GT_ReplyIMsg(imsg);
}
} while (!done);
ClearMenuStrip(cfgw);
FreeMenus(CfgMenu);
}
CloseWindow(cfgw);
if (cfggads[G_Cdelverify] ->Flags & GFLG_SELECTED) deleteverify=TRUE; else deleteverify=FALSE;
if (cfggads[G_Csetprotverify] ->Flags & GFLG_SELECTED) setprotverify=TRUE; else setprotverify=FALSE;
if (cfggads[G_Cignorehiddenbit] ->Flags & GFLG_SELECTED) ignorehiddenbit=TRUE; else ignorehiddenbit=FALSE;
if (cfggads[G_Cignoreinserteddisks] ->Flags & GFLG_SELECTED) ignoreinserteddisks=TRUE; else ignoreinserteddisks=FALSE;
if (cfggads[G_Cmixfilesanddraws] ->Flags & GFLG_SELECTED) mixfilesanddraws=TRUE; else mixfilesanddraws=FALSE;
if (cfggads[G_Cautooverwrite] ->Flags & GFLG_SELECTED) autooverwrite=TRUE; else autooverwrite=FALSE;
if (cfggads[G_Cnomessages] ->Flags & GFLG_SELECTED) nomessages=TRUE; else nomessages=FALSE;
if (cfggads[G_Cignorenodisk] ->Flags & GFLG_SELECTED) ignorenodisk=TRUE; else ignorenodisk=FALSE;
if (cfggads[G_Cuseworkbenchscreen] ->Flags & GFLG_SELECTED) useworkbenchscreen=TRUE; else useworkbenchscreen=FALSE;
if (cfggads[G_Cshufflescreens] ->Flags & GFLG_SELECTED) shufflescreens=TRUE; else shufflescreens=FALSE;
strcpy(defaulticonfile,((struct StringInfo *)cfggads[G_Cdefaulticonfile]->SpecialInfo)->Buffer);
strcpy(outputcon,((struct StringInfo *)cfggads[G_Coutputcon]->SpecialInfo)->Buffer);
strcpy(cancelcontmsg,((struct StringInfo *)cfggads[G_Ccancelcontmsg]->SpecialInfo)->Buffer);
strcpy(CommandString[C_View],((struct StringInfo *)cfggads[G_Cview]->SpecialInfo)->Buffer);
strcpy(CommandString[C_Read],((struct StringInfo *)cfggads[G_Cread]->SpecialInfo)->Buffer);
strcpy(CommandString[C_Edit],((struct StringInfo *)cfggads[G_Cedit]->SpecialInfo)->Buffer);
strcpy(CommandString[C_Hear],((struct StringInfo *)cfggads[G_Chear]->SpecialInfo)->Buffer);
strcpy(CommandString[C_Execute],((struct StringInfo *)cfggads[G_Cexecute]->SpecialInfo)->Buffer);
strcpy(CommandString[C_Archive],((struct StringInfo *)cfggads[G_Carchive]->SpecialInfo)->Buffer);
strcpy(CommandString[C_Unarc],((struct StringInfo *)cfggads[G_Cunarc]->SpecialInfo)->Buffer);
lines_per_side=(( struct StringInfo * )cfggads[G_Clines]->SpecialInfo )->LongInt;
if (lines_per_side <MIN_LINES_PER_SIDE) lines_per_side=MIN_LINES_PER_SIDE;
if (!useworkbenchscreen && scrID==-1) useworkbenchscreen=TRUE;
}
FreeGadgets(cfgglist);
}
checkcustomscreenwindows();
closeafcopywindow();
if (openafcopywindow())
{
UpdateMainWindow();
return(TRUE);
}
else return(FALSE);
}