home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / fileutil / stuff2.arj / STUFF.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-21  |  3.1 KB  |  109 lines

  1. /*
  2. Stuff 2.0.
  3.  
  4. Checksum:  620608636 (verify with "brik")
  5.  
  6. (C) Copyright 1988 Rahul Dhesi.  Permission is granted to copy and
  7. distribute this file in modified or unmodified form, whether for
  8. noncommercial or commercial use, provided (a) this copyright notice
  9. is preserved, (b) no attempt is made to restrict redistribution of
  10. this file, and (c) this file is not distributed as part of any
  11. collection whose redistribution is restricted by a compilation
  12. copyright.
  13. */
  14.  
  15. /*
  16. All functions and common types are declared here
  17. */
  18.  
  19. void *malloc (unsigned size);
  20. void *emalloc (unsigned size);
  21. void exit (int);
  22. void givehelp(void);
  23. void doarg (char *pathname);
  24. void forceslash (char *pathname);
  25. char *findlast (char *str, char *component);
  26. char *strlwr (char *str);
  27. void memerr(void);
  28. void parseopt (char **argv, int *i, int argc, int negate);
  29. void bugreport(char *func);
  30. int matchstr (char *str, char *pat);
  31. void dumpopts (void);
  32. char *fptr(char *pathname);
  33. long mstonix (unsigned date, unsigned time);
  34. long systime(void);
  35. long filetime (char *fname);
  36. char *lastptr (char *str);
  37.  
  38. #define     PATHSIZE 100
  39. #define     FMTSIZE  200
  40. #define     STRCMP(r,op,s)    (strcmp(r,s) op 0)
  41. #define     MAX_OPTS    4000  /* max options */
  42.  
  43. /* For each option, we have a structure to hold its details */
  44. typedef enum { BIGGER, SAME, SMALLER } compare_pt; /* for + or - options */
  45. typedef enum 
  46.  {PRINT,NAME,SIZE,MTIME,MODIFIED,OLDER,NEWER,TYPE,FORMAT,NONE,LIMIT}
  47.  choice_pt;
  48.  
  49. compare_pt getcompare (char *str);
  50. long getvalue (char *str);
  51.  
  52. /* whether to negate the next option or not -- used by parseopt() */
  53. #define     NORMAL   0
  54. #define     NEGATE   1
  55.  
  56. #define     OPT_PRINT   "-print"
  57. #define     OPT_NAME "-name"
  58. #define     OPT_SIZE "-size"
  59. #define     OPT_MTIME   "-mtime"
  60. #define     OPT_MODIFIED   "-modified"
  61. #define     OPT_OLDER   "-older"
  62. #define     OPT_NEWER   "-newer"
  63. #define     OPT_TYPE "-type"
  64. #define     OPT_FORMAT  "-format"
  65. #define     OPT_LIMIT   "-limit"
  66. typedef int boolean;
  67. typedef char      name_pt[PATHSIZE];         /* just a filename */
  68. typedef struct { long value;  compare_pt choice; } size_pt;                         /* -size +n */
  69. typedef struct { long value;   compare_pt choice; } mtime_pt;                          /* -mtime +n */
  70. typedef struct {
  71.          boolean negate;
  72.          choice_pt choice;
  73.          union {
  74.             name_pt name;
  75.             size_pt size_info;
  76.             mtime_pt mtime_info;
  77.          } info;
  78.       } request_rec;
  79.  
  80. struct file_info {
  81.    long utime;
  82.    long size;
  83.    char attrib;
  84. };
  85.  
  86. void dopath (char *pathname, struct file_info *);
  87.  
  88. int cmptime (long utime, compare_pt choice, long value);
  89. int cmptime2 (long utime, compare_pt choice, long value);
  90. int cmpsize (long size, compare_pt choice, long value);
  91.  
  92. #if   !defined(NDEBUG)
  93. #define assert(p) if(!(p)){printf(\
  94.       "Assertion failed: file %s, line %d\n",\
  95.       __FILE__, __LINE__);exit(1);}
  96. #else
  97. #define assert(p)
  98. #endif
  99.  
  100. #ifdef DEBUG
  101. # define debug(x) do{x}until(1)
  102. #else
  103. # define debug(x)
  104. #endif
  105.  
  106. #ifndef NULL
  107. #define NULL   0
  108. #endif
  109.