Commit ddc600fc authored by Claudio Scafuri's avatar Claudio Scafuri 💬
Browse files

imported from CVS repo

parent ffda550b
.pydevproject
.project
.cproject
.settings
obj
bin
core*
*~
*.pyc
*.so
*.so*
*.a
*.o
.pylintrc
.metadata
.idea
.cvsignore
.nse_depinfo
software
oldsrc
CVS
*_defs.h
*_server.c
*_client.c
*_support.c
# makefile for rpc error report utilities
REL_PATH=../
include ../Make.in
CFLAGS += $(ANSI) $(OPTIM) -I $(ELETTRA_INC) $(CCOPTS)
LIBS = -L $(ELETTRA_LIB) -lnc
RANLIB = ranlib
OBJS = rpc_perror.o lpcerror.o
SRCS = test_error.c rpc_perror.c lpcerror.c
BASELIBNAME = librpcutil
# most important parameter - builds the dt_soname / internal name of the library
LIBVERSION = 1
LIBRELEASE = 1
LIBRARY = $(BASELIBNAME).a
DT_SONAME = $(BASELIBNAME).$(SHLIB_SUFFIX).$(LIBVERSION).$(LIBRELEASE)
SHLIB = $(BASELIBNAME).$(SHLIB_SUFFIX)
target: archive shared
archive: $(LIBRARY)
shared: $(DT_SONAME)
test: test_error
all :target
$(LIBRARY): $(OBJS)
rm -f librpcutil.a
ar -r librpcutil.a $(OBJS)
$(DT_SONAME): $(OBJS) $(MAKEFILE)
@echo "Creating $(DT_SONAME) ...$(OBJS)"
$(CLD) $(LDFLAGS) $(LFLAGS_SONAME)$(DT_SONAME) -o $(DT_SONAME) $(OBJS)
ln -sf $(DT_SONAME) $(SHLIB)
ln -sf $(DT_SONAME) $(SHLIB).$(LIBVERSION)
@echo "done"
test_error: test_error.o $(OBJS)
$(CC) $(CFLAGS) test_error.o -L. -lrpcutil $(TRANSITIONLIB) $(LIBS) -o test_error
test_error.o:
$(CC) $(CFLAGS) -c test_error.c
rpc_error.o: cuherrt.h $(SOBJS)
$(CC) $(CFLAGS) -c rpc_error.c
lpcerror.o: lpcerror.h
$(CC) $(CFLAGS) -c lpcerror.c
clean:
rm -f *.o
rm -f core a.out
distclean: clean
rm -f test_error
rm -f $(LIBRARY) $(SHLIB) $(DT_SONAME)
install: $(DT_SONAME) $(LIBRARY)
$(INSTALL) $(DT_SONAME) $(ELETTRA_LIB); \
ln -sf $(DT_SONAME) $(ELETTRA_LIB)/$(SHLIB)
ln -sf $(DT_SONAME) $(ELETTRA_LIB)/$(SHLIB).$(LIBVERSION)
chmod 755 $(ELETTRA_LIB)/$(DT_SONAME);\
#$(INSTALL) $(LIBRARY) $(ELETTRA_LIB); \
#chmod 755 $(ELETTRA_LIB)/$(LIBRARY);\
$(INSTALL) rpcutil.h $(ELETTRA_INC);\
chmod 644 $(ELETTRA_INC)/rpcutil.h;\
$(INSTALL) cuherrt.h $(ELETTRA_INC);\
chmod 644 $(ELETTRA_INC)/cuherrt.h;
/*
* Module Name : cuherrt.h
* System(s) : OS-9/HP-UX
*
* First Version : 18/10/91
* Last Revision : 11/08/92
*
* Modification : 11/08/92: made public and genearal for all rpc
* services, modified ECERROR and ECFATAl to allow up to 249 different
* services to recognized by error type.
*
* Description : user error type definitions
* Modifications : 24/11/92 RADIOPROT service added
*/
/* ------------------------------------------------------------------------- */
/* for more informations look the "errtype.h" file in "/dd/DEFS/RPC". */
/* for remote errors ===>>> errno = errclass + errtype */
/* error class */
/* errclass: classe dell'errore ( ECWARN, ECERROR, ECFATAL, v. errtype.h );
WARNING -> Segnalazione di un evento che non comporta un degrado
permanente della funzionalita del software;
ERROR -> La ripresa completa della funzionalita' potra' essere
effettuata solo dopo una azione da parte dell'operato-
re anche se e' possibile un funzionamento parziale;
FATAL -> Non e' garantito neanche un funzionamento degradato
della scheda.
- errtype : tipo di errore ( s.o./protocollo/applicativi/ecc... ove e avvenuto
l'errore;
*/
#ifndef CUHERRT_H_INCLUDED
#define CUHERRT_H_INCLUDED
#define ETCLAS 0
#define ECWARN (ETCLAS+0) /* warning */
#define ECERROR (ETCLAS+10500) /* error */
#define ECFATAL (ETCLAS+21000) /* fatal */
#define ETWARN ECWARN /* warning - for compatibility*/
#define ETERROR ECERROR /* error- for compatibilty */
#define ETFATAL ECFATAL /* fatal - for compatibility */
#ifndef ETAPPL
#define ETAPPL (50) /* application errors */
#endif
/* ------------------------------------------------------------------------- */
/* Error type service identifiers: each official rpc service has its
* unique service error type. This is the sole authorized list of these
* identifiers.
* error type identifiers are integers between 0 and 249.
* the global variable errtype is calculated in the following way:
* - error : errtype=ETERROR+ETservice+ETsys;
* - warning : errtype=ETWARN+ETservice+ETsys;
* - fatal : errtype=ETFATAL+ETservice+ETsys;
* ETsys: a number defined in errtype.h, used to identify the operating
* system or communication layer where the error was detected.
*/
/* ------------------------------------------------------------------------- */
/* service error type start from ETAPPL! service error codes differs by ETAPPL,
* start form ETAPPL an go up to ETAPPL*189
*/
/*====================================================================*/
/* CONTROL SERVICES */
/*====================================================================*/
#define LPC 1
#define ETLPC (ETAPPL*LPC) /* lpc service */
#define BRK 2
#define ETBRK (ETAPPL*BRK) /* brk (shared memory read broker) service */
#define MFTL 3
#define ETMFTL (ETAPPL*MFTL) /* machine file-Transefer line service */
#define RADIOPROT 4
#define ETRADIOPROT (ETAPPL*RADIOPROT) /* health phisics monitor service */
#define INJ 5
#define ETINJ (ETAPPL*INJ) /* injection magnet control server */
#define FLSC 6
#define ETFLSC (ETAPPL*FLSC) /* fluorescent screen image server */
#define CYC 7
#define ETCYC (ETAPPL*CYC) /* magnet cycling server */
#define ALM 8
#define ETALM (ETAPPL*ALM) /* alrm server */
#define VAC 9
#define ETVAC (ETAPPL*VAC) /* vacuum server */
#define BUMP 10
#define ETBUMP (ETAPPL*BUMP) /* bump server */
#define BPM 11
#define ETBPM (ETAPPL*BPM) /* BPMs server */
#define SYNCR 12
#define ETSYN (ETAPPL*SYNCR) /* SYN server */
#define SYNB 13
#define ETSYNB (ETAPPL*SYNB) /* SYNB server */
#define TUNE 14
#define ETTUNE (ETAPPL*TUNE) /* tune lpc server */
#define SCRAPTL 15
#define ETSCRAPTL (ETAPPL*SCRAPTL) /* transfer line scraper server */
#define TIME 16
#define ETTIME (ETAPPL*TIME) /* timing server */
#define CM 17
#define ETCM (ETAPPL*CM) /* current monitor server */
#define DCCT 18
#define ETDCCT (ETAPPL*DCCT) /*dcct server */
#define SCRAPSR 19
#define ETSCRAPSR (ETAPPL*SCRAPSR) /* storage ring scraper server */
/* 188 service error type numbers are available. */
#endif /*CUHERRT_H_INCLUDED*/
/*
* Description : rpc service support functions
* Type : lcp service error analysis
* Procedure : lpcerror
*
*
* Module Name : lpcerror.c
* Author(s) : Claudio Scafuri
*
*
* System(s) : UNIX System V HPUX - nc2.8
*
* First Version : 24/03/93
*/
#include <ncc.h>
#include <stdio.h>
#include <errtype.h>
#include <errno.h>
#include "cuherrt.h"
#include "lpcerror.h"
/* global buffers */
static char buffer[256]; /*buffer for output*/
static char apperr[256];
/*----------------------------------------------------------------------------*/
/* decodes errors repoted from lpc service from the field */
char *lpcerror(int err_num )
{
switch(err_num){
case ER_OPEN:
sprintf(apperr,"error on path open");
break;
case ER_IO:
sprintf(apperr,"error on system I/O");
break;
case ER_RANGE:
sprintf(apperr,"value out of range");
break;
case ER_WRITE:
sprintf(apperr,"error on write");
break;
case ER_READ:
sprintf(apperr,"error on read");
break;
case ER_BAD_CODE:
sprintf(apperr,"bad mode for file open");
break;
case ER_BUFF_FULL:
sprintf(apperr,"no space on circular buffer");
break;
case ER_DEVS_BUSY:
sprintf(apperr,"device busy");
break;
case ER_MEM_FULL:
sprintf(apperr,"memory full");
break;
case ER_PNT_NOT_FOUND:
sprintf(apperr,"point not found");
break;
case ER_PNT_BUSY:
sprintf(apperr,"point busy");
break;
case ER_RAMP_ABORT:
sprintf(apperr,"ramp abort the procs don't respond");
break;
case ER_RAMP_START:
sprintf(apperr,"ramp start the procs don't respond");
break;
case ER_DATA_FAULT:
sprintf(apperr,"error in data conversion");
break;
case ER_BAD_MODE:
sprintf(apperr,"bad mode for file open");
break;
case ER_PNT_ACC:
sprintf(apperr,"unsufficient permissions for this point");
break;
default:
{
sprintf(apperr,"unknow error code");
}
}
return apperr;
}
/*---------------------------------------------------------------------------*/
/* lpcerror.h
* list of rpc error codes returned by remote procedure calls belonging to
* lpc service
* Author: C.Scafuri - Control Group
* First Version: 21 aug 1992
*/
#ifndef LPC_ERROR_H
#define LPC_ERROR_H
/* error number definition */
#define ER_OPEN 0 /* error on path open */
#define ER_IO 1 /* error on system I/O */
#define ER_RANGE 2 /* the request value is out of range */
#define ER_WRITE 3 /* error on write */
#define ER_READ 4 /* error on read */
#define ER_BAD_CODE 5 /* Bad mode for file open */
#define ER_BUFF_FULL 6 /* not space on circular buffer */
#define ER_DEVS_BUSY 7 /* device busy */
#define ER_MEM_FULL 8 /* memory full */
#define ER_PNT_NOT_FOUND 9 /* point not found in tab_pnts */
#define ER_PNT_BUSY 10 /* device is busy */
#define ER_RAMP_ABORT 11 /* ramp abort the procs don't respond */
#define ER_RAMP_START 12 /* ramp start the procs don't respond */
#define ER_DATA_FAULT 13 /* there is a problem in data conversion */
#define ER_BAD_MODE 14 /* Bad mode for file open */
#define ER_PNT_ACC 15 /* bad permission to operate with this point*/
#endif /*LPC_ERROR_H*/
/*
* Description : rpc service support functions
* Type : rpc error analysis & report
* Procedure : rpc_perror rpc_errstring
*
*
* Module Name : rpc_perror
* Author(s) : Claudio Scafuri
*
*
* System(s) : UNIX System V HPUX - nc2.8
*
* First Version : 24/03/93
*/
#include <ncc.h>
#include <stdio.h>
#include <errtype.h>
#include <errno.h>
#include "cuherrt.h"
#include "lpcerror.h"
#include <string.h>
/* global buffers */
static char buffer[256]; /*buffer for output*/
static char apperr[256]; /* buffer for layer/service analysis */
extern char *lpcerror(); /* lpc service error analysis */
extern int sys_nerr;
char *rpc_errorstring(char *err_str ,
int err_num ,
int err_type )
{
extern char *ncerror();
extern char *rxerror();
char buf1[80];
char source_st[6];
char class_st[7];
char service_st[22];
char layer_st[11];
int source_id=0;
int class_id=0;
int layer_id=0;
int service_id=0;
buffer[0]='\0'; /* init strings */
buf1[0]='\0';
source_st[0]='\0';
class_st[0]='\0';
service_st[0]='\0';
layer_st[0]='\0';
apperr[0]='\0';
/* determine if error report origins from client or server */
if (err_type >= 0 && err_type <= ETAPPL && err_num < sys_nerr) {
source_id=0; /*local*/
class_id=ETWARN; /* local errors are not claasified by severity...*/
layer_id=err_type; /* no service-client generated */
}
if (err_type >= ETOFSREM) {
err_type -= ETOFSREM;
source_id = ETOFSREM;
}
if(err_type>= ETFATAL) class_id=ETFATAL;
if(err_type>= ETERROR && err_type < ETFATAL) class_id=ETERROR;
if(err_type < ETERROR) class_id=ETWARN;
err_type -= class_id;
service_id=err_type / ETAPPL; /* which service sent the error ?*/
err_type-= service_id*ETAPPL;
layer_id=err_type; /* which software layer detected the error? */
/* now errtype components are split - itellegible diagnosys begins */
switch(source_id){
case 0: {
sprintf(buf1,"client");
/*strcpy(source_st,buf1);*/
strcpy(buf1,source_st);
break;
}
case ETOFSREM:{
sprintf(buf1,"server");
/*strcpy(source_st,buf1);*/
strcpy(buf1,source_st);
break;
}
}
switch(class_id){
case ETFATAL:{
sprintf(buf1,"FATAL");
/*strcpy(class_st,buf1);*/
strcpy(buf1,class_st);
break;
}
case ETERROR:{
sprintf(buf1,"ERROR");
/*strcpy(class_st,buf1);*/
strcpy(buf1,class_st);
break;
}
case ETWARN:{
sprintf(buf1,"warning");
/*strcpy(class_st,buf1);*/
strcpy(buf1,class_st);
break;
}
}
switch(layer_id){
case ETSYS:
case ETUNIX:{
sprintf(buf1,"Unix");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
strcpy(buf1,strerror(err_num));
if (strlen(buf1)) strcpy(apperr,buf1);
break;
}
case ETOS9:{
sprintf(buf1,"OS-9");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
break;
}
case ETVMS:{
sprintf(buf1,"VMS"); /* for completeness only ... */
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
break;
}
case ETNCRT:{
sprintf(buf1,"RPC runtime");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
strcpy(buf1,ncerror(err_num));
if (strlen(buf1)) strcpy(apperr,buf1);
break;
}
case ETNCSTB:{
sprintf(buf1,"RPC stub");
strcpy(layer_st,buf1);
break;
}
case ETTCPIP:{
sprintf(buf1,"tcp/ip socket");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
break;
}
case ETPROT:{
sprintf(buf1,"nc1.0 error");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
break;
}
case ETRX:{
sprintf(buf1,"RX protocol");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
strcpy(buf1,rxerror(err_num));
if (strlen(buf1)) strcpy(apperr,buf1);
break;
}
case ETMIL:{
sprintf(buf1,"MIL 1553b");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
break;
}
case ETPCIP:{
sprintf(buf1,"PCIP library");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
break;
}
case ETNODAL:{
sprintf(buf1,"NODAL error");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
break;
}
case ETNCNSTB:{
sprintf(buf1,"NODAL stub");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
break;
}
default:{
sprintf(buf1,"unknown");
/* strcpy(layer_st,buf1);*/
strcpy(buf1,layer_st);
}
}
switch(service_id){
case LPC:{
sprintf(buf1,"lpc");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
strcpy(buf1,lpcerror(err_num));
if (strlen(buf1)) strcpy(apperr,buf1);
break;
}
case BRK:{
sprintf(buf1,"shared memory broker");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
break;
}
case MFTL:{
sprintf(buf1,"TL machine file");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
break;
}
case RADIOPROT:{
sprintf(buf1,"helth physics monitor");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
break;
}
case INJ:{
sprintf(buf1,"injection control");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
break;
}
case FLSC:{
sprintf(buf1,"fluorescent screen image");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
break;
}
case CYC:{
sprintf(buf1,"magnet cycling");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
break;
}
case ALM:{
sprintf(buf1,"alarm");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
break;
}
case VAC:{
sprintf(buf1,"vacuum");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
break;
}
case BUMP:{
sprintf(buf1,"bump");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
break;
}
default:
sprintf(buf1,"unknown");
/*strcpy(service_st,buf1);*/
strcpy(buf1,service_st);
}
/* now build up the full message */