From ffbe181b58770e64dfae1eec6d1edb6c95b8f122 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 7 Mar 2001 16:11:55 +0000 Subject: [PATCH] reformat and remove junk --- src/ca/convert.cpp | 2251 +++++++++++++++++++++----------------------- 1 file changed, 1089 insertions(+), 1162 deletions(-) diff --git a/src/ca/convert.cpp b/src/ca/convert.cpp index f5dc6719b..83e613797 100644 --- a/src/ca/convert.cpp +++ b/src/ca/convert.cpp @@ -1,41 +1,28 @@ /* - * C O N V E R T . C + * C O N V E R T . C * - * Author: D. Kersteins + * Author: D. Kersteins * * - * NOTES: - * - * 1) All routines in this file have an encode argument which - * determines if we are converting from the standard format to - * the local format or vise versa. To date only float and double data - * types must be converted differently depending on the encode - * argument - joh - * - * History - * joh 10-21-90 Moved atomic types here to avoid - * maintenance problems in service.c - * This also provides for a cleaner seperation - * of function. - * joh 10-21-90 Added new DBR_XXXX types for release two - * joh 03-15-94 Added many missing types, named ca types, - * and ANSI C changes. - * joh 07-05-94 Fixed double invocation of ++ operator - * by byte swap macro bug in cvrt_short(), - * cvrt_long(), cvrt_enum(). - * joh 11-02-94 moved float convert to this source + * NOTES: * + * 1) All routines in this file have an encode argument which + * determines if we are converting from the standard format to + * the local format or vise versa. To date only float and double data + * types must be converted differently depending on the encode + * argument - joh * */ -#include +#include -#include "iocinf.h" +#include "iocinf.h" #if defined(VMS) -#include -#include +#include +#include #endif + /* * NOOP if this isnt required */ @@ -49,1382 +36,1274 @@ * */ -LOCAL CACVRTFUNC cvrt_string; -LOCAL CACVRTFUNC cvrt_short; -LOCAL CACVRTFUNC cvrt_float; -LOCAL CACVRTFUNC cvrt_enum; -LOCAL CACVRTFUNC cvrt_char; -LOCAL CACVRTFUNC cvrt_long; -LOCAL CACVRTFUNC cvrt_double; - -LOCAL CACVRTFUNC cvrt_sts_string; -LOCAL CACVRTFUNC cvrt_sts_short; -LOCAL CACVRTFUNC cvrt_sts_float; -LOCAL CACVRTFUNC cvrt_sts_enum; -LOCAL CACVRTFUNC cvrt_sts_char; -LOCAL CACVRTFUNC cvrt_sts_long; -LOCAL CACVRTFUNC cvrt_sts_double; - -LOCAL CACVRTFUNC cvrt_time_string; -LOCAL CACVRTFUNC cvrt_time_short; -LOCAL CACVRTFUNC cvrt_time_float; -LOCAL CACVRTFUNC cvrt_time_enum; -LOCAL CACVRTFUNC cvrt_time_char; -LOCAL CACVRTFUNC cvrt_time_long; -LOCAL CACVRTFUNC cvrt_time_double; - -LOCAL CACVRTFUNC cvrt_gr_short; -LOCAL CACVRTFUNC cvrt_gr_float; -LOCAL CACVRTFUNC cvrt_gr_enum; -LOCAL CACVRTFUNC cvrt_gr_char; -LOCAL CACVRTFUNC cvrt_gr_long; -LOCAL CACVRTFUNC cvrt_gr_double; - -LOCAL CACVRTFUNC cvrt_ctrl_short; -LOCAL CACVRTFUNC cvrt_ctrl_float; -LOCAL CACVRTFUNC cvrt_ctrl_enum; -LOCAL CACVRTFUNC cvrt_ctrl_char; -LOCAL CACVRTFUNC cvrt_ctrl_long; -LOCAL CACVRTFUNC cvrt_ctrl_double; - -LOCAL CACVRTFUNC cvrt_put_ackt; -LOCAL CACVRTFUNC cvrt_stsack_string; - -/* cvrt is (array of) (pointer to) (function returning) int */ -epicsShareDef CACVRTFUNC *cac_dbr_cvrt[] - = - { - cvrt_string, - cvrt_short, - cvrt_float, - cvrt_enum, - cvrt_char, - cvrt_long, - cvrt_double, - - cvrt_sts_string, - cvrt_sts_short, - cvrt_sts_float, - cvrt_sts_enum, - cvrt_sts_char, - cvrt_sts_long, - cvrt_sts_double, - - cvrt_time_string, - cvrt_time_short, - cvrt_time_float, - cvrt_time_enum, - cvrt_time_char, - cvrt_time_long, - cvrt_time_double, - - cvrt_sts_string, /* DBR_GR_STRING identical to dbr_sts_string */ - cvrt_gr_short, - cvrt_gr_float, - cvrt_gr_enum, - cvrt_gr_char, - cvrt_gr_long, - cvrt_gr_double, - - cvrt_sts_string, /* DBR_CTRL_STRING identical to dbr_sts_string */ - cvrt_ctrl_short, - cvrt_ctrl_float, - cvrt_ctrl_enum, - cvrt_ctrl_char, - cvrt_ctrl_long, - cvrt_ctrl_double, - - cvrt_put_ackt, - cvrt_put_ackt, /* DBR_PUT_ACKS identical to DBR_PUT_ACKT */ - cvrt_stsack_string, - cvrt_string - }; - - -#define dbr_ntohs(A) (ntohs(A)) -#define dbr_ntohl(A) (ntohl(A)) -#define dbr_htons(A) (htons(A)) -#define dbr_htonl(A) (htonl(A)) +#define dbr_ntohs(A) (ntohs(A)) +#define dbr_ntohl(A) (ntohl(A)) +#define dbr_htons(A) (htons(A)) +#define dbr_htonl(A) (htonl(A)) /* - * CVRT_STRING() + * CVRT_STRING() * * * * */ LOCAL void cvrt_string( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - char *pSrc = (char *) s; - char *pDest = (char *) d; + char *pSrc = (char *) s; + char *pDest = (char *) d; - /* convert "in place" -> nothing to do */ - if (s == d) - return; - if(num == 1){ - strcpy(pDest, pSrc); - } - else{ - memcpy(pDest, pSrc, num*MAX_STRING_SIZE); - } + /* convert "in place" -> nothing to do */ + if (s == d) + return; + if(num == 1){ + strcpy(pDest, pSrc); + } + else{ + memcpy(pDest, pSrc, num*MAX_STRING_SIZE); + } } /* - * CVRT_SHORT() - * - * - * - * + * CVRT_SHORT() */ LOCAL void cvrt_short( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - dbr_short_t *pSrc = (dbr_short_t *) s; - dbr_short_t *pDest = (dbr_short_t *) d; - unsigned long i; + dbr_short_t *pSrc = (dbr_short_t *) s; + dbr_short_t *pDest = (dbr_short_t *) d; + unsigned long i; - for(i=0; i nothing to do */ - if (s == d) - return; - for(i=0; i nothing to do */ + if (s == d) + return; + for(i=0; istatus = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); + struct dbr_sts_string *pSrc = (struct dbr_sts_string *) s; + struct dbr_sts_string *pDest = (struct dbr_sts_string *) d; + + /* convert ieee to vax format or vax to ieee */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); - /* convert "in place" -> nothing else to do */ - if (s == d) - return; + /* convert "in place" -> nothing else to do */ + if (s == d) + return; - if (num == 1) /* if single value */ - strcpy(pDest->value, pSrc->value); - else - memcpy(pDest->value, pSrc->value, (MAX_STRING_SIZE * num)); + if (num == 1) /* if single value */ + strcpy(pDest->value, pSrc->value); + else + memcpy(pDest->value, pSrc->value, (MAX_STRING_SIZE * num)); } /**************************************************************************** -** cvrt_sts_short(s,d) -** struct dbr_sts_int *s pointer to source struct -** struct dbr_sts_int *d pointer to destination struct -** int encode; boolean, if true vax to ieee -** else ieee to vax +** cvrt_sts_short(s,d) +** struct dbr_sts_int *s pointer to source struct +** struct dbr_sts_int *d pointer to destination struct +** int encode; boolean, if true vax to ieee +** else ieee to vax ** -** converts fields ofstruct in HOST format to ieee format -** or -** converts fields of struct in NET format to fields with HOST -** format +** converts fields ofstruct in HOST format to ieee format +** or +** converts fields of struct in NET format to fields with HOST +** format ****************************************************************************/ LOCAL void cvrt_sts_short( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_sts_int *pSrc = (struct dbr_sts_int *) s; - struct dbr_sts_int *pDest = (struct dbr_sts_int *) d; + struct dbr_sts_int *pSrc = (struct dbr_sts_int *) s; + struct dbr_sts_int *pDest = (struct dbr_sts_int *) d; - /* convert vax to ieee or ieee to vax format -- same code*/ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); + /* convert vax to ieee or ieee to vax format -- same code*/ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); - if (num == 1) /* single value */ - pDest->value = dbr_ntohs(pSrc->value); - else /* array chan-- multiple pts */ - { - cvrt_short(&pSrc->value, &pDest->value, encode, num); - } + if (num == 1) /* single value */ + pDest->value = dbr_ntohs(pSrc->value); + else /* array chan-- multiple pts */ + { + cvrt_short(&pSrc->value, &pDest->value, encode, num); + } } /**************************************************************************** -** cvrt_sts_float(s,d) -** struct dbr_sts_float *s pointer to source struct -** struct dbr_sts_float *d pointer to destination struct -** int encode; boolean, if true vax to ieee -** else ieee to vax +** cvrt_sts_float(s,d) +** struct dbr_sts_float *s pointer to source struct +** struct dbr_sts_float *d pointer to destination struct +** int encode; boolean, if true vax to ieee +** else ieee to vax ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_sts_float( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_sts_float *pSrc = (struct dbr_sts_float *) s; - struct dbr_sts_float *pDest = (struct dbr_sts_float *) d; + struct dbr_sts_float *pSrc = (struct dbr_sts_float *) s; + struct dbr_sts_float *pDest = (struct dbr_sts_float *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); - cvrt_float(&pSrc->value, &pDest->value, encode, num); + cvrt_float(&pSrc->value, &pDest->value, encode, num); } /**************************************************************************** -** cvrt_sts_double(s,d) +** cvrt_sts_double(s,d) ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_sts_double( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_sts_double *pSrc = (struct dbr_sts_double *) s; - struct dbr_sts_double *pDest = (struct dbr_sts_double *) d; + struct dbr_sts_double *pSrc = (struct dbr_sts_double *) s; + struct dbr_sts_double *pDest = (struct dbr_sts_double *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); - cvrt_double(&pSrc->value, &pDest->value, encode, num); + cvrt_double(&pSrc->value, &pDest->value, encode, num); } /**************************************************************************** -** cvrt_sts_enum(s,d) -** struct dbr_sts_enum *s pointer to source struct -** struct dbr_sts_enum *d pointer to destination struct -** int encode; boolean, if true vax to ieee -** else ieee to vax +** cvrt_sts_enum(s,d) +** struct dbr_sts_enum *s pointer to source struct +** struct dbr_sts_enum *d pointer to destination struct +** int encode; boolean, if true vax to ieee +** else ieee to vax ** -** converts fields of struct in NET format to fields with HOST format -** or -** converts fields of struct in HOST format to fields with NET format -** +** converts fields of struct in NET format to fields with HOST format +** or +** converts fields of struct in HOST format to fields with NET format +** ****************************************************************************/ LOCAL void cvrt_sts_enum( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_sts_enum *pSrc = (struct dbr_sts_enum *) s; - struct dbr_sts_enum *pDest = (struct dbr_sts_enum *) d; + struct dbr_sts_enum *pSrc = (struct dbr_sts_enum *) s; + struct dbr_sts_enum *pDest = (struct dbr_sts_enum *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - if (num == 1) - pDest->value = dbr_ntohs(pSrc->value); - else { - cvrt_enum(&pSrc->value,&pDest->value,encode,num); - } + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + if (num == 1) + pDest->value = dbr_ntohs(pSrc->value); + else { + cvrt_enum(&pSrc->value,&pDest->value,encode,num); + } } /**************************************************************************** -** cvrt_gr_short() +** cvrt_gr_short() ** -** converts fields of struct in NET format to fields with HOST format -** or -** converts fields of struct in HOST format to fields with NET format -** +** converts fields of struct in NET format to fields with HOST format +** or +** converts fields of struct in HOST format to fields with NET format +** ****************************************************************************/ LOCAL void cvrt_gr_short( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_gr_int *pSrc = (struct dbr_gr_int *) s; - struct dbr_gr_int *pDest = (struct dbr_gr_int *) d; + struct dbr_gr_int *pSrc = (struct dbr_gr_int *) s; + struct dbr_gr_int *pDest = (struct dbr_gr_int *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); - pDest->upper_disp_limit = dbr_ntohs(pSrc->upper_disp_limit); - pDest->lower_disp_limit = dbr_ntohs(pSrc->lower_disp_limit); - pDest->upper_alarm_limit = dbr_ntohs(pSrc->upper_alarm_limit); - pDest->upper_warning_limit = dbr_ntohs(pSrc->upper_warning_limit); - pDest->lower_alarm_limit = dbr_ntohs(pSrc->lower_alarm_limit); - pDest->lower_warning_limit = dbr_ntohs(pSrc->lower_warning_limit); + pDest->upper_disp_limit = dbr_ntohs(pSrc->upper_disp_limit); + pDest->lower_disp_limit = dbr_ntohs(pSrc->lower_disp_limit); + pDest->upper_alarm_limit = dbr_ntohs(pSrc->upper_alarm_limit); + pDest->upper_warning_limit = dbr_ntohs(pSrc->upper_warning_limit); + pDest->lower_alarm_limit = dbr_ntohs(pSrc->lower_alarm_limit); + pDest->lower_warning_limit = dbr_ntohs(pSrc->lower_warning_limit); - if (num == 1) - pDest->value = dbr_ntohs(pSrc->value); - else { - cvrt_short(&pSrc->value, &pDest->value, encode,num); - } + if (num == 1) + pDest->value = dbr_ntohs(pSrc->value); + else { + cvrt_short(&pSrc->value, &pDest->value, encode,num); + } } /**************************************************************************** -** cvrt_gr_char() +** cvrt_gr_char() ** -** converts fields of struct in NET format to fields with HOST format -** or -** converts fields of struct in HOST format to fields with NET format -** +** converts fields of struct in NET format to fields with HOST format +** or +** converts fields of struct in HOST format to fields with NET format +** ****************************************************************************/ LOCAL void cvrt_gr_char( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_gr_char *pSrc = (struct dbr_gr_char *) s; - struct dbr_gr_char *pDest = (struct dbr_gr_char *) d; + struct dbr_gr_char *pSrc = (struct dbr_gr_char *) s; + struct dbr_gr_char *pDest = (struct dbr_gr_char *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); - if (s == d) /* source == dest -> no more conversions */ - return; + if (s == d) /* source == dest -> no more conversions */ + return; - memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); + memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); - pDest->upper_disp_limit = pSrc->upper_disp_limit; - pDest->lower_disp_limit = pSrc->lower_disp_limit; - pDest->upper_alarm_limit = pSrc->upper_alarm_limit; - pDest->upper_warning_limit = pSrc->upper_warning_limit; - pDest->lower_alarm_limit = pSrc->lower_alarm_limit; - pDest->lower_warning_limit = pSrc->lower_warning_limit; + pDest->upper_disp_limit = pSrc->upper_disp_limit; + pDest->lower_disp_limit = pSrc->lower_disp_limit; + pDest->upper_alarm_limit = pSrc->upper_alarm_limit; + pDest->upper_warning_limit = pSrc->upper_warning_limit; + pDest->lower_alarm_limit = pSrc->lower_alarm_limit; + pDest->lower_warning_limit = pSrc->lower_warning_limit; - if (num == 1) - pDest->value = pSrc->value; - else { - memcpy((char *)&pDest->value, (char *)&pSrc->value, num); - } + if (num == 1) + pDest->value = pSrc->value; + else { + memcpy((char *)&pDest->value, (char *)&pSrc->value, num); + } } /**************************************************************************** -** cvrt_gr_long() +** cvrt_gr_long() ** -** converts fields of struct in NET format to fields with HOST format -** or -** converts fields of struct in HOST format to fields with NET format -** +** converts fields of struct in NET format to fields with HOST format +** or +** converts fields of struct in HOST format to fields with NET format +** ****************************************************************************/ LOCAL void cvrt_gr_long( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_gr_long *pSrc = (struct dbr_gr_long *) s; - struct dbr_gr_long *pDest = (struct dbr_gr_long *) d; + struct dbr_gr_long *pSrc = (struct dbr_gr_long *) s; + struct dbr_gr_long *pDest = (struct dbr_gr_long *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); - pDest->upper_disp_limit = dbr_ntohl(pSrc->upper_disp_limit); - pDest->lower_disp_limit = dbr_ntohl(pSrc->lower_disp_limit); - pDest->upper_alarm_limit = dbr_ntohl(pSrc->upper_alarm_limit); - pDest->upper_warning_limit = dbr_ntohl(pSrc->upper_warning_limit); - pDest->lower_alarm_limit = dbr_ntohl(pSrc->lower_alarm_limit); - pDest->lower_warning_limit = dbr_ntohl(pSrc->lower_warning_limit); + pDest->upper_disp_limit = dbr_ntohl(pSrc->upper_disp_limit); + pDest->lower_disp_limit = dbr_ntohl(pSrc->lower_disp_limit); + pDest->upper_alarm_limit = dbr_ntohl(pSrc->upper_alarm_limit); + pDest->upper_warning_limit = dbr_ntohl(pSrc->upper_warning_limit); + pDest->lower_alarm_limit = dbr_ntohl(pSrc->lower_alarm_limit); + pDest->lower_warning_limit = dbr_ntohl(pSrc->lower_warning_limit); - if (num == 1) - pDest->value = dbr_ntohl(pSrc->value); - else { - cvrt_long(&pSrc->value, &pDest->value, encode, num); - } + if (num == 1) + pDest->value = dbr_ntohl(pSrc->value); + else { + cvrt_long(&pSrc->value, &pDest->value, encode, num); + } } /**************************************************************************** -** cvrt_gr_enum(s,d) +** cvrt_gr_enum(s,d) ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_gr_enum( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_gr_enum *pSrc = (struct dbr_gr_enum *) s; - struct dbr_gr_enum *pDest = (struct dbr_gr_enum *) d; + struct dbr_gr_enum *pSrc = (struct dbr_gr_enum *) s; + struct dbr_gr_enum *pDest = (struct dbr_gr_enum *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->no_str = dbr_ntohs(pSrc->no_str); - memcpy((void *)pDest->strs,(void *)pSrc->strs,sizeof(pSrc->strs)); + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->no_str = dbr_ntohs(pSrc->no_str); + memcpy((void *)pDest->strs,(void *)pSrc->strs,sizeof(pSrc->strs)); - if (num == 1) /* single value */ - pDest->value = dbr_ntohs(pSrc->value); - else /* array chan-- multiple pts */ - { - cvrt_enum(&(pSrc->value), &(pDest->value), encode, num); - } + if (num == 1) /* single value */ + pDest->value = dbr_ntohs(pSrc->value); + else /* array chan-- multiple pts */ + { + cvrt_enum(&(pSrc->value), &(pDest->value), encode, num); + } } /**************************************************************************** -** cvrt_gr_double(s,d) +** cvrt_gr_double(s,d) ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_gr_double( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_gr_double *pSrc = (struct dbr_gr_double *) s; - struct dbr_gr_double *pDest = (struct dbr_gr_double *) d; + struct dbr_gr_double *pSrc = (struct dbr_gr_double *) s; + struct dbr_gr_double *pDest = (struct dbr_gr_double *) d; - /* these are same for vax to ieee or ieee to vax */ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->precision = dbr_ntohs(pSrc->precision); - memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); + /* these are same for vax to ieee or ieee to vax */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->precision = dbr_ntohs(pSrc->precision); + memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); - if (encode) /* vax to ieee convert */ - { - if (num == 1){ - dbr_htond(&pSrc->value, &pDest->value); - } - else { - cvrt_double(&pSrc->value, &pDest->value, encode,num); - } - dbr_htond(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); - dbr_htond(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); - dbr_htond(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); - dbr_htond(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); - dbr_htond(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); - dbr_htond(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); - } - else /* ieee to vax convert */ - { - if (num == 1){ - dbr_ntohd(&pSrc->value, &pDest->value); - } - else { - cvrt_double(&pSrc->value, &pDest->value, encode,num); - } - dbr_ntohd(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); - dbr_ntohd(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); - dbr_ntohd(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); - dbr_ntohd(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); - dbr_ntohd(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); - dbr_ntohd(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); - } + if (encode) /* vax to ieee convert */ + { + if (num == 1){ + dbr_htond(&pSrc->value, &pDest->value); + } + else { + cvrt_double(&pSrc->value, &pDest->value, encode,num); + } + dbr_htond(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); + dbr_htond(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); + dbr_htond(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); + dbr_htond(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); + dbr_htond(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); + dbr_htond(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); + } + else /* ieee to vax convert */ + { + if (num == 1){ + dbr_ntohd(&pSrc->value, &pDest->value); + } + else { + cvrt_double(&pSrc->value, &pDest->value, encode,num); + } + dbr_ntohd(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); + dbr_ntohd(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); + dbr_ntohd(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); + dbr_ntohd(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); + dbr_ntohd(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); + dbr_ntohd(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); + } } /**************************************************************************** -** cvrt_gr_float(s,d) -** struct dbr_gr_float *d pointer to destination struct -** int encode; boolean, if true vax to ieee -** else ieee to vax +** cvrt_gr_float(s,d) +** struct dbr_gr_float *d pointer to destination struct +** int encode; boolean, if true vax to ieee +** else ieee to vax ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_gr_float( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_gr_float *pSrc = (struct dbr_gr_float *) s; - struct dbr_gr_float *pDest = (struct dbr_gr_float *) d; + struct dbr_gr_float *pSrc = (struct dbr_gr_float *) s; + struct dbr_gr_float *pDest = (struct dbr_gr_float *) d; - /* these are same for vax to ieee or ieee to vax */ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->precision = dbr_ntohs(pSrc->precision); - memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); + /* these are same for vax to ieee or ieee to vax */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->precision = dbr_ntohs(pSrc->precision); + memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); - if (encode) /* vax to ieee convert */ - { - if (num == 1){ - dbr_htonf(&pSrc->value, &pDest->value); - } - else { - cvrt_float(&pSrc->value, &pDest->value, encode,num); - } - dbr_htonf(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); - dbr_htonf(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); - dbr_htonf(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); - dbr_htonf(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); - dbr_htonf(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); - dbr_htonf(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); - } - else /* ieee to vax convert */ - { - if (num == 1){ - dbr_ntohf(&pSrc->value, &pDest->value); - } - else { - cvrt_float(&pSrc->value, &pDest->value, encode,num); - } - dbr_ntohf(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); - dbr_ntohf(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); - dbr_ntohf(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); - dbr_ntohf(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); - dbr_ntohf(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); - dbr_ntohf(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); - } + if (encode) /* vax to ieee convert */ + { + if (num == 1){ + dbr_htonf(&pSrc->value, &pDest->value); + } + else { + cvrt_float(&pSrc->value, &pDest->value, encode,num); + } + dbr_htonf(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); + dbr_htonf(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); + dbr_htonf(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); + dbr_htonf(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); + dbr_htonf(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); + dbr_htonf(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); + } + else /* ieee to vax convert */ + { + if (num == 1){ + dbr_ntohf(&pSrc->value, &pDest->value); + } + else { + cvrt_float(&pSrc->value, &pDest->value, encode,num); + } + dbr_ntohf(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); + dbr_ntohf(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); + dbr_ntohf(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); + dbr_ntohf(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); + dbr_ntohf(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); + dbr_ntohf(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); + } } /**************************************************************************** -** cvrt_ctrl_short(s,d) -** struct dbr_gr_int *s pointer to source struct -** struct dbr_gr_int *d pointer to destination struct -** int encode; boolean, if true vax to ieee -** else ieee to vax +** cvrt_ctrl_short(s,d) +** struct dbr_gr_int *s pointer to source struct +** struct dbr_gr_int *d pointer to destination struct +** int encode; boolean, if true vax to ieee +** else ieee to vax ** -** converts fields of struct in NET format to fields with HOST format -** or -** converts fields of struct in HOST format to fields with NET format -** +** converts fields of struct in NET format to fields with HOST format +** or +** converts fields of struct in HOST format to fields with NET format +** ****************************************************************************/ LOCAL void cvrt_ctrl_short( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_ctrl_int *pSrc = (struct dbr_ctrl_int *) s; - struct dbr_ctrl_int *pDest = (struct dbr_ctrl_int *) d; + struct dbr_ctrl_int *pSrc = (struct dbr_ctrl_int *) s; + struct dbr_ctrl_int *pDest = (struct dbr_ctrl_int *) d; - /* vax to ieee or ieee to vax -- same code */ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); + /* vax to ieee or ieee to vax -- same code */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); - pDest->upper_disp_limit = dbr_ntohs(pSrc->upper_disp_limit); - pDest->lower_disp_limit = dbr_ntohs(pSrc->lower_disp_limit); - pDest->upper_alarm_limit = dbr_ntohs(pSrc->upper_alarm_limit); - pDest->upper_warning_limit = dbr_ntohs(pSrc->upper_warning_limit); - pDest->lower_alarm_limit = dbr_ntohs(pSrc->lower_alarm_limit); - pDest->lower_warning_limit = dbr_ntohs(pSrc->lower_warning_limit); - pDest->lower_ctrl_limit = dbr_ntohs(pSrc->lower_ctrl_limit); - pDest->upper_ctrl_limit = dbr_ntohs(pSrc->upper_ctrl_limit); + pDest->upper_disp_limit = dbr_ntohs(pSrc->upper_disp_limit); + pDest->lower_disp_limit = dbr_ntohs(pSrc->lower_disp_limit); + pDest->upper_alarm_limit = dbr_ntohs(pSrc->upper_alarm_limit); + pDest->upper_warning_limit = dbr_ntohs(pSrc->upper_warning_limit); + pDest->lower_alarm_limit = dbr_ntohs(pSrc->lower_alarm_limit); + pDest->lower_warning_limit = dbr_ntohs(pSrc->lower_warning_limit); + pDest->lower_ctrl_limit = dbr_ntohs(pSrc->lower_ctrl_limit); + pDest->upper_ctrl_limit = dbr_ntohs(pSrc->upper_ctrl_limit); - if (num == 1) - pDest->value = dbr_ntohs(pSrc->value); - else { - cvrt_short(&pSrc->value, &pDest->value, encode, num); - } + if (num == 1) + pDest->value = dbr_ntohs(pSrc->value); + else { + cvrt_short(&pSrc->value, &pDest->value, encode, num); + } } /**************************************************************************** -** cvrt_ctrl_long(s,d) +** cvrt_ctrl_long(s,d) ** -** converts fields of struct in NET format to fields with HOST format -** or -** converts fields of struct in HOST format to fields with NET format -** +** converts fields of struct in NET format to fields with HOST format +** or +** converts fields of struct in HOST format to fields with NET format +** ****************************************************************************/ LOCAL void cvrt_ctrl_long( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_ctrl_long *pSrc = (struct dbr_ctrl_long*) s; - struct dbr_ctrl_long *pDest = (struct dbr_ctrl_long *) d; + struct dbr_ctrl_long *pSrc = (struct dbr_ctrl_long*) s; + struct dbr_ctrl_long *pDest = (struct dbr_ctrl_long *) d; - /* vax to ieee or ieee to vax -- same code */ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); + /* vax to ieee or ieee to vax -- same code */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); - pDest->upper_disp_limit = dbr_ntohl(pSrc->upper_disp_limit); - pDest->lower_disp_limit = dbr_ntohl(pSrc->lower_disp_limit); - pDest->upper_alarm_limit = dbr_ntohl(pSrc->upper_alarm_limit); - pDest->upper_warning_limit = dbr_ntohl(pSrc->upper_warning_limit); - pDest->lower_alarm_limit = dbr_ntohl(pSrc->lower_alarm_limit); - pDest->lower_warning_limit = dbr_ntohl(pSrc->lower_warning_limit); - pDest->lower_ctrl_limit = dbr_ntohl(pSrc->lower_ctrl_limit); - pDest->upper_ctrl_limit = dbr_ntohl(pSrc->upper_ctrl_limit); + pDest->upper_disp_limit = dbr_ntohl(pSrc->upper_disp_limit); + pDest->lower_disp_limit = dbr_ntohl(pSrc->lower_disp_limit); + pDest->upper_alarm_limit = dbr_ntohl(pSrc->upper_alarm_limit); + pDest->upper_warning_limit = dbr_ntohl(pSrc->upper_warning_limit); + pDest->lower_alarm_limit = dbr_ntohl(pSrc->lower_alarm_limit); + pDest->lower_warning_limit = dbr_ntohl(pSrc->lower_warning_limit); + pDest->lower_ctrl_limit = dbr_ntohl(pSrc->lower_ctrl_limit); + pDest->upper_ctrl_limit = dbr_ntohl(pSrc->upper_ctrl_limit); - if (num == 1) - pDest->value = dbr_ntohl(pSrc->value); - else { - cvrt_long(&pSrc->value, &pDest->value, encode, num); - } + if (num == 1) + pDest->value = dbr_ntohl(pSrc->value); + else { + cvrt_long(&pSrc->value, &pDest->value, encode, num); + } } /**************************************************************************** -** cvrt_ctrl_short(s,d) +** cvrt_ctrl_short(s,d) ** -** converts fields of struct in NET format to fields with HOST format -** or -** converts fields of struct in HOST format to fields with NET format -** +** converts fields of struct in NET format to fields with HOST format +** or +** converts fields of struct in HOST format to fields with NET format +** ****************************************************************************/ LOCAL void cvrt_ctrl_char( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_ctrl_char *pSrc = (struct dbr_ctrl_char *) s; - struct dbr_ctrl_char *pDest = (struct dbr_ctrl_char *) d; + struct dbr_ctrl_char *pSrc = (struct dbr_ctrl_char *) s; + struct dbr_ctrl_char *pDest = (struct dbr_ctrl_char *) d; - /* vax to ieee or ieee to vax -- same code */ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); + /* vax to ieee or ieee to vax -- same code */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); - pDest->upper_disp_limit = pSrc->upper_disp_limit; - pDest->lower_disp_limit = pSrc->lower_disp_limit; - pDest->upper_alarm_limit = pSrc->upper_alarm_limit; - pDest->upper_warning_limit = pSrc->upper_warning_limit; - pDest->lower_ctrl_limit = pSrc->lower_ctrl_limit; - pDest->upper_ctrl_limit = pSrc->upper_ctrl_limit; + pDest->upper_disp_limit = pSrc->upper_disp_limit; + pDest->lower_disp_limit = pSrc->lower_disp_limit; + pDest->upper_alarm_limit = pSrc->upper_alarm_limit; + pDest->upper_warning_limit = pSrc->upper_warning_limit; + pDest->lower_ctrl_limit = pSrc->lower_ctrl_limit; + pDest->upper_ctrl_limit = pSrc->upper_ctrl_limit; - if (num == 1) - pDest->value = pSrc->value; - else { - memcpy((void *)&pDest->value, (void *)&pSrc->value, num); - } + if (num == 1) + pDest->value = pSrc->value; + else { + memcpy((void *)&pDest->value, (void *)&pSrc->value, num); + } } /**************************************************************************** -** cvrt_ctrl_double(s,d) +** cvrt_ctrl_double(s,d) ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_ctrl_double( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_ctrl_double *pSrc = (struct dbr_ctrl_double *) s; - struct dbr_ctrl_double *pDest = (struct dbr_ctrl_double *) d; + struct dbr_ctrl_double *pSrc = (struct dbr_ctrl_double *) s; + struct dbr_ctrl_double *pDest = (struct dbr_ctrl_double *) d; - /* these are the same for ieee to vax or vax to ieee */ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->precision = dbr_ntohs(pSrc->precision); - memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); - if (encode) /* vax to ieee convert */ - { - if (num == 1){ - dbr_htond(&pSrc->value, &pDest->value); - } - else { - cvrt_double(&pSrc->value, &pDest->value, encode, num); - } - dbr_htond(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); - dbr_htond(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); - dbr_htond(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); - dbr_htond(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); - dbr_htond(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); - dbr_htond(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); - dbr_htond(&pSrc->lower_ctrl_limit, &pDest->lower_ctrl_limit); - dbr_htond(&pSrc->upper_ctrl_limit, &pDest->upper_ctrl_limit); - } - else /* ieee to vax convert */ - { - if (num == 1){ - dbr_ntohd(&pSrc->value, &pDest->value); - } - else { - cvrt_double(&pSrc->value, &pDest->value, encode, num); - } - dbr_ntohd(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); - dbr_ntohd(&pSrc->upper_disp_limit, &pDest->upper_disp_limit); - dbr_ntohd(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); - dbr_ntohd(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); - dbr_ntohd(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); - dbr_ntohd(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); - dbr_ntohd(&pSrc->lower_ctrl_limit, &pDest->lower_ctrl_limit); - dbr_ntohd(&pSrc->upper_ctrl_limit, &pDest->upper_ctrl_limit); - } + /* these are the same for ieee to vax or vax to ieee */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->precision = dbr_ntohs(pSrc->precision); + memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); + if (encode) /* vax to ieee convert */ + { + if (num == 1){ + dbr_htond(&pSrc->value, &pDest->value); + } + else { + cvrt_double(&pSrc->value, &pDest->value, encode, num); + } + dbr_htond(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); + dbr_htond(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); + dbr_htond(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); + dbr_htond(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); + dbr_htond(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); + dbr_htond(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); + dbr_htond(&pSrc->lower_ctrl_limit, &pDest->lower_ctrl_limit); + dbr_htond(&pSrc->upper_ctrl_limit, &pDest->upper_ctrl_limit); + } + else /* ieee to vax convert */ + { + if (num == 1){ + dbr_ntohd(&pSrc->value, &pDest->value); + } + else { + cvrt_double(&pSrc->value, &pDest->value, encode, num); + } + dbr_ntohd(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); + dbr_ntohd(&pSrc->upper_disp_limit, &pDest->upper_disp_limit); + dbr_ntohd(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); + dbr_ntohd(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); + dbr_ntohd(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); + dbr_ntohd(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); + dbr_ntohd(&pSrc->lower_ctrl_limit, &pDest->lower_ctrl_limit); + dbr_ntohd(&pSrc->upper_ctrl_limit, &pDest->upper_ctrl_limit); + } } /**************************************************************************** -** cvrt_ctrl_float(s,d) +** cvrt_ctrl_float(s,d) ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_ctrl_float( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_ctrl_float *pSrc = (struct dbr_ctrl_float *) s; - struct dbr_ctrl_float *pDest = (struct dbr_ctrl_float *) d; + struct dbr_ctrl_float *pSrc = (struct dbr_ctrl_float *) s; + struct dbr_ctrl_float *pDest = (struct dbr_ctrl_float *) d; - /* these are the same for ieee to vaax or vax to ieee */ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->precision = dbr_ntohs(pSrc->precision); - memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); - if (encode) /* vax to ieee convert */ - { - if (num == 1){ - dbr_htonf(&pSrc->value, &pDest->value); - } - else { - cvrt_float(&pSrc->value, &pDest->value, encode, num); - } - dbr_htonf(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); - dbr_htonf(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); - dbr_htonf(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); - dbr_htonf(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); - dbr_htonf(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); - dbr_htonf(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); - dbr_htonf(&pSrc->lower_ctrl_limit, &pDest->lower_ctrl_limit); - dbr_htonf(&pSrc->upper_ctrl_limit, &pDest->upper_ctrl_limit); - } - else /* ieee to vax convert */ - { - if (num == 1){ - dbr_ntohf(&pSrc->value, &pDest->value); - } - else { - cvrt_float(&pSrc->value, &pDest->value, encode, num); - } - dbr_ntohf(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); - dbr_ntohf(&pSrc->upper_disp_limit, &pDest->upper_disp_limit); - dbr_ntohf(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); - dbr_ntohf(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); - dbr_ntohf(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); - dbr_ntohf(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); - dbr_ntohf(&pSrc->lower_ctrl_limit, &pDest->lower_ctrl_limit); - dbr_ntohf(&pSrc->upper_ctrl_limit, &pDest->upper_ctrl_limit); - } + /* these are the same for ieee to vaax or vax to ieee */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->precision = dbr_ntohs(pSrc->precision); + memcpy(pDest->units,pSrc->units,sizeof(pSrc->units)); + if (encode) /* vax to ieee convert */ + { + if (num == 1){ + dbr_htonf(&pSrc->value, &pDest->value); + } + else { + cvrt_float(&pSrc->value, &pDest->value, encode, num); + } + dbr_htonf(&pSrc->upper_disp_limit,&pDest->upper_disp_limit); + dbr_htonf(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); + dbr_htonf(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); + dbr_htonf(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); + dbr_htonf(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); + dbr_htonf(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); + dbr_htonf(&pSrc->lower_ctrl_limit, &pDest->lower_ctrl_limit); + dbr_htonf(&pSrc->upper_ctrl_limit, &pDest->upper_ctrl_limit); + } + else /* ieee to vax convert */ + { + if (num == 1){ + dbr_ntohf(&pSrc->value, &pDest->value); + } + else { + cvrt_float(&pSrc->value, &pDest->value, encode, num); + } + dbr_ntohf(&pSrc->lower_disp_limit, &pDest->lower_disp_limit); + dbr_ntohf(&pSrc->upper_disp_limit, &pDest->upper_disp_limit); + dbr_ntohf(&pSrc->upper_alarm_limit, &pDest->upper_alarm_limit); + dbr_ntohf(&pSrc->upper_warning_limit, &pDest->upper_warning_limit); + dbr_ntohf(&pSrc->lower_alarm_limit, &pDest->lower_alarm_limit); + dbr_ntohf(&pSrc->lower_warning_limit, &pDest->lower_warning_limit); + dbr_ntohf(&pSrc->lower_ctrl_limit, &pDest->lower_ctrl_limit); + dbr_ntohf(&pSrc->upper_ctrl_limit, &pDest->upper_ctrl_limit); + } } /**************************************************************************** -** cvrt_ctrl_enum(s,d) +** cvrt_ctrl_enum(s,d) ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_ctrl_enum( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_ctrl_enum *pSrc = (struct dbr_ctrl_enum *) s; - struct dbr_ctrl_enum *pDest = (struct dbr_ctrl_enum *) d; + struct dbr_ctrl_enum *pSrc = (struct dbr_ctrl_enum *) s; + struct dbr_ctrl_enum *pDest = (struct dbr_ctrl_enum *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->no_str = dbr_ntohs(pSrc->no_str); - memcpy((void *)pDest->strs,(void *)pSrc->strs,sizeof(pSrc->strs)); + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->no_str = dbr_ntohs(pSrc->no_str); + memcpy((void *)pDest->strs,(void *)pSrc->strs,sizeof(pSrc->strs)); - if (num == 1) /* single value */ - pDest->value = dbr_ntohs(pSrc->value); - else /* array chan-- multiple pts */ - { - cvrt_enum(&(pSrc->value), &(pDest->value), encode, num); - } + if (num == 1) /* single value */ + pDest->value = dbr_ntohs(pSrc->value); + else /* array chan-- multiple pts */ + { + cvrt_enum(&(pSrc->value), &(pDest->value), encode, num); + } } /**************************************************************************** -** cvrt_sts_char(s,d) -** struct dbr_sts_int *s pointer to source struct -** struct dbr_sts_int *d pointer to destination struct -** int encode; boolean, if true vax to ieee -** else ieee to vax +** cvrt_sts_char(s,d) +** struct dbr_sts_int *s pointer to source struct +** struct dbr_sts_int *d pointer to destination struct +** int encode; boolean, if true vax to ieee +** else ieee to vax ** -** converts fields ofstruct in HOST format to ieee format -** or -** converts fields of struct in NET format to fields with HOST -** format +** converts fields ofstruct in HOST format to ieee format +** or +** converts fields of struct in NET format to fields with HOST +** format ****************************************************************************/ LOCAL void cvrt_sts_char( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_sts_char *pSrc = (struct dbr_sts_char *) s; - struct dbr_sts_char *pDest = (struct dbr_sts_char *) d; + struct dbr_sts_char *pSrc = (struct dbr_sts_char *) s; + struct dbr_sts_char *pDest = (struct dbr_sts_char *) d; - /* convert vax to ieee or ieee to vax format -- same code*/ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); + /* convert vax to ieee or ieee to vax format -- same code*/ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); - if (num == 1) /* single value */ - pDest->value = pSrc->value; - else /* array chan-- multiple pts */ - { - memcpy((void *)&pDest->value, (void *)&pSrc->value, num); - } + if (num == 1) /* single value */ + pDest->value = pSrc->value; + else /* array chan-- multiple pts */ + { + memcpy((void *)&pDest->value, (void *)&pSrc->value, num); + } } /**************************************************************************** -** cvrt_sts_long(s,d) +** cvrt_sts_long(s,d) ** -** converts fields ofstruct in HOST format to ieee format -** or -** converts fields of struct in NET format to fields with HOST -** format +** converts fields ofstruct in HOST format to ieee format +** or +** converts fields of struct in NET format to fields with HOST +** format ****************************************************************************/ LOCAL void cvrt_sts_long( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_sts_long *pSrc = (struct dbr_sts_long *) s; - struct dbr_sts_long *pDest = (struct dbr_sts_long *) d; + struct dbr_sts_long *pSrc = (struct dbr_sts_long *) s; + struct dbr_sts_long *pDest = (struct dbr_sts_long *) d; - /* convert vax to ieee or ieee to vax format -- same code*/ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); + /* convert vax to ieee or ieee to vax format -- same code*/ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); - if (num == 1) /* single value */ - pDest->value = dbr_ntohl(pSrc->value); - else /* array chan-- multiple pts */ - { - cvrt_long(&pDest->value, &pSrc->value, encode, num); - } + if (num == 1) /* single value */ + pDest->value = dbr_ntohl(pSrc->value); + else /* array chan-- multiple pts */ + { + cvrt_long(&pDest->value, &pSrc->value, encode, num); + } } /**************************************************************************** -** cvrt_time_string(s,d) -** -** converts fields of struct in HOST format to NET format -** or -** converts fields of struct in NET format to fields with HOST -** format; +** cvrt_time_string(s,d) +** +** converts fields of struct in HOST format to NET format +** or +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_time_string( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_time_string *pSrc = (struct dbr_time_string *) s; - struct dbr_time_string *pDest = (struct dbr_time_string *) d; - - /* convert ieee to vax format or vax to ieee */ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); - pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); + struct dbr_time_string *pSrc = (struct dbr_time_string *) s; + struct dbr_time_string *pDest = (struct dbr_time_string *) d; + + /* convert ieee to vax format or vax to ieee */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); + pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); - if (num == 1) /* if single value */ - strcpy(pDest->value, pSrc->value); - else - memcpy(pDest->value, pSrc->value, (MAX_STRING_SIZE * num)); + if (num == 1) /* if single value */ + strcpy(pDest->value, pSrc->value); + else + memcpy(pDest->value, pSrc->value, (MAX_STRING_SIZE * num)); } /**************************************************************************** -** cvrt_time_short(s,d) +** cvrt_time_short(s,d) ** -** converts fields ofstruct in HOST format to ieee format -** or -** converts fields of struct in NET format to fields with HOST -** format +** converts fields ofstruct in HOST format to ieee format +** or +** converts fields of struct in NET format to fields with HOST +** format ****************************************************************************/ LOCAL void cvrt_time_short( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_time_short *pSrc = (struct dbr_time_short *) s; - struct dbr_time_short *pDest = (struct dbr_time_short *) d; + struct dbr_time_short *pSrc = (struct dbr_time_short *) s; + struct dbr_time_short *pDest = (struct dbr_time_short *) d; - /* convert vax to ieee or ieee to vax format -- same code*/ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); - pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); + /* convert vax to ieee or ieee to vax format -- same code*/ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); + pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); - if (num == 1) /* single value */ - pDest->value = dbr_ntohs(pSrc->value); - else /* array chan-- multiple pts */ - { - cvrt_short(&pSrc->value, &pDest->value, encode, num); - } + if (num == 1) /* single value */ + pDest->value = dbr_ntohs(pSrc->value); + else /* array chan-- multiple pts */ + { + cvrt_short(&pSrc->value, &pDest->value, encode, num); + } } /**************************************************************************** -** cvrt_time_float(s,d) +** cvrt_time_float(s,d) ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_time_float( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_time_float *pSrc = (struct dbr_time_float *) s; - struct dbr_time_float *pDest = (struct dbr_time_float *) d; + struct dbr_time_float *pSrc = (struct dbr_time_float *) s; + struct dbr_time_float *pDest = (struct dbr_time_float *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); - pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); + pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); - cvrt_float(&pSrc->value, &pDest->value, encode, num); + cvrt_float(&pSrc->value, &pDest->value, encode, num); } /**************************************************************************** -** cvrt_time_double(s,d) +** cvrt_time_double(s,d) ** -** if encode -** converts struct in HOST format to ieee format -** else -** converts fields of struct in NET format to fields with HOST -** format; +** if encode +** converts struct in HOST format to ieee format +** else +** converts fields of struct in NET format to fields with HOST +** format; ****************************************************************************/ LOCAL void cvrt_time_double( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_time_double *pSrc = (struct dbr_time_double *) s; - struct dbr_time_double *pDest = (struct dbr_time_double *) d; + struct dbr_time_double *pSrc = (struct dbr_time_double *) s; + struct dbr_time_double *pDest = (struct dbr_time_double *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); - pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); + pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); - cvrt_double(&pSrc->value, &pDest->value, encode, num); + cvrt_double(&pSrc->value, &pDest->value, encode, num); } /**************************************************************************** -** cvrt_time_enum(s,d) +** cvrt_time_enum(s,d) ** -** converts fields of struct in NET format to fields with HOST format -** or -** converts fields of struct in HOST format to fields with NET format -** +** converts fields of struct in NET format to fields with HOST format +** or +** converts fields of struct in HOST format to fields with NET format +** ****************************************************************************/ LOCAL void cvrt_time_enum( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_time_enum *pSrc = (struct dbr_time_enum *) s; - struct dbr_time_enum *pDest = (struct dbr_time_enum *) d; + struct dbr_time_enum *pSrc = (struct dbr_time_enum *) s; + struct dbr_time_enum *pDest = (struct dbr_time_enum *) d; - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); - pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); - if (num == 1) - pDest->value = dbr_ntohs(pSrc->value); - else { - cvrt_enum(&pSrc->value,&pDest->value,encode,num); - } + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); + pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); + if (num == 1) + pDest->value = dbr_ntohs(pSrc->value); + else { + cvrt_enum(&pSrc->value,&pDest->value,encode,num); + } } /**************************************************************************** -** cvrt_sts_char(s,d) +** cvrt_sts_char(s,d) ** -** converts fields ofstruct in HOST format to ieee format -** or -** converts fields of struct in NET format to fields with HOST -** format +** converts fields ofstruct in HOST format to ieee format +** or +** converts fields of struct in NET format to fields with HOST +** format ****************************************************************************/ LOCAL void cvrt_time_char( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_time_char *pSrc = (struct dbr_time_char *) s; - struct dbr_time_char *pDest = (struct dbr_time_char *) d; + struct dbr_time_char *pSrc = (struct dbr_time_char *) s; + struct dbr_time_char *pDest = (struct dbr_time_char *) d; - /* convert vax to ieee or ieee to vax format -- same code*/ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); - pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); + /* convert vax to ieee or ieee to vax format -- same code*/ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); + pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); - if (num == 1) /* single value */ - pDest->value = pSrc->value; - else /* array chan-- multiple pts */ - { - memcpy((void *)&pDest->value, (void *)&pSrc->value, num); - } + if (num == 1) /* single value */ + pDest->value = pSrc->value; + else /* array chan-- multiple pts */ + { + memcpy((void *)&pDest->value, (void *)&pSrc->value, num); + } } /**************************************************************************** -** cvrt_time_long(s,d) +** cvrt_time_long(s,d) ** -** converts fields ofstruct in HOST format to ieee format -** or -** converts fields of struct in NET format to fields with HOST -** format +** converts fields ofstruct in HOST format to ieee format +** or +** converts fields of struct in NET format to fields with HOST +** format ****************************************************************************/ LOCAL void cvrt_time_long( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - struct dbr_time_long *pSrc = (struct dbr_time_long *) s; - struct dbr_time_long *pDest = (struct dbr_time_long *) d; + struct dbr_time_long *pSrc = (struct dbr_time_long *) s; + struct dbr_time_long *pDest = (struct dbr_time_long *) d; - /* convert vax to ieee or ieee to vax format -- same code*/ - pDest->status = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); - pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); + /* convert vax to ieee or ieee to vax format -- same code*/ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->stamp.secPastEpoch = dbr_ntohl(pSrc->stamp.secPastEpoch); + pDest->stamp.nsec = dbr_ntohl(pSrc->stamp.nsec); - if (num == 1) /* single value */ - pDest->value = dbr_ntohl(pSrc->value); - else /* array chan-- multiple pts */ - { - cvrt_long(&pDest->value, &pSrc->value, encode, num); - } + if (num == 1) /* single value */ + pDest->value = dbr_ntohl(pSrc->value); + else /* array chan-- multiple pts */ + { + cvrt_long(&pDest->value, &pSrc->value, encode, num); + } } /* - * cvrt_put_ackt() + * cvrt_put_ackt() * * * * */ LOCAL void cvrt_put_ackt( -const void *s, /* source */ -void *d, /* destination */ -int encode, /* cvrt HOST to NET if T */ -unsigned long num /* number of values */ +const void *s, /* source */ +void *d, /* destination */ +int encode, /* cvrt HOST to NET if T */ +unsigned long num /* number of values */ ) { - dbr_put_ackt_t *pSrc = (dbr_put_ackt_t *) s; - dbr_put_ackt_t *pDest = (dbr_put_ackt_t *) d; - unsigned long i; + dbr_put_ackt_t *pSrc = (dbr_put_ackt_t *) s; + dbr_put_ackt_t *pDest = (dbr_put_ackt_t *) d; + unsigned long i; - for(i=0; istatus = dbr_ntohs(pSrc->status); - pDest->severity = dbr_ntohs(pSrc->severity); - pDest->ackt = dbr_ntohs(pSrc->ackt); - pDest->acks = dbr_ntohs(pSrc->acks); + struct dbr_stsack_string *pSrc = (struct dbr_stsack_string *) s; + struct dbr_stsack_string *pDest = (struct dbr_stsack_string *) d; + + /* convert ieee to vax format or vax to ieee */ + pDest->status = dbr_ntohs(pSrc->status); + pDest->severity = dbr_ntohs(pSrc->severity); + pDest->ackt = dbr_ntohs(pSrc->ackt); + pDest->acks = dbr_ntohs(pSrc->acks); - /* convert "in place" -> nothing else to do */ - if (s == d) - return; - - if (num == 1) /* if single value */ - strcpy(pDest->value, pSrc->value); - else - memcpy(pDest->value, pSrc->value, (MAX_STRING_SIZE * num)); + /* convert "in place" -> nothing else to do */ + if (s == d) + return; + if (num == 1) /* if single value */ + strcpy(pDest->value, pSrc->value); + else + memcpy(pDest->value, pSrc->value, (MAX_STRING_SIZE * num)); } #if defined(CA_FLOAT_MIT) /************************************************************************/ -/* double convert */ +/* double convert */ /* (THIS ASSUMES IEEE IS THE NETWORK FLOATING POINT FORMAT) */ /************************************************************************/ @@ -1478,41 +1357,41 @@ void dbr_htond(dbr_double_t *pHost, dbr_double_t *pNet) CVT$M_BIG_ENDIAN); # endif #else - dbr_double_t copyin; - struct mitdbl *pMIT; - struct ieeedbl *pIEEE; - ca_uint32_t *ptmp; - ca_uint32_t tmp; + dbr_double_t copyin; + struct mitdbl *pMIT; + struct ieeedbl *pIEEE; + ca_uint32_t *ptmp; + ca_uint32_t tmp; - /* - * Use internal buffer so the src and dest ptr - * can be identical - */ - copyin = *pHost; - pMIT = (struct mitdbl *) ©in; - pIEEE = (struct ieeedbl *) pNet; + /* + * Use internal buffer so the src and dest ptr + * can be identical + */ + copyin = *pHost; + pMIT = (struct mitdbl *) ©in; + pIEEE = (struct ieeedbl *) pNet; - if( ((int)pMIT->exp) < (DBLEXPMINMIT+MIT_DBL_SB) ){ - pIEEE->mant1 = 0; - pIEEE->mant2 = 0; - pIEEE->exp = 0; - pIEEE->sign = 0; - } - else{ - pIEEE->exp = ((int)pMIT->exp)+(IEEE_DBL_SB-MIT_DBL_SB); - pIEEE->mant1 = (pMIT->mant1<<13) | (pMIT->mant2>>3); - pIEEE->mant2 = (pMIT->mant2<<29) | (pMIT->mant3<<13) | - (pMIT->mant4>>3); - pIEEE->sign = pMIT->sign; - } + if( ((int)pMIT->exp) < (DBLEXPMINMIT+MIT_DBL_SB) ){ + pIEEE->mant1 = 0; + pIEEE->mant2 = 0; + pIEEE->exp = 0; + pIEEE->sign = 0; + } + else{ + pIEEE->exp = ((int)pMIT->exp)+(IEEE_DBL_SB-MIT_DBL_SB); + pIEEE->mant1 = (pMIT->mant1<<13) | (pMIT->mant2>>3); + pIEEE->mant2 = (pMIT->mant2<<29) | (pMIT->mant3<<13) | + (pMIT->mant4>>3); + pIEEE->sign = pMIT->sign; + } - /* - * byte swap to net order - */ - ptmp = (ca_uint32_t *) pNet; - tmp = dbr_htonl(ptmp[0]); - ptmp[0] = dbr_htonl(ptmp[1]); - ptmp[1] = tmp; + /* + * byte swap to net order + */ + ptmp = (ca_uint32_t *) pNet; + tmp = dbr_htonl(ptmp[0]); + ptmp[0] = dbr_htonl(ptmp[1]); + ptmp[1] = tmp; #endif } @@ -1536,54 +1415,54 @@ void dbr_ntohd(dbr_double_t *pNet, dbr_double_t *pHost) CVT$M_BIG_ENDIAN); # endif #else - struct ieeedbl copyin; - struct mitdbl *pMIT; - struct ieeedbl *pIEEE; - ca_uint32_t *ptmp; - ca_uint32_t tmp; + struct ieeedbl copyin; + struct mitdbl *pMIT; + struct ieeedbl *pIEEE; + ca_uint32_t *ptmp; + ca_uint32_t tmp; - pIEEE = (struct ieeedbl *)pNet; - pMIT = (struct mitdbl *)pHost; + pIEEE = (struct ieeedbl *)pNet; + pMIT = (struct mitdbl *)pHost; - /* - * Use internal buffer so the src and dest ptr - * can be identical - */ - copyin = *pIEEE; - pIEEE = ©in; + /* + * Use internal buffer so the src and dest ptr + * can be identical + */ + copyin = *pIEEE; + pIEEE = ©in; - /* - * Byte swap from net order to host order - */ - ptmp = (ca_uint32_t *) pIEEE; - tmp = dbr_htonl(ptmp[0]); - ptmp[0] = dbr_htonl(ptmp[1]); - ptmp[1] = tmp; + /* + * Byte swap from net order to host order + */ + ptmp = (ca_uint32_t *) pIEEE; + tmp = dbr_htonl(ptmp[0]); + ptmp[0] = dbr_htonl(ptmp[1]); + ptmp[1] = tmp; - if( ((int)pIEEE->exp) > (DBLEXPMAXMIT + IEEE_DBL_SB) ){ - pMIT->sign = pIEEE->sign; - pMIT->exp = DBLEXPMAXMIT + MIT_DBL_SB; - pMIT->mant1 = ~0; - pMIT->mant2 = ~0; - pMIT->mant3 = ~0; - pMIT->mant4 = ~0; - } - else if( ((int)pIEEE->exp) < (DBLEXPMINMIT + IEEE_DBL_SB) ){ - pMIT->sign = 0; - pMIT->exp = 0; - pMIT->mant1 = 0; - pMIT->mant2 = 0; - pMIT->mant3 = 0; - pMIT->mant4 = 0; - } - else{ - pMIT->sign = pIEEE->sign; - pMIT->exp = ((int)pIEEE->exp)+(MIT_DBL_SB-IEEE_DBL_SB); - pMIT->mant1 = pIEEE->mant1>>13; - pMIT->mant2 = (pIEEE->mant1<<3) | (pIEEE->mant2>>29); - pMIT->mant3 = pIEEE->mant2>>13; - pMIT->mant4 = pIEEE->mant2<<3; - } + if( ((int)pIEEE->exp) > (DBLEXPMAXMIT + IEEE_DBL_SB) ){ + pMIT->sign = pIEEE->sign; + pMIT->exp = DBLEXPMAXMIT + MIT_DBL_SB; + pMIT->mant1 = ~0; + pMIT->mant2 = ~0; + pMIT->mant3 = ~0; + pMIT->mant4 = ~0; + } + else if( ((int)pIEEE->exp) < (DBLEXPMINMIT + IEEE_DBL_SB) ){ + pMIT->sign = 0; + pMIT->exp = 0; + pMIT->mant1 = 0; + pMIT->mant2 = 0; + pMIT->mant3 = 0; + pMIT->mant4 = 0; + } + else{ + pMIT->sign = pIEEE->sign; + pMIT->exp = ((int)pIEEE->exp)+(MIT_DBL_SB-IEEE_DBL_SB); + pMIT->mant1 = pIEEE->mant1>>13; + pMIT->mant2 = (pIEEE->mant1<<3) | (pIEEE->mant2>>29); + pMIT->mant3 = pIEEE->mant2>>13; + pMIT->mant4 = pIEEE->mant2<<3; + } #endif } @@ -1630,29 +1509,29 @@ struct mitflt{ void dbr_htonf(dbr_float_t *pHost, dbr_float_t *pNet) { #if defined(VMS) - cvt$convert_float(pHost, CVT$K_VAX_F , - pNet , CVT$K_IEEE_S, - CVT$M_BIG_ENDIAN); + cvt$convert_float(pHost, CVT$K_VAX_F , + pNet , CVT$K_IEEE_S, + CVT$M_BIG_ENDIAN); #else - struct mitflt *pMIT = (struct mitflt *) pHost; - struct ieeeflt *pIEEE = (struct ieeeflt *) pNet; - long exp,mant,sign; + struct mitflt *pMIT = (struct mitflt *) pHost; + struct ieeeflt *pIEEE = (struct ieeeflt *) pNet; + long exp,mant,sign; - sign = pMIT->sign; + sign = pMIT->sign; - if( ((int)pMIT->exp) < EXPMINIEEE + MIT_SB){ - exp = 0; - mant = 0; - sign = 0; - } - else{ - exp = ((int)pMIT->exp)-MIT_SB+IEEE_SB; - mant = (pMIT->mant1<<16) | pMIT->mant2; - } - pIEEE->mant = mant; - pIEEE->exp = exp; - pIEEE->sign = sign; - *(ca_uint32_t *)pIEEE = dbr_htonl(*(ca_uint32_t *)pIEEE); + if( ((int)pMIT->exp) < EXPMINIEEE + MIT_SB){ + exp = 0; + mant = 0; + sign = 0; + } + else{ + exp = ((int)pMIT->exp)-MIT_SB+IEEE_SB; + mant = (pMIT->mant1<<16) | pMIT->mant2; + } + pIEEE->mant = mant; + pIEEE->exp = exp; + pIEEE->sign = sign; + *(ca_uint32_t *)pIEEE = dbr_htonl(*(ca_uint32_t *)pIEEE); #endif } @@ -1667,37 +1546,37 @@ void dbr_htonf(dbr_float_t *pHost, dbr_float_t *pNet) void dbr_ntohf(dbr_float_t *pNet, dbr_float_t *pHost) { #if defined(VMS) - cvt$convert_float(pNet , CVT$K_IEEE_S, - pHost, CVT$K_VAX_F , - CVT$M_BIG_ENDIAN); + cvt$convert_float(pNet , CVT$K_IEEE_S, + pHost, CVT$K_VAX_F , + CVT$M_BIG_ENDIAN); #else - struct mitflt *pMIT = (struct mitflt *) pHost; - struct ieeeflt *pIEEE = (struct ieeeflt *) pNet; - long exp,mant2,mant1,sign; + struct mitflt *pMIT = (struct mitflt *) pHost; + struct ieeeflt *pIEEE = (struct ieeeflt *) pNet; + long exp,mant2,mant1,sign; - *(ca_uint32_t *)pIEEE = dbr_ntohl(*(ca_uint32_t *)pIEEE); - if( ((int)pIEEE->exp) > EXPMAXMIT + IEEE_SB){ - sign = pIEEE->sign; - exp = EXPMAXMIT + MIT_SB; - mant2 = ~0; - mant1 = ~0; - } - else if( pIEEE->exp == 0){ - sign = 0; - exp = 0; - mant2 = 0; - mant1 = 0; - } - else{ - sign = pIEEE->sign; - exp = pIEEE->exp+MIT_SB-IEEE_SB; - mant2 = pIEEE->mant; - mant1 = pIEEE->mant>>(unsigned)16; - } - pMIT->exp = exp; - pMIT->mant2 = mant2; - pMIT->mant1 = mant1; - pMIT->sign = sign; + *(ca_uint32_t *)pIEEE = dbr_ntohl(*(ca_uint32_t *)pIEEE); + if( ((int)pIEEE->exp) > EXPMAXMIT + IEEE_SB){ + sign = pIEEE->sign; + exp = EXPMAXMIT + MIT_SB; + mant2 = ~0; + mant1 = ~0; + } + else if( pIEEE->exp == 0){ + sign = 0; + exp = 0; + mant2 = 0; + mant1 = 0; + } + else{ + sign = pIEEE->sign; + exp = pIEEE->exp+MIT_SB-IEEE_SB; + mant2 = pIEEE->mant; + mant1 = pIEEE->mant>>(unsigned)16; + } + pMIT->exp = exp; + pMIT->mant2 = mant2; + pMIT->mant1 = mant1; + pMIT->sign = sign; #endif } @@ -1713,20 +1592,20 @@ void dbr_ntohf(dbr_float_t *pNet, dbr_float_t *pHost) void dbr_htond (dbr_double_t *IEEEhost, dbr_double_t *IEEEnet) { #ifdef CA_LITTLE_ENDIAN - ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost; - ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet; - ca_uint32_t tmp; + ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost; + ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet; + ca_uint32_t tmp; - /* - * byte swap to net order - * (assume that src and dest ptrs - * may be identical) - */ - tmp = pHost[0]; - pNet[0] = dbr_htonl (pHost[1]); - pNet[1] = dbr_htonl (tmp); + /* + * byte swap to net order + * (assume that src and dest ptrs + * may be identical) + */ + tmp = pHost[0]; + pNet[0] = dbr_htonl (pHost[1]); + pNet[1] = dbr_htonl (tmp); #else - *IEEEnet = *IEEEhost; + *IEEEnet = *IEEEhost; #endif } @@ -1737,20 +1616,20 @@ void dbr_htond (dbr_double_t *IEEEhost, dbr_double_t *IEEEnet) void dbr_ntohd (dbr_double_t *IEEEnet, dbr_double_t *IEEEhost) { #ifdef CA_LITTLE_ENDIAN - ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost; - ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet; - ca_uint32_t tmp; + ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost; + ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet; + ca_uint32_t tmp; - /* - * byte swap to net order - * (assume that src and dest ptrs - * may be identical) - */ - tmp = pNet[0]; - pHost[0] = dbr_ntohl (pNet[1]); - pHost[1] = dbr_ntohl (tmp); + /* + * byte swap to net order + * (assume that src and dest ptrs + * may be identical) + */ + tmp = pNet[0]; + pHost[0] = dbr_ntohl (pNet[1]); + pHost[1] = dbr_ntohl (tmp); #else - *IEEEhost = *IEEEnet; + *IEEEhost = *IEEEnet; #endif } @@ -1760,10 +1639,10 @@ void dbr_ntohd (dbr_double_t *IEEEnet, dbr_double_t *IEEEhost) */ void dbr_ntohf (dbr_float_t *IEEEnet, dbr_float_t *IEEEhost) { - ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost; - ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet; + ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost; + ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet; - *pHost = dbr_ntohl (*pNet); + *pHost = dbr_ntohl (*pNet); } /* @@ -1772,14 +1651,62 @@ void dbr_ntohf (dbr_float_t *IEEEnet, dbr_float_t *IEEEhost) */ void dbr_htonf (dbr_float_t *IEEEhost, dbr_float_t *IEEEnet) { - ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost; - ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet; + ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost; + ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet; - *pNet = dbr_htonl (*pHost); + *pNet = dbr_htonl (*pHost); } #endif /* IEEE float and little endian */ +/* cvrt is (array of) (pointer to) (function returning) int */ +epicsShareDef CACVRTFUNC *cac_dbr_cvrt[] = { + cvrt_string, + cvrt_short, + cvrt_float, + cvrt_enum, + cvrt_char, + cvrt_long, + cvrt_double, + + cvrt_sts_string, + cvrt_sts_short, + cvrt_sts_float, + cvrt_sts_enum, + cvrt_sts_char, + cvrt_sts_long, + cvrt_sts_double, + + cvrt_time_string, + cvrt_time_short, + cvrt_time_float, + cvrt_time_enum, + cvrt_time_char, + cvrt_time_long, + cvrt_time_double, + + cvrt_sts_string, /* DBR_GR_STRING identical to dbr_sts_string */ + cvrt_gr_short, + cvrt_gr_float, + cvrt_gr_enum, + cvrt_gr_char, + cvrt_gr_long, + cvrt_gr_double, + + cvrt_sts_string, /* DBR_CTRL_STRING identical to dbr_sts_string */ + cvrt_ctrl_short, + cvrt_ctrl_float, + cvrt_ctrl_enum, + cvrt_ctrl_char, + cvrt_ctrl_long, + cvrt_ctrl_double, + + cvrt_put_ackt, + cvrt_put_ackt, /* DBR_PUT_ACKS identical to DBR_PUT_ACKT */ + cvrt_stsack_string, + cvrt_string +}; + #endif /* CONVERSION_REQUIRED */