Skip to content

Commit cdc47d1

Browse files
committed
Add some tuning machinery
Merge hdsTune and hdsGtune into a single file that can share variables. Read HDS_MAP and HDS_SHELL environment variables.
1 parent 2e0884d commit cdc47d1

File tree

6 files changed

+418
-260
lines changed

6 files changed

+418
-260
lines changed

Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ hdsDimC2F.c \
113113
hdsDimF2C.c \
114114
hdsFree.c \
115115
hdsGroup.c \
116-
hdsGtune.c \
117116
hdsInfoI.c \
118117
hdsLock.c \
119118
hdsNew.c \
@@ -122,7 +121,6 @@ hdsShow.c \
122121
hdsState.c \
123122
hdsStop.c \
124123
hdsTrace.c \
125-
hdsTune.c \
126124
hdsWild.c \
127125
datConv.c \
128126
hdsClose.c \
@@ -133,6 +131,7 @@ datnew0.c \
133131
datnew1.c \
134132
datput0.c \
135133
datput1.c \
134+
hdstuning.c \
136135
hdsgroups.c
137136

138137
PRIVATE_C_ROUTINES = \
@@ -152,6 +151,7 @@ dat1GetAttrHdsdims.c \
152151
dat1GetAttrInt.c \
153152
dat1GetAttrString.c \
154153
dat1GetBounds.c \
154+
dat1Getenv.c \
155155
dat1GetFullName.c \
156156
dat1H5EtoEMS.c \
157157
dat1ImportDims.c \

dat1.h

+17
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ typedef enum {
101101
HDSTYPE_STRUCTURE
102102
} hdstype_t;
103103

104+
/* Which shell should be used when expanding environment
105+
variables. Not all HDS supported shells are supported
106+
by this library.
107+
*/
108+
109+
typedef enum {
110+
HDS__NOSHELL = -1, /* Do not expand shell variables */
111+
HDS__SHSHELL, /* Use "sh" aka wordexp() */
112+
HDS__MAXSHELL /* Too high */
113+
} hds_shell_t;
114+
104115
/* Global Constants: */
105116
/* ================ */
106117
#include "dat_par.h"
@@ -372,5 +383,11 @@ dat1GetAttrString( hid_t objid, const char * attrname, hdsbool_t usedef,
372383
const char * defval, char * attrval, size_t attrvallen,
373384
int *status);
374385

386+
void dat1Getenv( const char *varname, int def, int *val );
387+
388+
hdsbool_t hds1GetUseMmap();
389+
390+
hds_shell_t hds1GetShell();
391+
375392
/* DAT1_H_INCLUDED */
376393
#endif

dat1Getenv.c

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#if HAVE_CONFIG_H
2+
# include <config.h>
3+
#endif
4+
5+
#include <stdlib.h>
6+
#include <stdio.h>
7+
8+
#include "dat1.h"
9+
10+
11+
/*
12+
*+
13+
* Name:
14+
* dat1Getenv
15+
16+
* Purpose:
17+
* Obtain an integer value from an environment variable.
18+
19+
* Invocation:
20+
* dat1Getenv( varname, def, val );
21+
22+
* Description:
23+
* This function obtains the value of a specified environment variable
24+
* as an integer. If the variable is not defined, or its value does not
25+
* make sense as an integer, or any other error occurs, then a default
26+
* value is returned instead.
27+
28+
* Parameters:
29+
* const char *varname
30+
* Pointer to a null-terminated character string giving the name of
31+
* the environment variable. The use of upper case is recommended.
32+
* int def
33+
* The default value to be used if an integer value cannot be
34+
* obtained from the environment variable.
35+
* int *val
36+
* Pointer to an integer in which the result will be returned.
37+
38+
* Notes:
39+
* This routine does not perform error checking.
40+
41+
* Authors:
42+
* RFWS: R.F. Warren-Smith (STARLINK)
43+
* {@enter_new_authors_here@}
44+
45+
* History:
46+
* 25-FEB-1992 (RFWS):
47+
* Original version.
48+
* {@enter_changes_here@}
49+
50+
* Licence:
51+
* This program is free software; you can redistribute it and/or
52+
* modify it under the terms of the GNU General Public License as
53+
* published by the Free Software Foundation; either version 3 of
54+
* the License, or (at your option) any later version.
55+
*
56+
* This program is distributed in the hope that it will be
57+
* useful, but WITHOUT ANY WARRANTY; without even the implied
58+
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
59+
* PURPOSE. See the GNU General Public License for more details.
60+
*
61+
* You should have received a copy of the GNU General Public License
62+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
63+
64+
*-
65+
*/
66+
void dat1Getenv( const char *varname, int def, int *val ) {
67+
68+
/* Local Variables: */
69+
char *txt; /* Pointer to translation value */
70+
71+
/* Obtain a pointer to the environment variable's value. */
72+
txt = getenv( varname );
73+
74+
/* If no value was obtained, then use the default. */
75+
if ( txt == NULL ) {
76+
77+
*val = def;
78+
79+
/* Otherwise, try to read an integer value from it. If unsuccessful, then */
80+
/* use the default. */
81+
} else if ( sscanf( txt, "%d", val ) != 1 ) {
82+
*val = def;
83+
}
84+
85+
return;
86+
}

hdsGtune.c

-115
This file was deleted.

0 commit comments

Comments
 (0)