Created anstoutil to share the getParam function.
Modified motor_dmc2280 and counterdiv to use anstoutil r1033 | ffr | 2006-07-25 16:48:14 +1000 (Tue, 25 Jul 2006) | 3 lines
This commit is contained in:
committed by
Douglas Clowes
parent
36f76e9486
commit
a7ebdff308
25
site_ansto/anstoutil.c
Normal file
25
site_ansto/anstoutil.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#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: No '%s' parameter given for dmc2280 motor", parName);
|
||||
SCWrite(pCon,pError, eError);
|
||||
}
|
||||
return pPtr;
|
||||
}
|
||||
Reference in New Issue
Block a user