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
|
/*****************************************************************************
* Johns Hopkins University
* Center For Astrophysical Sciences
* FUSE
*****************************************************************************
*
* Synopsis: cf_cal_file(char *calfile)
*
* Description: Returns a pointer to a string with the full calibration
* path (from the CF_CALDIR environment variable) prepended
* to the given file name.
*
* Arguments: char *calfile Name of the calibration file.
*
* Returns: A pointer to a string which contains the full path filename.
*
* History: 02/26/99 emurphy Begin and finish work.
* 03/01/99 emurphy Added some error checking
* 03/02/99 emurphy Added use of cf_if_warning
* 04/04/99 emurphy removed cf_error_init
* 04/08/99 barrett replaced fitsio.h with calfuse.h
* 05/18/99 emurphy Added checks on strlen and ending "/"
* 06/04/99 peb Removed 160 character string limit
* Added cf_malloc function.
* 08/05/99 emurphy Created cf_populate_file, to support
* cf_cal_file and cf_hist_file.c
* 08/25/99 emurphy Added cf_parm_file for parameter files.
* 12/18/03 bjg Change calfusettag.h to calfuse.h
*
****************************************************************************/
#include <stdlib.h>
#include <string.h>
#include "calfuse.h"
static char
*cf_populate_file(char *calfile, char *enviro_name)
{
char *enviro, *filen;
int strl, strt;
enviro = getenv(enviro_name);
if (enviro) {
strl = strlen(enviro);
strt = strl + strlen(calfile) + 16;
filen = cf_malloc(strt);
strcpy(filen, enviro);
/* Check to see if last character is a "/" */
if (strncmp(filen+strl-1, "/", 1)!=0)
strcat(filen, "/");
strcat(filen, calfile);
return filen;
}
else {
printf("Environment variable %-20.20s undefined.",enviro_name);
cf_if_warning("Environment variable undefined");
return calfile;
}
}
char *cf_cal_file(char *calfile)
{
return cf_populate_file(calfile, "CF_CALDIR");
}
char *cf_hist_file(char *calfile)
{
return cf_populate_file(calfile, "CF_HISTDIR");
}
char *cf_parm_file(char *calfile)
{
return cf_populate_file(calfile, "CF_PARMDIR");
}
|