1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
include <smw.h>
# SMW_SAPID -- Set aperture id.
procedure smw_sapid (smw, index1, index2, apid)
pointer smw #I SMW pointer
int index1 #I Spectrum index
int index2 #I Spectrum index
char apid[ARB] #I Aperture id
pointer ptr
bool streq()
errchk malloc
begin
switch (SMW_FORMAT(smw)) {
case SMW_ND:
call strcpy (apid, Memc[SMW_APID(smw)], SZ_LINE)
case SMW_ES, SMW_MS:
if (index1 < 0 || index1 > SMW_NSPEC(smw))
call error (1, "smw_sapid: index out of bounds")
if (index1 == 0)
call strcpy (apid, Memc[SMW_APID(smw)], SZ_LINE)
else {
ptr = Memi[SMW_APIDS(smw)+index1-1]
if (streq (apid, Memc[SMW_APID(smw)]))
call mfree (ptr, TY_CHAR)
else {
if (ptr == NULL)
call malloc (ptr, SZ_LINE, TY_CHAR)
call strcpy (apid, Memc[ptr], SZ_LINE)
}
Memi[SMW_APIDS(smw)+index1-1] = ptr
}
}
end
|