Remove all non-supported stuff
This commit is contained in:
-1005
File diff suppressed because it is too large
Load Diff
@@ -1,188 +0,0 @@
|
||||
#ifndef ___BS_H
|
||||
#define ___BS_H
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
*/
|
||||
|
||||
/*
|
||||
Author: Jim Kowalkowski
|
||||
Date: 9/1/95
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
/* got from protocols(5) (cheated) or /etc/protocols */
|
||||
#define BS_UDP 17
|
||||
#define BS_TCP 6
|
||||
|
||||
/* server ports - in the user reserved area - above 50000 */
|
||||
#define BS_UDP_PORT 50296
|
||||
#define BS_TCP_PORT 50297
|
||||
|
||||
/* message types */
|
||||
#define BS_Ok 0
|
||||
#define BS_Error 1
|
||||
#define BS_Close 2
|
||||
#define BS_Ping 3
|
||||
#define BS_Done 4
|
||||
|
||||
#define BS_LAST_VERB 4
|
||||
#define BS_RETRY_COUNT 3
|
||||
|
||||
/* protocol states */
|
||||
typedef enum { BSidle,BSunbound,BSsData,BSrData,BSbad,BSeof } BSstate;
|
||||
|
||||
struct bs
|
||||
{
|
||||
int soc;
|
||||
int remaining_send;
|
||||
int remaining_recv;
|
||||
BSstate state;
|
||||
};
|
||||
typedef struct bs BS;
|
||||
|
||||
struct bs_udp_data
|
||||
{
|
||||
struct sockaddr sin;
|
||||
int len;
|
||||
};
|
||||
typedef struct bs_udp_data BSDATA;
|
||||
|
||||
struct BSmsgHead
|
||||
{
|
||||
unsigned short verb;
|
||||
unsigned long size;
|
||||
};
|
||||
typedef struct BSmsgHead BSmsgHead;
|
||||
|
||||
typedef unsigned long BS_ULONG;
|
||||
|
||||
#define BSgetSocket(BS) (BS->soc)
|
||||
#define BSgetResidualWrite(BS) (BS->remaining_send)
|
||||
#define BSgetResidualRead(BS) (BS->remaining_recv)
|
||||
#define BSgetProtoState(BS) (BS->state)
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
Server functions:
|
||||
|
||||
BSopenListenerTCP:
|
||||
Open a socket locally bound to the bulk data transfer TCP server port.
|
||||
Set the socket up as a listener. Return the open socket.
|
||||
|
||||
BSopenListenerUDP:
|
||||
Open a socket locally bound to the bulk data transfer UDP server port.
|
||||
Return the open socket.
|
||||
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
int BSopenListenerTCP(int Port);
|
||||
int BSopenListenerUDP(int Port);
|
||||
int BSopenTCP(BSDATA*);
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
Utilities functions:
|
||||
|
||||
BSmakeServer:
|
||||
Available under unix only. Put process in the background, disassociate
|
||||
process from controlling terminal and parent process, and prepare
|
||||
signals for reaping children spawned by the process.
|
||||
|
||||
BSserverClearSignals:
|
||||
Clear the signal handlers for a process, set them to default.
|
||||
|
||||
BSmakeBS:
|
||||
Allocate and initialize a BS from a socket.
|
||||
|
||||
BSfreeBS:
|
||||
Close the open socket and free the memory for the BS.
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
#ifndef vxWorks
|
||||
int BSmakeServer(char** argv);
|
||||
int BSserverClearSignals();
|
||||
#endif
|
||||
|
||||
BS* BSmakeBS(int socket); /* make a BS from a socket */
|
||||
int BSfreeBS(BS* bdt); /* free a BS */
|
||||
|
||||
int BSgetBroadcastSocket(int port, struct sockaddr_in* sin);
|
||||
int BSipBroadcastOpen(BSDATA* info, int default_dest_port);
|
||||
int BSgetAddressPort(BSDATA* info,char* ip_addr, int* dest_port);
|
||||
int BSsetAddressPort(BSDATA* info,char* ip_addr, int dest_port);
|
||||
int BSsetAddress(BSDATA* info,char* ip_addr);
|
||||
int BSsetPort(BSDATA* info,int dest_port);
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
UDP functions:
|
||||
------------------------------------------------------------------------ */
|
||||
int BStransUDP(int soc,BSDATA* info,void* obuf,int osize,void* ibuf,int isize);
|
||||
int BSwriteUDP(int soc,BSDATA* info,void* obuf,int osize);
|
||||
int BSwriteDataUDP(int soc,int dest_port, char* ip_addr,void* obuf,int osize);
|
||||
int BSreadUDP(int soc,BSDATA* info,BS_ULONG tout,void* buf,int size);
|
||||
int BSbroadcast(int soc,BSDATA* info,void* buf,int size);
|
||||
int BSbroadcastTrans(int soc,int trys,BSDATA* o_info,BSDATA* i_info,
|
||||
void* obuf,int osize,void* ibuf,int isize);
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
Client functions:
|
||||
|
||||
BSipOpen:
|
||||
Open a connection to an bulk data transfer given the IP address of the
|
||||
machine where the server exists. The returned BS is returned unbound,
|
||||
a connect must be issued before data transactions can take place.
|
||||
|
||||
BSclose:
|
||||
Completely close a connection to a server and free the BS.
|
||||
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
BS* BSipOpen(char* address, int port);
|
||||
BS* BSipOpenData(BSDATA* info);
|
||||
int BSclose(BS* bdt);
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
Client and Server shared functions:
|
||||
|
||||
BSsendHeader:
|
||||
Send a message header out to a connect BS with command and message body
|
||||
size information.
|
||||
|
||||
BSsendData:
|
||||
Send a portion or all the message body out a connected BS. A header
|
||||
must have previously been sent with length information. The interface
|
||||
will only allow the amount of data specified in the header to be sent.
|
||||
|
||||
BSwrite:
|
||||
This call will block until all the data specified in the size parameter
|
||||
are sent down the socket.
|
||||
|
||||
BSread:
|
||||
This call will block until all the data specified in the size parameter
|
||||
is read from the socket.
|
||||
|
||||
BSreceiveHeader:
|
||||
Wait until a message header appears at the BS, return the action and
|
||||
remaining message body size.
|
||||
|
||||
BSreceiveData:
|
||||
Wait for a chunk or the entire body of a message to appear at the BS.
|
||||
Put the data into the buffer for a maximum size. Return the amount of
|
||||
data actually received, or zero if there is no data remaining for the
|
||||
current message.
|
||||
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
int BSsendHeader(BS* bdt, unsigned short verb, int size);
|
||||
int BSsendData(BS* bdt, void* buffer, int size);
|
||||
int BSreceiveHeader(BS* bdt, int* verb, int* size);
|
||||
int BSreceiveData(BS* bdt, void* buffer, int size);
|
||||
int BSread(int socket, void* buffer, int size);
|
||||
int BSwrite(int socket, void* buffer, int size);
|
||||
int BSflushOutput(BS* bdt);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,15 +28,13 @@ else
|
||||
|
||||
# library to build from BSlib.c:
|
||||
#
|
||||
LIBSRCS := BSlib.c
|
||||
LIBRARY := BSlib
|
||||
|
||||
# products to build,
|
||||
# all use BSlib, dbLoadTemplate needs lib Db:
|
||||
# (it doesn't hurt if all link Db...)
|
||||
#
|
||||
PROD_LIBS := BSlib Db Com
|
||||
PROD := subtool dbLoadTemplate rdbls rdbapplist PVSserver
|
||||
PROD_LIBS := Db Com
|
||||
PROD := subtool dbLoadTemplate
|
||||
|
||||
endif
|
||||
|
||||
|
||||
@@ -4,10 +4,13 @@ include $(TOP)/config/CONFIG_BASE
|
||||
YACCOPT = -l
|
||||
LEXOPT = -L
|
||||
|
||||
SRCS.c = dbLoadTemplate_lex.c dbLoadTemplate.c \
|
||||
dbLoadRecords_lex.c dbLoadRecords.c ../BSlib.c ../PVSvx.c ../vx_stats.c ../client_stats.c
|
||||
SRCS.c = dbLoadTemplate_lex.c
|
||||
SRCS.c += dbLoadTemplate.c
|
||||
SRCS.c += dbLoadRecords_lex.c
|
||||
SRCS.c += dbLoadRecords.c
|
||||
|
||||
LIBOBJS = dbLoadTemplate.o dbLoadRecords.o BSlib.o PVSvx.o vx_stats.o client_stats.o
|
||||
LIBOBJS = dbLoadTemplate.o
|
||||
LIBOBJS += dbLoadRecords.o
|
||||
|
||||
LIBNAME = dbSubs
|
||||
|
||||
@@ -19,8 +22,6 @@ include $(TOP)/config/RULES.Vx
|
||||
|
||||
USR_CFLAGS = -I../../rsrv -I../../ca
|
||||
|
||||
#dbLoadTemplate.o: dbLoadTemplate_lex.c dbLoadTemplate.c
|
||||
#dbLoadRecords.o: dbLoadRecords_lex.c dbLoadRecords.c
|
||||
dbLoadTemplate.o: dbLoadTemplate_lex.c
|
||||
dbLoadRecords.o: dbLoadRecords_lex.c
|
||||
subtool: dbLoadTemplate_lex.c
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef __PVS_H
|
||||
#define __PVS_H
|
||||
|
||||
#include "BSlib.h"
|
||||
|
||||
#define PVS_RETRY_COUNT 4
|
||||
#define PVS_TRANSFER_SIZE 1024
|
||||
#define PVS_UDP 17
|
||||
#define PVS_TCP 6
|
||||
#define PVS_UDP_PORT 50298
|
||||
#define PVS_TCP_PORT 50299
|
||||
#define PVS_UDP_CPORT 50300
|
||||
|
||||
#define PVS_Data (BS_LAST_VERB+1)
|
||||
#define PVS_Alive (BS_LAST_VERB+2)
|
||||
#define PVS_RecList (BS_LAST_VERB+3)
|
||||
#define PVS_AppList (BS_LAST_VERB+4)
|
||||
#define PVS_RecDump (BS_LAST_VERB+5)
|
||||
|
||||
#define PVS_LAST_VERB PVS_RecDump
|
||||
|
||||
struct pvs_info_packet
|
||||
{
|
||||
unsigned short cmd;
|
||||
char text[90];
|
||||
};
|
||||
typedef struct pvs_info_packet PVS_INFO_PACKET;
|
||||
|
||||
#define PVS_SET_CMD(pvs_info,command) (pvs_info)->cmd=htons(command)
|
||||
|
||||
#endif
|
||||
@@ -1,263 +0,0 @@
|
||||
|
||||
/* only runable on work station now */
|
||||
|
||||
#include "PVS.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct PVSnode
|
||||
{
|
||||
BSDATA info;
|
||||
int alive;
|
||||
struct PVSnode* next;
|
||||
};
|
||||
typedef struct PVSnode PVSNODE;
|
||||
|
||||
static PVSNODE* ioc_list = (PVSNODE*)NULL;
|
||||
|
||||
static int read_pvs(BSDATA* info,int serv,char* sname);
|
||||
|
||||
#ifndef PVS_SERVER_PROG
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
BSDATA info;
|
||||
int serv;
|
||||
int rc;
|
||||
|
||||
if(argc<4)
|
||||
{
|
||||
fprintf(stderr,"usage: %s IOC-name server-number [server-name]\n",
|
||||
argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
serv=atoi(argv[2]);
|
||||
BSsetAddress(&info,argv[1]);
|
||||
|
||||
if(serv>PVS_LAST_VERB)
|
||||
rc=read_pvs(&info,serv,argv[3]);
|
||||
else
|
||||
rc=read_pvs(&info,serv,(char*)NULL);
|
||||
|
||||
if(rc<0) fprintf(stderr,"read of data failed horribly\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
int soc,mlen;
|
||||
unsigned short buf,in_buf,ping;
|
||||
BSDATA info;
|
||||
PVSNODE* node;
|
||||
|
||||
if(BSmakeServer(argv)<0)
|
||||
{
|
||||
fprintf(stderr,"Cannot make into a server\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((soc=BSopenListenerUDP(PVS_UDP_PORT))<0)
|
||||
{
|
||||
fprintf(stderr,"Open of UDP listener socket failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf=htons(BS_Ok); /* always sends this out */
|
||||
ping=htons(BS_Ping); /* always sends this out */
|
||||
|
||||
while(1)
|
||||
{
|
||||
/* wait forever until a message comes in */
|
||||
|
||||
mlen=BSreadUDP(soc,&info,7,&in_buf,sizeof(in_buf));
|
||||
|
||||
/* check for errors */
|
||||
switch(mlen)
|
||||
{
|
||||
case 0: /* timeout */
|
||||
printf("Why did a timeout occur?\n");
|
||||
/* send out a ping to each of the IOCs in the ioc_list */
|
||||
for(node=ioc_list;node;node=node->next)
|
||||
{
|
||||
mlen=BStransUDP(soc,&(node->info),&ping,sizeof(ping),
|
||||
&in_buf,sizeof(in_buf));
|
||||
|
||||
/* check for errors */
|
||||
switch(mlen)
|
||||
{
|
||||
case 0: /* timeout */
|
||||
printf("IOC dead\n");
|
||||
node->alive=0;
|
||||
break;
|
||||
case -1: /* error */
|
||||
printf("Communications failed\n");
|
||||
break;
|
||||
default: /* ok */
|
||||
if(node->alive==0)
|
||||
{
|
||||
switch(fork())
|
||||
{
|
||||
case -1: /* error */
|
||||
perror("fork failure");
|
||||
break;
|
||||
case 0: /* child */
|
||||
close(soc);
|
||||
BSserverClearSignals();
|
||||
sleep(1);
|
||||
if(read_pvs(&(node->info))==0)
|
||||
node->alive=1;
|
||||
default: /* parent */
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case -1: /* error */
|
||||
fprintf(stderr,"Communications failure\n");
|
||||
break;
|
||||
default: /* ok */
|
||||
if(BSwriteUDP(soc,&info,&buf,sizeof(buf))<0)
|
||||
fprintf(stderr,"respone send failed\n");
|
||||
else
|
||||
{
|
||||
node=(PVSNODE*)malloc(sizeof(PVSNODE));
|
||||
node->alive=1;
|
||||
node->info=info;
|
||||
BSsetPort(&(node->info),PVS_UDP_CPORT);
|
||||
node->next=ioc_list;
|
||||
ioc_list=node;
|
||||
|
||||
switch(fork())
|
||||
{
|
||||
case -1: /* error */
|
||||
perror("fork failure");
|
||||
break;
|
||||
case 0: /* child */
|
||||
close(soc);
|
||||
BSserverClearSignals();
|
||||
sleep(1);
|
||||
return read_pvs(&info,PVS_RecList,NULL);
|
||||
default: /* parent */
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
close(soc);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int read_pvs(BSDATA* info,int serv,char* sname)
|
||||
{
|
||||
BS* bs;
|
||||
int verb,size,done,len,i,port,rsize;
|
||||
char* buffer;
|
||||
char ip_from[40];
|
||||
FILE* fd;
|
||||
|
||||
BSgetAddressPort(info,ip_from,&port);
|
||||
|
||||
/* printf("IOC %s starting\n",ip_from); */
|
||||
|
||||
/* verify ioc not already added */
|
||||
if(access(ip_from,F_OK)==0)
|
||||
{
|
||||
/* delete the existing file for this IOC */
|
||||
unlink(ip_from);
|
||||
}
|
||||
|
||||
done=0;
|
||||
BSsetPort(info,PVS_TCP_PORT);
|
||||
|
||||
if((bs=BSipOpenData(info))==NULL)
|
||||
{
|
||||
fprintf(stderr,"Open of socket to IOC failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(serv>PVS_LAST_VERB)
|
||||
rsize=strlen(sname)+1;
|
||||
else
|
||||
rsize=0;
|
||||
|
||||
if(BSsendHeader(bs,serv,rsize)<0)
|
||||
{
|
||||
fprintf(stderr,"Command send failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(rsize>0)
|
||||
{
|
||||
if(BSsendData(bs,sname,rsize)<0)
|
||||
{
|
||||
fprintf(stderr,"send of command name failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PVS_SERVER_PROG
|
||||
if((fd=fopen(ip_from,"w"))==(FILE*)NULL)
|
||||
{
|
||||
fprintf(stderr,"Open of name file failed\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
fd=stdout;
|
||||
#endif
|
||||
|
||||
buffer=(char*)malloc(PVS_TRANSFER_SIZE+2);
|
||||
|
||||
while(done==0)
|
||||
{
|
||||
if(BSreceiveHeader(bs,&verb,&size)<0)
|
||||
{
|
||||
fprintf(stderr,"Receive header failed\n");
|
||||
done=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(verb)
|
||||
{
|
||||
case PVS_Data: /* read a block of names */
|
||||
if((len=BSreceiveData(bs,buffer,size))<0)
|
||||
{
|
||||
fprintf(stderr,"Receive data failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
if(buffer[i]==' ') buffer[i]='\n';
|
||||
}
|
||||
buffer[len]='\n';
|
||||
buffer[len+1]='\0';
|
||||
|
||||
fputs(buffer,fd);
|
||||
}
|
||||
break;
|
||||
case BS_Done: /* transfers complete */
|
||||
BSclose(bs);
|
||||
done=-1;
|
||||
break;
|
||||
default:
|
||||
if(size>0) done=-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PVS_SERVER_PROG
|
||||
fclose(fd);
|
||||
#endif
|
||||
free(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,361 +0,0 @@
|
||||
|
||||
/* This file not really set up to run under Unix yet, just under vxWorks. */
|
||||
|
||||
#include "PVS.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <iv.h>
|
||||
#include <taskLib.h>
|
||||
#include <sysSymTbl.h>
|
||||
#include <sysLib.h>
|
||||
#include <symLib.h>
|
||||
#include <dbStaticLib.h>
|
||||
|
||||
extern struct dbBase *pdbbase;
|
||||
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
static void PVSserver(int want_annouce,char* name);
|
||||
static int PVSannouce(int want_annouce,char* name);
|
||||
static void handle_requests(BS* bs);
|
||||
static void handle_reclist(BS* bs);
|
||||
static void handle_applist(BS* bs);
|
||||
static void handle_recdump(BS* bs);
|
||||
static void handle_spylist(BS* bs);
|
||||
static void handle_tasklist(BS* bs);
|
||||
void PVS_test_server(BS* bs);
|
||||
|
||||
static char* names = (char*)NULL;
|
||||
static char* buffer = (char*)NULL;
|
||||
|
||||
#ifdef vxWorks
|
||||
int PVSstart(int want_annouce, char* name)
|
||||
#else
|
||||
int main(int argc,char** argv)
|
||||
#endif
|
||||
{
|
||||
#ifndef vxWorks
|
||||
char* name;
|
||||
int want_annouce;
|
||||
#endif
|
||||
|
||||
#ifndef vxWorks
|
||||
if(argc<3)
|
||||
{
|
||||
fprintf(stderr,"bad args\n");
|
||||
fprintf(stderr," usage: %s a_flag host_name\n",
|
||||
argv[0]);
|
||||
fprintf(stderr," where\n");
|
||||
fprintf(stderr," a_flag=0(want),1(don't want) to annouce boot\n");
|
||||
fprintf(stderr," host_name=PV master host (if one exists)\n");
|
||||
return -1;
|
||||
}
|
||||
name=argv[2];
|
||||
if(sscanf(argv[1],"%d",&want_annouce)<1)
|
||||
{
|
||||
fprintf(stderr,"bad a_flag\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
taskSpawn("PVS",150,VX_FP_TASK|VX_STDIO,5000,
|
||||
(FUNCPTR)PVSserver,want_annouce,(int)name,0,0,0,0,0,0,0,0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int PVSannouce(int want_annouce,char* name)
|
||||
{
|
||||
int soc,mlen;
|
||||
PVS_INFO_PACKET buf,in_buf;
|
||||
BSDATA info;
|
||||
|
||||
if(want_annouce==0 && name)
|
||||
{
|
||||
if((soc=BSopenListenerUDP(0))<0)
|
||||
{
|
||||
printf("Open of UDP socket failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(BSsetAddressPort(&info,name,PVS_UDP_PORT)<0)
|
||||
{
|
||||
printf("Set send port failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
PVS_SET_CMD(&buf,PVS_Alive);
|
||||
mlen=BStransUDP(soc,&info,&buf,sizeof(buf),&in_buf,sizeof(in_buf));
|
||||
|
||||
/* check for errors */
|
||||
switch(mlen)
|
||||
{
|
||||
case 0: /* timeout */
|
||||
printf("No server running on host\n");
|
||||
break;
|
||||
case -1: /* error */
|
||||
printf("Communications failed\n");
|
||||
break;
|
||||
default: /* ok */
|
||||
break;
|
||||
}
|
||||
|
||||
close(soc);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void PVSserver(int want_annouce,char* name)
|
||||
{
|
||||
fd_set fds,rfds;
|
||||
int tsoc,usoc,nsoc,len;
|
||||
struct sockaddr stemp;
|
||||
int stemp_len;
|
||||
PVS_INFO_PACKET buf;
|
||||
BSDATA info;
|
||||
BS* bs;
|
||||
|
||||
bs=(BS*)NULL;
|
||||
buffer=(char*)malloc(100); /* just make the buffer */
|
||||
names=(char*)malloc(PVS_TRANSFER_SIZE);
|
||||
|
||||
if((tsoc=BSopenListenerTCP(PVS_TCP_PORT))<0)
|
||||
{
|
||||
printf("PVSserver: Open of TCP listener socket failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if((usoc=BSopenListenerUDP(PVS_UDP_CPORT))<0)
|
||||
{
|
||||
printf("PVSserver: Open of UDP listener socket failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(tsoc,&fds);
|
||||
FD_SET(usoc,&fds);
|
||||
|
||||
PVSannouce(want_annouce,name);
|
||||
|
||||
while(1)
|
||||
{
|
||||
rfds=fds;
|
||||
if(select(FD_SETSIZE,&rfds,(fd_set*)NULL,(fd_set*)NULL,
|
||||
(struct timeval*)NULL)<0)
|
||||
{
|
||||
printf("PVSserver: Select failure\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FD_ISSET(tsoc,&rfds))
|
||||
{
|
||||
/* handle the request here - single threaded server */
|
||||
|
||||
stemp_len=sizeof(stemp);
|
||||
if((nsoc=accept(tsoc,&stemp,&stemp_len))<0)
|
||||
printf("PVSserver: Bad accept\n");
|
||||
else
|
||||
{
|
||||
bs=BSmakeBS(nsoc);
|
||||
handle_requests(bs);
|
||||
BSfreeBS(bs);
|
||||
}
|
||||
}
|
||||
if(FD_ISSET(usoc,&rfds))
|
||||
{
|
||||
/* only pings will come in here for now */
|
||||
len=BSreadUDP(usoc,&info,0,&buf,sizeof(buf));
|
||||
if(len<=0)
|
||||
printf("PVSserver: UDP listener read failure\n");
|
||||
else
|
||||
{
|
||||
if(BSwriteUDP(usoc,&info,&buf,sizeof(buf))<0)
|
||||
printf("PVSserver: UDP listener ping write failure\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_reclist(BS* bs)
|
||||
{
|
||||
DBENTRY db;
|
||||
long rc;
|
||||
char* n;
|
||||
unsigned long names_len;
|
||||
int s;
|
||||
|
||||
dbInitEntry(pdbbase,&db);
|
||||
names_len=0;
|
||||
|
||||
for(rc=dbFirstRecordType(&db);rc==0;rc=dbNextRecordType(&db))
|
||||
{
|
||||
for(rc=dbFirstRecord(&db);rc==0;rc=dbNextRecord(&db))
|
||||
{
|
||||
/* collect the names util we excede the max */
|
||||
n=dbGetRecordName(&db);
|
||||
s=strlen(n);
|
||||
if((names_len+s)>PVS_TRANSFER_SIZE)
|
||||
{
|
||||
names[names_len++]='\0';
|
||||
if(BSsendHeader(bs,PVS_Data,names_len)<0)
|
||||
printf("PVSserver: data cmd failed\n");
|
||||
else
|
||||
{
|
||||
if(BSsendData(bs,names,names_len)<0)
|
||||
printf("PVSserver: data send failed\n");
|
||||
}
|
||||
names_len=0;
|
||||
}
|
||||
memcpy(&names[names_len],n,s);
|
||||
names_len+=s;
|
||||
names[names_len++]=' ';
|
||||
}
|
||||
}
|
||||
if(names_len>0)
|
||||
{
|
||||
names[names_len++]='\0';
|
||||
if(BSsendHeader(bs,PVS_Data,names_len)<0)
|
||||
printf("PVSserver: data cmd failed\n");
|
||||
else
|
||||
{
|
||||
if(BSsendData(bs,names,names_len)<0)
|
||||
printf("PVSserver: data send failed\n");
|
||||
}
|
||||
}
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
|
||||
static void handle_requests(BS* bs)
|
||||
{
|
||||
int verb,size,notdone,len;
|
||||
void (*func)(BS*);
|
||||
SYM_TYPE stype;
|
||||
|
||||
notdone=1;
|
||||
while(notdone)
|
||||
{
|
||||
/* at this point I should be getting a command */
|
||||
if(BSreceiveHeader(bs,&verb,&size)<0)
|
||||
{
|
||||
printf("PVSserver: receive header failed\n");
|
||||
notdone=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(verb)
|
||||
{
|
||||
case PVS_RecList: handle_reclist(bs); break;
|
||||
case PVS_AppList: handle_applist(bs); break;
|
||||
case PVS_RecDump: handle_recdump(bs); break;
|
||||
case BS_Close:
|
||||
BSsendHeader(bs,BS_Ok,0);
|
||||
notdone=0;
|
||||
break;
|
||||
case PVS_Data: break;
|
||||
case PVS_Alive: break;
|
||||
case BS_Ok: break;
|
||||
case BS_Error: break;
|
||||
case BS_Ping: break;
|
||||
case BS_Done: break;
|
||||
default:
|
||||
/* custom service */
|
||||
if(size>0)
|
||||
{
|
||||
/* this should be the name of the service */
|
||||
/* look up the symbol name in buffer and call as
|
||||
subroutine, passing it the BS */
|
||||
|
||||
len=BSreceiveData(bs,&buffer[1],size);
|
||||
switch(len)
|
||||
{
|
||||
case 0: /* timeout */ notdone=0; break;
|
||||
case -1: /* error */ notdone=0; break;
|
||||
default:
|
||||
buffer[0]='_';
|
||||
|
||||
if(strncmp(buffer,"_PVS",4)==0)
|
||||
{
|
||||
if(symFindByName(sysSymTbl,buffer,
|
||||
(char**)&func,&stype)==ERROR)
|
||||
func=(void (*)(BS*))NULL;
|
||||
|
||||
if(func)
|
||||
func(bs);
|
||||
else
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
else
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
}
|
||||
else
|
||||
printf("PVSserver: unknown command received\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
struct dbnode
|
||||
{
|
||||
char* name;
|
||||
struct dbnode* next;
|
||||
};
|
||||
typedef struct dbnode DBNODE;
|
||||
|
||||
extern DBNODE* DbApplList;
|
||||
|
||||
void handle_applist(BS* bs)
|
||||
{
|
||||
DBNODE* n;
|
||||
int len;
|
||||
|
||||
len=0;
|
||||
for(n=DbApplList;n;n=n->next)
|
||||
{
|
||||
len=strlen(n->name)+1;
|
||||
|
||||
if(BSsendHeader(bs,PVS_Data,len)<0)
|
||||
printf("PVSserver: data cmd failed\n");
|
||||
else
|
||||
{
|
||||
if(BSsendData(bs,n->name,len)<0)
|
||||
printf("PVSserver: data send failed\n");
|
||||
}
|
||||
}
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
void handle_recdump(BS* bs)
|
||||
{
|
||||
printf("RecDump server invoked\n");
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
|
||||
void PVS_test_server(BS* bs)
|
||||
{
|
||||
printf("PVS_test_server invoked\n");
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
|
||||
void handle_spylist(BS* bs)
|
||||
{
|
||||
printf("PVS spy list server invoked\n");
|
||||
}
|
||||
|
||||
void handle_tasklist(BS* bs)
|
||||
{
|
||||
printf("PVS task list server invoked\n");
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
BSlib, PVSlib and client_stats are all no used.
|
||||
Should be removed completely next release
|
||||
|
||||
Get rid of PVS server stuff in the IOC. Replace it with RPC/XDR.
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
|
||||
/*
|
||||
You must run PVSstart() in your vxWorks startup script before these
|
||||
functions can be used.
|
||||
|
||||
Just ld() the object file for this code in your vxWorks startup script.
|
||||
|
||||
Services added in this file:
|
||||
PVS_MemStats - Send the bytes free and allocated to the requestor.
|
||||
PVS_ClientStats - Send a CA client statistics summary report to
|
||||
the requestor. Includes host name, user id, number of channels
|
||||
in use.
|
||||
PVS_TaskList - Send a report of all the tasks in the IOC, along
|
||||
with there state and priority.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vxWorks.h>
|
||||
#include <iv.h>
|
||||
#include <taskLib.h>
|
||||
#include <memLib.h>
|
||||
#include <private/memPartLibP.h> /* sucks, don't it */
|
||||
|
||||
/* required for client stat section */
|
||||
#include <sockLib.h>
|
||||
#include <socket.h>
|
||||
#include <in.h>
|
||||
#include <ellLib.h>
|
||||
#include <server.h>
|
||||
|
||||
#include "PVS.h"
|
||||
|
||||
void PVS_ClientStats(BS* bs)
|
||||
{
|
||||
int len;
|
||||
char line[120];
|
||||
struct client *pclient;
|
||||
|
||||
/* report columns:
|
||||
client_host_name client_login_id number_of_channels
|
||||
*/
|
||||
|
||||
LOCK_CLIENTQ;
|
||||
pclient = (struct client *) ellFirst(&clientQ);
|
||||
while (pclient)
|
||||
{
|
||||
sprintf(line,"%s %s %d\n",
|
||||
pclient->pHostName, pclient->pUserName, ellCount(&pclient->addrq));
|
||||
len=strlen(line)+1;
|
||||
|
||||
if(BSsendHeader(bs,PVS_Data,len)<0)
|
||||
printf("PVSserver: data cmd failed\n");
|
||||
else
|
||||
{
|
||||
if(BSsendData(bs,line,len)<0)
|
||||
printf("PVSserver: data send failed\n");
|
||||
}
|
||||
pclient = (struct client *) ellNext(&pclient->node);
|
||||
}
|
||||
UNLOCK_CLIENTQ;
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
|
||||
#include "PVS.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int read_data(BSDATA* info,char* service_name);
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
BSDATA info;
|
||||
int rc;
|
||||
|
||||
if(argc<3)
|
||||
{
|
||||
fprintf(stderr,"usage: %s IOC-name service-name\n",argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
BSsetAddress(&info,argv[1]);
|
||||
rc=read_data(&info,argv[2]);
|
||||
if(rc<0) fprintf(stderr,"read of data failed horribly\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_data(BSDATA* info,char* sname)
|
||||
{
|
||||
BS* bs;
|
||||
int verb,size,done,len,i,port,rsize;
|
||||
char* buffer;
|
||||
char ip_from[40];
|
||||
FILE* fd;
|
||||
|
||||
BSgetAddressPort(info,ip_from,&port);
|
||||
BSsetPort(info,PVS_TCP_PORT);
|
||||
done=0;
|
||||
rsize=strlen(sname)+1;
|
||||
fd=stdout;
|
||||
|
||||
if((bs=BSipOpenData(info))==NULL)
|
||||
{
|
||||
fprintf(stderr,"Open of socket to IOC failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(BSsendHeader(bs,9999,rsize)<0)
|
||||
{
|
||||
fprintf(stderr,"Command send failed\n");
|
||||
return -1;
|
||||
}
|
||||
if(rsize>0)
|
||||
{
|
||||
if(BSsendData(bs,sname,rsize)<0)
|
||||
{
|
||||
fprintf(stderr,"send of command name failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
buffer=(char*)malloc(PVS_TRANSFER_SIZE+2);
|
||||
|
||||
while(done==0)
|
||||
{
|
||||
if(BSreceiveHeader(bs,&verb,&size)<0)
|
||||
{
|
||||
fprintf(stderr,"Receive header failed\n");
|
||||
done=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(verb)
|
||||
{
|
||||
case PVS_Data: /* read a block of names */
|
||||
if((len=BSreceiveData(bs,buffer,size))<0)
|
||||
fprintf(stderr,"Receive data failed\n");
|
||||
else
|
||||
{
|
||||
/* buffer[len]='\n'; */
|
||||
buffer[len+1]='\0';
|
||||
fputs(buffer,fd);
|
||||
}
|
||||
break;
|
||||
case BS_Done: /* transfers complete */
|
||||
BSclose(bs);
|
||||
done=-1;
|
||||
break;
|
||||
default:
|
||||
if(size>0) done=-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
|
||||
/* only runable on work station now */
|
||||
|
||||
#include "PVS.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int read_pvs(BSDATA* info,int serv,char* sname);
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
BSDATA info;
|
||||
int rc;
|
||||
|
||||
if(argc<2)
|
||||
{
|
||||
fprintf(stderr,"usage: %s IOC-ip-address\n",argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(BSsetAddress(&info,argv[1])<0)
|
||||
{
|
||||
fprintf(stderr,"Cannot determine address for %s\n",argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc=read_pvs(&info,PVS_AppList,(char*)NULL);
|
||||
|
||||
if(rc<0) fprintf(stderr,"read of data failed horribly\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_pvs(BSDATA* info,int serv,char* sname)
|
||||
{
|
||||
BS* bs;
|
||||
int verb,size,done,len,i,port,rsize;
|
||||
char* buffer;
|
||||
char ip_from[40];
|
||||
FILE* fd;
|
||||
|
||||
BSgetAddressPort(info,ip_from,&port);
|
||||
|
||||
/* verify ioc not already added */
|
||||
if(access(ip_from,F_OK)==0)
|
||||
{
|
||||
/* delete the existing file for this IOC */
|
||||
unlink(ip_from);
|
||||
}
|
||||
|
||||
done=0;
|
||||
BSsetPort(info,PVS_TCP_PORT);
|
||||
|
||||
if((bs=BSipOpenData(info))==NULL)
|
||||
{
|
||||
fprintf(stderr,"Open of socket to IOC failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(serv>PVS_LAST_VERB)
|
||||
rsize=strlen(sname)+1;
|
||||
else
|
||||
rsize=0;
|
||||
|
||||
if(BSsendHeader(bs,serv,rsize)<0)
|
||||
{
|
||||
fprintf(stderr,"Command send failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(rsize>0)
|
||||
{
|
||||
if(BSsendData(bs,sname,rsize)<0)
|
||||
{
|
||||
fprintf(stderr,"send of command name failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
fd=stdout;
|
||||
buffer=(char*)malloc(PVS_TRANSFER_SIZE+2);
|
||||
|
||||
while(done==0)
|
||||
{
|
||||
if(BSreceiveHeader(bs,&verb,&size)<0)
|
||||
{
|
||||
fprintf(stderr,"Receive header failed\n");
|
||||
done=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(verb)
|
||||
{
|
||||
case PVS_Data: /* read a block of names */
|
||||
if((len=BSreceiveData(bs,buffer,size))<0)
|
||||
fprintf(stderr,"Receive data failed\n");
|
||||
else
|
||||
fputs(buffer,fd);
|
||||
fputc('\n',fd);
|
||||
break;
|
||||
case BS_Done: /* transfers complete */
|
||||
BSclose(bs);
|
||||
done=-1;
|
||||
break;
|
||||
default:
|
||||
if(size>0) done=-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
|
||||
/* only runable on work station now */
|
||||
|
||||
#include "PVS.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int read_pvs(BSDATA* info,int serv,char* sname);
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
BSDATA info;
|
||||
int rc;
|
||||
|
||||
if(argc<2)
|
||||
{
|
||||
fprintf(stderr,"usage: %s IOC-ip-address\n",argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(BSsetAddress(&info,argv[1])<0)
|
||||
{
|
||||
fprintf(stderr,"Cannot determine address for %s\n",argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc=read_pvs(&info,PVS_RecList,(char*)NULL);
|
||||
|
||||
if(rc<0) fprintf(stderr,"read of data failed horribly\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_pvs(BSDATA* info,int serv,char* sname)
|
||||
{
|
||||
BS* bs;
|
||||
int verb,size,done,len,i,port,rsize;
|
||||
char* buffer;
|
||||
char ip_from[40];
|
||||
FILE* fd;
|
||||
|
||||
BSgetAddressPort(info,ip_from,&port);
|
||||
|
||||
/* printf("IOC %s starting\n",ip_from); */
|
||||
|
||||
/* verify ioc not already added */
|
||||
if(access(ip_from,F_OK)==0)
|
||||
{
|
||||
/* delete the existing file for this IOC */
|
||||
unlink(ip_from);
|
||||
}
|
||||
|
||||
done=0;
|
||||
BSsetPort(info,PVS_TCP_PORT);
|
||||
|
||||
if((bs=BSipOpenData(info))==NULL)
|
||||
{
|
||||
fprintf(stderr,"Open of socket to IOC failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(serv>PVS_LAST_VERB)
|
||||
rsize=strlen(sname)+1;
|
||||
else
|
||||
rsize=0;
|
||||
|
||||
if(BSsendHeader(bs,serv,rsize)<0)
|
||||
{
|
||||
fprintf(stderr,"Command send failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(rsize>0)
|
||||
{
|
||||
if(BSsendData(bs,sname,rsize)<0)
|
||||
{
|
||||
fprintf(stderr,"send of command name failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
fd=stdout;
|
||||
buffer=(char*)malloc(PVS_TRANSFER_SIZE+2);
|
||||
|
||||
while(done==0)
|
||||
{
|
||||
if(BSreceiveHeader(bs,&verb,&size)<0)
|
||||
{
|
||||
fprintf(stderr,"Receive header failed\n");
|
||||
done=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(verb)
|
||||
{
|
||||
case PVS_Data: /* read a block of names */
|
||||
if((len=BSreceiveData(bs,buffer,size))<0)
|
||||
{
|
||||
fprintf(stderr,"Receive data failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
if(buffer[i]==' ') buffer[i]='\n';
|
||||
}
|
||||
buffer[len]='\n';
|
||||
buffer[len+1]='\0';
|
||||
|
||||
fputs(buffer,fd);
|
||||
}
|
||||
break;
|
||||
case BS_Done: /* transfers complete */
|
||||
BSclose(bs);
|
||||
done=-1;
|
||||
break;
|
||||
default:
|
||||
if(size>0) done=-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
|
||||
/*
|
||||
You must run PVSstart() in your vxWorks startup script before these
|
||||
functions can be used.
|
||||
|
||||
Just ld() the object file for this code in your vxWorks startup script.
|
||||
|
||||
Services added in this file:
|
||||
PVS_MemStats - Send the bytes free and allocated to the requestor.
|
||||
PVS_ClientStats - Send a CA client statistics summary report to
|
||||
the requestor. Includes host name, user id, number of channels
|
||||
in use.
|
||||
PVS_TaskList - Send a report of all the tasks in the IOC, along
|
||||
with there state and priority.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vxWorks.h>
|
||||
#include <iv.h>
|
||||
#include <taskLib.h>
|
||||
#include <memLib.h>
|
||||
#include <private/memPartLibP.h> /* sucks, don't it */
|
||||
|
||||
/* required for client stat section */
|
||||
#include <sockLib.h>
|
||||
#include <socket.h>
|
||||
#include <in.h>
|
||||
#include <dbStaticLib.h>
|
||||
|
||||
#include "PVS.h"
|
||||
|
||||
#define MAX_TASK 100
|
||||
|
||||
extern struct dbBase *pdbbase;
|
||||
static int* task_list=NULL;
|
||||
|
||||
void PVS_MemStats(BS* bs)
|
||||
{
|
||||
int len;
|
||||
unsigned long b_free, b_alloc;
|
||||
char line[100];
|
||||
|
||||
b_free=2*(memSysPartId->totalWords-memSysPartId->curWordsAllocated);
|
||||
b_alloc=2*memSysPartId->curWordsAllocated;
|
||||
|
||||
/* report columns:
|
||||
bytes_free bytes allocated
|
||||
*/
|
||||
|
||||
sprintf(line,"%lu %lu\n",b_free,b_alloc);
|
||||
len=strlen(line)+1;
|
||||
|
||||
if(BSsendHeader(bs,PVS_Data,len)<0)
|
||||
printf("PVSserver: data cmd failed\n");
|
||||
else
|
||||
{
|
||||
if(BSsendData(bs,line,len)<0)
|
||||
printf("PVSserver: data send failed\n");
|
||||
}
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
|
||||
void PVS_TaskList(BS* bs)
|
||||
{
|
||||
int len,i,tot,pri;
|
||||
char line[100];
|
||||
char state[30];
|
||||
char* name;
|
||||
|
||||
if(task_list==NULL)
|
||||
task_list=(int*)malloc(sizeof(int)*MAX_TASK);
|
||||
|
||||
if((tot=taskIdListGet(task_list,MAX_TASK))==0)
|
||||
{
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* report columns:
|
||||
name_of_task state_of_task priority of task
|
||||
*/
|
||||
|
||||
for(i=0;i<tot;i++)
|
||||
{
|
||||
if((name=taskName(task_list[i]))==NULL) continue;
|
||||
if((taskPriorityGet(task_list[i],&pri))==ERROR) continue;
|
||||
if((taskStatusString(task_list[i],state))==ERROR) continue;
|
||||
|
||||
sprintf(line,"%s %s %d\n",name,state,pri);
|
||||
len=strlen(line)+1;
|
||||
|
||||
if(BSsendHeader(bs,PVS_Data,len)<0)
|
||||
printf("PVSserver: data cmd failed\n");
|
||||
else
|
||||
{
|
||||
if(BSsendData(bs,line,len)<0)
|
||||
printf("PVSserver: data send failed\n");
|
||||
}
|
||||
}
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void PVS_FieldList(BS* bs)
|
||||
{
|
||||
DBENTRY dbe;
|
||||
char buffer[50]; /* max size of a PV */
|
||||
char *name,*value;
|
||||
int size,verb;
|
||||
long rc,len;
|
||||
|
||||
if(BSreceiveHeader(bs,&verb,&size)<0)
|
||||
{
|
||||
printf("PVS_FieldList(): Receive header failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(verb)
|
||||
{
|
||||
case PVS_Data:
|
||||
/* read the PV name */
|
||||
if((len=BSreceiveData(bs,buffer,size))<0)
|
||||
fprintf(stderr,"PVS_FieldList(): Receive data failed\n");
|
||||
else
|
||||
{
|
||||
if(ptr=strchr(buffer,'.')) *ptr='\0';
|
||||
|
||||
dbInitEntry(pdbbase,&dbe);
|
||||
dbFindRecord(&dbe,buffer);
|
||||
|
||||
for(rc=dbFirstFielddes(&dbe,FALSE); rc==0;
|
||||
rc=dbNextFieldDes(&dbe,FALSE))
|
||||
{
|
||||
name=dbGetFieldName(&dbe);
|
||||
value=dbGetString(&dbe);
|
||||
printf("name=<%s>, value=<%s>\n",name,value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"PVS_FieldList(): Unknown packet received\n");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
BSsendHeader(bs,BS_Done,0);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user