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
|
# GETTABHDR -- Read a keyword from an table header into a string
#
# B.Simon 14-Aug-87 First Code
# B.Simon 12-Dec-94 Added error check
procedure gettabhdr (hd, keyword, maxch, value, keytype)
pointer hd # i: Table descriptor
char keyword[ARB] # i: Name of header keyword
int maxch # i: Maximum length of keyword value
char value[ARB] # o: Keyword value
int keytype # o: Type of header keyword
#--
int ip
pointer keyval, sp
int tabhdrtyp()
errchk tbhgtt
begin
call smark (sp)
call salloc (keyval, maxch, TY_CHAR)
# Read table header keyword and get datatype
call tbhgtt (hd, keyword, Memc[keyval], maxch)
keytype = tabhdrtyp (hd, keyword)
if (keytype == TY_CHAR) {
# Just do a straight copy if the keyword is a string
call strcpy (Memc[keyval], value, maxch)
} else{
# Otherwise, strip whitespace from keyword value
ip = 1
call ctowrd (Memc[keyval], ip, value, maxch)
# If boolean, convert to the standard names
if (keytype == TY_BOOL) {
if (value[1] == '1')
call strcpy ("yes", value, maxch)
else
call strcpy ("no", value, maxch)
}
}
call sfree (sp)
return
end
|