home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -seriously_amiga- / archivers / arcppc / src / rcs / arccvt.c,v < prev    next >
Text File  |  1998-04-23  |  6KB  |  291 lines

  1. head     1.5;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    hyc:1.5; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.5
  10. date     88.06.01.19.17.40;  author hyc;  state Exp;
  11. branches ;
  12. next     1.4;
  13.  
  14. 1.4
  15. date     88.06.01.15.19.21;  author hyc;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.06.01.15.16.46;  author hyc;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.04.11.17.51.28;  author hyc;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.04.11.17.50.00;  author hyc;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 1.5
  40. log
  41. @Change compilation conditionals
  42. @
  43. text
  44. @/*
  45.  * $Header: arccvt.c,v 1.4 88/06/01 15:19:21 hyc Locked $
  46.  */
  47.  
  48. /*
  49.  * ARC - Archive utility - ARCCVT
  50.  * 
  51.  * Version 1.16, created on 02/03/86 at 22:53:02
  52.  * 
  53.  * (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  54.  * 
  55.  * By:  Thom Henderson
  56.  * 
  57.  * Description: This file contains the routines used to convert archives to use
  58.  * newer file storage methods.
  59.  * 
  60.  * Language: Computer Innovations Optimizing C86
  61.  */
  62. #include <stdio.h>
  63. #include "arc.h"
  64.  
  65. void    openarc(), rempath(), closearc(), abort(), pack(), writehdr(), filecopy();
  66. int    match(), readhdr(), unpack(), unlink();
  67.  
  68. static char     tempname[STRLEN];    /* temp file name */
  69.  
  70. void
  71. cvtarc(num, arg)        /* convert archive */
  72.     int             num;    /* number of arguments */
  73.     char           *arg[];    /* pointers to arguments */
  74. {
  75.     struct heads    hdr;    /* file header */
  76.     int             cvt;    /* true to convert current file */
  77.     int             did[MAXARG];/* true when argument was used */
  78.     int             n;    /* index */
  79.     char           *makefnam();    /* filename fixer */
  80.     FILE           *fopen();/* file opener */
  81.     void            cvtfile();
  82.  
  83.     if (arctemp)        /* use temp area if specified */
  84.         sprintf(tempname, "%s.CVT", arctemp);
  85.     else
  86.         makefnam("$ARCTEMP.CVT", arcname, tempname);
  87. #if    !DOS
  88.     image = 1;
  89. #endif
  90.  
  91.     openarc(1);        /* open archive for changes */
  92.  
  93.     for (n = 0; n < num; n++)    /* for each argument */
  94.         did[n] = 0;    /* reset usage flag */
  95.     rempath(num, arg);    /* strip off paths */
  96.  
  97.     if (num) {        /* if files were named */
  98.         while (readhdr(&hdr, arc)) {    /* while more files to check */
  99.             cvt = 0;/* reset convert flag */
  100.             for (n = 0; n < num; n++) {    /* for each template
  101.                              * given */
  102.                 if (match(hdr.name, arg[n])) {
  103.                     cvt = 1;    /* turn on convert flag */
  104.                     did[n] = 1;    /* turn on usage flag */
  105.                     break;    /* stop looking */
  106.                 }
  107.             }
  108.  
  109.             if (cvt)/* if converting this one */
  110.                 cvtfile(&hdr);    /* then do it */
  111.             else {    /* else just copy it */
  112.                 writehdr(&hdr, new);
  113.                 filecopy(arc, new, hdr.size);
  114.             }
  115.         }
  116.     } else
  117.         while (readhdr(&hdr, arc))    /* else convert all files */
  118.             cvtfile(&hdr);
  119.  
  120.     hdrver = 0;        /* archive EOF type */
  121.     writehdr(&hdr, new);    /* write out our end marker */
  122.     closearc(1);        /* close archive after changes */
  123.  
  124.     if (note) {
  125.         for (n = 0; n < num; n++) {    /* report unused args */
  126.             if (!did[n]) {
  127.                 printf("File not found: %s\n", arg[n]);
  128.                 nerrs++;
  129.             }
  130.         }
  131.     }
  132. }
  133.  
  134. void
  135. cvtfile(hdr)            /* convert a file */
  136.     struct heads   *hdr;    /* pointer to header data */
  137. {
  138.     long            starts, ftell();    /* where the file goes */
  139.     FILE           *tmp, *fopen();    /* temporary file */
  140.  
  141.     if (!(tmp = fopen(tempname, "w+b")))
  142.         abort("Unable to create temporary file %s", tempname);
  143.  
  144.     if (note) {
  145.         printf("Converting file: %-12s   reading, ", hdr->name);
  146.         fflush(stdout);
  147.     }
  148.     unpack(arc, tmp, hdr);    /* unpack the entry */
  149.     fseek(tmp, 0L, 0);    /* reset temp for reading */
  150.  
  151.     starts = ftell(new);    /* note where header goes */
  152.     hdrver = ARCVER;        /* anything but end marker */
  153.     writehdr(hdr, new);    /* write out header skeleton */
  154.     pack(tmp, new, hdr);    /* pack file into archive */
  155.     fseek(new, starts, 0);    /* move back to header skeleton */
  156.     writehdr(hdr, new);    /* write out real header */
  157.     fseek(new, hdr->size, 1);    /* skip over data to next header */
  158.     fclose(tmp);        /* all done with the file */
  159.     if (unlink(tempname) && warn) {
  160.         printf("Cannot unsave %s\n", tempname);
  161.         nerrs++;
  162.     }
  163. }
  164. @
  165.  
  166.  
  167. 1.4
  168. log
  169. @Removed unused MTS code...
  170. @
  171. text
  172. @d2 1
  173. a2 1
  174.  * $Header: arccvt.c,v 1.3 88/06/01 15:16:46 hyc Locked $
  175. d44 1
  176. a44 1
  177. #ifndef DOS
  178. @
  179.  
  180.  
  181. 1.3
  182. log
  183. @Fixed declarations
  184. @
  185. text
  186. @d2 1
  187. a2 1
  188.  * $Header: arccvt.c,v 1.4 88/04/19 01:39:28 hyc Exp $
  189. d44 1
  190. a44 1
  191. #ifndef MSDOS
  192. a96 4
  193. /*
  194. #ifdef MTS
  195.     char            name[16];
  196. #endif */
  197. a97 1
  198. #ifdef MTS
  199. a98 3
  200. #else
  201.     if (!(tmp = fopen(tempname, "w+")))
  202. #endif
  203. a104 6
  204. /*
  205. #ifdef MTS
  206.     strcpy(name, hdr->name);
  207.     fseek(tmp, 0, 0);
  208. #endif
  209.  */
  210. a112 5
  211. /*
  212. #ifdef MTS
  213.     strcpy(hdr->name, name);
  214. #endif
  215.  */
  216. @
  217.  
  218.  
  219. 1.2
  220. log
  221. @re-synch wuth MTS, minor formatting
  222. @
  223. text
  224. @d2 1
  225. a2 12
  226.  * $Log:    arccvt.c,v $
  227.  * Revision 1.1  88/04/11  17:50:00  hyc
  228.  * Initial revision
  229.  * 
  230.  * Revision 1.1  87/12/19  04:02:03  hyc
  231.  * Initial revision
  232.  * 
  233.  * Revision 1.3  87/08/13  17:03:07  hyc
  234.  * Run thru the indent program...
  235.  *  Revision 1.2  87/07/21  06:57:53  hyc *** empty
  236.  * log message ***
  237.  * 
  238. d22 2
  239. a23 1
  240. static char     tempname[100];    /* temp file name */
  241. d25 3
  242. a27 1
  243. INT
  244. d29 1
  245. a29 1
  246.     INT             num;    /* number of arguments */
  247. d33 3
  248. a35 3
  249.     INT             cvt;    /* true to convert current file */
  250.     INT             did[25];/* true when argument was used */
  251.     INT             n;    /* index */
  252. d38 1
  253. a38 1
  254.     INT             cvtfile();
  255. d44 1
  256. a44 1
  257. #ifdef MTS
  258. d91 1
  259. a91 1
  260. INT
  261. d95 1
  262. a95 1
  263.     LONG            starts, ftell();    /* where the file goes */
  264. d97 1
  265. d100 1
  266. a100 1
  267. #endif
  268. d113 1
  269. d118 1
  270. d123 1
  271. a123 1
  272.     hdrver = 8;        /* anything but end marker */
  273. d127 1
  274. d131 1
  275. @
  276.  
  277.  
  278. 1.1
  279. log
  280. @Initial revision
  281. @
  282. text
  283. @d3 3
  284. d65 1
  285. a65 1
  286.             for (n = 0; n < num; n++) {    /* for each template *
  287. d99 1
  288. a99 1
  289. static          INT
  290. @
  291.