home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / tarsrc30.sit / tar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-04  |  1.7 KB  |  94 lines

  1. /*
  2.  * Macintosh TAR
  3.  *
  4.  * Written by Craig Ruff
  5.  *
  6.  * Main routine and global variables.
  7.  */
  8.  
  9. #include "tar.h"
  10. #include <SegLoad.h>
  11. #include <GestaltEqu.h>
  12.  
  13. /*
  14.  * Global variable declarations
  15.  */
  16. Boolean doneFlag = false;    /* Quit item selected? */
  17. Boolean ignorez = false;    /* Ignore zero blocks */
  18. Boolean    pOpen = false;        /* Printer open? */
  19. Boolean reblock = false;    /* Read enough for a full block size buffer */
  20.  
  21. THPrint    prRecHdl;        /* Printer record (when printing) */
  22.  
  23. char    header[128];        /* Common header for listings */
  24.  
  25. main() {
  26.     WindowPtr    wind;
  27.     EventRecord    e;
  28.     long        response;
  29.  
  30.     /*
  31.      * Standard Mac Initializations
  32.      */
  33.     InitGraf(&qd.thePort);
  34.     InitFonts();
  35.     FlushEvents(everyEvent, 0);
  36.     InitWindows();
  37.     InitMenus();
  38.     TEInit();
  39.     InitDialogs(nil);
  40.     InitCursor();
  41.  
  42.     if (
  43.         (Gestalt(gestaltSystemVersion, &response) != noErr) ||
  44.         ((response & 0xffff) < 0x0605)
  45.     ) {
  46.         VersionAlert();
  47.         ExitToShell();
  48.     }
  49.  
  50.     GetPreferences();
  51.     if (MenuInit())
  52.         ExitToShell();
  53.  
  54.     if ((prRecHdl = (THPrint) NewHandle(sizeof(TPrint))) == nil) {
  55.         OSAlert("\pmain", "\pNewHandle returned nil", nil, MemError());
  56.         ExitToShell();
  57.     }
  58.  
  59.     sprintf(header, "T     Size Date              Name%*s", 40, "");
  60.     do {
  61.         /* Should never have a window open while a DA is running */
  62.         if (!menusOK && (FrontWindow() == nil))
  63.             DDaMenus();
  64.  
  65.         if (WaitNextEvent(everyEvent, &e, 20L, nil))
  66.             switch (e.what) {
  67.             case mouseDown:
  68.                 switch (FindWindow(e.where, &wind)) {
  69.                 case inSysWindow:
  70.                     SystemClick(&e, wind);
  71.                     break;
  72.  
  73.                 case inMenuBar:
  74.                     MenuCmd(MenuSelect(e.where));
  75.                     break;
  76.  
  77.                 }
  78.                 break;
  79.  
  80.             case keyDown:
  81.             case autoKey:
  82.                 if (e.modifiers & cmdKey)
  83.                     MenuCmd(MenuKey(e.message & charCodeMask));
  84.                 break;
  85.             }
  86.  
  87.     } while (!doneFlag);
  88.  
  89.     if (pOpen)
  90.         PrClose();
  91.  
  92.     ExitToShell();
  93. }
  94.