|
|
1.1 root 1: /*
2: * static char ID_mn[] = "@(#) tstc.c: 1.2 3/17/82";
3: */
4:
5: /* main program for the compress utility is used as a bridge
6: * between the 3 main functions: frstpass, build, and secpass.
7: */
8:
9:
10: #include <stdio.h>
11: #include "sdp.h"
12: #include "sdp1.h"
13: #include <signal.h>
14: #include "filehdr.h"
15: #include "syms.h"
16: #include "ldfcn.h"
17:
18: long tag_sum = 0;
19: int vflag = 0;
20: int pflag = 0;
21: extern struct ENVIRON *ENV;
22:
23:
24: main(argc, argv)
25:
26: int argc;
27: char *argv[];
28: {
29: extern int frstpass();
30: extern int secpass();
31: extern int build();
32: extern int tagfini(),
33: symfini();
34: extern long delsum;
35: char *c;
36: int nargs;
37:
38: nargs = argc;
39: while (--argc > 0 && **++argv == '-' ) {
40: --nargs;
41: for ( c =argv[0]+1; *c != '\0'; c++)
42: switch(*c) {
43: case 'v': vflag++; break;
44: case 'p': pflag++; break;
45: default:
46: fprintf(stderr, "invalid option '%c' ignored \n", *c);
47: break;
48: } /* end of switch */
49: } /* end of othermost while */
50:
51: if ( nargs < 3 ) {
52: fprintf(stderr,"usage: cprs [-v] [-p] infile outfile\n");
53: exit (1);
54: }
55:
56: if(frstpass(*argv) != SUCCESS) {
57: fprintf(stderr, "error condition: no compression\n");
58: exit (1);
59: }
60: if ( pflag > 0)
61: printf("number of tags read %ld\n",tag_sum);
62: if ( delsum == 0) {
63: if ( pflag > 0)
64: fprintf(stderr, "no duplicate tags\n");
65: if ( cpyfile(argv[0], argv[1]) != SUCCESS)
66: fprintf(stderr,"error in copying file\n");
67: kill_sdp();
68: exit (2);
69: }
70: if ( build() != SUCCESS) {
71: if ( vflag > 0)
72: fprintf(stderr,"unable to build table for compression\n");
73: exit (3);
74: }
75: kill_sdp();
76: if(secpass(argv[0], argv[1]) != SUCCESS) {
77: fprintf(stderr,"couldn't compress\n");
78: }
79:
80: exit(0);
81: }
82:
83: kill_sdp()
84: {
85: if (tagfini() != SUCCESS || symfini() != SUCCESS)
86: return(FAILURE);
87: else
88: {
89: if (sdp_vacate(ENV) == SDPERROR)
90: {
91: fprintf(stderr,"Failed to close SDP");
92: return(FAILURE);
93: }
94: return(SUCCESS);
95: }
96: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.