Added portnum command
r1183 | ffr | 2006-10-26 10:28:49 +1000 (Thu, 26 Oct 2006) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
03a8c420c4
commit
29432a7f44
@@ -4,6 +4,8 @@
|
||||
#include <sics.h>
|
||||
#include "anstoutil.h"
|
||||
|
||||
#define MAXNUMCHAR 32
|
||||
|
||||
/** \brief Get configuration parameter
|
||||
* \param *pCon (r) connection object.
|
||||
* \param *pTcl (r) Tcl interpreter
|
||||
@@ -37,7 +39,7 @@ int getPortNum(SConnection *pCon, char *portName) {
|
||||
struct servent *sp=NULL;
|
||||
char pError[ERRLEN];
|
||||
|
||||
sp = getservbyname(portName, "tcp");
|
||||
sp = getservbyname(portName, NULL);
|
||||
if (sp == NULL) {
|
||||
snprintf(pError, ERRLEN,"ERROR: '%s' service not found", portName);
|
||||
SCWrite(pCon,pError, eError);
|
||||
@@ -45,3 +47,29 @@ int getPortNum(SConnection *pCon, char *portName) {
|
||||
}
|
||||
return ntohs(sp->s_port);
|
||||
}
|
||||
|
||||
int portNumCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, char *argv[]) {
|
||||
OutCode eOut = eWarning;
|
||||
int pn;
|
||||
int iMacro;
|
||||
char portNum[MAXNUMCHAR];
|
||||
|
||||
assert(pCon != NULL);
|
||||
assert(pInter != NULL);
|
||||
|
||||
switch (argc) {
|
||||
case 2:
|
||||
pn = getPortNum(pCon, argv[1]);
|
||||
snprintf(portNum, MAXNUMCHAR, "%d", pn);
|
||||
break;
|
||||
default:
|
||||
SCWrite(pCon,"Insufficient arguments to portNumCmd",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//iMacro = SCinMacro(pCon);
|
||||
//SCsetMacro(pCon,0);
|
||||
SCWrite(pCon,portNum,eValue);
|
||||
//SCsetMacro(pCon,iMacro);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
#define FAILURE 0
|
||||
#define SUCCESS 1
|
||||
/*@observer@*/ char *getParam(/*@dependent@*/SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave );
|
||||
int portNumCmd(/*@dependent@*/SConnection *pCon, SicsInterp *pInter, void *pData, int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "lakeshore340.h"
|
||||
/* Added HTTP support for Histogra Server */
|
||||
#include "anstohttp.h"
|
||||
#include "anstoutil.h"
|
||||
|
||||
/*@observer@*//*@null@*/ pCounterDriver CreateMonCounter(/*@observer@*/SConnection *pCon, /*@observer@*/char *name, char *params);
|
||||
|
||||
@@ -48,22 +49,13 @@ static pSite /*@null@*/ siteANSTO = NULL;
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void AddCommands(SicsInterp *pInter)
|
||||
{
|
||||
// int iRet;
|
||||
// SConnection *pDummyConn;
|
||||
(void) AddCommand(pInter,"MakeTCPSelector",VelSelTcpFactory,NULL,NULL);
|
||||
/*
|
||||
* Initialisation: Force execution here or use config script
|
||||
*/
|
||||
// pDummyConn = SCCreateDummyConnection(pInter);
|
||||
// iRet = InterpExecute(pInter,pDummyConn,"config outcode warning");
|
||||
// iRet = InterpExecute(pInter,pDummyConn,"InstallSinfox");
|
||||
// iRet = InterpExecute(pInter,pDummyConn,"InstallProtocolHandler");
|
||||
// SCDeleteConnection(pDummyConn);
|
||||
(void) AddCommand(pInter,"portnum",portNumCmd,NULL,NULL);
|
||||
// (void) AddCommand(pInter,"MakePLC",MakePLC,NULL,NULL);
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void RemoveCommands(SicsInterp *pSics){
|
||||
// RemoveCommand(pInter,"InstallProtocolHandler"0);
|
||||
// RemoveCommand(pInter,"InstallSinfox");
|
||||
// RemoveCommand(pInter,"MakePLC");
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
/*@null@*/ static pMotor CreateMotorAnsto(SConnection *pCon, int argc, char *argv[])
|
||||
@@ -104,7 +96,6 @@ static void RemoveCommands(SicsInterp *pSics){
|
||||
|
||||
return pNew;
|
||||
}
|
||||
/*extern pCounterDriver CreateCtrNitio10(SConnection *pCon,char *name,int argc,char *argv[]); */
|
||||
/*-------------------------------------------------------------------*/
|
||||
static pCounterDriver CreateCounterDriverAnsto(SConnection *pCon,
|
||||
int argc,
|
||||
|
||||
Reference in New Issue
Block a user