aboutsummaryrefslogtreecommitdiff
path: root/sys/mwcs/mwsdefwcs.x
blob: 2cddc6ac1f319fa26f8bf486c7e2a90c09952926 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<mwset.h>
include	"mwcs.h"

# MW_SDEFWCS -- Set the default WCS.  This is the WCS indicated by the user
# environment variable "setwcs", if defined and the named WCS exists, else
# the first world system is used, else the physical system is used.

procedure mw_sdefwcs (mw)

pointer	mw			#I pointer to MWCS descriptor

pointer	sp, defwcs
int	envfind()

begin
	call smark (sp)
	call salloc (defwcs, SZ_FNAME, TY_CHAR)

	MI_WCS(mw) = NULL

	# Set the default WCS defined in the user environment, if defined
	# and the named WCS exists in this MWCS.

	if (envfind ("defwcs", Memc[defwcs], SZ_FNAME) > 0)
	    iferr (call mw_ssystem (mw, Memc[defwcs]))
		;

	# Otherwise, the default WCS is the first world system, if any,
	# else it is the physical system.  The first world system is WCS 3
	# as the physical and logical systems are systems 1 and 2 and are
	# always defined in any MWCS.

	if (MI_WCS(mw) == NULL) {
	    if (MI_NWCS(mw) >= 3)
		MI_WCS(mw) = MI_WCSP(mw,3)
	    else
		call mw_ssystem (mw, "physical")
	}

	call sfree (sp)
end