Added two new envParams and converted iocsh to use these instead of getenv()

This commit is contained in:
Andrew Johnson
2004-05-17 21:40:10 +00:00
parent 668ecc9b94
commit 2bef3a2d08
5 changed files with 49 additions and 50 deletions

View File

@@ -15,16 +15,14 @@
#
# CONFIG_ENV - EPICS Environment Parameter configuration file
#
# This file is interpreted by the Bourne Shell, so spaces are
# not allowed around the '=' signs or in unquoted values.
# Makefile variables are not defined here.
# This file is read by the script base/src/libCom/env/bldEnvdata.pl
# Variable definitions must take the form
# VAR = VALUE
# or
# VAR = "Value containing spaces"
# with each one on its own line.
# Enclosing spaces and "" will be trimmed.
#
# Note: This file is read by base/src/libCom/env/bldEnvdata.pl,
# so the variable definitions in here should be kept 'simple':
# VAR=VALUE
# each one on a single line.
#
# Default environment settings

View File

@@ -15,34 +15,42 @@
#
# CONFIG_SITE_ENV - EPICS Environment Parameter Site configuration file
#
# This file is interpreted by the Bourne Shell, so spaces are
# not allowed around the '=' signs or in unquoted values.
# Makefile variables are not defined here.
#
# Note: This file is read by base/src/libCom/env/bldEnvdata.pl,
# so the variable definitions in here should be kept 'simple':
# VAR=VALUE
# each one on a single line.
# This file is read by the script base/src/libCom/env/bldEnvdata.pl
# Variable definitions must take the form
# VAR = VALUE
# or
# VAR = "Value containing spaces"
# with each one on its own line.
# Enclosing spaces and "" will be trimmed.
#
# Site-specific environment settings
# Time service:
# EPICS_TIMEZONE needed for vxWorks
# EPICS_TIMEZONE=<name>::<minutesWest>:<start daylight>:<end daylight>
#NOTE: start and end are mmddhh that bis mounth,day,hour
# eg EPICS_TIMEZONE=CUS::360:033102:102802
# EPICS_TIMEZONE
# local timezone info for vxWorks IOCs. The format required is
# <name>::<minutesWest>:<start daylight>:<end daylight>
# where the start and end are mmddhh - that is month,day,hour
# eg EPICS_TIMEZONE=CUS::360:033102:102802
#
# DST for 2004 US: Apr 4 - Oct 31
# EU: Mar 28 - Oct 31
# (see: http://www.worldtimezone.org/daylight.html)
# DST for 2004 US: Apr 4 - Oct 31
# EU: Mar 28 - Oct 31
# (see: http://www.worldtimezone.org/daylight.html)
#
# EPICS_TS_NTP_INET ntp or Unix time server ip addr.
# EPICS_TS_NTP_INET
# NTP or Unix time server ip address. Uses boot host if not set.
EPICS_TIMEZONE=CUS::360:040402:103102
#EPICS_TIMEZONE=MET::-60:032802:103102
EPICS_TS_NTP_INET=
# IOC Shell:
# IOCSH_PS1
# Prompt string
# IOCSH_HISTSIZE
# Number of lines of command history to keep.
IOCSH_PS1="epics> "
IOCSH_HISTSIZE=50
# Log Server:
# EPICS_IOC_LOG_INET
@@ -52,7 +60,7 @@ EPICS_TS_NTP_INET=
# EPICS_IOC_LOG_FILE_LIMIT
# maximum log file size.
# EPICS_IOC_LOG_FILE_COMMAND
# A shell command string used to obtain a new
# A shell command string used to obtain a new
# path name in response to SIGHUP - the new path name will
# replace any path name supplied in EPICS_IOC_LOG_FILE_NAME

View File

@@ -25,6 +25,7 @@
#include "epicsString.h"
#include "epicsThread.h"
#include "epicsMutex.h"
#include "envDefs.h"
#include "registry.h"
#define epicsExportSharedSymbols
#include "iocsh.h"
@@ -299,7 +300,7 @@ iocsh (const char *pathname)
* See if command interpreter is interactive
*/
if ((pathname == NULL) || (strcmp (pathname, "<telnet>") == 0)) {
if ((prompt = getenv ("IOCSH_PS1")) == NULL)
if ((prompt = envGetConfigParamPtr(&IOCSH_PS1)) == NULL)
prompt = "epics> ";
}
else {
@@ -538,8 +539,8 @@ iocsh (const char *pathname)
break;
}
if((prompt != NULL) && (strcmp(argv[0], "epicsEnvSet") == 0)) {
char *newPrompt;
if ((newPrompt = getenv ("IOCSH_PS1")) != NULL)
const char *newPrompt;
if ((newPrompt = envGetConfigParamPtr(&IOCSH_PS1)) != NULL)
prompt = newPrompt;
}
}

View File

@@ -73,6 +73,8 @@ epicsShareExtern READONLY ENV_PARAM EPICS_IOC_LOG_FILE_NAME;
epicsShareExtern READONLY ENV_PARAM EPICS_IOC_LOG_FILE_COMMAND;
epicsShareExtern READONLY ENV_PARAM EPICS_CMD_PROTO_PORT;
epicsShareExtern READONLY ENV_PARAM EPICS_AR_PORT;
epicsShareExtern READONLY ENV_PARAM IOCSH_PS1;
epicsShareExtern READONLY ENV_PARAM IOCSH_HISTSIZE;
/*
* bldEnvData looks for "epicsShareExtern ENV_PARAM" so
@@ -94,8 +96,6 @@ epicsShareFunc long epicsShareAPI
envGetDoubleConfigParam(const ENV_PARAM *pParam, double *pDouble);
epicsShareFunc long epicsShareAPI
envGetLongConfigParam(const ENV_PARAM *pParam, long *pLong);
epicsShareFunc const char * epicsShareAPI
envGetConfigParamPtr(const ENV_PARAM *pParam);
epicsShareFunc unsigned short epicsShareAPI envGetInetPortConfigParam
(const ENV_PARAM *pEnv, unsigned short defaultPort);
epicsShareFunc long epicsShareAPI epicsPrtEnvParams(void);

View File

@@ -10,10 +10,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "envDefs.h"
#define epicsExportSharedSymbols
#include <epicsReadline.h>
#include "epicsReadline.h"
#define EPICS_COMMANDLINE_LIBRARY_EPICS 0
#define EPICS_COMMANDLINE_LIBRARY_LIBTECLA 1
@@ -36,13 +37,10 @@ void * epicsShareAPI
epicsReadlineBegin (FILE *in)
{
GetLine *gl;
const char *histSize = getenv("IOCSH_HISTSIZE");
int i;
long i = 50;
if (histSize == NULL)
i = 50;
else if ((i = atoi(histSize)) < 0)
i = 0;
envGetLongConfigParam(&IOCSH_HISTSIZE, &i);
if (i < 0) i = 0;
gl = new_GetLine(200, i * 40);
if ((gl != NULL) && (in != NULL))
gl_change_terminal(gl, in, stdout, NULL);
@@ -97,13 +95,10 @@ epicsReadlineBegin(FILE *in)
readlineContext->in = in;
readlineContext->line = NULL;
if (in == NULL) {
const char *histSize = getenv("IOCSH_HISTSIZE");
int i;
long i = 50;
if (histSize == NULL)
i = 50;
else if ((i = atoi(histSize)) < 0)
i = 0;
envGetLongConfigParam(&IOCSH_HISTSIZE, &i);
if (i < 0) i = 0;
stifle_history (i);
rl_bind_key ('\t', rl_insert);
}
@@ -211,13 +206,10 @@ epicsReadlineBegin(FILE *in)
readlineContext->ledId = ERROR;
readlineContext->in = in;
if (in == NULL) {
const char *histSize = getenv("IOCSH_HISTSIZE");
int i;
long i = 50;
if (histSize == NULL)
i = 50;
else if ((i = atoi(histSize)) < 0)
i = 1;
envGetLongConfigParam(&IOCSH_HISTSIZE, &i);
if (i < 1) i = 1;
readlineContext->ledId = ledOpen(fileno(stdin), fileno(stdout), i);
if (readlineContext->ledId == ERROR) {
readlineContext->in = stdin;