home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / zoo / part01 / generic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-16  |  3.0 KB  |  130 lines

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