Blob


1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4 #include "sky.h"
6 struct
7 {
8 char name[9];
9 char offset;
10 } Hproto[] =
11 {
12 "ppo1", Pppo1,
13 "ppo2", Pppo2,
14 "ppo3", Pppo3,
15 "ppo4", Pppo4,
16 "ppo5", Pppo5,
17 "ppo6", Pppo6,
19 "amdx1", Pamdx1,
20 "amdx2", Pamdx2,
21 "amdx3", Pamdx3,
22 "amdx4", Pamdx4,
23 "amdx5", Pamdx5,
24 "amdx6", Pamdx6,
25 "amdx7", Pamdx7,
26 "amdx8", Pamdx8,
27 "amdx9", Pamdx9,
28 "amdx10", Pamdx10,
29 "amdx11", Pamdx11,
30 "amdx12", Pamdx12,
31 "amdx13", Pamdx13,
32 "amdx14", Pamdx14,
33 "amdx15", Pamdx15,
34 "amdx16", Pamdx16,
35 "amdx17", Pamdx17,
36 "amdx18", Pamdx18,
37 "amdx19", Pamdx19,
38 "amdx20", Pamdx20,
40 "amdy1", Pamdy1,
41 "amdy2", Pamdy2,
42 "amdy3", Pamdy3,
43 "amdy4", Pamdy4,
44 "amdy5", Pamdy5,
45 "amdy6", Pamdy6,
46 "amdy7", Pamdy7,
47 "amdy8", Pamdy8,
48 "amdy9", Pamdy9,
49 "amdy10", Pamdy10,
50 "amdy11", Pamdy11,
51 "amdy12", Pamdy12,
52 "amdy13", Pamdy13,
53 "amdy14", Pamdy14,
54 "amdy15", Pamdy15,
55 "amdy16", Pamdy16,
56 "amdy17", Pamdy17,
57 "amdy18", Pamdy18,
58 "amdy19", Pamdy19,
59 "amdy20", Pamdy20,
61 "pltscale", Ppltscale,
62 "xpixelsz", Pxpixelsz,
63 "ypixelsz", Pypixelsz,
65 "pltrah", Ppltrah,
66 "pltram", Ppltram,
67 "pltras", Ppltras,
68 "pltdecd", Ppltdecd,
69 "pltdecm", Ppltdecm,
70 "pltdecs", Ppltdecs,
72 };
74 Header*
75 getheader(char *rgn)
76 {
77 char rec[81], name[81], value[81];
78 char *p;
79 Biobuf *bin;
80 Header hd, *h;
81 int i, j, decsn, dss;
83 dss = 0;
84 sprint(rec, "/lib/sky/dssheaders/%s.hhh", rgn);
85 bin = Bopen(unsharp(rec), OREAD);
86 /*
87 if(bin == 0) {
88 dss = 102;
89 sprint(rec, "/n/juke/dss/dss.102/headers/%s.hhh", rgn);
90 bin = Bopen(rec, OREAD);
91 }
92 if(bin == 0) {
93 dss = 61;
94 sprint(rec, "/n/juke/dss/dss.061/headers/%s.hhh", rgn);
95 bin = Bopen(rec, OREAD);
96 }
97 */
98 if(bin == 0) {
99 fprint(2, "cannot open %s\n", rgn);
100 exits("file");
102 if(debug)
103 Bprint(&bout, "reading %s\n", rec);
104 if(dss)
105 Bprint(&bout, "warning: reading %s from jukebox\n", rec);
107 memset(&hd, 0, sizeof(hd));
108 j = 0;
109 decsn = 0;
110 for(;;) {
111 if(dss) {
112 if(Bread(bin, rec, 80) != 80)
113 break;
114 rec[80] = 0;
115 } else {
116 p = Brdline(bin, '\n');
117 if(p == 0)
118 break;
119 p[Blinelen(bin)-1] = 0;
120 strcpy(rec, p);
123 p = strchr(rec, '/');
124 if(p)
125 *p = 0;
126 p = strchr(rec, '=');
127 if(p == 0)
128 continue;
129 *p++ = 0;
130 if(getword(name, rec) == 0)
131 continue;
132 if(getword(value, p) == 0)
133 continue;
134 if(strcmp(name, "pltdecsn") == 0) {
135 if(strchr(value, '-'))
136 decsn = 1;
137 continue;
139 for(i=0; i<nelem(Hproto); i++) {
140 j++;
141 if(j >= nelem(Hproto))
142 j = 0;
143 if(strcmp(name, Hproto[j].name) == 0) {
144 hd.param[(uchar)Hproto[j].offset] = atof(value);
145 break;
149 Bterm(bin);
151 hd.param[Ppltra] = RAD(hd.param[Ppltrah]*15 +
152 hd.param[Ppltram]/4 + hd.param[Ppltras]/240);
153 hd.param[Ppltdec] = RAD(hd.param[Ppltdecd] +
154 hd.param[Ppltdecm]/60 + hd.param[Ppltdecs]/3600);
155 if(decsn)
156 hd.param[Ppltdec] = -hd.param[Ppltdec];
157 hd.amdflag = 0;
158 for(i=Pamdx1; i<=Pamdx20; i++)
159 if(hd.param[i] != 0) {
160 hd.amdflag = 1;
161 break;
163 h = malloc(sizeof(*h));
164 *h = hd;
165 return h;
168 void
169 getplates(void)
171 char rec[81], *q;
172 Plate *p;
173 Biobuf *bin;
174 int c, i, dss;
176 dss = 0;
177 sprint(rec, "/lib/sky/dssheaders/lo_comp.lis");
178 bin = Bopen(rec, OREAD);
179 if(bin == 0) {
180 dss = 102;
181 sprint(rec, "%s/headers/lo_comp.lis", dssmount(dss));
182 bin = Bopen(rec, OREAD);
184 if(bin == 0) {
185 dss = 61;
186 sprint(rec, "%s/headers/lo_comp.lis", dssmount(dss));
187 bin = Bopen(rec, OREAD);
189 if(bin == 0) {
190 fprint(2, "can't open lo_comp.lis; try 9fs juke\n");
191 exits("open");
193 if(debug)
194 Bprint(&bout, "reading %s\n", rec);
195 if(dss)
196 Bprint(&bout, "warning: reading %s from jukebox\n", rec);
197 for(nplate=0;;) {
198 if(dss) {
199 if(Bread(bin, rec, 80) != 80)
200 break;
201 rec[80] = 0;
202 } else {
203 q = Brdline(bin, '\n');
204 if(q == 0)
205 break;
206 q[Blinelen(bin)-1] = 0;
207 strcpy(rec, q);
209 if(rec[0] == '#')
210 continue;
211 if(nplate < nelem(plate)) {
212 p = &plate[nplate];
213 memmove(p->rgn, rec+0, 5);
214 if(p->rgn[4] == ' ')
215 p->rgn[4] = 0;
216 for(i=0; c=p->rgn[i]; i++)
217 if(c >= 'A' && c <= 'Z')
218 p->rgn[i] += 'a'-'A';
219 p->ra = RAD(atof(rec+12)*15 +
220 atof(rec+15)/4 +
221 atof(rec+18)/240);
222 p->dec = RAD(atof(rec+26) +
223 atof(rec+29)/60 +
224 atof(rec+32)/3600);
225 if(rec[25] == '-')
226 p->dec = -p->dec;
227 p->disk = atoi(rec+53);
228 if(p->disk == 0)
229 continue;
231 nplate++;
233 Bterm(bin);
235 if(nplate >= nelem(plate))
236 fprint(2, "nplate too small %d %d\n", nelem(plate), nplate);
237 if(debug)
238 Bprint(&bout, "%d plates\n", nplate);
241 char*
242 dssmount(int dskno)
244 Bprint(&bout, "not mounting dss\n");
245 return "/n/dss";