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 <sics.h>
|
||||||
#include "anstoutil.h"
|
#include "anstoutil.h"
|
||||||
|
|
||||||
|
#define MAXNUMCHAR 32
|
||||||
|
|
||||||
/** \brief Get configuration parameter
|
/** \brief Get configuration parameter
|
||||||
* \param *pCon (r) connection object.
|
* \param *pCon (r) connection object.
|
||||||
* \param *pTcl (r) Tcl interpreter
|
* \param *pTcl (r) Tcl interpreter
|
||||||
@@ -37,7 +39,7 @@ int getPortNum(SConnection *pCon, char *portName) {
|
|||||||
struct servent *sp=NULL;
|
struct servent *sp=NULL;
|
||||||
char pError[ERRLEN];
|
char pError[ERRLEN];
|
||||||
|
|
||||||
sp = getservbyname(portName, "tcp");
|
sp = getservbyname(portName, NULL);
|
||||||
if (sp == NULL) {
|
if (sp == NULL) {
|
||||||
snprintf(pError, ERRLEN,"ERROR: '%s' service not found", portName);
|
snprintf(pError, ERRLEN,"ERROR: '%s' service not found", portName);
|
||||||
SCWrite(pCon,pError, eError);
|
SCWrite(pCon,pError, eError);
|
||||||
@@ -45,3 +47,29 @@ int getPortNum(SConnection *pCon, char *portName) {
|
|||||||
}
|
}
|
||||||
return ntohs(sp->s_port);
|
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 FAILURE 0
|
||||||
#define SUCCESS 1
|
#define SUCCESS 1
|
||||||
/*@observer@*/ char *getParam(/*@dependent@*/SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave );
|
/*@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
|
#endif
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "lakeshore340.h"
|
#include "lakeshore340.h"
|
||||||
/* Added HTTP support for Histogra Server */
|
/* Added HTTP support for Histogra Server */
|
||||||
#include "anstohttp.h"
|
#include "anstohttp.h"
|
||||||
|
#include "anstoutil.h"
|
||||||
|
|
||||||
/*@observer@*//*@null@*/ pCounterDriver CreateMonCounter(/*@observer@*/SConnection *pCon, /*@observer@*/char *name, char *params);
|
/*@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)
|
static void AddCommands(SicsInterp *pInter)
|
||||||
{
|
{
|
||||||
// int iRet;
|
(void) AddCommand(pInter,"MakeTCPSelector",VelSelTcpFactory,NULL,NULL);
|
||||||
// SConnection *pDummyConn;
|
(void) AddCommand(pInter,"portnum",portNumCmd,NULL,NULL);
|
||||||
(void) AddCommand(pInter,"MakeTCPSelector",VelSelTcpFactory,NULL,NULL);
|
// (void) AddCommand(pInter,"MakePLC",MakePLC,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);
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
static void RemoveCommands(SicsInterp *pSics){
|
static void RemoveCommands(SicsInterp *pSics){
|
||||||
// RemoveCommand(pInter,"InstallProtocolHandler"0);
|
// RemoveCommand(pInter,"MakePLC");
|
||||||
// RemoveCommand(pInter,"InstallSinfox");
|
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
/*@null@*/ static pMotor CreateMotorAnsto(SConnection *pCon, int argc, char *argv[])
|
/*@null@*/ static pMotor CreateMotorAnsto(SConnection *pCon, int argc, char *argv[])
|
||||||
@@ -104,7 +96,6 @@ static void RemoveCommands(SicsInterp *pSics){
|
|||||||
|
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
/*extern pCounterDriver CreateCtrNitio10(SConnection *pCon,char *name,int argc,char *argv[]); */
|
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
static pCounterDriver CreateCounterDriverAnsto(SConnection *pCon,
|
static pCounterDriver CreateCounterDriverAnsto(SConnection *pCon,
|
||||||
int argc,
|
int argc,
|
||||||
|
|||||||
Reference in New Issue
Block a user