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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <syserr.h>
include <ctype.h>
include <imhdr.h>
include <mach.h>
include "idb.h"
# IDB_PUTSTRING -- Set the value of a standard header parameter given the new
# value of the parameter encoded as a string. If actual type of the parameter
# is non string the value must be decoded. ERR is returned if the key is not
# a standard header parameter or if the key is known but the value cannot be
# decoded.
int procedure idb_putstring (im, key, strval)
pointer im # image descriptor
char key[ARB] # parameter to be returned
char strval[ARB] # string value of parameter
long lval
double dval
bool numeric
int ip, axis
int idb_kwlookup(), idb_naxis(), ctod()
long clktime()
begin
ip = 1
numeric = (ctod (strval, ip, dval) > 0)
if (numeric) {
if (IS_INDEFD (dval))
lval = INDEFL
else if (real(MAX_LONG) < abs(dval))
lval = INDEFL
else
lval = nint (dval)
}
# The keywords "naxis1", "naxis2", etc. are treated as a special case.
if (idb_naxis (key, axis) == YES)
if (axis > 0) {
if (numeric)
IM_LEN(im,axis) = lval
else
return (ERR)
}
# Lookup the keyword in the dictionary and set the value of the
# header parameter. If the parameter is string valued copy the
# string value and return immediately.
switch (idb_kwlookup (key)) {
case I_CTIME:
if (numeric)
IM_CTIME(im) = lval
case I_LIMTIME:
if (numeric)
IM_LIMTIME(im) = lval
case I_MAXPIXVAL:
if (numeric) {
IM_MAX(im) = dval
IM_LIMTIME(im) = clktime (long(0))
}
case I_MINPIXVAL:
if (numeric) {
IM_MIN(im) = dval
IM_LIMTIME(im) = clktime (long(0))
}
case I_MTIME:
if (numeric)
IM_MTIME(im) = lval
case I_NAXIS:
if (numeric)
IM_NDIM(im) = lval
case I_PIXFILE:
call strcpy (strval, IM_PIXFILE(im), SZ_IMPIXFILE)
return (OK)
case I_PIXTYPE:
if (numeric)
IM_PIXTYPE(im) = lval
case I_TITLE:
call strcpy (strval, IM_TITLE(im), SZ_IMTITLE)
return (OK)
default:
return (ERR)
}
# We make it here only if the actual keyword is numeric, so return
# ERR if the keyword value was nonnumeric.
if (numeric)
return (OK)
else
return (ERR)
end
|