1 | /*
|
---|
2 | =============================================================================
|
---|
3 | instdir.c -- read an instrument library and print its directory
|
---|
4 | Version 2 -- 1988-08-03 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define M7CAT 1 /* so libdsp.h gets it right */
|
---|
9 |
|
---|
10 | #include "stdio.h"
|
---|
11 | #include "stddefs.h"
|
---|
12 | #include "graphdef.h"
|
---|
13 | #include "vsdd.h"
|
---|
14 |
|
---|
15 | #include "midas.h"
|
---|
16 | #include "instdsp.h"
|
---|
17 | #include "libdsp.h"
|
---|
18 |
|
---|
19 | #define LIBNAME "m7slot00.orc" /* library name */
|
---|
20 |
|
---|
21 | extern int errno;
|
---|
22 |
|
---|
23 | char libname[64];
|
---|
24 |
|
---|
25 | struct instdef idefs[1];
|
---|
26 | struct mlibhdr ldhead;
|
---|
27 |
|
---|
28 | /* |
---|
29 |
|
---|
30 | */
|
---|
31 |
|
---|
32 | /*
|
---|
33 | =============================================================================
|
---|
34 | skipit() -- skip past data in a file, with error checking
|
---|
35 | =============================================================================
|
---|
36 | */
|
---|
37 |
|
---|
38 | short
|
---|
39 | skipit(fp, len)
|
---|
40 | register FILE *fp;
|
---|
41 | register long len;
|
---|
42 | {
|
---|
43 | if (fseek(fp, len, 1))
|
---|
44 | return(FAILURE);
|
---|
45 | else
|
---|
46 | return(SUCCESS);
|
---|
47 | }
|
---|
48 |
|
---|
49 | /*
|
---|
50 | =============================================================================
|
---|
51 | die() -- close a file and terminate the program
|
---|
52 | =============================================================================
|
---|
53 | */
|
---|
54 |
|
---|
55 | die(fp)
|
---|
56 | FILE *fp;
|
---|
57 | {
|
---|
58 | fclose(fp);
|
---|
59 | printf("Program terminated\n");
|
---|
60 | exit(1);
|
---|
61 | }
|
---|
62 |
|
---|
63 | /* |
---|
64 |
|
---|
65 | */
|
---|
66 |
|
---|
67 | /*
|
---|
68 | =============================================================================
|
---|
69 | readit() -- read a file, with error checking
|
---|
70 | =============================================================================
|
---|
71 | */
|
---|
72 |
|
---|
73 | short
|
---|
74 | readit(fp, to, len)
|
---|
75 | register FILE *fp;
|
---|
76 | register char *to;
|
---|
77 | register long len;
|
---|
78 | {
|
---|
79 | register long count;
|
---|
80 | register int c;
|
---|
81 |
|
---|
82 | for (count = 0; count < len; count++) {
|
---|
83 |
|
---|
84 | if (EOF EQ (c = getc(fp))) {
|
---|
85 |
|
---|
86 | printf("ERROR: Unexpected EOF -- errno = %d\n", errno);
|
---|
87 | fclose(fp);
|
---|
88 | return(FAILURE);
|
---|
89 |
|
---|
90 | } else {
|
---|
91 |
|
---|
92 | *to++ = c;
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | return(SUCCESS);
|
---|
97 | }
|
---|
98 |
|
---|
99 | /* |
---|
100 |
|
---|
101 | */
|
---|
102 |
|
---|
103 | /*
|
---|
104 | =============================================================================
|
---|
105 | print the directory of an instrument library
|
---|
106 | =============================================================================
|
---|
107 | */
|
---|
108 |
|
---|
109 | main(argc, argv)
|
---|
110 | int argc;
|
---|
111 | char *argv[];
|
---|
112 | {
|
---|
113 | register FILE *fp;
|
---|
114 | register struct instdef *ip;
|
---|
115 | register short i;
|
---|
116 |
|
---|
117 | strcpy(libname, LIBNAME);
|
---|
118 |
|
---|
119 | if (argc EQ 2)
|
---|
120 | strcpy(libname, argv[1]);
|
---|
121 |
|
---|
122 | if ((FILE *)NULL EQ (fp = fopenb(libname, "r"))) {
|
---|
123 |
|
---|
124 | printf("Unable to open [%s]\n", libname);
|
---|
125 | exit(1);
|
---|
126 | }
|
---|
127 |
|
---|
128 | if (readit(fp, &ldhead, (long)LH_LEN))
|
---|
129 | die(fp);
|
---|
130 |
|
---|
131 | printf("Directory of Orchestra in [%s]\n", libname);
|
---|
132 | printf("N_ Name Comments\n");
|
---|
133 | printf("-- ---------------- ---------------- ---------------- ----------------\n");
|
---|
134 |
|
---|
135 | for (i = 0; i < NINORC; i++) {
|
---|
136 |
|
---|
137 | ip = &idefs;
|
---|
138 |
|
---|
139 | if (readit(fp, ip, (long)OR_LEN1))
|
---|
140 | die(fp);
|
---|
141 |
|
---|
142 | if (skipit(fp, (long)OR_LEN2))
|
---|
143 | die(fp);
|
---|
144 |
|
---|
145 | if (skipit(fp, (long)OR_LEN2))
|
---|
146 | die(fp);
|
---|
147 |
|
---|
148 | printf("%2d: %-16.16s", i + 1, ip->idhname);
|
---|
149 | printf(" %-16.16s", ip->idhcom1);
|
---|
150 | printf(" %-16.16s", ip->idhcom2);
|
---|
151 | printf(" %-16.16s\n", ip->idhcom3);
|
---|
152 | }
|
---|
153 |
|
---|
154 | fclose(fp);
|
---|
155 | exit(0);
|
---|
156 | }
|
---|