home *** CD-ROM | disk | FTP | other *** search
- /*
- * idle.c - the idle process
- * This is somewhat of a misnomer, since idle() is responsible for
- * starting the ball rolling and stopping it later.
- */
-
- #include "RevRdist.h"
- #include "dispatch.h"
- #include <TransSkelProto.h>
- #include <TransDisplayProto.h>
-
-
-
- /*
- *=========================================================================
- * idle - the idle process.
- * this routine is the bottom routine on the dispatch stack and is
- * the one which starts things going and shuts them down.
- *=========================================================================
- */
-
- DISPATCHED (idle)
- {
- struct lm /* local memory */
- {
- frame_t f;
- dnode_t * dt; /* control file tree */
- };
- typedef struct lm lm_t;
- register lm_t * m; /* pointer to local memory */
- OSErr error;
- short result;
- Boolean injunk; /* for matchFolder call */
- Ptr paramv[5]; /* param list for pushCalls */
-
- error = 0;
- result = request;
- m = *(lm_t **)fh;
- switch (request)
- {
- case R_INIT:
- /*
- * Initial call. Just extend frame by needed local memory.
- */
- if (error = resizeFrame (fh, sizeof (lm_t)))
- break;
- m = *(lm_t **)fh;
- m->f.state = 1;
- result = R_CONT;
- break;
-
- case R_CONT:
- /*
- * Continue call. Advance from phase to phase of processing on the
- * control file.
- */
- if (Quit && (Flags & DB_STARTUP) == 0)
- {
- /*
- * Possibly save preference file before quitting
- */
- if (PrefDialog)
- prefDoFMenu (FILE_CLOSE);
- }
- if (Quit)
- if (m->f.state == 1)
- return R_QUIT;
- else
- return R_BACKOUT;
- switch (m->f.state)
- {
- /*
- * Normal state when waiting for user to decide what to do.
- * I.e. to open a control file.
- */
- case 1:
- if (Pending == PA_NULL)
- {
- /*
- * Nothing requested, possibly update status display,
- * but otherwise, do nothing.
- */
- if (Pause != S_IDLE)
- {
- Pause = S_IDLE;
- setStat ();
- }
- }
- if (Pending == PA_PREF)
- {
- Pending = PA_NULL;
- doPref ();
- }
- if (Pending != PA_GO)
- break;
-
- /*
- * Check if everything set up, then go to it!
- * Start by parsing the configured distribution control file
- */
- Pending = PA_NULL;
- if (error = getSet ())
- {
- error = 0;
- Quit = false;
- Pending = PA_PREF;
- break;
- }
- if (Quit)
- break;
- Depth = 0;
- m->f.state = 2;
- Watch = GetCursor (watchCursor);
- Pause = S_RUNNING;
- setStat ();
- result = pushCall (parseDistFile, nil);
- break;
-
- case 2:
- /*
- * Check result of parseDistFile
- */
- if (argv == nil || argv[0] == nil)
- {
- if (ClueID > 0)
- panic (false, ClueID, nil);
- else
- panic (false, E_SYS, nil);
- return R_BACKOUT; /* failed */
- }
- m->dt = (dnode_t *) argv[0];
- m->f.state = 3;
- break;
-
- case 3:
- /*
- * Control file parsed okay. Empty the Junk folder in preparation
- * for moving other files there.
- */
- m->f.state = 4;
- result = pushCall (cleanJunk, nil);
- break;
-
- case 4:
- m->f.state = 5;
- break;
-
- case 5:
- /*
- * Set up to match the root folder against the master
- */
- statMsg ((SP)"\p"); /* clear status */
- injunk = false;
- paramv[0] = (Ptr) m->dt;
- paramv[1] = (Ptr) &m->dt->childp->actions;
- paramv[2] = (Ptr) &ServerRoot;
- paramv[3] = (Ptr) &ClientRoot;
- paramv[4] = (Ptr) &injunk;
- m->f.state = 6;
- result = pushCall (matchFolder, paramv);
- break;
-
- case 6:
- updateRoot (m->dt);
- verifyBlessed ();
- result = R_BACKOUT;
- break;
- }
- /*
- * End of R_CONT state switch
- */
- if (error)
- {
- if (error < 0)
- {
- ClueID = error;
- error = E_SYS;
- }
- panic (false, error, nil);
- result = R_BACKOUT;
- }
- break;
-
- case R_BACKOUT:
- if (Flags & DB_STARTUP)
- {
- result = R_QUIT;
- break;
- }
- /*
- * When we back out to the idle level, wait for something to do
- */
- notice (L_DONE, nil);
- SysBeep (1);
- SysBeep (1);
- result = R_CONT;
- if (ErrorMsgs)
- doWindowMenu (WIND_ERRORS);
- ErrorMsgs = 0;
- if (SizeResource ((Handle)fh) >= sizeof (lm_t) && m->f.state > 2)
- {
- freeDist (m->dt);
- }
- Quit = false;
- m->f.state = 1;
- break;
-
- case R_QUIT:
- Quit = true;
- SkelWhoa ();
- SkelBackground (nil);
- break;
- }
- return result;
- }