home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / comm / revrdist.sit / RevRdist / headers / RevRdist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-26  |  10.7 KB  |  341 lines  |  [TEXT/KAHL]

  1. /*
  2.  * RevRdist.h - #defines and declarations needed for most of the
  3.  * other files making up RevRdist
  4.  */
  5.  
  6. #include <HFS.h>
  7. #include <C_config.h>
  8.  
  9. typedef    StringPtr        SP;
  10.  
  11. #define    ROOTDIRID        2L            /* DirID of Mac root folder */
  12.  
  13. /*
  14.  * e_action - the list of possible actions to apply to a file/folder
  15.  *        note: order is important
  16.  */
  17.  
  18. enum e_action
  19. {
  20.      A_DEFAULT = 0                    /* not specified */
  21.     ,A_PASS                            /* ignore this criterion */
  22.     ,A_IGNORE                        /* leave alone */
  23.     ,A_JUNK                            /* move to "junk" folder */
  24.     ,A_DISCARD                        /* remove permanently */
  25.     ,A_UPDATE                        /* copy from server */
  26. };
  27. typedef enum e_action action_t;
  28.  
  29. /*
  30.  * e_ctype - the types of cat_nodes
  31.  */
  32. enum e_ctype
  33. {
  34.      C_FOLDER                        /* node represents folder */
  35.     ,C_FILE                            /* node represents file */
  36. };
  37. typedef enum e_ctype ctype_t;
  38.  
  39. /*
  40.  * e_dtype - the types of dist_nodes
  41.  */
  42.  
  43. enum e_dtype
  44. {
  45.      D_FOLDER                        /* node represents a folder */
  46.     ,D_FILE                            /* node represents a file */
  47.     ,D_FOLDERDEF                    /* node holds folder defaults */
  48. };
  49. typedef enum e_dtype dtype_t;
  50.  
  51. /*
  52.  * actions - list of actions to apply under given conditions
  53.  */
  54.  
  55. struct actions
  56. {
  57.     action_t    ifclient;            /* C if on client but not server */
  58.     action_t    ifserver;            /* S if on server but not client */
  59.     action_t    ifcreate;            /* V if server copy has different creation date */
  60.     action_t    ifnewer;            /* N if server copy is newer */
  61.     action_t    ifolder;            /* O if server copy is older */
  62.     action_t    ifsize;                /* Z if server copy is different size */
  63.     action_t    otherwise;            /* E if none of the above apply */
  64.     action_t    copywindow;            /* W set client window posn from server*/
  65.     action_t    invisible;            /* H set client object invisible */
  66.     action_t    locked;                /* L set client object locked */
  67. };
  68. typedef struct actions    actions_t;
  69.  
  70. /*
  71.  * dist_node - the structure of an entry read from the control file.
  72.  * These are linked into a tree which mimics the significant subset
  73.  * of the folder structure on the client disk.
  74.  */
  75.  
  76. struct    dist_node
  77. {
  78.     struct dist_node *    sibp;        /* sibling node */
  79.     struct dist_node *    childp;        /* child node */
  80.     struct dist_node *    parentp;    /* parent node */
  81.     struct type_node *    tlistp;        /* start of file type list */
  82.     StringPtr            altname;    /* name on server (when different) */
  83.     struct actions        actions;    /* condition/action list for node */
  84.     dtype_t                d_type;        /* type of node */
  85.     unsigned char        name[32];    /* component of path name */
  86. };
  87. typedef struct dist_node dnode_t;
  88.  
  89. /*
  90.  * type_node - a list of file types/creators also read from the
  91.  * control file.  Used to select files by type/creator instead of name.
  92.  * These are linked into a tree in which the leaves and intermediate
  93.  * nodes point back toward the root.  The tlistp pointer in a directory
  94.  * dist_node gives the start of a type_node chain which applies to files
  95.  * in that directory.
  96.  */
  97.  
  98. struct    type_node
  99. {
  100.     struct type_node *    morep;        /* upward link */
  101.     OsType                ftype;        /* file type */
  102.     OsType                fcreator;    /* file creator */
  103.     struct actions        actions;    /* actions to apply if file type/
  104.                                      *  creator match above */
  105. };
  106. typedef struct type_node    tnode_t;
  107.  
  108. /*
  109.  * cat_node - the structure for saving information from GetCatInfo
  110.  */
  111.  
  112. struct    cat_node
  113. {
  114.     struct cat_node *    link;        /* next file/folder in list */
  115.     Longint                dirID;        /* file/folder directory id */
  116.     Longint                parID;        /* dirID of containing folder */
  117.     unsigned long        crDate;        /* (file) creation date */
  118.     unsigned long        mdDate;        /* (file) modification date */
  119.     union
  120.     {
  121.         struct
  122.         {
  123.             FInfo        finfo;        /* (file) Finder info */
  124.             Longint        fileLen;    /* (file) data fork length */
  125.             Longint        rsrcLen;    /* (file) resource fork length */
  126.         } f;
  127.         struct
  128.         {
  129.             DInfo        dinfo;        /* (folder) Finder info */
  130.             Point        frScroll;    /* (folder) scroll posn */
  131.             Longint        frOChain;    /* (folder) open chain */
  132.         } d;
  133.     } in;
  134.     Byte                attrib;        /* file/folder attribute byte */
  135.     Byte                access;        /* (AppleShare) access rights */
  136.     ctype_t                ctype;        /* file/folder */
  137.     unsigned char        name[32];    /* the component name */
  138. };
  139. typedef struct cat_node cnode_t;
  140.  
  141. #include "junkp.h"
  142.  
  143. /*
  144.  * e_psind - index into preferences string array
  145.  */
  146. enum e_psind
  147. {
  148.      PS_ZONE                        /* name of AppleShare server zone */
  149.     ,PS_SRVR                        /* name of AppleShare server */
  150.     ,PS_USER                        /* user name on server */
  151.     ,PS_PASS                        /* user's password */
  152.     ,PS_DISTF                        /* path to distribution control file */
  153.     ,PS_MASTF                        /* full path to master folder */
  154.     ,PS_JUNKF                        /* name of junk folder */
  155.     ,PS_MAX                            /* count of number of strings */
  156.     ,PS_TIME                        /* boot-time run interval */
  157. };
  158. typedef enum e_psind psind_t;
  159. /* NOTE: any changes to the above must be reflected in the prefinfo
  160.  * structure in pref.c
  161.  */
  162.  
  163. /*
  164.  * prefs - Preferences information
  165.  */
  166.  
  167. struct prefs
  168. {
  169.     StringHandle    p[PS_MAX];        /* handles to preference strings */
  170.     unsigned long    p_interval;        /* running interval */
  171.     junkp_t            p_jparam;        /* junking parameters */
  172.     Boolean            p_modified;        /* values have changed */
  173. };
  174. typedef    struct prefs prefs_t;
  175.  
  176. /*
  177.  * e_pindex - index into preferences array
  178.  */
  179.  
  180. enum e_pindex
  181. {
  182.      P_WORK    = 0                        /* the preference values to use */
  183.     ,P_FILE                            /* preference values from pref file */
  184. };
  185. typedef    enum e_pindex pindex_t;
  186.  
  187. /*
  188.  * file_info - information about important files/folders
  189.  */
  190.  
  191. struct file_info
  192. {
  193.     StringHandle    f_path;            /* full path name of file/folder */
  194.     Integer            f_vol;            /* vRefNum giving vol for file */
  195.     Integer            f_ref;            /* refNum of file/working dir if open */
  196.     Boolean            f_launch;        /* true if supplied at launch */
  197.     Boolean            f_set;            /* true if list entry initialized */
  198.     cnode_t            f_info;            /* the bulk of the information */
  199. };
  200. typedef struct file_info file_info_t;
  201.  
  202. /*
  203.  * f_index - index of file info in file_info array
  204.  */
  205.  
  206. enum f_index
  207. {
  208.      FL_APPL                        /* the Application */
  209.     ,FL_PREF                        /* preference file */
  210.     ,FL_DIST                        /* dist control file */
  211.     ,FL_MAST                        /* master folder */
  212.     ,FL_JUNK                        /* junk folder */
  213.     ,FL_ROOT                        /* client root folder */
  214.     ,FL_TEMP                        /* temp file */
  215.     ,FL_MAX                            /* how many files */
  216. };
  217. typedef enum f_index findex_t;
  218.  
  219.  
  220. /*
  221.  * e_pending - Pending action to perform (values for Pending)
  222.  */
  223. enum e_pending
  224. {
  225.      PA_NULL = 0                    /* nothing pending */
  226.     ,PA_PREF                        /* invoke preferences dialog */
  227.     ,PA_GO                            /* (try to) go to it */
  228. };
  229. typedef enum e_pending pending_t;
  230.  
  231.  
  232. /*
  233.  * e_rstat - Running state
  234.  */
  235. enum e_rstat
  236. {
  237.      S_IDLE = 0                        /* idle, accepting commands */
  238.     ,S_RUNNING                        /* scanning & matching */
  239.     ,S_PAUSED                        /* paused while scanning */
  240. };
  241. typedef enum e_rstat rstat_t;
  242.  
  243. /*
  244.  * Useful macros
  245.  */
  246. #define COPYPS(s,d)    BlockMove (s, d, (Size)(((s)[0]) + 1))    /* copy pas. str */
  247. #define DISPLAY(s)    DisplayString ((StringPtr) s)
  248. #define    ZERO(s)        setmem ((char *)&(s), sizeof (s), 0)    /* zero struct */
  249. #define ZEROAT(s)    setmem ((char *)(s), sizeof (*(s)), 0)    /* zero *struct * */
  250. #define    fLocked        0x01            /* Finder locked flag */
  251.  
  252. /*
  253.  * Declarations for global variables
  254.  */
  255. extern WindowPtr        ActivityWind;    /* window for listing actions */
  256. extern AppFile            Ap_file;    /* our argument file */
  257. extern Integer            Ap_refNum;    /* file refNum of application */
  258. extern Str255            Ap_volName;    /* name of volume Ap is running from */
  259. extern Integer            BlessedWD;    /* current system folder */
  260. extern Longint            ClientRoot;    /* directory id of client root */
  261. extern unsigned long    ClientSp;    /* client volume space remaining */
  262. extern Integer            ClientVol;    /* client volume VRefNum */
  263. extern OSErr            ClueID;        /* error message STR# index */
  264. extern StringPtr        Clue0;        /* name of RevRdist routine detecting
  265.                                      * error */
  266. extern StringPtr        Clue1;        /* name of MacOS routine detecting
  267.                                      * error, or other error hint */
  268. extern StringPtr        Clue2, Clue3;    /* more hints */
  269. extern short            Depth;        /* folder depth */
  270. extern Integer            Deskrefnum;    /* refnum for Desktop file */
  271. extern short            ErrorMsgs;    /* count of messages in ErrorWind */
  272. extern WindowPtr        ErrorWind;    /* error message window */
  273. extern file_info_t *    File_list;    /* pointer to array of file info */
  274. extern long                Flags;        /* processing flags */
  275. #define    DB_ECHODIST        0x00000001    /* echo control file as read */
  276. #define DB_LISTONLY        0x00000002    /* list actions without doing them */
  277. #define DB_STARTUP        0x00000004    /* running as startup application */
  278. #define    DB_VERBOSE        0x00000008    /* list everything */
  279. #define    DB_LOCKED        0x00000010    /* disallow preference changes */
  280. #define    DB_DIALOG        0x00000020    /* bring up Debug dialog at start */
  281.  
  282. extern unsigned char    HighValue[];/* string lexically after any file name */
  283. extern Byte                Junksuf[1+8];/* suffix to handle junk name conflicts */
  284. extern Str255            Mbuf;        /* temp string, often used for msgs */
  285. extern StringPtr        NullStr;    /* constant empty string */
  286. extern rstat_t            Pause;        /* running state */
  287. extern pending_t        Pending;    /* pending action */
  288. extern DialogPtr        PrefDialog;    /* preferences dialog window */
  289. extern prefs_t            Prefs[];    /* preferences values */
  290. extern Boolean            Quit;        /* true if requested to quit */
  291. extern Longint            ServerRoot;    /* ioDirID of master folder on server */
  292. extern Integer            ServerVol;    /* vRefNum of server volume */
  293. extern DialogPtr        StatusDialog;    /* status window */
  294. extern StringHandle        Untitled;    /* anonymous document name */
  295. extern CursHandle        Watch;        /* "busy" cursor */
  296.  
  297. #include "rsrc.h"
  298. /*
  299.  * prototypes for cross-file RevRdist functions
  300.  */
  301. extern OSErr            createFolder (StringPtr, Integer, Longint, cnode_t *);
  302. extern OSErr            discard (cnode_t *, Boolean);
  303. extern void                dispIndStr (WindowPtr, Integer, ...);
  304. extern void                doPref (void);
  305. extern void                doWindowMenu (Integer);
  306. extern void                freeDist (dnode_t *);
  307. extern void                freeInfo (file_info_t *);
  308. extern void                freeList (cnode_t *);
  309. extern StringPtr        fullpath (StringPtr, Integer, Longint);
  310. extern OSErr            getInfo (StringPtr, Integer, Longint, cnode_t *);
  311. extern OSErr            getInfoByPath (StringPtr, file_info_t *);
  312. extern OSErr            getSet (void);
  313. extern void                initGlobals (void);
  314. extern cnode_t *        listFolder (Integer, Longint);
  315. extern OSErr            makeJunk (void);
  316. extern OSErr            moveToJunk (cnode_t *);
  317. extern void                notice (Integer, ...);
  318. extern void                panic (Boolean, Integer, ...);
  319. extern void                prefDoFMenu (Integer);
  320. extern OSErr            prefFetch (Integer);
  321. extern OSErr            prefFFetch (file_info_t *);
  322. extern void                prefMerge (pindex_t, Boolean);
  323. extern StringPtr        pstrcat (StringPtr dest, StringPtr src);
  324. extern StringPtr        pstrcat2 (StringPtr dest, StringPtr, StringPtr);
  325. extern OSErr            relock (cnode_t *);
  326. extern void                saveCatInfo (CInfoPBRec *, cnode_t *);
  327. extern void                setDebug (void);
  328. extern void                setmem (char *p, unsigned n, char c);
  329. extern void                setStat (void);
  330. extern void                statMsg (StringPtr);
  331. extern void                statMsgClr (void);
  332. extern void                showstat (void);
  333. extern void                TextDialog (int dlogNum, Handle textHandle,
  334.                             int fontNum, int fontSize, Boolean wrap);
  335. extern void                tidyUp (void);
  336. extern OSErr            unlock (cnode_t *);
  337. extern void                updateRoot (dnode_t *);
  338. extern void                verifyBlessed (void);
  339. extern void                warning (Integer, ...);
  340.  
  341. #include <MacProto.h>