home *** CD-ROM | disk | FTP | other *** search
- /*
- * RevRdist.c - the main routines for RevRdist
- *
- * RevRdist is intended to be similar in utility to the BSD Unix program
- * "rdist".
- * That is, it uses a file of distribution rules ("distfile") to keep
- * the files and folders on client volumes synchronized with those on a
- * server volume.
- * That is about the end of the similarity.
- * RevRdist runs on the client systems, which are assumed to be the
- * student/worker Mac workstations in an AppleShare network.
- * The server volume is assumed to reside on an AppleShare server.
- * RevRdist itself should be in the System Folder of each client, as should
- * its settings file "RevRdist prefs".
- * The prefs file gives the location of the control file, which can be on the
- * client or server.
- * RevRdist normally runs only at reboot time. It contains an INIT which
- * checks the prefs file to see if it is time to run the full RevRdist.
- * If so, RevRdist is temporarily made the startup application.
- * RevRdist can also be run at any time just by launching it as an ordinary
- * application.
- */
-
- #include "RevRdist.h"
- #include <TransSkelProto.h>
- #include <TransDisplayProto.h>
- #include "dispatch.h"
-
- Boolean checkAbort (EventRecord *);
- void doAbout (void);
- void doEditMenu (Integer);
- void doFileMenu (Integer);
- void main (void);
-
-
- /*
- *=========================================================================
- * checkAbort (e) - check event for <command>-. and set quit flag if needed
- *=========================================================================
- */
-
- static
- Boolean
- checkAbort (theEvent)
- EventRecord *theEvent;
- {
- if ( theEvent->what == keyDown
- && (theEvent->message & 0xff) == '.'
- && (theEvent->modifiers & cmdKey)
- )
- {
- Quit = true;
- return true;
- }
- return false;
- }
-
-
-
- /*
- *=========================================================================
- * doAbout () - handle About box (using TextDialog routine from net)
- *=========================================================================
- */
-
- static
- void
- doAbout ()
- {
- Handle theText;
-
- theText = GetResource (TYPE_TEXT, RSRC_ABOUT);
- if (theText)
- {
- HLock (theText);
- TextDialog (WIND_ABOUT + RSRC_BASE, theText, 1, 9, true);
- HUnlock (theText);
- ReleaseResource (theText);
- }
- }
-
-
-
- /*
- *=========================================================================
- * doEditMenu (item) - handle selection from the Edit menu
- * entry: item = selected item number
- *=========================================================================
- */
- static
- void
- doEditMenu (item)
- Integer item;
- {
- DialogPtr w;
-
- w = (DialogPtr) FrontWindow ();
- if (w)
- {
- if (w == (DialogPtr) PrefDialog)
- {
- switch (item)
- {
- case EDT_CUT: DlgCut (w); break;
- case EDT_COPY: DlgCopy (w); break;
- case EDT_PASTE: DlgPaste (w); break;
- case EDT_CLEAR: DlgDelete (w); break;
- }
- }
- }
- }
-
-
-
- /*
- *=========================================================================
- * doFileMenu (item) - handle selection from the File menu
- * entry: item = selected item number
- *=========================================================================
- */
- static
- void
- doFileMenu (item)
- Integer item;
- {
- WindowPtr w;
-
- switch (item)
- {
- case FILE_OPEN:
- case FILE_SAVE:
- case FILE_SAVEAS:
- w = FrontWindow ();
- if (w && w == PrefDialog)
- prefDoFMenu (item);
- break;
- case FILE_QUIT:
- Quit = true;
- if (Pause == S_PAUSED)
- Pause = S_RUNNING;
- break;
- }
- }
-
-
-
- /*
- *=========================================================================
- * doWindowMenu (item) - handle selection from window menu
- * entry: item = menu selection number
- *=========================================================================
- */
-
- void
- doWindowMenu (item)
- Integer item;
- {
- WindowPtr w;
-
- switch (item)
- {
- case WIND_STATUS: w = StatusDialog; break;
- case WIND_ACTIVITY: w = ActivityWind; break;
- case WIND_ERRORS: w = ErrorWind; break;
- case WIND_PREF: w = PrefDialog;
- Pending = PA_PREF; break;
- default: w = nil;
- }
- if (w)
- {
- SelectWindow (w);
- ShowWindow (w);
- }
- }
-
-
-
-
- /*
- *=========================================================================
- * main () - Set things up and turn control over to SkelMain ()
- *=========================================================================
- */
-
-
- static unsigned char nullstr[1] = { 0 };
- void
- main ()
- {
- Handle h;
- MenuHandle m;
- short result;
- Str255 s;
-
- NullStr = nullstr;
- SkelInit (6, nil); /* initialize */
- /*
- * Set up our menus: Apple, File, Edit (inactive), and Windows
- */
- m = GetMenu (1); /* Apple */
- if (!m)
- goto abandon;
- GetItem (m, 1, s); /* About... text */
- SkelApple (s, doAbout); /* handle desk accessories */
-
- m = GetMenu (2); /* File */
- if (!m)
- goto abandon;
- if (!SkelMenu (m, doFileMenu, nil, false))
- goto abandon;
- DisableItem (m, FILE_OPEN);
- DisableItem (m, FILE_SAVE);
- DisableItem (m, FILE_SAVEAS);
-
- m = GetMenu (3); /* Edit */
- if (!m)
- goto abandon;
- if (!SkelMenu (m, doEditMenu, nil, false))
- goto abandon;
- DisableItem (m, 0); /* disable it */
-
- m = GetMenu (4); /* Window */
- if (!m)
- goto abandon;
- if (!SkelMenu (m, doWindowMenu, nil, false))
- goto abandon;
- DisableItem (m, 0); /* disable it for now */
- DrawMenuBar ();
-
- initGlobals ();
- if (!Quit) /* if initialized okay */
- {
- if (Flags & DB_LOCKED)
- DisableItem (m, WIND_PREF); /* if locked, can't do prefs */
- EnableItem (m, 0); /* Okay to enable Windows now */
- DrawMenuBar ();
-
- SkelEventHook (checkAbort);
- SkelBackground (dispatch);
-
- Pending = PA_PREF;
- if ((Flags & DB_STARTUP)
- || File_list[FL_PREF].f_launch
- || File_list[FL_DIST].f_launch)
- Pending = PA_GO;
-
- showstat ();
- result = pushCall (idle, nil);
- if (result == R_CONT)
- SkelMain ();
- }
- abandon:
- SkelClobber (); /* clean up */
- tidyUp (); /* more clean up */
- if (Flags & DB_STARTUP) /* if boot application, reboot */
- ShutDwnStart ();
- }