26 lines
862 B
C
26 lines
862 B
C
#include <stdlib.h>
|
|
#include <sics.h>
|
|
#include "anstoutil.h"
|
|
|
|
/** \brief Get configuration parameter
|
|
* \param *pCon (r) connection object.
|
|
* \param *pTcl (r) Tcl interpreter
|
|
* \param *params Tcl array of configuration parameters
|
|
* \param *parName name of parameter to get from the array
|
|
* \param mustHave indicates optional or mandatory parameters\n
|
|
* possible values
|
|
* - _REQUIRED
|
|
* - _OPTIONAL
|
|
* \return (r) a reference to a string representation of the parameter value
|
|
*/
|
|
char *getParam(SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave ) {
|
|
char *pPtr=NULL;
|
|
char pError[ERRLEN];
|
|
pPtr = Tcl_GetVar2(pTcl,params,parName,TCL_GLOBAL_ONLY);
|
|
if((mustHave == _REQUIRED) && !pPtr){
|
|
snprintf(pError, ERRLEN,"ERROR: You must supply an '%s' parameter", parName);
|
|
SCWrite(pCon,pError, eError);
|
|
}
|
|
return pPtr;
|
|
}
|