aboutsummaryrefslogtreecommitdiff
path: root/noao/rv/rvwparam.x
blob: 15b1f85d19925735ef5445ab84b2458d9a3c563a (plain) (blame)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
include <time.h>
include "rvpackage.h"
include "rvflags.h"
include "rvcont.h"
include "rvcomdef.h"

define	SZ_DATEBUF		16

# RV_PARAM -- Procedure to write the rv parameters to a text file.

procedure rv_param (rv, out, task)

pointer	rv		# RV struct pointer
pointer	out		# database descriptor
char	task[ARB]	# task name

int	nchars
pointer	sp, outstr, date, time
int	envfind(), gstrcpy()

begin
	if (out == NULL)
	    return
	 
	# Allocate working space.
	call smark (sp)
	call salloc (outstr, SZ_LINE, TY_CHAR)
	call salloc (date, SZ_DATEBUF, TY_CHAR)
	call salloc (time, SZ_DATEBUF, TY_CHAR)

	# Write the id.
	nchars = envfind ("version", Memc[outstr], SZ_LINE)
	if (nchars <= 0)
	    nchars = gstrcpy ("NOAO/IRAF", Memc[outstr], SZ_LINE)
	call rv_sparam (out, "IRAF", Memc[outstr], "version",
	    "current version of IRAF")
	nchars = envfind ("userid", Memc[outstr], SZ_LINE)
	call rv_sparam (out, "USER", Memc[outstr], "name", "user id")
	call gethost (Memc[outstr], SZ_LINE)
	call rv_sparam (out, "HOST", Memc[outstr], "computer",
	    "IRAF host machine")
	call rv_date (Memc[date], Memc[time], SZ_DATEBUF)
	call rv_sparam (out, "DATE", Memc[date], "yyyy-mm-dd", "date")
	call rv_sparam (out, "TIME", Memc[time], "hh:mm:ss", "time")
	call rv_sparam (out, "PACKAGE", "rv", "name",
	    "name of IRAF package")
	call rv_sparam (out, "TASK", task, "name", "name of rv task")

	call sfree (sp)
end


# RV_DATE -- Procedure to produce the date and time strings for RV output files.

procedure rv_date (date, time, maxch)

char	date[SZ_LINE]	# the date string
char	time[SZ_LINE]	# the time string
int	maxch		# the maximum number of character in the string

int	tm[LEN_TMSTRUCT]
long	clktime()

begin
	call brktime (clktime (long(0)), tm)
	call sprintf (date, maxch, "%04d-%02d-%02d")
	    call pargi (TM_YEAR(tm))
	    call pargi (TM_MONTH(tm))
	    call pargi (TM_MDAY(tm))
	call sprintf (time, maxch, "%02d:%02d:%02d")
	    call pargi (TM_HOUR(tm))
	    call pargi (TM_MIN(tm))
	    call pargi (TM_SEC(tm))
end


# RV_IPARAM -- Procedure to encode an rv integer parameter.

procedure rv_iparam (out, keyword, value, units, comments)

pointer	out		# output file descriptor
char	keyword[ARB]	# keyword string
int	value		# parameter value
char	units[ARB]	# units string
char	comments[ARB]	# comment string

begin
	if (out == NULL)
	    return

	call strupr (keyword)
        call fprintf (out, "#K%4t%-10.10s%14t = %17t%-15d\n")
	    call pargstr (keyword)
	    call pargi (value)
	    call pargstr (units)
end


# RV_SPARAM -- Procedure to encode an rv string parameter.

procedure rv_sparam (out, keyword, value, units, comments)

pointer	out		# output file descriptor
char	keyword[ARB]	# keyword string
char	value[ARB]	# parameter value
char	units[ARB]	# units string
char	comments[ARB]	# comment string

bool	streq()

begin
	if (out == NULL)
	    return

	call strupr (keyword)
	if (streq(keyword,"REGIONS") ||
	    streq(keyword,"APNUM")) {
                call fprintf (out, "#K%4t%-10.10s%14t = %17t%-s\n")
	            call pargstr (keyword)
	            call pargstr (value)
	} else {
            call fprintf (out, "#K%4t%-10.10s%14t = %17t%-30.30s%48t%-10.10s\n")
	        call pargstr (keyword)
	        call pargstr (value)
	        call pargstr (units)
	}
end