aboutsummaryrefslogtreecommitdiff
path: root/sys/imio/db/imrenf.x
blob: 3b1bf7a644fc089fafbdd5ed0ef3c1b096f59b3d (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<syserr.h>
include	<imhdr.h>
include	"idb.h"

# IMRENF -- Rename a user field keyword. It is an error if the
# named field does not exist.

procedure imrenf (im, oldkey, newkey)

pointer	im			# image descriptor
char	oldkey[ARB]		# old keyword
char	newkey[ARB]		# new keyword

int	off
pointer	rp, sp, keyname
int	idb_kwlookup(), idb_findrecord(), stridxs()
errchk	syserrs

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

	# FITS format requires that the keyword name be upper case.
	call strcpy (oldkey, Memc[keyname], IDB_SZFITSKEY)
	call strupr (Memc[keyname])

	# Cannot delete standard header keywords.
	if (idb_kwlookup (oldkey) > 0)
	    call syserrs (SYS_IDBNODEL, oldkey)

	# Verify that the named user field exists.
	if (idb_findrecord (im, oldkey, rp) <= 0)
	    call syserrs (SYS_IDBDELNXKW, oldkey)
	
	# Rename the keyword.
	call sprintf (Memc[keyname], IDB_SZFITSKEY, "%-8.8s")
	    call pargstr (newkey)
	call strupr (Memc[keyname])
	call amovc (Memc[keyname], Memc[rp], 8)
	
	call sfree (sp)
end