home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / zoo141_c.lzh / GENERIC.C < prev    next >
C/C++ Source or Header  |  1987-02-07  |  3KB  |  126 lines

  1. /* Generic template for machine-dependent functions. */
  2.  
  3. /****************
  4. function trunc() truncates a file.
  5. */
  6.  
  7. int trunc (handle)
  8. int handle;
  9. {
  10.    /* code to truncate file goes here -- may be left empty */
  11. }
  12.  
  13. /*****************
  14. Function gettime() or getutime() gets the date and time of the file handle 
  15. or filename supplied.  Date and time is in MSDOS format.
  16. */
  17. #ifdef GETUTIME
  18. getutime (fname, date, time)
  19. char *fname;
  20. #else
  21. gettime (handle,date,time)
  22. int handle;
  23. #endif
  24. int *date, *time;
  25. {
  26.    *date = *time = 0; /* not yet implemented */
  27. }
  28.  
  29. /*****************
  30. Function settime() or setutime() sets the date and time of the file handle
  31. or filename supplied.  Date and time is in MSDOS format.
  32. */
  33. #ifdef NIXTIME
  34. int setutime(path,date,time)
  35. char *path;
  36. #else
  37. int settime(handle, date, time)
  38. int handle;
  39. #endif
  40. unsigned int date, time;
  41. {
  42.    /* not yet implemented */
  43. }
  44.  
  45. /*****************
  46. Function mktemp() accepts a template of the form `baseXXXXXX' where
  47. base is an arbitrary string, and returns a unique temporary filename.
  48. If template is not correct, it is returned unchanged.
  49. */
  50. char *mktemp(template)
  51. char *template;
  52. {
  53.  
  54. #ifndef NDEBUG
  55.    if (index(template, "XXXXXX") == -1)
  56.       prterror ('w', "Incorrect template [%s] supplied to mktemp().\n",
  57.          template);
  58. #endif
  59.  
  60.    strcpy(&template[index(template, "XXXXXX")],"{zoo}.@@@");
  61.    return (template);
  62. }
  63.  
  64. /*****************
  65. Function isadir() or isuadir() returns 1 if supplied handle or 
  66. filename is a directory or other special file that should not be 
  67. archived, else it returns 0.
  68. */
  69.  
  70. #ifdef CHEKDIR
  71. int isadir(han)
  72. int han;
  73. {
  74.    return (0); /* by default assume never a directory */
  75. }
  76. #endif
  77.  
  78. #ifdef CHEKUDIR
  79. int isuadir(path)
  80. char *path;
  81. {
  82.    return (0); /* by default assume never a directory */
  83. }
  84. #endif
  85.  
  86. /****************
  87. Function fixfname() converts the supplied filename to a syntax
  88. legal for the host system.  It is used during extraction to make sure
  89. that a file can be extracted even if a badly-implemented archiver
  90. stored it with an illegal filename.
  91. */
  92.  
  93. char *fixfname(fname)
  94. char *fname;
  95. {
  96.    return (fname); /* default is no-op */
  97. }
  98.  
  99. /*****************
  100. Function nextfile() is effectively a no-op.  Any wildcard expansion 
  101. must have been done before Zoo receives the arguments.
  102. */
  103.  
  104. #define FMAX 1
  105. char *nextfile (what, filespec, fileset)
  106. int what;                        /* whether to initialize or match      */
  107. register char *filespec;         /* filespec to match if initializing   */
  108. register int fileset;            /* which set of files                  */
  109. {
  110.    static int first_time [FMAX+1];
  111.    static char saved_fspec [FMAX+1][PATHSIZE];  /* our own copy of filespec */
  112.  
  113.    if (what == 0) {
  114.       strcpy (saved_fspec[fileset], filespec);  /* save the filespec */
  115.       first_time[fileset] = 1;
  116.       return (NULL);
  117.    }
  118.  
  119.    if (first_time[fileset]) {
  120.       first_time[fileset] = 0;
  121.       return (saved_fspec[fileset]);
  122.    } else {
  123.       return (NULL);
  124.    }
  125. }
  126.