mrr@softie.UUCP (09/26/87)
# This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file" # Created Fri Sep 25 07:26:10 1987 # # This archive contains: # Menu.c # Menu.h # MiscRequest.c # PathRequest.c # Restore.c # UserPrefs.c echo "Creating Menu.c" cat > Menu.c <<"***EOF Menu.c***" /***************************************************** * Menu Definitions * * * * Created with Menu Creator * * by * * David Pehrson * * * * Copyright (C) 1986 David Pehrson * * Mantis Development * * * *****************************************************/ #include <exec/types.h> #include <intuition/intuition.h> char stTopaz[] = "topaz.font"; struct TextAttr taPlain = { (STRPTR) stTopaz, 8, FS_NORMAL, FPF_ROMFONT }; struct TextAttr taBIU = { (STRPTR) stTopaz, 8, FSF_BOLD | FSF_ITALIC | FSF_UNDERLINED, FPF_ROMFONT }; struct TextAttr taBU = { (STRPTR) stTopaz, 8, FSF_BOLD | FSF_UNDERLINED, FPF_ROMFONT }; struct TextAttr taBI = { (STRPTR) stTopaz, 8, FSF_BOLD | FSF_ITALIC, FPF_ROMFONT }; struct TextAttr taB = { (STRPTR) stTopaz, 8, FSF_BOLD, FPF_ROMFONT }; struct TextAttr taIU = { (STRPTR) stTopaz, 8, FSF_ITALIC | FSF_UNDERLINED, FPF_ROMFONT }; struct TextAttr taI = { (STRPTR) stTopaz, 8, FSF_ITALIC, FPF_ROMFONT }; struct TextAttr taU = { (STRPTR) stTopaz, 8, FSF_UNDERLINED, FPF_ROMFONT }; struct IntuiText ItemText[] = { { 0, 1, JAM1, 0, 1, &taPlain, "Backup", NULL }, { 0, 1, JAM1, 0, 1, &taPlain, "Restore", NULL }, { 0, 1, JAM1, 0, 1, &taPlain, "About", NULL }, { 0, 1, JAM1, 0, 1, &taPlain, "Quit", NULL }, { 0, 1, JAM1, 0, 1, &taPlain, " Compression", NULL }, { 0, 1, JAM1, 0, 1, &taPlain, " No Compression", NULL }, { 0, 1, JAM1, 0, 1, &taPlain, " Listing", NULL }, { 0, 1, JAM1, 0, 1, &taPlain, " No Listing", NULL }, { 0, 1, JAM1, 0, 1, &taPlain, " Speech", NULL }, { 0, 1, JAM1, 0, 1, &taPlain, " No Speech", NULL }, }; struct MenuItem Items[] = { { /* Backup */ &Items[1], 0, 0, 72, 10, ITEMENABLED | ITEMTEXT | HIGHCOMP , 0, (APTR)&ItemText[0], NULL, NULL, NULL, MENUNULL }, { &Items[2], 0, 10, 72, 10, ITEMENABLED | ITEMTEXT | HIGHCOMP , 0, (APTR)&ItemText[1], NULL, NULL, NULL, MENUNULL }, { &Items[3], 0, 20, 72, 10, ITEMENABLED | ITEMTEXT | HIGHCOMP, 0, (APTR)&ItemText[2], NULL, NULL, NULL, MENUNULL }, { NULL, 0, 30, 72, 10, ITEMENABLED | ITEMTEXT | HIGHCOMP, 0, (APTR)&ItemText[3], NULL, NULL, NULL, MENUNULL }, { &Items[5], 0, 0, 152, 10, /* Compression */ ITEMENABLED | ITEMTEXT | CHECKIT | HIGHCOMP | CHECKED, 2, (APTR)&ItemText[4], NULL, NULL, NULL, MENUNULL }, { &Items[6], 0, 10, 152, 10, /* No Compression */ ITEMENABLED | ITEMTEXT | CHECKIT | HIGHCOMP, 1, (APTR)&ItemText[5], NULL, NULL, NULL, MENUNULL }, { &Items[7], 0, 20, 152, 10, /* Listing */ ITEMENABLED | ITEMTEXT | CHECKIT | HIGHCOMP | CHECKED, 8, (APTR)&ItemText[6], NULL, NULL, NULL, MENUNULL }, { &Items[8], 0, 30, 152, 10, /* No Listing */ ITEMENABLED | ITEMTEXT | CHECKIT | HIGHCOMP, 4, (APTR)&ItemText[7], NULL, NULL, NULL, MENUNULL }, { &Items[9], 0, 40, 152, 10, /* Speech */ ITEMENABLED | ITEMTEXT | CHECKIT | HIGHCOMP | CHECKED, 32, (APTR)&ItemText[8], NULL, NULL, NULL, MENUNULL }, { NULL, 0, 50, 152, 10, /* No Speech */ ITEMENABLED | ITEMTEXT | CHECKIT | HIGHCOMP, 16, (APTR)&ItemText[9], NULL, NULL, NULL, MENUNULL }, }; struct Menu Titles[] = { { &Titles[1], 3, 0, 70, 0, MENUENABLED, "Project", &Items[0],0,0,0,0 }, { NULL, 72, 0, 54, 0, MENUENABLED, "Flags", &Items[4],0,0,0,0 }, }; ***EOF Menu.c*** echo "Creating Menu.h" cat > Menu.h <<"***EOF Menu.h***" /* Menu constant definitions */ #define MENU_PROJECT 0 #define ITEM_BACKUP 0 #define ITEM_RESTORE 1 #define ITEM_ABOUT 2 #define ITEM_QUIT 3 #define MENU_FLAGS 1 #define ITEM_COMPRESS 0 #define ITEM_NOCOMPRESS 1 #define ITEM_LIST 2 #define ITEM_NOLIST 3 #define ITEM_SPEECH 4 #define ITEM_NOSPEECH 5 ***EOF Menu.h*** echo "Creating MiscRequest.c" cat > MiscRequest.c <<"***EOF MiscRequest.c***" /* Miscellaneous requester support routines. */ #include <exec/memory.h> #include <intuition/intuition.h> #include <intuition/intuitionbase.h> #include <libraries/dosextens.h> #include <graphics/text.h> #include <functions.h> #include <ctype.h> struct IntuiText diskreq_body_text = { AUTOFRONTPEN, /* FrontPen */ AUTOBACKPEN, /* BackPen */ AUTODRAWMODE, /* DrawMode */ AUTOLEFTEDGE, /* LeftEdge */ AUTOTOPEDGE, /* TopEdge */ NULL, /* ITextFont Pointer */ (UBYTE *)"", /* IText */ NULL /* NextText */ }; struct IntuiText diskreq_pos_text = { AUTOFRONTPEN, /* FrontPen */ AUTOBACKPEN, /* BackPen */ AUTODRAWMODE, /* DrawMode */ AUTOLEFTEDGE, /* LeftEdge */ AUTOTOPEDGE, /* TopEdge */ NULL, /* ITextFont Pointer */ (UBYTE *)"OK", /* IText */ NULL /* NextText */ }; struct IntuiText diskreq_neg_text = { AUTOFRONTPEN, /* FrontPen */ AUTOBACKPEN, /* BackPen */ AUTODRAWMODE, /* DrawMode */ AUTOLEFTEDGE, /* LeftEdge */ AUTOTOPEDGE, /* TopEdge */ NULL, /* ITextFont Pointer */ (UBYTE *)"Cancel", /* IText */ NULL /* NextText */ }; /* Generate an autorequest for the insertion of a floppy disk. * Called with: * window: pointer to window for request * drivespec: the disk drive name */ int RequestDisk(window, drivespec) struct Window *window; char *drivespec; { UBYTE prompt[41]; strcpy(prompt,"Insert blank disk in "); strncat(prompt,drivespec,(sizeof(prompt)-strlen(prompt)-1)); diskreq_body_text.IText = prompt; return AutoRequest( window, &diskreq_body_text, &diskreq_pos_text, &diskreq_neg_text, DISKINSERTED, NULL, 300L, 50L); } ***EOF MiscRequest.c*** echo "Creating PathRequest.c" cat > PathRequest.c <<"***EOF PathRequest.c***" /* MRBackup Pathname Specifications "Requester" * Filename: PathRequest.c * History: (most recent change first) * * 09/20/87 -MRR- V1.3: The pathname gadgets were formerly attached to * a requester. I have removed the requester stuff, since * it did nothing to enhance the functionality of the * pathname specification window. */ /********************************************************************** * Gadget Structure Definitions * * Some of the following structures were defined using the Gadget Editor * created by the Programmer's Network. * The credits for the Gadget Editor are: * * John Draper - Initial design, coordination, and integration. * Ray Larson - Images and Intuitext. * Brent Southard - Saving and restoring gadgets in binary form. * Dave Milligan - Gadget Editor Main menu. * * **********************************************************************/ /* The header files needed for gadget definitions */ #include <exec/memory.h> #include <intuition/intuition.h> #include <intuition/intuitionbase.h> #include <libraries/dosextens.h> #include <graphics/gfxbase.h> #include <graphics/gfx.h> #include <graphics/display.h> #include <graphics/text.h> #include <functions.h> #include <ctype.h> #include "gadget.h" #define PATHGADTYPE STRGADGET /********************************************************************** * Text attribute structures used in rendering IntuiTexts **********************************************************************/ /* A note to the fastidious: These things are duplicated in the menu * package. Some ambitious soul should consolidate them into a single * definition. */ char def_font[] ="topaz.font"; struct TextAttr TxtAt_Plain = { (UBYTE *)def_font, 8, FS_NORMAL, FPF_ROMFONT}; struct TextAttr TxtAt_BIU = {(UBYTE *)def_font, 8, FSF_BOLD | FSF_ITALIC | FSF_UNDERLINED, FPF_ROMFONT}; struct TextAttr TxtAt_BU = {(UBYTE *)def_font, 8, FSF_BOLD | FSF_UNDERLINED, FPF_ROMFONT}; struct TextAttr TxtAt_BI = {(UBYTE *)def_font, 8, FSF_BOLD | FSF_ITALIC, FPF_ROMFONT}; struct TextAttr TxtAt_B ={(UBYTE *)def_font, 8, FSF_BOLD, FPF_ROMFONT}; struct TextAttr TxtAt_IU ={(UBYTE *)def_font, 8, FSF_ITALIC | FSF_UNDERLINED, FPF_ROMFONT}; struct TextAttr TxtAt_I ={(UBYTE *)def_font, 8, FSF_ITALIC, FPF_ROMFONT}; struct TextAttr TxtAt_U ={(UBYTE *)def_font, 8, FSF_UNDERLINED, FPF_ROMFONT}; /* STOP gadget definition */ /***************************************************************/ /* The following data structure contains the image data */ /***************************************************************/ USHORT StopGadImg_dat[]= { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0000, 0x00ff, 0xffff, 0xffe0, 0x0000, 0x0006, 0x0000, 0x03ff, 0xffff, 0xfff8, 0x0000, 0x0006, 0x0000, 0x07ff, 0xffff, 0xfffc, 0x0000, 0x0027, 0x0000, 0x1fff, 0xffff, 0xffff, 0x0000, 0x0021, 0x0000, 0x3fff, 0xffff, 0xffff, 0x8000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xe000, 0x0026, 0x0001, 0xffff, 0xffff, 0xffff, 0xf000, 0x0000, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0020, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0038, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0010, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0000, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0000, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0000, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0000, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0000, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0000, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0036, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0020, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0006, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x003c, 0x000f, 0xffff, 0xffff, 0xffff, 0xfe00, 0x0006, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0031, 0x0001, 0xffff, 0xffff, 0xffff, 0xf000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xe000, 0x0000, 0x0000, 0x3fff, 0xffff, 0xffff, 0x8000, 0x000f, 0x0000, 0x1fff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x07ff, 0xffff, 0xfffc, 0x0000, 0x0000, 0x0000, 0x03ff, 0xffff, 0xfff8, 0x0000, 0x0000, 0x0000, 0x00ff, 0xffff, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0007, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x00ff, 0xffff, 0xffe0, 0x0000, 0x0000, 0x0000, 0x03ff, 0xffff, 0xfff8, 0x0000, 0x0000, 0x0000, 0x07ff, 0xffff, 0xfffc, 0x0000, 0x0000, 0x0000, 0x1fff, 0xffff, 0xffff, 0x0000, 0x0020, 0x0000, 0x3fff, 0xffff, 0xffff, 0x8000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xe000, 0x003f, 0x0001, 0xffff, 0xffff, 0xffff, 0xf000, 0x0006, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0001, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0026, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0000, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0001, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0006, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0006, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0003, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0001, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0000, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0024, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0000, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0006, 0x0007, 0xffff, 0xffff, 0xffff, 0xfc00, 0x0000, 0x0001, 0xffff, 0xffff, 0xffff, 0xf000, 0x0001, 0x0000, 0xffff, 0xffff, 0xffff, 0xe000, 0x0000, 0x0000, 0x3fff, 0xffff, 0xffff, 0x8000, 0x0001, 0x0000, 0x1fff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x07ff, 0xffff, 0xfffc, 0x0000, 0x0000, 0x0000, 0x03ff, 0xffff, 0xfff8, 0x0000, 0x0000, 0x0000, 0x00ff, 0xffff, 0xffe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x003f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0007, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0002 }; /***************************************************************/ /* The following data structure defines the image */ /***************************************************************/ struct Image StopGadImg = { 0, 0, /* Left, Top */ 90, 38, /* Width, Height */ 2, /* Depth */ (USHORT *)&StopGadImg_dat, /* ImageData */ 0xff, /* PlanePick */ 0x00, /* PlaneOnOff */ NULL /* Next Image */ }; /********************************************************************** * IntuiTexts for the StopGad gadget. **********************************************************************/ struct IntuiText StopGad_Text_0 = { 0, 3, /* FrontPen, BackPen */ JAM2, /* DrawMode */ 26, 13, /* LeftEdge, TopEdge */ &TxtAt_B, /* ITextFont Pointer - bold */ /* The IText */ (UBYTE *)"STOP", NULL }; /********************************************************************** * Gadget Structure definition for the StopGad gadget. **********************************************************************/ struct Gadget StopGad = { NULL, /* NextGadget pointer */ 76, 30, /* LeftEdge, TopEdge */ 90, 38, /* Width, Height */ GADGIMAGE, /* Gadget Flags */ RELVERIFY, /* Activation Flags */ BOOLGADGET, /* GadgetType */ (APTR)&StopGadImg, /* GadgetRender */ NULL, /* SelectRender */ &StopGad_Text_0, /* GadgetText */ 0x0, /* MutualExclude */ NULL, /* SpecialInfo */ STOPGAD, /* GadgetID */ 0x0 /* UserData Pointer */ }; #define REQUESTWIDTH 260 #define REQUESTHEIGHT 70 /* New window structure */ static struct NewWindow pathreqnw = { 640 - REQUESTWIDTH - 8, /* LeftEdge */ 12, /* TopEdge */ REQUESTWIDTH + 4, /* Width */ REQUESTHEIGHT + 10, /* Height */ 0, /* DetailPen */ 1, /* BlockPen */ GADGETDOWN | GADGETUP , /* IDCMP Flags */ WINDOWDEPTH | WINDOWDRAG | ACTIVATE ,/* Flags */ NULL, /* First gadget */ NULL, /* Checkmark */ (UBYTE *)"Pathname Specifications", /* Window title */ NULL, /* No custom streen */ NULL, /* Not a super bitmap window */ REQUESTWIDTH+4, /* MinWidth */ REQUESTHEIGHT + 10, /* MinHeight */ 640, /* MaxWidth */ 200, /* MaxHeight */ WBENCHSCREEN }; /********************************************************************** * IntuiTexts for the excludepat gadget. **********************************************************************/ struct IntuiText excludepath_Text_0 = { 3, 0, /* FrontPen, BackPen */ JAM2, /* DrawMode */ -112, 0, /* LeftEdge, TopEdge */ &TxtAt_Plain, /* ITextFont Pointer */ (UBYTE *)"Exclude Path:", /* The IText */ NULL }; /********************************************************************** * String information for the excludepat string gadget. **********************************************************************/ static UBYTE excludepath_sbuf_1[81]; static UBYTE excludepath_ubuf_1[81]; struct StringInfo excludepath_txstr_1 = { excludepath_sbuf_1, /* Buffer */ excludepath_ubuf_1, /* UndoBuffer */ 0, 80, 0, /* BufferPos, MaxChars, DispPos */ 0, 0, /* UndoPos, NumChars */ 0, 0, 0, /* DispCount, CLeft, CTop */ 0x0, 0, /* LayerPtr, LongInt */ 0x0 /* AltKeyMap */ }; /********************************************************************** * Gadget Structure definition for the excludepat gadget. **********************************************************************/ struct Gadget excludepathgad = { NULL, /* NextGadget pointer */ 144, 60, /* LeftEdge, TopEdge */ 100, 9, /* Width, Height */ GADGHCOMP, /* Gadget Flags */ GADGIMMEDIATE | RELVERIFY, /* Activation Flags */ PATHGADTYPE, /* GadgetType */ NULL, /* GadgetRender */ NULL, /* SelectRender */ &excludepath_Text_0, /* GadgetText */ 0x0, /* MutualExclude */ (APTR)&excludepath_txstr_1, /* SpecialInfo */ XCLDPATHGAD, /* GadgetID */ NULL /* UserData Pointer */ }; /********************************************************************** * IntuiTexts for the listpath gadget. **********************************************************************/ struct IntuiText listpath_Text_0 = { 3, 0, /* FrontPen, BackPen */ JAM2, /* DrawMode */ -112, 0, /* LeftEdge, TopEdge */ &TxtAt_Plain, /* ITextFont Pointer */ (UBYTE *)"Listing Path:", /* The IText */ NULL }; /********************************************************************** * String information for the listpath string gadget. **********************************************************************/ UBYTE listpath_sbuf_1[81] = "PRT:"; UBYTE listpath_ubuf_1[81]; struct StringInfo listpath_txstr_1 = { listpath_sbuf_1, listpath_ubuf_1, /* Buffer, UndoBuffer */ 0, 80, 0, /* BufferPos, MaxChars, DispPos */ 0, 4, /* UndoPos, NumChars */ 0, 0, 0, /* DispCount, CLeft, CTop */ 0x0, 0, /* LayerPtr, LongInt */ 0x0 /* AltKeyMap */ }; /********************************************************************** * Gadget Structure definition for the listpath gadget. **********************************************************************/ struct Gadget listpathgad = { NULL, /* NextGadget pointer */ 144, 48, /* LeftEdge, TopEdge */ 100, 9, /* Width, Height */ GADGHCOMP, /* Gadget Flags */ GADGIMMEDIATE | RELVERIFY , /* Activation Flags */ PATHGADTYPE, /* GadgetType */ NULL, /* GadgetRender */ NULL, /* SelectRender */ &listpath_Text_0, /* GadgetText */ 0x0, /* MutualExclude */ (APTR)&listpath_txstr_1, /* SpecialInfo */ LISTPATHGAD, /* GadgetID */ NULL /* UserData Pointer */ }; /********************************************************************** * IntuiTexts for the backpath gadget. **********************************************************************/ struct IntuiText backpath_Text_0 = { 3, 0, /* FrontPen, BackPen */ JAM2, /* DrawMode */ -104, 0, /* LeftEdge, TopEdge */ &TxtAt_Plain, /* ITextFont Pointer */ (UBYTE *)"Backup Path:", /* The IText */ NULL }; /********************************************************************** * String information for the backpath string gadget. **********************************************************************/ UBYTE backpath_sbuf_1[81] = "DF0:"; UBYTE backpath_ubuf_1[81]; struct StringInfo backpath_txstr_1 = { backpath_sbuf_1, /* Buffer */ backpath_ubuf_1, /* UndoBuffer */ 0, 80, 0, /* BufferPos, MaxChars, DispPos */ 0, 4, /* UndoPos, NumChars */ 0, 0, 0, /* DispCount, CLeft, CTop */ 0x0, 0, /* LayerPtr, LongInt */ 0x0 /* AltKeyMap */ }; /********************************************************************** * Gadget Structure definition for the backpath gadget. **********************************************************************/ struct Gadget backpathgad = { NULL, /* NextGadget pointer */ 144, 36, /* LeftEdge, TopEdge */ 100, 9, /* Width, Height */ GADGHCOMP, /* Flags */ GADGIMMEDIATE | RELVERIFY , /* Activation */ PATHGADTYPE, /* GadgetType */ NULL, /* GadgetRender */ NULL, /* SelectRender */ &backpath_Text_0, /* GadgetText */ 0x0, /* MutualExclude */ (APTR)&backpath_txstr_1, /* SpecialInfo */ BACKPATHGAD, /* GadgetID */ NULL /* UserData Pointer */ }; /********************************************************************** * IntuiTexts for the homepath gadget. **********************************************************************/ struct IntuiText homepath_Text_0 = { 3, 0, /* FrontPen, BackPen */ JAM2, /* DrawMode */ -88, 0, /* LeftEdge, TopEdge */ &TxtAt_Plain, /* ITextFont Pointer */ (UBYTE *)"Home Path:", /* The IText */ NULL }; /********************************************************************** * String information for the homepath string gadget. **********************************************************************/ UBYTE homepath_sbuf_1[81] = "DH0:"; UBYTE homepath_ubuf_1[81]; struct StringInfo homepath_txstr_1 = { homepath_sbuf_1, /* Buffer */ homepath_ubuf_1, /* UndoBuffer */ 0, 80, 0, /* BufferPos, MaxChars, DispPos */ 0, 4, /* UndoPos, NumChars */ 0, 0, 0, /* DispCount, CLeft, CTop */ 0x0, 0, /* LayerPtr, LongInt */ 0x0 /* AltKeyMap */ }; /********************************************************************** * Gadget Structure definition for the homepath gadget. **********************************************************************/ struct Gadget homepathgad = { NULL, /* NextGadget pointer */ 144, 24, /* LeftEdge, TopEdge */ 100, 9, /* Width, Height */ GADGHCOMP, /* Gadget Flags */ GADGIMMEDIATE | RELVERIFY, /* Activation Flags */ PATHGADTYPE, /* GadgetType */ NULL, /* GadgetRender */ NULL, /* SelectRender */ &homepath_Text_0, /* GadgetText */ 0x0, /* MutualExclude */ (APTR)&homepath_txstr_1, /* SpecialInfo */ HOMEPATHGAD, /* GadgetID */ NULL /* UserData Pointer */ }; struct Requester *pathrequest; struct Window *pathwindow; /* Initialize the pathname requester. */ int InitPathRequest() { int status = 0; if (pathwindow = OpenWindow(&pathreqnw)) { /* I used AddGList here - got a crash. Problems with fullword * alignment, maybe? */ AddGadget(pathwindow, homepathgad, -1L); AddGadget(pathwindow, backpathgad, -1L); AddGadget(pathwindow, listpathgad, -1L); AddGadget(pathwindow, excludepathgad, -1L); } else { status = IoErr(); TypeAndSpeak("I couldn't open the pathname window!\n"); } return status; } /* Shut down the pathname requester mechanisms. */ CancelPathRequest() { if (pathwindow) CloseWindow(pathwindow); } ***EOF PathRequest.c*** echo "Creating Restore.c" cat > Restore.c <<"***EOF Restore.c***" /* Filename: restore.c * Author: Mark R. Rinfret * Date: 08/02/87 * Description: Restore processing module for MRBackup * * History: (most recent change first) * * 09/19/87 -MRR- Added NewHomeDir() which creates subdirectories as * necessary when the initial backup path specifies a * subdirectory. */ #include "MRBackup.h" #ifdef DEBUG extern char debugmsg[]; #endif static char fullbackpath[256], fullhomepath[256]; static unsigned home_is_device; /* true => home is "DH<N>:" */ /* Create a new directory on the home device. * Called with: * name: directory pathname * Returns: * false => success * true => failure */ int NewHomeDir(name) char *name; { char c; struct Lock *dirlock; int dirleng; int errnum; char dirname[256]; int nameindx = 0, nameleng; *dirname = '\0'; dirleng = 0; nameleng = strlen(name); /* Parse the pathname, one directory node at a time, creating * directories as needed. */ while (nameindx < nameleng) { if (nameindx) /* 2nd - nth pass? */ dirname[dirleng++] = '/'; /* directory separator */ while ((c = name[nameindx++]) && c != '/') dirname[dirleng++] = c; dirname[dirleng] = '\0'; /* terminate with null */ if (dirlock = Lock(dirname,SHARED_LOCK)) /* subdir exists? */ UnLock(dirlock); else { /* create subdirectory */ if ((dirlock = CreateDir(dirname))== NULL){ if ((errnum = IoErr())== ERROR_DIRECTORY_NOT_EMPTY){ sprintf(conmsg, "Directory %s already exists!\n",dirname); TypeAndSpeak(conmsg); } else { sprintf(conmsg, "ERROR %d: Unable to create directory %s\n", errnum,dirname); TypeAndSpeak(conmsg); return errnum; } } else UnLock(dirlock); } } /* endwhile */ return 0; } /* Restore files from floppy disk. */ int Restore() { int status = 0; Speak("And away we go!"); if (!IsDir(backpath)) { TypeAndSpeak("Backup path must be a device or directory name!\n"); return ERR_ABORT; } BreakPath(backpath, srcvol, srcpath); home_is_device = (homepath[strlen(homepath)-1] == ':'); status = RestoreFile(srcpath); if (status == 0) { TypeAndSpeak("Your restoration project is completed, sire.\n"); } else { sprintf(conmsg,"Restore terminated with status %d.\n",status); TypeAndSpeak(conmsg); TypeAndSpeak( "Perhaps you should check things out and try it again.\n"); } return status; } /* Restore all the files in a directory. * Called with: * lock: lock on the directory * fib: pointer to file info block * path: directory pathname (without volume) * Returns: * status (0 => success) */ int RestoreDir(lock, fib, path) struct Lock *lock; struct FileInfoBlock *fib; char *path; { struct Lock *dirlock = NULL, *filelock = NULL; char newpath[256]; int status = 0; strcpy(temp, homepath); if (*path) { if (!home_is_device) strcat(temp, "/"); strcat(temp, path); } #ifdef DEBUG sprintf(debugmsg,"Checking for directory %s\n",temp); DebugWrite(debugmsg); #endif if (!(dirlock = Lock(temp, SHARED_LOCK))) { if ((status = IoErr()) == ERROR_OBJECT_NOT_FOUND) { #ifdef DEBUG sprintf(debugmsg,"Creating directory %s\n",temp); DebugWrite(debugmsg); #endif if (status = NewHomeDir(temp)) return status; } else { sprintf(conmsg,"RestoreDir cannot lock %s: %d\n",temp, status); TypeAndSpeak(conmsg); return status; } } if (dirlock) UnLock(dirlock); while (ExNext(lock,fib)) { strcpy(newpath, path); if (*newpath) strcat(newpath, "/"); strcat(newpath, fib->fib_FileName); if (status = RestoreFile(newpath)) { /* filter out "permissable:" errors */ if (status == ERROR_OBJECT_IN_USE || status == ERROR_WRITE_PROTECTED) status = 0; else break; } } done: return status; } /* Restore one or more files according to the calling pathname. * The path argument does not contain the backup volume name. */ int RestoreFile(path) char *path; { struct FileInfoBlock *fib = NULL, *fib2 = NULL; UBYTE exists = FALSE, ignore = FALSE; struct Lock *lock = NULL; USHORT namelength; UBYTE savechar; int status = 0; if (status = CheckStop()) return status; if (!(fib = (struct FileInfoBlock *) AllocMem((long) sizeof (struct FileInfoBlock), MEMF_PUBLIC | MEMF_CHIP))) { TypeAndSpeak("RestoreFile could not allocate FIB!\n"); return ERROR_NO_FREE_STORE; } sprintf(fullbackpath, "%s:%s",srcvol,path); strcpy(fullhomepath, homepath); if (*path) { if (!home_is_device) strcat(fullhomepath, "/"); strcat(fullhomepath, path); } #ifdef DEBUG sprintf(conmsg,"fullbackpath = %s\n",fullbackpath); DebugWrite(conmsg); sprintf(conmsg,"fullhomepath = %s\n",fullhomepath); DebugWrite(conmsg); #endif if (!(lock = Lock(fullbackpath, SHARED_LOCK))) { status = IoErr(); sprintf(conmsg, "RestoreFile: can't lock %s: %d\n", fullbackpath, status); TypeAndSpeak(conmsg); goto done; } if (!Examine(lock, fib)) { status = IoErr(); sprintf(conmsg, "RestoreFile can't examine %s: %d\n", fullbackpath, status); TypeAndSpeak(conmsg); goto done; } if (fib->fib_DirEntryType > 0) { /* path is a directory */ status = RestoreDir(lock, fib, path); UnLock(lock); lock = NULL; } else { UnLock(lock); lock = NULL; /*#define NOCOPY*/ #ifndef NOCOPY /* If this file exists, then check its modification date. If * it's newer than the backup, don't replace it. */ if ((lock = Lock(fullhomepath, SHARED_LOCK))) { if (!(fib2 = (struct FileInfoBlock *) AllocMem((long) sizeof (struct FileInfoBlock), MEMF_PUBLIC | MEMF_CHIP))) { TypeAndSpeak("RestoreFile could not allocate FIB!\n"); status = ERROR_NO_FREE_STORE; goto done; } Examine(lock, fib2); UnLock(lock); lock = NULL; if (CompareDS(&fib2->fib_Date, &fib->fib_Date) >= 0) ignore = TRUE; } if (ignore) { sprintf(conmsg,"Skipping %s. Current version is newer.\n", path); TypeAndSpeak(conmsg); } else { if (!do_compress || !IsCompressed(fullhomepath)) { copyfile: sprintf(conmsg,"Copying %s\n", fullbackpath); WriteConsole(conmsg); status = CopyFile(fullbackpath, fullhomepath); } else { /* truncate the destination pathname (remove ".z") */ namelength = strlen(fullhomepath); fullhomepath[namelength-2] = '\0'; sprintf(conmsg, "Decompressing %s\n", fullbackpath); WriteConsole(conmsg); if (status = decompress(fullbackpath, fullhomepath)) { sprintf(conmsg, "Decompression of %s failed; status is %d.\n", fullbackpath, status); TypeAndSpeak(conmsg); TypeAndSpeak("I will try to copy the file, instead.\n"); /* restore ".z" to name */ fullhomepath[namelength-2] = '.'; goto copyfile; } CopyFileDate(fullbackpath, fullhomepath); } } #endif } done: if (lock) UnLock(lock); if (fib) FreeMem(fib, (long) sizeof(struct FileInfoBlock)); if (fib2) FreeMem(fib2, (long) sizeof(struct FileInfoBlock)); return status; } ***EOF Restore.c*** echo "Creating UserPrefs.c" cat > UserPrefs.c <<"***EOF UserPrefs.c***" /* MRBackup user preferences processing. * Filename: UserPrefs.c * Date: 08/23/87 */ #include "MRBackup.h" char *fgets(); extern struct Gadget backpathgad; extern struct Gadget excludepathgad; extern struct Gadget homepathgad; extern struct Gadget listpathgad; extern struct Requester *pathrequest; extern struct Window *pathwindow; #define KEYMAX 20 /* max length of a keyword */ #define NKEYWORD 7 /* number of keywords supported */ #define PREFERENCES_FILE "S:MRBackup.init" #define KW_HOME 0 #define KW_BACKUP 1 #define KW_LIST 2 #define KW_EXCLUDE 3 #define KW_COMPRESSION 4 #define KW_LISTING 5 #define KW_SPEECH 6 static char *keywords[NKEYWORD] = { "home", "backup", "list", "exclude", "compression", "listing", "speech" }; /* Process the user preferences file. */ GetUserPrefs() { char c; USHORT i; char keyword[KEYMAX+1]; short keyindex; USHORT keyleng; FILE *prefs; char s[81]; char *s1, *s2, *s3; if (!(prefs = fopen(PREFERENCES_FILE,"r"))) { WriteConsole("I couldn't get your preferences.\n"); return; } while (fgets(s, 80, prefs)) { if (*s == '#') continue; WriteConsole(s); s1 = s; keyleng = 0; while ((c = *s1++) && isalpha(c)) { if (keyleng < KEYMAX) keyword[keyleng++] = tolower(c); else { badkey: WriteConsole("Keyword error in preferences file.\n"); err: goto done; } } keyword[keyleng] = '\0'; for (keyindex = -1, i = 0; i < NKEYWORD; ++i) { if (!strcmp(keyword, keywords[i])) { keyindex = i; /* found it */ break; } } if (keyindex < 0) goto badkey; while (c == ' ') c = *s1++; if (c != '=') { badsyn: WriteConsole("Syntax error in preferences file.\n"); goto done; } /* Get the parameter field, minus any leading or trailing * blanks. */ while ((c = *s1) == ' ') ++s1; /* skip leading blanks */ /* Delete trailing blanks. */ s2 = s3 = s1; while (c && c != '\n') { if (c != ' ') s2 = s3; /* record non-blank end of string */ c = *s3++; } *s2 = '\0'; /* truncate the string here */ SetUserPref(keyindex, s1); } done: fclose(prefs); } /* Save the current program settings in the user preferences file. */ PutUserPrefs() { WriteConsole("PutUserPrefs() is not implemented\n"); } /* Set/Clear checkmarks according to the item being set. This routine * is VERY application specific and assumes that the affected menu * items are * 1. grouped in pairs (on/off) * 2. adjacent (item, item+1) * 3. ordered in on, off order (Listing, No Listing) */ BOOL SetMenuItem(item, value) USHORT item; char *value; { BOOL boolean; LONG excludebits, excludemask; LONG menu1, menu2; struct MenuItem *item1, *item2; short i; /* Get pointers and menu numbers for the affected items. */ menu1 = SHIFTITEM((long) item) | SHIFTMENU((long) MENU_FLAGS); item1 = ItemAddress(&Titles[0], menu1); menu2 = SHIFTITEM((long) item + 1) | SHIFTMENU((long) MENU_FLAGS); item2 = ItemAddress(&Titles[0], menu2); if (item1 == NULL || item2 == NULL) { WriteConsole("Null menu item in SetMenuItem - call Mark!!\n"); return false; } boolean = ( tolower(*value) == 'y' ); if (boolean) { /* true? */ item1->Flags |= CHECKED; item2->Flags &= ~CHECKED; } else { /* false */ item1->Flags &= ~CHECKED; item2->Flags |= CHECKED; } return boolean; } void SetStringGadget(gadget, value) struct Gadget *gadget; char *value; { UBYTE *gs; /* pointer to gadget string */ RemoveGadget(pathwindow, gadget); gs = (UBYTE *) GadgetString(gadget); strcpy(gs, value); ResetStringInfo(gadget->SpecialInfo); AddGadget(pathwindow, gadget, -1L); DoGadget(pathwindow, GADGETUP, gadget); /* simulate GADGETUP */ } /* Set one user preference item. * Called with: * kw: keyword index * parm: parameter string */ SetUserPref(kw, parm) USHORT kw; char *parm; { switch (kw) { case KW_HOME: SetStringGadget(&homepathgad, parm); break; case KW_BACKUP: SetStringGadget(&backpathgad, parm); break; case KW_LIST: SetStringGadget(&listpathgad, parm); break; case KW_LISTING: do_listing = SetMenuItem(ITEM_LIST, parm); break; case KW_EXCLUDE: SetStringGadget(&excludepathgad, parm); break; case KW_COMPRESSION: do_compress = SetMenuItem(ITEM_COMPRESS, parm); break; case KW_SPEECH: do_speech = SetMenuItem(ITEM_SPEECH, parm); break; default: break; } } ***EOF UserPrefs.c*** -- < Mark R. Rinfret, mrr@softie, ..rayssd!unisec!softie!mrr > < SofTech, Inc. Home: 401-846-7639 > < 1 Silva Lane, Work: 401-849-4174 > < Middletown, RI 02840 "The name has changed but I'm still guilty." >