fixed problems in aitString and the conversion matrix

This commit is contained in:
Jeff Hill
1997-08-05 00:51:16 +00:00
parent 1e8abfda04
commit 8b97305072
15 changed files with 890 additions and 626 deletions

View File

@@ -5,6 +5,9 @@
// $Id$
//
// $Log$
// Revision 1.5 1997/04/23 17:12:53 jhill
// fixed export of symbols from WIN32 DLL
//
// Revision 1.4 1996/11/02 01:24:39 jhill
// strcpy => styrcpy (shuts up purify)
//
@@ -36,7 +39,7 @@
#include "aitConvert.h"
extern "C" {
void aitNoConvert(void* /*dest*/,const void* /*src*/,aitIndex /*count*/) { }
int aitNoConvert(void* /*dest*/,const void* /*src*/,aitIndex /*count*/) {return -1;}
}
#ifdef AIT_CONVERT
@@ -49,45 +52,52 @@ void aitNoConvert(void* /*dest*/,const void* /*src*/,aitIndex /*count*/) { }
#undef AIT_FROM_NET_CONVERT
#endif
#ifndef min
#define min(A,B) ((A)<(B)?(A):(B))
#endif
/* put the fixed conversion functions here (ones not generated) */
/* ------- extra string conversion functions --------- */
static void aitConvertStringString(void* d,const void* s,aitIndex c)
static int aitConvertStringString(void* d,const void* s,aitIndex c)
{
// does not work - need to be fixed
int i;
aitIndex i;
aitString *in=(aitString*)s, *out=(aitString*)d;
for(i=0;i<c;i++) out[i]=in[i];
return 0;
}
static void aitConvertToNetStringString(void* d,const void* s,aitIndex c)
{ aitConvertStringString(d,s,c); }
static void aitConvertFromNetStringString(void* d,const void* s,aitIndex c)
{ aitConvertStringString(d,s,c); }
static int aitConvertToNetStringString(void* d,const void* s,aitIndex c)
{ return aitConvertStringString(d,s,c);}
static int aitConvertFromNetStringString(void* d,const void* s,aitIndex c)
{ return aitConvertStringString(d,s,c);}
/* ------ all the fixed string conversion functions ------ */
static void aitConvertFixedStringFixedString(void* d,const void* s,aitIndex c)
static int aitConvertFixedStringFixedString(void* d,const void* s,aitIndex c)
{
aitUint32 len = c*AIT_FIXED_STRING_SIZE;
memcpy(d,s,len);
return 0;
}
static void aitConvertToNetFixedStringFixedString(void* d,const void* s,aitIndex c)
{ aitConvertFixedStringFixedString(d,s,c); }
static void aitConvertFromNetFixedStringFixedString(void* d,const void* s,aitIndex c)
{ aitConvertFixedStringFixedString(d,s,c); }
static int aitConvertToNetFixedStringFixedString(void* d,const void* s,aitIndex c)
{ return aitConvertFixedStringFixedString(d,s,c);}
static int aitConvertFromNetFixedStringFixedString(void* d,const void* s,aitIndex c)
{ return aitConvertFixedStringFixedString(d,s,c);}
static void aitConvertStringFixedString(void* d,const void* s,aitIndex c)
static int aitConvertStringFixedString(void* d,const void* s,aitIndex c)
{
int i;
aitIndex i;
aitString* out = (aitString*)d;
aitFixedString* in = (aitFixedString*)s;
for(i=0;i<c;i++) out[i].installString(in[i].fixed_string);
for(i=0;i<c;i++) out[i].copy(in[i].fixed_string);
return 0;
}
static void aitConvertFixedStringString(void* d,const void* s,aitIndex c)
static int aitConvertFixedStringString(void* d,const void* s,aitIndex c)
{
int i;
aitIndex i;
aitString* in = (aitString*)s;
aitFixedString* out = (aitFixedString*)d;
@@ -101,16 +111,17 @@ static void aitConvertFixedStringString(void* d,const void* s,aitIndex c)
strncpy(out[i].fixed_string,in[i].string(),AIT_FIXED_STRING_SIZE);
out[i].fixed_string[AIT_FIXED_STRING_SIZE-1u] = '\0';
}
return 0;
}
static void aitConvertToNetStringFixedString(void* d,const void* s,aitIndex c)
{ aitConvertStringFixedString(d,s,c); }
static void aitConvertFromNetFixedStringString(void* d,const void* s,aitIndex c)
{ aitConvertFixedStringString(d,s,c); }
static void aitConvertToNetFixedStringString(void* d,const void* s,aitIndex c)
{ aitConvertStringFixedString(d,s,c); }
static void aitConvertFromNetStringFixedString(void* d,const void* s,aitIndex c)
{ aitConvertFixedStringString(d,s,c); }
static int aitConvertToNetStringFixedString(void* d,const void* s,aitIndex c)
{ return aitConvertStringFixedString(d,s,c); }
static int aitConvertFromNetFixedStringString(void* d,const void* s,aitIndex c)
{ return aitConvertFixedStringString(d,s,c); }
static int aitConvertToNetFixedStringString(void* d,const void* s,aitIndex c)
{ return aitConvertStringFixedString(d,s,c); }
static int aitConvertFromNetStringFixedString(void* d,const void* s,aitIndex c)
{ return aitConvertFixedStringString(d,s,c); }
#define AIT_CONVERT 1
#include "aitConvertGenerated.cc"

View File

@@ -8,6 +8,9 @@
* $Id$
*
* $Log$
* Revision 1.4 1997/04/10 19:59:22 jhill
* api changes
*
* Revision 1.3 1996/10/17 12:41:07 jbk
* network byte order stuff / added strDup function to Helpers
*
@@ -43,7 +46,7 @@
typedef enum { aitLocalDataFormat=0, aitNetworkDataFormat } aitDataFormat;
/* all conversion functions have this prototype */
typedef void (*aitFunc)(void* dest,const void* src,aitIndex count);
typedef int (*aitFunc)(void* dest,const void* src,aitIndex count);
#ifdef __cplusplus
extern "C" {
@@ -68,28 +71,28 @@ epicsShareExtern aitFunc aitConvertFromNetTable[aitTotal][aitTotal];
#if defined(__cplusplus) && !defined(__GNUC__)
inline void aitConvert(aitEnum desttype, void* dest,
inline int aitConvert(aitEnum desttype, void* dest,
aitEnum srctype, const void* src, aitIndex count)
{ aitConvertTable[desttype][srctype](dest,src,count); }
{ return (*aitConvertTable[desttype][srctype])(dest,src,count); }
inline void aitConvertToNet(aitEnum desttype, void* dest,
inline int aitConvertToNet(aitEnum desttype, void* dest,
aitEnum srctype, const void* src, aitIndex count)
{ aitConvertToNetTable[desttype][srctype](dest,src,count); }
{ return (*aitConvertToNetTable[desttype][srctype])(dest,src,count); }
inline void aitConvertFromNet(aitEnum desttype, void* dest,
inline int aitConvertFromNet(aitEnum desttype, void* dest,
aitEnum srctype, const void* src, aitIndex count)
{ aitConvertFromNetTable[desttype][srctype](dest,src,count); }
{ return (*aitConvertFromNetTable[desttype][srctype])(dest,src,count); }
#else
#define aitConvert(DESTTYPE,DEST,SRCTYPE,SRC,COUNT) \
aitConvertTable[DESTTYPE][SRCTYPE](DEST,SRC,COUNT)
(*aitConvertTable[DESTTYPE][SRCTYPE])(DEST,SRC,COUNT)
#define aitConvertToNet(DESTTYPE,DEST,SRCTYPE,SRC,COUNT) \
aitConvertToNetTable[DESTTYPE][SRCTYPE](DEST,SRC,COUNT)
(*aitConvertToNetTable[DESTTYPE][SRCTYPE])(DEST,SRC,COUNT)
#define aitConvertFromNet(DESTTYPE,DEST,SRCTYPE,SRC,COUNT) \
aitConvertFromNetTable[DESTTYPE][SRCTYPE](DEST,SRC,COUNT)
(*aitConvertFromNetTable[DESTTYPE][SRCTYPE])(DEST,SRC,COUNT)
#endif

View File

@@ -5,6 +5,9 @@
* $Id$
*
* $Log$
* Revision 1.6 1997/06/13 09:26:04 jhill
* fixed generated conversion functions
*
* Revision 1.5 1997/05/01 19:54:50 jhill
* updated dll keywords
*
@@ -167,49 +170,28 @@ void MakeStringFuncFrom(int i,int j,int k)
/* assumes that void* d in an array of char pointers of length c */
/* takes numeric data from source j and convert it to string in dest i */
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
pr(dfd,"static int %s%s%s(void* d,const void* s,aitIndex c)\n",
table_type[k],&(aitName[i])[3],&(aitName[j])[3]);
pr(dfd,"{\n");
pr(dfd,"\taitIndex i;\n");
pr(dfd,"\tint status=0;\n");
pr(dfd,"\tchar temp[AIT_FIXED_STRING_SIZE];\n");
pr(dfd,"\taitString* out=(aitString*)d;\n");
pr(dfd,"\t%s* in=(%s*)s;\n",aitName[j],aitName[j]);
#if 0
if(j==aitEnumInt8)
{
pr(dfd,"\n\t// assume source s is string if count c is 1\n");
pr(dfd,"\n\tif(c==1) {\n");
pr(dfd,"\t\tout->copy((char*)in);\n");
pr(dfd,"\t\treturn;\n");
pr(dfd,"\t}\n\n");
}
#endif
if(j==aitEnumInt8)
pr(dfd,"\taitInt32 itmp;\n");
else if(j==aitEnumUint8)
pr(dfd,"\taitUint32 itmp;\n");
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
if(j==aitEnumInt8)
pr(dfd,"\t\titmp=(aitInt32)in[i];\n");
else if(j==aitEnumUint8)
pr(dfd,"\t\titmp=(aitUint32)in[i];\n");
if(j==aitEnumInt8)
pr(dfd,"\t\tsprintf(temp, \"%s\",itmp);\n",
aitStringType[aitEnumInt32]);
else if(j==aitEnumUint8)
pr(dfd,"\t\tsprintf(temp, \"%s\",itmp);\n",
aitStringType[aitEnumUint32]);
else
pr(dfd,"\t\tsprintf(temp, \"%s\",in[i]);\n",
aitStringType[j]);
pr(dfd,"\t\tout[i].installString(temp);\n");
pr(dfd,"\t\tint nChar;\n");
pr(dfd,"\t\tnChar = sprintf(temp, \"%%%s\",in[i]);\n",
aitPrintf[j]);
pr(dfd,"\t\tif (nChar>=0) {\n");
pr(dfd,"\t\t\tstatus += nChar;\n");
pr(dfd,"\t\t\tout[i].copy(temp);\n");
pr(dfd,"\t\t}\n");
pr(dfd,"\t\telse {\n");
pr(dfd,"\t\t\treturn -1;\n");
pr(dfd,"\t\t}\n");
pr(dfd,"\t}\n");
pr(dfd,"\treturn status;\n");
pr(dfd,"}\n");
}
@@ -218,57 +200,47 @@ void MakeStringFuncTo(int i,int j,int k)
/* assumes that void* d in an array of char pointers of length c */
/* takes string data from source j and convert it to numeric in dest i */
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
pr(dfd,"static int %s%s%s(void* d,const void* s,aitIndex c)\n",
table_type[k],&(aitName[i])[3],&(aitName[j])[3]);
pr(dfd,"{\n");
pr(dfd,"\taitIndex i;\n");
pr(dfd,"\taitString* in=(aitString*)s;\n");
pr(dfd,"\t%s* out=(%s*)d;\n",aitName[i],aitName[i]);
/* I special cased the Int8 and Uint8 - yuck */
#if 0
if(i==aitEnumInt8)
{
pr(dfd,"\n\t// assume dest d is string if count c is 1\n");
pr(dfd,"\n\tif(c==1) {\n");
pr(dfd,"\t\tin->extractString((char*)out);\n");
pr(dfd,"\t\treturn;\n");
pr(dfd,"\t}\n\n");
}
#endif
if(i==aitEnumInt8)
pr(dfd,"\taitInt32 itmp;\n");
else if(i==aitEnumUint8)
pr(dfd,"\taitUint32 itmp;\n");
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
pr(dfd,"\t\tif(in[i].string()) {\n");
pr(dfd,"\t\t\tint j;\n");
pr(dfd,"\t\t\tdouble ftmp;\n");
if(i==aitEnumInt8)
{
pr(dfd,"\t\t\tj = sscanf(in[i],\"%s\",&itmp);\n",
aitStringType[aitEnumInt32]);
pr(dfd,"\t\t\tout[i]=(aitInt8)itmp;\n");
}
else if(i==aitEnumUint8)
{
pr(dfd,"\t\t\tj = sscanf(in[i], \"%s\",&itmp);\n",
aitStringType[aitEnumUint32]);
pr(dfd,"\t\t\tout[i]=(aitUint8)itmp;\n");
}
else
pr(dfd,"\t\t\tj = sscanf(in[i].string(), \"%s\",&out[i]);\n",
aitStringType[i]);
pr(dfd,"\t\t\tif (j!=1) {\n");
pr(dfd,"\t\t\t\tprintf (\"warning scanf() failed!\\n\");\n");
pr(dfd,"\t\t\t\tout[i]=0;\n");
pr(dfd,"\t\t\tj = sscanf(in[i],\"%%lf\",&ftmp);\n");
pr(dfd,"\t\t\tif (j==1) {\n");
pr(dfd,"\t\t\t\tif (ftmp>=%g && ftmp<=%g) {\n",
aitMin[i], aitMax[i]);
pr(dfd,"\t\t\t\t\tout[i] = (%s) ftmp;\n", aitName[i]);
pr(dfd,"\t\t\t\t}\n");
pr(dfd,"\t\t\t\telse {\n");
pr(dfd,"\t\t\t\t\treturn -1;\n");
pr(dfd,"\t\t\t\t}\n");
pr(dfd,"\t\t\t}\n");
pr(dfd,"\t\t} else\n");
pr(dfd,"\t\t\tout[i]=0;\n");
pr(dfd,"\t}\n}\n");
pr(dfd,"\t\t\telse {\n");
pr(dfd,"\t\t\t\tunsigned long itmp;\n");
pr(dfd,"\t\t\t\tj = sscanf(in[i],\"%%lx\",&itmp);\n");
pr(dfd,"\t\t\t\tif (j==1) {\n");
pr(dfd,"\t\t\t\t\tif (%g<=(double)itmp && %g>=(double)itmp) {\n",
aitMin[i], aitMax[i]);
pr(dfd,"\t\t\t\t\t\tout[i] = (%s) itmp;\n", aitName[i]);
pr(dfd,"\t\t\t\t\t}\n");
pr(dfd,"\t\t\t\t\telse {\n");
pr(dfd,"\t\t\t\t\t\treturn -1;\n");
pr(dfd,"\t\t\t\t\t}\n");
pr(dfd,"\t\t\t\t}\n");
pr(dfd,"\t\t\t\telse {\n");
pr(dfd,"\t\t\t\t\treturn -1;\n");
pr(dfd,"\t\t\t\t}\n");
pr(dfd,"\t\t\t}\n");
pr(dfd,"\t\t}\n");
pr(dfd,"\t}\n");
pr(dfd,"\treturn (int) (sizeof(%s)*c);\n}\n", aitName[i]);
}
void MakeFStringFuncFrom(int i,int j,int k)
@@ -276,7 +248,7 @@ void MakeFStringFuncFrom(int i,int j,int k)
/* assumes that void* d in an array of char pointers of length c */
/* takes numeric data from source j and convert it to string in dest i */
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
pr(dfd,"static int %s%s%s(void* d,const void* s,aitIndex c)\n",
table_type[k],&(aitName[i])[3],&(aitName[j])[3]);
pr(dfd,"{\n");
pr(dfd,"\taitIndex i;\n");
@@ -294,103 +266,64 @@ void MakeFStringFuncFrom(int i,int j,int k)
}
#endif
if(j==aitEnumInt8)
pr(dfd,"\taitInt32 itmp;\n");
else if(j==aitEnumUint8)
pr(dfd,"\taitUint32 itmp;\n");
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
if(j==aitEnumInt8)
pr(dfd,"\t\titmp=(aitInt32)in[i];\n");
else if(j==aitEnumUint8)
pr(dfd,"\t\titmp=(aitUint32)in[i];\n");
/*
* shut up purify
* (sprintf is so slow that is unliekly to be significant overhead)
*/
pr(dfd,"\t\tmemset(out[i].fixed_string,\'\\0\',sizeof(aitFixedString));\n");
if(j==aitEnumInt8)
pr(dfd,"\t\tsprintf(out[i].fixed_string, \"%s\",itmp);\n",
aitStringType[aitEnumInt32]);
else if(j==aitEnumUint8)
pr(dfd,"\t\tsprintf(out[i].fixed_string, \"%s\",itmp);\n",
aitStringType[aitEnumUint32]);
else
pr(dfd,"\t\tsprintf(out[i].fixed_string, \"%s\",in[i]);\n",
aitStringType[j]);
pr(dfd,"\t}\n}\n");
pr(dfd,"\t\tint nChar;\n");
pr(dfd,"\t\tnChar = sprintf(out[i].fixed_string, \"%%%s\",in[i]);\n",
aitPrintf[j]);
pr(dfd,"\t\tif (nChar>=0) {\n");
pr(dfd,"\t\t\tnChar = min(nChar,AIT_FIXED_STRING_SIZE-1)+1;\n");
pr(dfd,"\t\t\t/* shuts up purify */\n");
pr(dfd,"\t\t\tmemset(&out[i].fixed_string[nChar],\'\\0\',AIT_FIXED_STRING_SIZE-nChar);\n");
pr(dfd,"\t\t}\n");
pr(dfd,"\t\telse {\n");
pr(dfd,"\t\t\treturn -1;\n");
pr(dfd,"\t\t}\n");
pr(dfd,"\t}\n\treturn c*AIT_FIXED_STRING_SIZE;\n}\n");
}
void MakeFStringFuncTo(int i,int j,int k)
{
/* assumes that void* d in an array of char pointers of length c */
/* takes string data from source j and convert it to numeric in dest i */
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
pr(dfd,"static int %s%s%s(void* d,const void* s,aitIndex c)\n",
table_type[k],&(aitName[i])[3],&(aitName[j])[3]);
pr(dfd,"{\n");
pr(dfd,"\taitIndex i;\n");
pr(dfd,"\taitFixedString* in=(aitFixedString*)s;\n");
pr(dfd,"\t%s* out=(%s*)d;\n",aitName[i],aitName[i]);
/* I special cased the Int8 and Uint8 - yuck */
#if 0
if(i==aitEnumInt8)
{
pr(dfd,"\n\t// assume dest d is string if count c is 1\n");
pr(dfd,"\n\tif(c==1) {\n");
pr(dfd,"\t\tstrcpy((char*)out,in->fixed_string);\n");
pr(dfd,"\t\treturn;\n");
pr(dfd,"\t}\n\n");
}
#endif
if(i==aitEnumInt8)
pr(dfd,"\taitInt32 itmp;\n");
else if(i==aitEnumUint8)
pr(dfd,"\taitUint32 itmp;\n");
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
pr(dfd,"\t\tint j;\n");
pr(dfd,"\t\tdouble ftmp;\n");
if(i==aitEnumInt8)
{
pr(dfd,"\t\tj = sscanf(in[i].fixed_string,\"%s\",&itmp);\n",
aitStringType[aitEnumInt32]);
pr(dfd,"\t\tif (j==1) {\n");
pr(dfd,"\t\t\tout[i]=(aitInt8)itmp;\n");
pr(dfd,"\t\t}\n");
pr(dfd,"\t\telse {\n");
pr(dfd,"\t\t\tprintf (\"warning scanf() failed!\\n\");\n");
pr(dfd,"\t\t\tout[i]=0;\n");
pr(dfd,"\t\t}\n");
}
else if(i==aitEnumUint8)
{
pr(dfd,"\t\tj =sscanf(in[i].fixed_string, \"%s\",&itmp);\n",
aitStringType[aitEnumUint32]);
pr(dfd,"\t\tif (j==1) {\n");
pr(dfd,"\t\t\tout[i]=(aitUint8)itmp;\n");
pr(dfd,"\t\t}\n");
pr(dfd,"\t\telse {\n");
pr(dfd,"\t\t\tprintf (\"warning scanf() failed!\\n\");\n");
pr(dfd,"\t\t\tout[i]=0;\n");
pr(dfd,"\t\t}\n");
}
else {
pr(dfd,"\t\tj = sscanf(in[i].fixed_string, \"%s\",&out[i]);\n",
aitStringType[i]);
pr(dfd,"\t\tif (j!=1) {\n");
pr(dfd,"\t\t\tprintf (\"warning scanf() failed!\\n\");\n");
pr(dfd,"\t\t\tout[i]=0;\n");
pr(dfd,"\t\t}\n");
}
pr(dfd,"\t}\n}\n");
pr(dfd,"\t\tj = sscanf(in[i].fixed_string,\"%%lf\",&ftmp);\n");
pr(dfd,"\t\tif (j==1) {\n");
pr(dfd,"\t\t\tif (ftmp>=%g && ftmp<=%g) {\n",
aitMin[i], aitMax[i]);
pr(dfd,"\t\t\t\tout[i] = (%s) ftmp;\n", aitName[i]);
pr(dfd,"\t\t\t}\n");
pr(dfd,"\t\t\telse {\n");
pr(dfd,"\t\t\t\treturn -1;\n");
pr(dfd,"\t\t\t}\n");
pr(dfd,"\t\t}\n");
pr(dfd,"\t\telse {\n");
pr(dfd,"\t\t\tunsigned long itmp;\n");
pr(dfd,"\t\t\tj = sscanf(in[i].fixed_string,\"%%lx\",&itmp);\n");
pr(dfd,"\t\t\tif (j==1) {\n");
pr(dfd,"\t\t\t\tif (%g<=(double)itmp && %g>=(double)itmp) {\n",
aitMin[i], aitMax[i]);
pr(dfd,"\t\t\t\t\tout[i] = (%s) itmp;\n", aitName[i]);
pr(dfd,"\t\t\t\t}\n");
pr(dfd,"\t\t\t\telse {\n");
pr(dfd,"\t\t\t\t\treturn -1;\n");
pr(dfd,"\t\t\t\t}\n");
pr(dfd,"\t\t\t}\n");
pr(dfd,"\t\t\telse {\n");
pr(dfd,"\t\t\t\treturn -1;\n");
pr(dfd,"\t\t\t}\n");
pr(dfd,"\t\t}\n");
pr(dfd,"\t}\n");
pr(dfd,"\treturn (int) (sizeof(%s)*c);\n}\n", aitName[i]);
}
void GenName(int i,int j,int k)
@@ -398,7 +331,7 @@ void GenName(int i,int j,int k)
const char* i_name = &((aitName[i])[3]);
const char* j_name = &((aitName[j])[3]);
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
pr(dfd,"static int %s%s%s(void* d,const void* s,aitIndex c)\n",
table_type[k],i_name,j_name);
}
@@ -461,7 +394,7 @@ void MakeFromFunc(int i,int j,int k)
pr(dfd,"\t\td_val[i]=(%s)temp;\n",aitName[i]);
pr(dfd,"\t}\n");
}
pr(dfd,"}\n");
pr(dfd,"\treturn (int) (sizeof(%s)*c);\n}\n",aitName[i]);
}
void MakeToFunc(int i,int j,int k)
@@ -516,7 +449,7 @@ void MakeToFunc(int i,int j,int k)
pr(dfd,"(aitUint%s*)&temp);\n",len_msg);
pr(dfd,"\t}\n");
}
pr(dfd,"\treturn (int) (sizeof(%s)*c);\n",aitName[i]);
pr(dfd,"}\n");
}
@@ -533,6 +466,7 @@ void MakeNormalFunc(int i,int j,int k)
pr(dfd,"\tfor(i=0;i<c;i++)\n");
pr(dfd,"\t\td_val[i]=(%s)(s_val[i]);\n",aitName[i]);
}
pr(dfd,"\treturn (int) (sizeof(%s)*c);\n",aitName[i]);
pr(dfd,"}\n");
}

View File

@@ -5,6 +5,9 @@
// $Id$
//
// $Log$
// Revision 1.7 1997/06/25 06:17:33 jhill
// fixed warnings
//
// Revision 1.6 1997/04/23 17:12:54 jhill
// fixed export of symbols from WIN32 DLL
//
@@ -33,8 +36,9 @@ void aitString::mallocFailure(void)
{
str="";
len=0u;
type=aitStrConst;
fprintf(stderr,"aitString: no pool => continuing with nill str\n");
bufLen=1u;
type=aitStrRefConstImortal;
fprintf(stderr,"aitString: no pool => continuing with zero char str\n");
}
void aitString::dump(const char* p) const
@@ -48,9 +52,13 @@ void aitString::dump(void) const
fprintf(stderr,"this=%p ", this);
if(str) fprintf(stderr,"string=%p<%s>, ",str,str);
else fprintf(stderr,"no string present, ");
fprintf(stderr,"length=%d, ",(int)len);
if(type==aitStrConst) fprintf(stderr,"type=Constant\n");
else fprintf(stderr,"type=Allocated\n");
fprintf(stderr,"length=%u, ",len);
fprintf(stderr,"buf length=%u, ",bufLen);
if(type==aitStrRefConstImortal) fprintf(stderr,"type=Imortal Constant Reference\n");
else if(type==aitStrRefConst) fprintf(stderr,"type=Constant Reference\n");
else if(type==aitStrRef) fprintf(stderr,"type=Reference\n");
else if(type==aitStrCopy) fprintf(stderr,"type=Allocated\n");
else fprintf(stderr,"type=Invalid\n");
}
aitIndex aitString::compact(aitString* array, aitIndex arraySize,
@@ -72,9 +80,8 @@ aitIndex aitString::compact(aitString* array, aitIndex arraySize,
if((pos+str[i].length())>bufSize) break; // quick exit from loop
if(array[i].string())
{
memcpy(&ptr[pos],array[i].string(),array[i].length()+1);
str[i].force(&ptr[pos]);
str[i].len=array[i].length();
memcpy(&ptr[pos],array[i].string(),array[i].length()+1u);
str[i].installBuf(&ptr[pos], array[i].length(), array[i].length()+1u);
pos+=str[i].length()+1;
}
}
@@ -104,3 +111,56 @@ aitUint32 aitString::stringsLength(aitString* array, aitIndex arraySize)
return tot;
}
int aitString::copy(const char* p, unsigned newStrLength, unsigned bufSizeIn)
{
if (newStrLength>=bufSizeIn) {
return -1;
}
if (this->type==aitStrRefConst || this->type==aitStrRefConstImortal
|| bufSizeIn>this->bufLen) {
char *pStrNew;
pStrNew = new char [bufSizeIn];
if (!pStrNew) {
mallocFailure();
return -1;
}
if (this->type==aitStrCopy) {
delete [] this->str;
}
this->str = pStrNew;
this->bufLen = bufSizeIn;
this->type = aitStrCopy;
}
// test above verifies that bufLen exceeds
// length of p
strncpy (this->str,p,this->bufLen);
this->len = newStrLength;
return 0;
}
int aitString::init(const char* p, aitStrType typeIn, unsigned strLengthIn, unsigned bufSizeIn)
{
int rc;
this->init();
switch (typeIn) {
case aitStrCopy:
rc = this->copy(p, strLengthIn, bufSizeIn);
break;
case aitStrRef:
rc = this->installBuf(p, strLengthIn, bufSizeIn);
break;
case aitStrRefConst:
rc = this->installConstBuf(p, strLengthIn, bufSizeIn);
break;
case aitStrRefConstImortal:
rc = this->installConstImortalBuf(p, strLengthIn, bufSizeIn);
break;
default:
rc=-1;
break;
}
return rc;
}

View File

@@ -8,6 +8,9 @@
* $Id$
*
* $Log$
* Revision 1.13 1997/04/23 17:12:54 jhill
* fixed export of symbols from WIN32 DLL
*
* Revision 1.12 1997/04/10 19:59:23 jhill
* api changes
*
@@ -59,6 +62,10 @@
#include "shareLib.h"
#ifndef max
#define max(A,B) ((A)>(B)?(A):(B))
#endif
#define NSecPerSec 1000000000u
#define NSecPerUSec 1000u
#define SecPerMin 60u
@@ -173,71 +180,77 @@ inline int operator>= (const aitTimeStamp &lhs, const aitTimeStamp &rhs)
// very simple class for string storage (for now)
//
//
enum aitStrType {
aitStrRefConstImortal, // any constant string that always exists - ie "abc"
aitStrRefConst, // user provides constant string buffer for life of aitSting
aitStrRef, // user provides modifiable string buffer for life of aitSting
aitStrCopy}; // aitSting copies into internal storage
class epicsShareClass aitString
{
public:
aitString(char* p); // copy the user's string
aitString(aitString* p); // copy the user's string
aitString(aitString& p); // copy the user's string
inline aitString(void);
inline aitString(const aitString* p);
inline aitString(const aitString& p);
inline aitString(const char* p, aitStrType type=aitStrCopy);
inline aitString(const char* p, aitStrType type, unsigned strLength);
inline aitString(const char* p, aitStrType type, unsigned strLength, unsigned bufSize);
inline ~aitString(void); // free up string is required
aitString(const char* p); // reference a user's constant string
aitString(const aitString* p); // reference a user's constant string
aitString(const aitString& p); // reference a user's constant string
aitString(void);
~aitString(void); // free up string is required
void clear(void); // clear everything, free string if required
inline void clear(void); // clear everything, free string if required
void dump(void) const;
void dump(const char* id) const;
// casts from aitString to other things - pulls info out of aitString
operator aitUint16(void) const { return (aitUint16)len; }
operator aitUint32(void) const { return (aitUint32)len; }
operator aitInt32(void) const { return (aitInt32)len; }
operator const char*(void) const { return str; }
operator char*(void) const { return str; }
int isConstant(void) const;
inline operator aitUint16(void) const { return (aitUint16)len; }
inline operator aitUint32(void) const { return (aitUint32)len; }
inline operator aitInt32(void) const { return (aitInt32)len; }
inline operator const char*(void) const { return str; }
inline operator char*(void) const
{
assert(type!=aitStrRefConst && type!=aitStrRefConstImortal);
return str;
}
inline int isConstant(void) const;
aitUint32 length(void) const { return (aitUint32)len; }
const char* string(void) const { return str; }
inline aitUint32 length(void) const { return (aitUint32)len; }
inline const char* string(void) const { return str; }
// completely reset the aitString to a new value
aitString& operator=(aitString& p);
aitString& operator=(aitString* p);
aitString& operator=(char* p);
aitString& operator=(const aitString& p);
aitString& operator=(const aitString* p);
aitString& operator=(const char* p);
// - the same as copy()
inline aitString& operator=(const aitString& pString);
inline aitString& operator=(const aitString* pString);
inline aitString& operator=(const char* pString);
// change strings into the aitString (actually makes new strings)
int copy(aitString* p);
int copy(aitString& p);
int copy(char* p);
int copy(const aitString* p);
int copy(const aitString& p);
int copy(const char* p);
inline int copy(const aitString* pString);
inline int copy(const aitString& pString);
inline int copy(const char* pString);
inline int copy(const char* pString, unsigned stringLength);
int copy(const char* pString, unsigned stringLength, unsigned bufSize);
int installString(aitString* p);
int installString(aitString& p);
int installString(char* p);
int installString(const aitString* p);
int installString(const aitString& p);
int installString(const char* p);
//
// make ait string point at string in application's modifiable buffer
//
inline int installBuf(const char* pString);
inline int installBuf(const char* pString, unsigned stringLength);
inline int installBuf(const char* pString, unsigned stringLength, unsigned bufSize);
// set data in the aitString and retrieve data from the aitString
void replaceData(const char* p);
void replaceData(const aitString* p);
void replaceData(aitString& p);
void replaceData(const aitString& p);
void extractString(char* to_here);
//
// make ait string point at constant string in application's constant buffer
//
inline int installConstBuf(const char* pString);
inline int installConstBuf(const char* pString, unsigned stringLength);
inline int installConstBuf(const char* pString, unsigned stringLength, unsigned bufSize);
// special function to change the string - internal use with gdd library
void force(char* x) { str=x; }
void force(unsigned char* x) { str=(char*)x; }
void force(unsigned long x) { str=(char*)x; }
void forceConstant(void) { type=aitStrConst; }
void init(void);
//
// make ait string point at constant string in application's constant buffer
// that exists forever (such as "abc")
//
inline int installConstImortalBuf(const char* pString);
inline int installConstImortalBuf(const char* pString, unsigned stringLength);
inline int installConstImortalBuf(const char* pString, unsigned stringLength, unsigned bufSize);
inline void extractString(char* to_here, unsigned bufSize);
// take the aitString array, and put it and all the string into buf,
// return the total length the data copied
@@ -246,126 +259,213 @@ public:
static aitIndex compact(aitString* array, aitIndex arraySize,
void* buf, aitIndex bufSize);
//
// for gdd's use only! (to construct class inside union)
// (it is possible to leak memory if this is called on
// an already constructed aitString). This practice should
// be eliminated by deriving from aitString and replacing
// the new operator?
//
inline void init(void);
private:
enum aitStrType {aitStrMalloc, aitStrConst};
char* str;
aitUint16 len;
aitUint16 type; // aitStrType goes here
unsigned len:14; // actual length of string
unsigned bufLen:14; // length of string buffer
unsigned type:4; // aitStrType goes here
void mallocFailure(void);
int set(const char* p, aitUint32 len);
int cset(const char* p, aitUint32 len);
aitStrType getType(void) const { return (aitStrType)type; }
inline aitStrType getType(void) const { return (aitStrType)type; }
int init(const char* p, aitStrType type, unsigned strLength, unsigned bufSize);
};
inline void aitString::init(void)
{
str="";
len=0u;
bufLen=1u;
type=aitStrRefConstImortal;
}
inline int aitString::isConstant(void) const
{
return (getType()==aitStrConst && str)?1:0;
return ( (getType()==aitStrRefConst||getType()==aitStrRefConstImortal) && str)?1:0;
}
inline void aitString::clear(void)
{
if(str && type==aitStrMalloc) delete [] str;
type=aitStrConst;
str=NULL;
len=0;
if(str && type==aitStrCopy) delete [] str;
this->init();
}
inline int aitString::set(const char* p,aitUint32 l)
{
int rc=0;
clear();
len=l;
str=new char[len+1];
if(str)
{
strncpy(str, p, len);
str[len] = '\0';
type=aitStrMalloc;
inline void aitString::extractString(char* p, unsigned bufLength)
{
if (bufLength==0u) {
return;
}
else
{
mallocFailure();
rc=-1;
else if (str) {
strncpy(p,str,bufLength);
p[bufLength-1u]='\0';
}
else {
p[0u] = '\0';
}
return rc;
}
inline int aitString::cset(const char* p,aitUint32 l)
//
// make ait string point at string in application's buffer
//
inline int aitString::installBuf(const char* pString, unsigned strLengthIn, unsigned bufSizeIn)
{
clear();
str=(char*)p;
type=aitStrConst;
len=l;
if (this->type==aitStrCopy) {
delete [] str;
}
this->str = (char *) pString;
this->bufLen = bufSizeIn;
this->type = aitStrRef;
this->len = strLengthIn;
return 0;
}
inline int aitString::installBuf(const char* pString)
{
unsigned strLengthIn = strlen(pString);
return this->installBuf(pString, strLengthIn, strLengthIn+1u);
}
inline int aitString::installBuf(const char* pString, unsigned strLengthIn)
{
return this->installBuf(pString, strLengthIn, strLengthIn+1u);
}
//
// make ait string point at constant string in application's buffer
//
inline int aitString::installConstBuf(const char* pString, unsigned strLengthIn, unsigned bufSizeIn)
{
if (this->type==aitStrCopy) {
delete [] str;
}
this->str = (char *) pString;
this->bufLen = bufSizeIn;
this->type = aitStrRefConst;
this->len = strLengthIn;
return 0;
}
inline int aitString::installConstBuf(const char* pString)
{
unsigned strLengthIn = strlen(pString);
return this->installConstBuf(pString, strLengthIn, strLengthIn+1u);
}
inline int aitString::installConstBuf(const char* pString, unsigned strLengthIn)
{
return this->installConstBuf(pString, strLengthIn, strLengthIn+1u);
}
//
// make ait string point at constant string in application's buffer
// that always exists (such as "abc")
//
inline int aitString::installConstImortalBuf(const char* pString,
unsigned strLengthIn, unsigned bufSizeIn)
{
if (this->type==aitStrCopy) {
delete [] str;
}
this->str = (char *) pString;
this->bufLen = bufSizeIn;
this->type = aitStrRefConstImortal;
this->len = strLengthIn;
return 0;
}
inline int aitString::installConstImortalBuf(const char* pString)
{
unsigned strLengthIn = strlen(pString);
return this->installConstImortalBuf(pString, strLengthIn, strLengthIn+1u);
}
inline int aitString::installConstImortalBuf(const char* pString, unsigned strLengthIn)
{
return this->installConstImortalBuf(pString, strLengthIn, strLengthIn+1u);
}
inline int aitString::copy(const char* pString, unsigned stringLength)
{
return this->copy(pString, stringLength, max(this->bufLen,stringLength+1u));
}
inline int aitString::copy(const char* p)
{ return p?set(p,strlen(p)):-1; }
inline int aitString::copy(char* p)
{ return p?set(p,strlen(p)):-1; }
inline int aitString::copy(aitString* p)
{ return p?set((char*)*p,p->length()):-1; }
inline int aitString::copy(aitString& p)
{ return set((char*)p,p.length()); }
{
return this->copy(p, strlen(p));
}
inline int aitString::copy(const aitString* p)
{ return p?set((const char*)*p,p->length()):-1; }
{
if (p->type==aitStrRefConstImortal) {
//
// fast reference if the string is constant and it
// exists forever
//
return this->installConstImortalBuf(p->str, p->len, p->len+1u);
}
return this->copy(p->str, p->len);
}
inline int aitString::copy(const aitString& p)
{ return set((const char*)p,p.length()); }
inline void aitString::replaceData(const char* p)
{ if(p && str) strncpy(str,p,len); }
inline void aitString::replaceData(const aitString* p)
{ if(p && str) strncpy(str,p->string(),len); }
inline void aitString::replaceData(aitString& p)
{ if(str) strncpy(str,p.string(),len); }
inline void aitString::replaceData(const aitString& p)
{ if(str) strncpy(str,p.string(),len); }
inline void aitString::extractString(char* p)
{ if(p && str) strcpy(p,str); }
inline int aitString::installString(const char* p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(char* p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(aitString* p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(aitString& p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(const aitString* p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(const aitString& p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
{
return this->copy(&p);
}
inline aitString& aitString::operator=(const aitString& p)
{ this->copy(p); return *this; }
inline aitString& aitString::operator=(const aitString* p)
{ this->copy(p); return *this; }
inline aitString& aitString::operator=(aitString& p)
{ this->copy(p); return *this; }
inline aitString& aitString::operator=(aitString* p)
{ this->copy(p); return *this; }
inline aitString& aitString::operator=(const char* p)
{ this->copy(p); return *this; }
inline aitString& aitString::operator=(char* p)
{ this->copy(p); return *this; }
inline void aitString::init(void) { str=NULL; len=0u; type=aitStrConst; }
inline aitString::~aitString(void)
{
// dump("~aitString");
clear();
}
inline aitString::aitString(void) { init(); }
inline aitString::aitString(char* p) { init(); copy(p); }
inline aitString::aitString(aitString* p) { init(); copy(p); }
inline aitString::aitString(aitString& p) { init(); copy(p); }
inline aitString::aitString(void)
{
this->init();
}
inline aitString::aitString(const char* p) { init(); copy(p); }
inline aitString::aitString(const aitString* p) { init(); copy(p); }
inline aitString::aitString(const aitString& p) { init(); copy(p); }
inline aitString::aitString(const char* p, aitStrType typeIn)
{
unsigned strLengthIn = strlen(p);
this->init(p, typeIn, strLengthIn, strLengthIn+1u);
}
inline aitString::aitString(const char* p, aitStrType typeIn, unsigned strLengthIn)
{
this->init(p, typeIn, strLengthIn, strLengthIn+1u);
}
inline aitString::aitString(const char* p, aitStrType typeIn, unsigned strLength, unsigned bufSize)
{
this->init(p,typeIn,strLength,bufSize);
}
inline aitString::aitString(const aitString* p)
{
this->init();
this->copy(p);
}
inline aitString::aitString(const aitString& p)
{
this->init();
this->copy(p);
}
#endif // aitHelpersInclude

View File

@@ -5,6 +5,9 @@
* $Id$
*
* $Log$
* Revision 1.3 1997/05/01 19:54:51 jhill
* updated dll keywords
*
* Revision 1.2 1997/04/10 19:59:24 jhill
* api changes
*
@@ -16,9 +19,13 @@
*
*/
#include <limits.h>
#include <float.h>
#define AIT_TYPES_SOURCE 1
#include <sys/types.h>
#define epicsExportSharedSymbols
#include "aitTypes.h"
@@ -54,19 +61,74 @@ epicsShareDef const char* aitName[aitTotal] = {
"aitContainer"
};
epicsShareDef const char* aitStringType[aitTotal] = {
"%8.8x",
"%2.2x",
"%2.2x",
"%hd",
"%hu",
"%hu",
"%d",
"%u",
"%f",
"%lf",
"%s",
"%s",
"%8.8x"
/*
* conversion characters used with stdio lib
*/
epicsShareDef const char* aitPrintf[aitTotal] = {
0,
"c",
"c",
"hd",
"hu",
"hu",
"d",
"u",
"g",
"g",
"s",
0, /* printf doesnt know about aitString */
0
};
epicsShareDef const char* aitScanf[aitTotal] = {
0,
"c",
"c",
"hd",
"hu",
"hu",
"d",
"u",
"g",
"lg",
"s",
0, /* scanf doesnt know about aitString */
0
};
/*
* maximum value within type - joh
*/
epicsShareDef double aitMax[aitTotal] = {
-1,
SCHAR_MAX,
UCHAR_MAX,
SHRT_MAX,
USHRT_MAX,
USHRT_MAX,
INT_MAX,
UINT_MAX,
FLT_MAX,
DBL_MAX,
-1,
-1,
-1
};
/*
* minimum value within ait type - joh
*/
epicsShareDef double aitMin[aitTotal] = {
+1,
SCHAR_MIN,
0u,
SHRT_MIN,
0u,
0u,
INT_MIN,
0u,
FLT_MIN,
DBL_MIN,
+1,
+1,
+1
};

View File

@@ -8,6 +8,9 @@
* $Id$
*
* $Log$
* Revision 1.4 1997/04/10 19:59:24 jhill
* api changes
*
* Revision 1.3 1997/03/21 01:56:00 jbk
* *** empty log message ***
*
@@ -36,17 +39,17 @@
#include "shareLib.h"
typedef char aitInt8;
typedef char aitInt8;
typedef unsigned char aitUint8;
typedef short aitInt16;
typedef short aitInt16;
typedef unsigned short aitUint16;
typedef aitUint16 aitEnum16;
typedef int aitInt32;
typedef unsigned int aitUint32;
typedef float aitFloat32;
typedef double aitFloat64;
typedef aitUint32 aitIndex;
typedef void* aitPointer;
typedef float aitFloat32;
typedef double aitFloat64;
typedef aitUint32 aitIndex;
typedef void* aitPointer;
typedef aitUint32 aitStatus;
/* should the bool be added as a conversion type? it currently is not */
@@ -76,7 +79,8 @@ typedef struct {
#endif
#ifndef vxWorks
#if (_POSIX_C_SOURCE < 3) && !defined(solaris) && !defined(SOLARIS)
#if (_POSIX_C_SOURCE < 3) && !defined(solaris) && !defined(SOLARIS) && !defined(HP_UX)
struct timespec
{
time_t tv_sec;
@@ -146,7 +150,10 @@ extern "C" {
#endif
epicsShareExtern const size_t aitSize[aitTotal];
epicsShareExtern const char* aitName[aitTotal];
epicsShareExtern const char* aitStringType[aitTotal];
epicsShareExtern const char* aitPrintf[aitTotal];
epicsShareExtern const char* aitScanf[aitTotal];
epicsShareExtern double aitMax[aitTotal];
epicsShareExtern double aitMin[aitTotal];
#ifdef __cplusplus
}
#endif

View File

@@ -4,6 +4,9 @@
// $Id$
//
// $Log$
// Revision 1.17 1997/04/23 17:12:55 jhill
// fixed export of symbols from WIN32 DLL
//
// Revision 1.16 1996/12/20 13:09:49 jbk
// Working version, intermediate, still has problems
//
@@ -83,10 +86,9 @@
// hardcoded in same order as aitConvert.h
// no way to detect a string type!!!!!!!
static gddApplicationTypeTable* type_table = NULL;
static aitDataFormat local_data_format=aitLocalDataFormat;
const chtype gddAitToDbr[] = {
// addition of extern here makes ms compiler
// happy when globaldef is used
extern epicsShareDef const chtype gddAitToDbr[] = {
0,
DBR_CHAR,
DBR_CHAR,
@@ -102,7 +104,12 @@ const chtype gddAitToDbr[] = {
999
};
gddDbrToAitTable gddDbrToAit[] = {
// addition of extern here makes ms compiler
// happy when epicsShareDef is used
#ifdef _MSC_VER
extern
#endif
epicsShareDef gddDbrToAitTable gddDbrToAit[] = {
// normal
{ aitEnumFixedString, 0, "value" },
{ aitEnumInt16, 0, "value" },
@@ -145,6 +152,9 @@ gddDbrToAitTable gddDbrToAit[] = {
{ aitEnumFloat64, 0, "dbr_ctrl_double" }
};
static gddApplicationTypeTable* type_table = NULL;
static aitDataFormat local_data_format=aitLocalDataFormat;
// I generated a container for each of the important DBR types. This
// includes all the control and graphic structures. The others are
// not needed become you can get time stamp and status in each gdd.
@@ -174,10 +184,30 @@ static gdd* mapStringToGdd(void* v,aitIndex count) {
return dd;
}
static int mapGddToString(void* v, gdd* dd) {
aitFixedString* db = (aitFixedString*)v;
if((aitFixedString*)dd->dataPointer()!=db) dd->get(db);
return dd->getDataSizeElements();
static int mapGddToString(void* vd, aitIndex count, gdd* dd) {
aitFixedString* db = (aitFixedString*)vd;
aitIndex sz = dd->getDataSizeElements();
void* v=dd->dataVoid();
int status;
if (count==sz) {
if(local_data_format==aitLocalDataFormat) {
if((aitFixedString*)v!=db) {
status = aitConvert(aitEnumFixedString,db,dd->primitiveType(),v,sz);
}
else {
status = sz*sizeof(aitFixedString);
}
}
else {
status = aitConvertToNet(aitEnumFixedString,db,dd->primitiveType(),v,sz);
}
}
else {
status = -1;
}
return status;
}
static gdd* mapShortToGdd(void* v,aitIndex count) {
@@ -195,18 +225,30 @@ static gdd* mapShortToGdd(void* v,aitIndex count) {
return dd;
}
static int mapGddToShort(void* vd, gdd* dd) {
static int mapGddToShort(void* vd, aitIndex count, gdd* dd) {
dbr_short_t* sv = (dbr_short_t*)vd;
int sz=dd->getDataSizeElements();
aitIndex sz = dd->getDataSizeElements();
void* v=dd->dataVoid();
int status;
if(local_data_format==aitLocalDataFormat)
if((dbr_short_t*)v!=sv)
aitConvert(aitEnumInt16,sv,dd->primitiveType(),v,sz);
else
aitConvertToNet(aitEnumInt16,sv,dd->primitiveType(),v,sz);
if (count==sz) {
if (local_data_format==aitLocalDataFormat) {
if((dbr_short_t*)v!=sv) {
status = aitConvert(aitEnumInt16,sv,dd->primitiveType(),v,sz);
}
else {
status = sz*sizeof(dbr_short_t);
}
}
else {
status = aitConvertToNet(aitEnumInt16,sv,dd->primitiveType(),v,sz);
}
}
else {
status = -1;
}
return sz;
return status;
}
static gdd* mapFloatToGdd(void* v,aitIndex count) {
@@ -224,18 +266,30 @@ static gdd* mapFloatToGdd(void* v,aitIndex count) {
return dd;
}
static int mapGddToFloat(void* vd, gdd* dd) {
static int mapGddToFloat(void* vd, aitIndex count, gdd* dd) {
dbr_float_t* sv = (dbr_float_t*)vd;
int sz=dd->getDataSizeElements();
aitIndex sz=dd->getDataSizeElements();
void* v=dd->dataVoid();
int status;
if(local_data_format==aitLocalDataFormat)
if((dbr_float_t*)v!=sv)
aitConvert(aitEnumFloat32,sv,dd->primitiveType(),v,sz);
else
aitConvertToNet(aitEnumFloat32,sv,dd->primitiveType(),v,sz);
if (count==sz) {
if(local_data_format==aitLocalDataFormat) {
if((dbr_float_t*)v!=sv) {
status = aitConvert(aitEnumFloat32,sv,dd->primitiveType(),v,sz);
}
else {
status = sz*sizeof(dbr_float_t);
}
}
else {
status = aitConvertToNet(aitEnumFloat32,sv,dd->primitiveType(),v,sz);
}
}
else {
status = -1;
}
return sz;
return status;
}
static gdd* mapEnumToGdd(void* v,aitIndex count) {
@@ -253,18 +307,30 @@ static gdd* mapEnumToGdd(void* v,aitIndex count) {
return dd;
}
static int mapGddToEnum(void* vd, gdd* dd) {
static int mapGddToEnum(void* vd, aitIndex count, gdd* dd) {
dbr_enum_t* sv = (dbr_enum_t*)vd;
int sz=dd->getDataSizeElements();
aitIndex sz=dd->getDataSizeElements();
void* v=dd->dataVoid();
int status;
if(local_data_format==aitLocalDataFormat)
if((dbr_enum_t*)v!=sv)
aitConvert(aitEnumEnum16,sv,dd->primitiveType(),v,sz);
else
aitConvertToNet(aitEnumEnum16,sv,dd->primitiveType(),v,sz);
if (count==sz) {
if(local_data_format==aitLocalDataFormat) {
if((dbr_enum_t*)v!=sv) {
status = aitConvert(aitEnumEnum16,sv,dd->primitiveType(),v,sz);
}
else {
status = sizeof(dbr_enum_t)*count;
}
}
else {
status = aitConvertToNet(aitEnumEnum16,sv,dd->primitiveType(),v,sz);
}
}
else {
status = -1;
}
return sz;
return status;
}
static gdd* mapCharToGdd(void* v,aitIndex count) {
@@ -282,18 +348,30 @@ static gdd* mapCharToGdd(void* v,aitIndex count) {
return dd;
}
static int mapGddToChar(void* vd, gdd* dd) {
static int mapGddToChar(void* vd, aitIndex count, gdd* dd) {
dbr_char_t* sv = (dbr_char_t*)vd;
int sz=dd->getDataSizeElements();
aitIndex sz=dd->getDataSizeElements();
void* v=dd->dataVoid();
int status;
if(local_data_format==aitLocalDataFormat)
if((dbr_char_t*)v!=sv)
aitConvert(aitEnumInt8,sv,dd->primitiveType(),v,sz);
else
aitConvertToNet(aitEnumInt8,sv,dd->primitiveType(),v,sz);
if (count==sz) {
if (local_data_format==aitLocalDataFormat) {
if((dbr_char_t*)v!=sv) {
status = aitConvert(aitEnumInt8,sv,dd->primitiveType(),v,sz);
}
else {
status = sz*sizeof(dbr_char_t);
}
}
else {
status = aitConvertToNet(aitEnumInt8,sv,dd->primitiveType(),v,sz);
}
}
else {
status = -1;
}
return sz;
return status;
}
static gdd* mapLongToGdd(void* v,aitIndex count) {
@@ -311,18 +389,30 @@ static gdd* mapLongToGdd(void* v,aitIndex count) {
return dd;
}
static int mapGddToLong(void* vd, gdd* dd) {
static int mapGddToLong(void* vd, aitIndex count, gdd* dd) {
dbr_long_t* sv = (dbr_long_t*)vd;
int sz=dd->getDataSizeElements();
aitIndex sz=dd->getDataSizeElements();
void* v=dd->dataVoid();
int status;
if(local_data_format==aitLocalDataFormat)
if((dbr_long_t*)v!=sv)
aitConvert(aitEnumInt32,sv,dd->primitiveType(),v,sz);
else
aitConvertToNet(aitEnumInt32,sv,dd->primitiveType(),v,sz);
if (count==sz) {
if (local_data_format==aitLocalDataFormat) {
if ((dbr_long_t*)v!=sv) {
status = aitConvert(aitEnumInt32,sv,dd->primitiveType(),v,sz);
}
else {
status = count*sizeof(dbr_long_t);
}
}
else {
status = aitConvertToNet(aitEnumInt32,sv,dd->primitiveType(),v,sz);
}
}
else {
status = -1;
}
return sz;
return status;
}
static gdd* mapDoubleToGdd(void* v,aitIndex count) {
@@ -340,18 +430,30 @@ static gdd* mapDoubleToGdd(void* v,aitIndex count) {
return dd;
}
static int mapGddToDouble(void* vd, gdd* dd) {
static int mapGddToDouble(void* vd, aitIndex count, gdd* dd) {
dbr_double_t* sv = (dbr_double_t*)vd;
int sz=dd->getDataSizeElements();
aitIndex sz=dd->getDataSizeElements();
void* v=dd->dataVoid();
int status;
if(local_data_format==aitLocalDataFormat)
if((dbr_double_t*)v!=sv)
aitConvert(aitEnumFloat64,sv,dd->primitiveType(),v,sz);
else
aitConvertToNet(aitEnumFloat64,sv,dd->primitiveType(),v,sz);
if (count==sz) {
if (local_data_format==aitLocalDataFormat) {
if ((dbr_double_t*)v!=sv) {
status = aitConvert(aitEnumFloat64,sv,dd->primitiveType(),v,sz);
}
else {
status = count*sizeof(dbr_double_t);
}
}
else {
status = aitConvertToNet(aitEnumFloat64,sv,dd->primitiveType(),v,sz);
}
}
else {
status = -1;
}
return sz;
return status;
}
// ********************************************************************
@@ -381,16 +483,14 @@ static gdd* mapStsStringToGdd(void* v,aitIndex count)
return dd;
}
static int mapStsGddToString(void* v, gdd* dd)
static int mapStsGddToString(void* v, aitIndex count, gdd* dd)
{
// what about arrays of string? is this allowed?
dbr_sts_string* db = (dbr_sts_string*)v;
aitFixedString* dbv = (aitFixedString*)db->value;
// copy string into user buffer for now if not the same as one in gdd
if((aitFixedString*)dd->dataPointer()!=dbv) dd->get(dbv);
dd->getStatSevr(db->status,db->severity);
return dd->getDataSizeElements();
return mapGddToString(dbv, count, dd);
}
static gdd* mapStsShortToGdd(void* v,aitIndex count)
@@ -401,11 +501,11 @@ static gdd* mapStsShortToGdd(void* v,aitIndex count)
return dd;
}
static int mapStsGddToShort(void* v, gdd* dd)
static int mapStsGddToShort(void* v, aitIndex count, gdd* dd)
{
dbr_sts_short* dbv = (dbr_sts_short*)v;
dd->getStatSevr(dbv->status,dbv->severity);
return mapGddToShort(&dbv->value,dd);
return mapGddToShort(&dbv->value, count, dd);
}
static gdd* mapStsFloatToGdd(void* v,aitIndex count)
@@ -416,11 +516,11 @@ static gdd* mapStsFloatToGdd(void* v,aitIndex count)
return dd;
}
static int mapStsGddToFloat(void* v, gdd* dd)
static int mapStsGddToFloat(void* v, aitIndex count, gdd* dd)
{
dbr_sts_float* dbv = (dbr_sts_float*)v;
dd->getStatSevr(dbv->status,dbv->severity);
return mapGddToFloat(&dbv->value,dd);
return mapGddToFloat(&dbv->value,count,dd);
}
static gdd* mapStsEnumToGdd(void* v,aitIndex count)
@@ -431,11 +531,11 @@ static gdd* mapStsEnumToGdd(void* v,aitIndex count)
return dd;
}
static int mapStsGddToEnum(void* v, gdd* dd)
static int mapStsGddToEnum(void* v, aitIndex count, gdd* dd)
{
dbr_sts_enum* dbv = (dbr_sts_enum*)v;
dd->getStatSevr(dbv->status,dbv->severity);
return mapGddToEnum(&dbv->value,dd);
return mapGddToEnum(&dbv->value,count,dd);
}
static gdd* mapStsCharToGdd(void* v,aitIndex count)
@@ -446,12 +546,12 @@ static gdd* mapStsCharToGdd(void* v,aitIndex count)
return dd;
}
static int mapStsGddToChar(void* v, gdd* dd)
static int mapStsGddToChar(void* v, aitIndex count, gdd* dd)
{
dbr_sts_char* dbv = (dbr_sts_char*)v;
dd->getStatSevr(dbv->status,dbv->severity);
dbv->RISC_pad = '\0'; // shut up purify
return mapGddToChar(&dbv->value,dd);
return mapGddToChar(&dbv->value,count,dd);
}
static gdd* mapStsLongToGdd(void* v,aitIndex count)
@@ -462,11 +562,11 @@ static gdd* mapStsLongToGdd(void* v,aitIndex count)
return dd;
}
static int mapStsGddToLong(void* v, gdd* dd)
static int mapStsGddToLong(void* v, aitIndex count, gdd* dd)
{
dbr_sts_long* dbv = (dbr_sts_long*)v;
dd->getStatSevr(dbv->status,dbv->severity);
return mapGddToLong(&dbv->value,dd);
return mapGddToLong(&dbv->value,count,dd);
}
static gdd* mapStsDoubleToGdd(void* v,aitIndex count)
@@ -477,12 +577,12 @@ static gdd* mapStsDoubleToGdd(void* v,aitIndex count)
return dd;
}
static int mapStsGddToDouble(void* v, gdd* dd)
static int mapStsGddToDouble(void* v, aitIndex count, gdd* dd)
{
dbr_sts_double* dbv = (dbr_sts_double*)v;
dd->getStatSevr(dbv->status,dbv->severity);
dbv->RISC_pad = 0; // shut up purify
return mapGddToDouble(&dbv->value,dd);
return mapGddToDouble(&dbv->value,count,dd);
}
// ********************************************************************
@@ -513,16 +613,14 @@ static gdd* mapTimeStringToGdd(void* v,aitIndex count)
return dd;
}
static int mapTimeGddToString(void* v, gdd* dd)
static int mapTimeGddToString(void* v, aitIndex count, gdd* dd)
{
dbr_time_string* db = (dbr_time_string*)v;
aitFixedString* dbv = (aitFixedString*)db->value;
// copy string into user buffer for now if not the same as one in gdd
if(dbv!=(aitFixedString*)dd->dataPointer()) dd->get(dbv);
dd->getStatSevr(db->status,db->severity);
dd->getTimeStamp((aitTimeStamp*)&db->stamp);
return dd->getDataSizeElements();
return mapGddToString(dbv, count, dd);
}
static gdd* mapTimeShortToGdd(void* v,aitIndex count)
@@ -534,13 +632,13 @@ static gdd* mapTimeShortToGdd(void* v,aitIndex count)
return dd;
}
static int mapTimeGddToShort(void* v, gdd* dd)
static int mapTimeGddToShort(void* v, aitIndex count, gdd* dd)
{
dbr_time_short* dbv = (dbr_time_short*)v;
dd->getStatSevr(dbv->status,dbv->severity);
dd->getTimeStamp((aitTimeStamp*)&dbv->stamp);
dbv->RISC_pad = 0; // shut up purify
return mapGddToShort(&dbv->value,dd);
return mapGddToShort(&dbv->value,count,dd);
}
static gdd* mapTimeFloatToGdd(void* v,aitIndex count)
@@ -552,12 +650,12 @@ static gdd* mapTimeFloatToGdd(void* v,aitIndex count)
return dd;
}
static int mapTimeGddToFloat(void* v, gdd* dd)
static int mapTimeGddToFloat(void* v, aitIndex count, gdd* dd)
{
dbr_time_float* dbv = (dbr_time_float*)v;
dd->getStatSevr(dbv->status,dbv->severity);
dd->getTimeStamp((aitTimeStamp*)&dbv->stamp);
return mapGddToFloat(&dbv->value,dd);
return mapGddToFloat(&dbv->value,count,dd);
}
static gdd* mapTimeEnumToGdd(void* v,aitIndex count)
@@ -569,13 +667,13 @@ static gdd* mapTimeEnumToGdd(void* v,aitIndex count)
return dd;
}
static int mapTimeGddToEnum(void* v, gdd* dd)
static int mapTimeGddToEnum(void* v, aitIndex count, gdd* dd)
{
dbr_time_enum* dbv = (dbr_time_enum*)v;
dd->getStatSevr(dbv->status,dbv->severity);
dd->getTimeStamp((aitTimeStamp*)&dbv->stamp);
dbv->RISC_pad = 0; // shut up purify
return mapGddToEnum(&dbv->value,dd);
return mapGddToEnum(&dbv->value,count,dd);
}
static gdd* mapTimeCharToGdd(void* v,aitIndex count)
@@ -587,14 +685,14 @@ static gdd* mapTimeCharToGdd(void* v,aitIndex count)
return dd;
}
static int mapTimeGddToChar(void* v, gdd* dd)
static int mapTimeGddToChar(void* v, aitIndex count, gdd* dd)
{
dbr_time_char* dbv = (dbr_time_char*)v;
dd->getStatSevr(dbv->status,dbv->severity);
dd->getTimeStamp((aitTimeStamp*)&dbv->stamp);
dbv->RISC_pad0 = 0; // shut up purify
dbv->RISC_pad1 = '\0'; // shut up purify
return mapGddToChar(&dbv->value,dd);
return mapGddToChar(&dbv->value,count,dd);
}
static gdd* mapTimeLongToGdd(void* v,aitIndex count)
@@ -606,12 +704,12 @@ static gdd* mapTimeLongToGdd(void* v,aitIndex count)
return dd;
}
static int mapTimeGddToLong(void* v, gdd* dd)
static int mapTimeGddToLong(void* v, aitIndex count, gdd* dd)
{
dbr_time_long* dbv = (dbr_time_long*)v;
dd->getStatSevr(dbv->status,dbv->severity);
dd->getTimeStamp((aitTimeStamp*)&dbv->stamp);
return mapGddToLong(&dbv->value,dd);
return mapGddToLong(&dbv->value,count,dd);
}
static gdd* mapTimeDoubleToGdd(void* v,aitIndex count)
@@ -623,13 +721,13 @@ static gdd* mapTimeDoubleToGdd(void* v,aitIndex count)
return dd;
}
static int mapTimeGddToDouble(void* v, gdd* dd)
static int mapTimeGddToDouble(void* v, aitIndex count, gdd* dd)
{
dbr_time_double* dbv = (dbr_time_double*)v;
dd->getStatSevr(dbv->status,dbv->severity);
dd->getTimeStamp((aitTimeStamp*)&dbv->stamp);
dbv->RISC_pad = 0; // shut up purify
return mapGddToDouble(&dbv->value,dd);
return mapGddToDouble(&dbv->value,count,dd);
}
// ********************************************************************
@@ -646,7 +744,7 @@ static gdd* mapGraphicShortToGdd(void* v, aitIndex count)
aitString* str=NULL;
dd[gddAppTypeIndex_dbr_gr_short_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_gr_short_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_gr_short_graphicHigh]=db->upper_disp_limit;
@@ -678,7 +776,7 @@ static gdd* mapControlShortToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_short_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_ctrl_short_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_ctrl_short_graphicHigh]=db->upper_disp_limit;
@@ -703,7 +801,7 @@ static gdd* mapControlShortToGdd(void* v, aitIndex count)
return dd;
}
static int mapGraphicGddToShort(void* v, gdd* dd)
static int mapGraphicGddToShort(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_gr_short* db = (dbr_gr_short*)v;
@@ -723,10 +821,10 @@ static int mapGraphicGddToShort(void* v, gdd* dd)
db->upper_warning_limit=dd[gddAppTypeIndex_dbr_gr_short_alarmHighWarning];
vdd.getStatSevr(db->status,db->severity);
return mapGddToShort(&db->value,&vdd);
return mapGddToShort(&db->value,count,&vdd);
}
static int mapControlGddToShort(void* v, gdd* dd)
static int mapControlGddToShort(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_ctrl_short* db = (dbr_ctrl_short*)v;
@@ -748,7 +846,7 @@ static int mapControlGddToShort(void* v, gdd* dd)
db->upper_warning_limit=dd[gddAppTypeIndex_dbr_ctrl_short_alarmHighWarning];
vdd.getStatSevr(db->status,db->severity);
return mapGddToShort(&db->value,&vdd);
return mapGddToShort(&db->value,count,&vdd);
}
// -------------map the float structures----------------
@@ -761,7 +859,7 @@ static gdd* mapGraphicFloatToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_gr_float_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_gr_float_precision]=db->precision;
dd[gddAppTypeIndex_dbr_gr_float_graphicLow]=db->lower_disp_limit;
@@ -794,7 +892,7 @@ static gdd* mapControlFloatToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_float_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_ctrl_float_precision]=db->precision;
dd[gddAppTypeIndex_dbr_ctrl_float_graphicLow]=db->lower_disp_limit;
@@ -820,7 +918,7 @@ static gdd* mapControlFloatToGdd(void* v, aitIndex count)
return dd;
}
static int mapGraphicGddToFloat(void* v, gdd* dd)
static int mapGraphicGddToFloat(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_gr_float* db = (dbr_gr_float*)v;
@@ -842,10 +940,10 @@ static int mapGraphicGddToFloat(void* v, gdd* dd)
db->RISC_pad0 = 0; // shut up purify
vdd.getStatSevr(db->status,db->severity);
return mapGddToFloat(&db->value,&vdd);
return mapGddToFloat(&db->value,count,&vdd);
}
static int mapControlGddToFloat(void* v, gdd* dd)
static int mapControlGddToFloat(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_ctrl_float* db = (dbr_ctrl_float*)v;
@@ -869,7 +967,7 @@ static int mapControlGddToFloat(void* v, gdd* dd)
db->RISC_pad = 0; // shut up purify
vdd.getStatSevr(db->status,db->severity);
return mapGddToFloat(&db->value,&vdd);
return mapGddToFloat(&db->value,count,&vdd);
}
// -------------map the enum structures----------------
@@ -880,7 +978,7 @@ static gdd* mapGraphicEnumToGdd(void* v, aitIndex /*count*/)
gdd& vdd = dd[gddAppTypeIndex_dbr_gr_enum_value];
gdd& menu = dd[gddAppTypeIndex_dbr_gr_enum_enums];
aitFixedString* str = menu;
aitFixedString* f = (aitFixedString*)db->strs;
//aitFixedString* f = (aitFixedString*)db->strs;
aitIndex sz,i;
// int i;
@@ -897,7 +995,7 @@ static gdd* mapGraphicEnumToGdd(void* v, aitIndex /*count*/)
}
else
{
if((sz=menu.getDataSizeElements())>db->no_str)
if((sz=menu.getDataSizeElements())>(aitIndex)db->no_str)
sz=db->no_str;
}
@@ -922,7 +1020,7 @@ static gdd* mapControlEnumToGdd(void* v, aitIndex /*count*/)
gdd& menu = dd[gddAppTypeIndex_dbr_ctrl_enum_enums];
gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_enum_value];
aitFixedString* str = menu;
aitFixedString* f = (aitFixedString*)db->strs;
//aitFixedString* f = (aitFixedString*)db->strs;
aitIndex sz,i;
// int i;
@@ -939,7 +1037,7 @@ static gdd* mapControlEnumToGdd(void* v, aitIndex /*count*/)
}
else
{
if((sz=menu.getDataSizeElements())>db->no_str)
if((sz=menu.getDataSizeElements())>(aitIndex)db->no_str)
sz=db->no_str;
}
@@ -957,7 +1055,7 @@ static gdd* mapControlEnumToGdd(void* v, aitIndex /*count*/)
return dd;
}
static int mapGraphicGddToEnum(void* v, gdd* dd)
static int mapGraphicGddToEnum(void* v, aitIndex count, gdd* dd)
{
dbr_gr_enum* db = (dbr_gr_enum*)v;
gdd& menu = dd[gddAppTypeIndex_dbr_gr_enum_enums];
@@ -967,7 +1065,6 @@ static int mapGraphicGddToEnum(void* v, gdd* dd)
int i;
vdd.getStatSevr(db->status,db->severity);
db->value=vdd; // always scaler
db->no_str=menu.getDataSizeElements();
if(str && str!=f)
@@ -978,10 +1075,10 @@ static int mapGraphicGddToEnum(void* v, gdd* dd)
db->strs[i][sizeof(aitFixedString)-1u] = '\0';
}
}
return 1;
return mapGddToEnum(&db->value, count, &vdd);
}
static int mapControlGddToEnum(void* v, gdd* dd)
static int mapControlGddToEnum(void* v, aitIndex count, gdd* dd)
{
dbr_ctrl_enum* db = (dbr_ctrl_enum*)v;
gdd& menu = dd[gddAppTypeIndex_dbr_ctrl_enum_enums];
@@ -991,7 +1088,6 @@ static int mapControlGddToEnum(void* v, gdd* dd)
int i;
vdd.getStatSevr(db->status,db->severity);
db->value=vdd; // always scaler
db->no_str=menu.getDataSizeElements();
if(str && str!=f)
@@ -1002,7 +1098,7 @@ static int mapControlGddToEnum(void* v, gdd* dd)
db->strs[i][sizeof(aitFixedString)-1u] = '\0';
}
}
return 1;
return mapGddToEnum(&db->value, count, &vdd);
}
// -------------map the char structures----------------
@@ -1015,7 +1111,7 @@ static gdd* mapGraphicCharToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_gr_char_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_gr_char_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_gr_char_graphicHigh]=db->upper_disp_limit;
@@ -1047,7 +1143,7 @@ static gdd* mapControlCharToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_char_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_ctrl_char_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_ctrl_char_graphicHigh]=db->upper_disp_limit;
@@ -1072,7 +1168,7 @@ static gdd* mapControlCharToGdd(void* v, aitIndex count)
return dd;
}
static int mapGraphicGddToChar(void* v, gdd* dd)
static int mapGraphicGddToChar(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_gr_char* db = (dbr_gr_char*)v;
@@ -1093,10 +1189,10 @@ static int mapGraphicGddToChar(void* v, gdd* dd)
db->RISC_pad = 0;
vdd.getStatSevr(db->status,db->severity);
return mapGddToChar(&db->value,&vdd);
return mapGddToChar(&db->value,count,&vdd);
}
static int mapControlGddToChar(void* v, gdd* dd)
static int mapControlGddToChar(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_ctrl_char* db = (dbr_ctrl_char*)v;
@@ -1119,7 +1215,7 @@ static int mapControlGddToChar(void* v, gdd* dd)
db->RISC_pad = '\0'; // shut up purify
vdd.getStatSevr(db->status,db->severity);
return mapGddToChar(&db->value,&vdd);
return mapGddToChar(&db->value,count,&vdd);
}
// -------------map the long structures----------------
@@ -1132,7 +1228,7 @@ static gdd* mapGraphicLongToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_gr_long_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_gr_long_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_gr_long_graphicHigh]=db->upper_disp_limit;
@@ -1164,7 +1260,7 @@ static gdd* mapControlLongToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_long_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_ctrl_long_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_ctrl_long_graphicHigh]=db->upper_disp_limit;
@@ -1189,7 +1285,7 @@ static gdd* mapControlLongToGdd(void* v, aitIndex count)
return dd;
}
static int mapGraphicGddToLong(void* v, gdd* dd)
static int mapGraphicGddToLong(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_gr_long* db = (dbr_gr_long*)v;
@@ -1209,10 +1305,10 @@ static int mapGraphicGddToLong(void* v, gdd* dd)
db->upper_warning_limit=dd[gddAppTypeIndex_dbr_gr_long_alarmHighWarning];
vdd.getStatSevr(db->status,db->severity);
return mapGddToLong(&db->value,&vdd);
return mapGddToLong(&db->value,count,&vdd);
}
static int mapControlGddToLong(void* v, gdd* dd)
static int mapControlGddToLong(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_ctrl_long* db = (dbr_ctrl_long*)v;
@@ -1234,7 +1330,7 @@ static int mapControlGddToLong(void* v, gdd* dd)
db->upper_warning_limit=dd[gddAppTypeIndex_dbr_ctrl_long_alarmHighWarning];
vdd.getStatSevr(db->status,db->severity);
return mapGddToLong(&db->value,&vdd);
return mapGddToLong(&db->value,count,&vdd);
}
// -------------map the double structures----------------
@@ -1247,7 +1343,7 @@ static gdd* mapGraphicDoubleToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_gr_double_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_gr_double_precision]=db->precision;
dd[gddAppTypeIndex_dbr_gr_double_graphicLow]=db->lower_disp_limit;
@@ -1280,7 +1376,7 @@ static gdd* mapControlDoubleToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_double_units].getRef(str);
str->installString(db->units);
str->copy(db->units);
dd[gddAppTypeIndex_dbr_ctrl_double_precision]=db->precision;
dd[gddAppTypeIndex_dbr_ctrl_double_graphicLow]=db->lower_disp_limit;
@@ -1306,7 +1402,7 @@ static gdd* mapControlDoubleToGdd(void* v, aitIndex count)
return dd;
}
static int mapGraphicGddToDouble(void* v, gdd* dd)
static int mapGraphicGddToDouble(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_gr_double* db = (dbr_gr_double*)v;
@@ -1328,10 +1424,10 @@ static int mapGraphicGddToDouble(void* v, gdd* dd)
db->RISC_pad0 = 0; // shut up purify
vdd.getStatSevr(db->status,db->severity);
return mapGddToDouble(&db->value,&vdd);
return mapGddToDouble(&db->value,count,&vdd);
}
static int mapControlGddToDouble(void* v, gdd* dd)
static int mapControlGddToDouble(void* v, aitIndex count, gdd* dd)
{
aitString* str;
dbr_ctrl_double* db = (dbr_ctrl_double*)v;
@@ -1355,13 +1451,12 @@ static int mapControlGddToDouble(void* v, gdd* dd)
db->RISC_pad0 = '\0'; // shut up purify
vdd.getStatSevr(db->status,db->severity);
return mapGddToDouble(&db->value,&vdd);
return mapGddToDouble(&db->value,count,&vdd);
}
// ----------------must run this to use mapping functions--------------
void gddMakeMapDBR(gddApplicationTypeTable* tt);
void gddMakeMapDBR(gddApplicationTypeTable& tt) { gddMakeMapDBR(&tt); }
void gddMakeMapDBR(gddApplicationTypeTable* tt)
epicsShareFunc void gddMakeMapDBR(gddApplicationTypeTable& tt) { gddMakeMapDBR(&tt); }
epicsShareFunc void gddMakeMapDBR(gddApplicationTypeTable* tt)
{
type_table=tt;
size_t i;
@@ -1380,7 +1475,9 @@ void gddMakeMapDBR(gddApplicationTypeTable* tt)
// An array of one function per DBR structure is provided here so conversions
// can take place quickly by knowing the DBR enumerated type.
gddDbrMapFuncTable gddMapDbr[] = {
// addition of extern here makes ms compiler
// happy when globaldef is used
extern epicsShareDef const gddDbrMapFuncTable gddMapDbr[] = {
{ mapStringToGdd, mapGddToString }, // DBR_STRING
{ mapShortToGdd, mapGddToShort }, // DBR_SHORT
{ mapFloatToGdd, mapGddToFloat }, // DBR_FLOAT

View File

@@ -8,6 +8,9 @@
* $Id$
*
* $Log$
* Revision 1.3 1997/04/23 17:12:57 jhill
* fixed export of symbols from WIN32 DLL
*
* Revision 1.2 1997/04/10 19:59:25 jhill
* api changes
*
@@ -39,9 +42,9 @@ typedef gdd* (*to_gdd)(void* db_struct, aitIndex element_count);
// Function proto to convert from a gdd to a dbr structure, returns the
// number of elements that the value field of db_struct points to if the
// gdd points to an array. The db_struct will reference the data
// contained within the gdd (which is probably also referenced from the user).
typedef int (*to_dbr)(void* db_struct, gdd*);
// gdd points to an array or -1 if the number of elements in the value
// field is not identical to element_count available in db_struct.
typedef int (*to_dbr)(void* db_struct, aitIndex element_count, gdd*);
struct gddDbrMapFuncTable {
to_gdd conv_gdd;
@@ -58,9 +61,10 @@ typedef struct gddDbrToAitTable gddDbrToAitTable;
epicsShareExtern gddDbrToAitTable gddDbrToAit[];
epicsShareExtern const chtype gddAitToDbr[];
epicsShareExtern gddDbrMapFuncTable gddMapDbr[];
epicsShareExtern void gddMakeMapDBR(gddApplicationTypeTable& tt);
epicsShareExtern void gddMakeMapDBR(gddApplicationTypeTable* tt);
epicsShareExtern const gddDbrMapFuncTable gddMapDbr[];
epicsShareFunc void gddMakeMapDBR(gddApplicationTypeTable& tt);
epicsShareFunc void gddMakeMapDBR(gddApplicationTypeTable* tt);
#endif

View File

@@ -4,6 +4,9 @@
// $Id$
//
// $Log$
// Revision 1.22 1997/06/25 06:17:34 jhill
// fixed warnings
//
// Revision 1.21 1997/04/23 17:12:57 jhill
// fixed export of symbols from WIN32 DLL
//
@@ -431,7 +434,7 @@ gddStatus gdd::copyStuff(gdd* dd,int ctype)
aitUint8* array;
size_t a_size;
a_size=dd->getDataSizeBytes();
if(array=new aitUint8[a_size])
if( (array=new aitUint8[a_size]) )
{
destruct=new gddDestructor;
destruct->reference();
@@ -548,15 +551,13 @@ size_t gdd::getTotalSizeBytes(void) const
aitUint32 gdd::getDataSizeElements(void) const
{
unsigned long total=0;
unsigned long total=1u;
unsigned i;
if(dimension()==0)
total=1;
else
if(dimension()>0u && dataPointer())
{
if(dataPointer())
for(i=0;i<dimension();i++) total+=bounds[i].size();
for(i=0u;i<dimension();i++)
total*=bounds[i].size();
}
return total;
@@ -637,8 +638,7 @@ size_t gdd::flattenWithAddress(void* buf, size_t size, aitIndex* total_dd)
if(str->string())
{
memcpy((char*)&pdd[pos],str->string(),str->length()+1);
str->force((char*)&pdd[pos]);
str->forceConstant();
str->installBuf((char*)&pdd[pos],str->length(),str->length()+1);
}
else
str->init();
@@ -772,8 +772,7 @@ gddStatus gdd::flattenData(gdd* dd, int tot_dds, void* buf,size_t size)
if(str->string())
{
memcpy(ptr,str->string(),str->length()+1);
str->force((char*)ptr);
str->forceConstant();
str->installBuf((char *)ptr, str->length(), str->length()+1);
ptr+=str->length()+1;
}
else
@@ -875,7 +874,8 @@ gddStatus gdd::convertOffsetsToAddress(void)
if(str[i].string())
{
cstr=str[i].string();
str[i].force(pdd+(unsigned long)cstr);
str[i].installBuf((char *)(pdd+(unsigned long)cstr),
str[i].length(), str[i].length()+1);
}
else
str[i].init();
@@ -892,7 +892,8 @@ gddStatus gdd::convertOffsetsToAddress(void)
if(str->string())
{
cstr=str->string();
str->force(pdd+(unsigned long)cstr);
str->installBuf((char *)(pdd+(unsigned long)cstr),
str->length(), str->length()+1u);
}
else
str->init();
@@ -949,7 +950,8 @@ gddStatus gdd::convertAddressToOffsets(void)
for(i=0;i<getDataSizeElements();i++)
{
cstr=str[i].string();
if(cstr) str[i].force(cstr-(const char*)pdd);
if(cstr) str[i].installBuf((char *)(cstr-(const char*)pdd),
str[i].length(), str[i].length()+1u);
else str[i].init();
}
}
@@ -966,7 +968,8 @@ gddStatus gdd::convertAddressToOffsets(void)
{
str=(aitString*)dataAddress();
cstr=str->string();
if(cstr) str->force(cstr-(const char*)pdd);
if(cstr) str->installBuf((char *)(cstr-(const char*)pdd),
str->length(), str->length()+1u);
else str->init();
}
}
@@ -1060,16 +1063,7 @@ void gdd::get(aitString& d)
}
else if(dim==1 && primitiveType()==aitEnumInt8)
{
if(isConstant())
{
const char* ci=(const char*)dataPointer();
d.installString(ci);
}
else
{
char* i=(char*)dataPointer();
d.installString(i);
}
d.copy((char *)dataPointer());
}
else
get(aitEnumString,&d);
@@ -1094,16 +1088,7 @@ void gdd::getConvert(aitString& d)
{
if(primitiveType()==aitEnumInt8 && dim==1)
{
if(isConstant())
{
const char* ci=(const char*)dataPointer();
d.installString(ci);
}
else
{
char* i=(char*)dataPointer();
d.installString(i);
}
d.copy((char*)dataPointer());
}
else
get(aitEnumString,&d);
@@ -1138,24 +1123,6 @@ gddStatus gdd::put(const aitString& d)
return rc;
}
gddStatus gdd::put(aitString& d)
{
gddStatus rc=0;
if(isScalar())
{
aitString* s=(aitString*)dataAddress();
*s=d;
setPrimType(aitEnumString);
}
else
{
gddAutoPrint("gdd::put(aitString&)",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
}
return rc;
}
// this is dangerous, should the fixed string be copied here?
gddStatus gdd::put(const aitFixedString& d)
{
@@ -1188,7 +1155,7 @@ void gdd::putConvert(const aitString& d)
cp[len]='\0';
}
else
set(aitEnumString,(aitString*)&d);
set(aitEnumString,&d);
}
void gdd::putConvert(const aitFixedString& d)
@@ -1252,15 +1219,22 @@ gddStatus gdd::put(const gdd* dd)
gddAutoPrint("gdd::put(const gdd*)",gddErrorNotSupported);
return gddErrorNotSupported;
}
//
// After careful consideration I (joh) commented this section out.
// It should not be necesary to initialize the primative type.
// Forcing the bounds and dimension to be the same as the source dd
// ignores the user's requested bounds.
//
// this primitive must be valid for this is work - set to dd if invalid
if(!aitValid(primitiveType()))
{
//if(!aitValid(primitiveType()))
//{
// note that flags, etc. are not set here - just data related stuff
destroyData();
setPrimType(dd->primitiveType());
setDimension(dd->dimension(),dd->getBounds());
}
//destroyData();
//setPrimType(dd->primitiveType());
//setDimension(dd->dimension(),dd->getBounds());
//}
if(isScalar() && dd->isScalar())
{
@@ -1379,7 +1353,7 @@ size_t gdd::outHeader(void* buf,aitUint32 bufsize)
aitUint8* stat = (aitUint8*)&status;
aitUint8* ts_sec = (aitUint8*)&time_stamp.tv_sec;
aitUint8* ts_nsec = (aitUint8*)&time_stamp.tv_nsec;
int i,j,sz;
size_t i,j,sz;
aitIndex ff,ss;
aitUint8 *f,*s;
@@ -1405,9 +1379,9 @@ size_t gdd::outHeader(void* buf,aitUint32 bufsize)
else
{
*(b++)=app[1]; *(b++)=app[0];
for(i=sizeof(status)-1;i>=0;i--) *(b++)=stat[i];
for(i=sizeof(time_stamp.tv_sec)-1;i>=0;i--) *(b++)=ts_sec[i];
for(i=sizeof(time_stamp.tv_nsec)-1;i>=0;i--) *(b++)=ts_nsec[i];
i=sizeof(status)-1u; do { *(b++)=stat[i]; } while(i-->0u);
i=sizeof(time_stamp.tv_sec)-1u; do { *(b++)=ts_sec[i]; } while(i-->0u);
i=sizeof(time_stamp.tv_nsec)-1u; do { *(b++)=ts_nsec[i]; } while(i-->0u);
}
// put out the bounds info
@@ -1422,8 +1396,8 @@ size_t gdd::outHeader(void* buf,aitUint32 bufsize)
}
else
{
for(i=sizeof(aitIndex)-1;i>=0;i--) *(b++)=s[i];
for(i=sizeof(aitIndex)-1;i>=0;i--) *(b++)=f[i];
i=sizeof(aitIndex)-1u; do { *(b++)=s[i]; } while(i-->0u);
i=sizeof(aitIndex)-1u; do { *(b++)=f[i]; } while(i-->0u);
}
}
return sz;
@@ -1477,7 +1451,7 @@ size_t gdd::inHeader(void* buf)
aitUint8* stat = (aitUint8*)&status;
aitUint8* ts_sec = (aitUint8*)&time_stamp.tv_sec;
aitUint8* ts_nsec = (aitUint8*)&time_stamp.tv_nsec;
int i,j;
size_t i,j;
aitIndex ff,ss;
aitUint8 *f,*s;
@@ -1491,24 +1465,25 @@ size_t gdd::inHeader(void* buf)
{
app[0]=*(b++); app[1]=*(b++);
init(inapp,(aitEnum)inprim,indim);
for(i=0;i<sizeof(status);i++) stat[i]=*(b++);
for(i=0;i<sizeof(time_stamp.tv_sec);i++) ts_sec[i]=*(b++);
for(i=0;i<sizeof(time_stamp.tv_nsec);i++) ts_nsec[i]=*(b++);
for(i=0u;i<sizeof(status);i++) stat[i]=*(b++);
for(i=0u;i<sizeof(time_stamp.tv_sec);i++) ts_sec[i]=*(b++);
for(i=0u;i<sizeof(time_stamp.tv_nsec);i++) ts_nsec[i]=*(b++);
}
else
{
app[1]=*(b++); app[0]=*(b++);
init(inapp,(aitEnum)inprim,indim);
for(i=sizeof(status)-1;i>=0;i--) stat[i]=*(b++);
for(i=sizeof(time_stamp.tv_sec)-1;i>=0;i--) ts_sec[i]=*(b++);
for(i=sizeof(time_stamp.tv_nsec)-1;i>=0;i--) ts_nsec[i]=*(b++);
i=sizeof(status)-1u; do { stat[i]=*(b++); } while(i-->0u);
i=sizeof(time_stamp.tv_sec)-1u; do { ts_sec[i]=*(b++); } while(i-->0u);
i=sizeof(time_stamp.tv_nsec)-1u; do { ts_nsec[i]=*(b++); } while(i-->0u);
}
// read in the bounds info
f=(aitUint8*)&ff;
s=(aitUint8*)&ss;
for(j=0;j<dim;j++)
for(j=0u;j<dim;j++)
{
if(aitLocalNetworkDataFormatSame)
{
@@ -1517,8 +1492,8 @@ size_t gdd::inHeader(void* buf)
}
else
{
for(i=sizeof(aitIndex)-1;i>=0;i--) s[i]=*(b++);
for(i=sizeof(aitIndex)-1;i>=0;i--) f[i]=*(b++);
i=sizeof(aitIndex)-1u; do { s[i]=*(b++); } while(i-->0u);
i=sizeof(aitIndex)-1u; do { f[i]=*(b++); } while(i-->0u);
}
bounds[j].setFirst(ff);
bounds[j].setSize(ss);

View File

@@ -8,6 +8,9 @@
* $Id$
*
* $Log$
* Revision 1.23 1997/04/23 17:12:59 jhill
* fixed export of symbols from WIN32 DLL
*
* Revision 1.22 1997/03/21 01:56:03 jbk
* *** empty log message ***
*
@@ -99,7 +102,7 @@
#include <limits.h>
#include <sys/types.h>
#if defined(WIN32)
#if defined(_WIN32)
# include <stdlib.h>
#elif defined(vxWorks)
# include <time.h>
@@ -365,7 +368,6 @@ public:
gddStatus put(aitInt16 d);
gddStatus put(aitUint8 d);
gddStatus put(aitInt8 d);
gddStatus put(aitString& d);
gddStatus put(const aitString& d);
gddStatus put(const aitFixedString& d);
gddStatus put(aitType* d);
@@ -418,7 +420,6 @@ public:
gdd& operator=(aitInt16 d);
gdd& operator=(aitUint8 d);
gdd& operator=(aitInt8 d);
gdd& operator=(aitString& d);
gdd& operator=(const aitString& d);
// gdd& operator=(aitFixedString d); // not present

View File

@@ -4,6 +4,9 @@
// $Id$
//
// $Log$
// Revision 1.8 1997/04/23 17:13:00 jhill
// fixed export of symbols from WIN32 DLL
//
// Revision 1.7 1996/09/04 20:55:02 jhill
// add GDD_NAME_PV_NAME
//
@@ -40,8 +43,6 @@
#define epicsExportSharedSymbols
#include "gddAppTable.h"
static char* thing = "12345678";
// useless utility function
gddApplicationTypeTable* gddGenerateApplicationTypeTable(long x/*=(1<<13)*/)
{

View File

@@ -4,6 +4,9 @@
// $Id$
//
// $Log$
// Revision 1.8 1997/04/23 17:13:01 jhill
// fixed export of symbols from WIN32 DLL
//
// Revision 1.7 1997/01/12 20:32:48 jbk
// many errors fixed
//
@@ -61,7 +64,7 @@ gddApplicationTypeTable::gddApplicationTypeTable(aitUint32 tot)
aitUint32 i,total;
// round tot up to nearest power of 2
for(i=1<<31;i && !(tot&i);i>>=1);
for(i=1u<<31;i && !(tot&i);i>>=1);
if(i==0)
total=1;
else if(i==tot)
@@ -96,7 +99,7 @@ void operator delete(void* x)
gddApplicationTypeTable::~gddApplicationTypeTable(void)
{
int i,j;
unsigned i,j;
gdd* dd;
aitUint8* blk;
@@ -104,29 +107,29 @@ gddApplicationTypeTable::~gddApplicationTypeTable(void)
if(this!=&app_table) return;
for(i=0;i<max_groups;i++)
for(i=0u;i<max_groups;i++)
{
if(attr_table[i])
{
// fprintf(stderr,"Delete TypeTable: group %d exists\n",i);
for(j=0;j<APPLTABLE_GROUP_SIZE;j++)
for(j=0u;j<APPLTABLE_GROUP_SIZE;j++)
{
switch(attr_table[i][j].type)
{
case gddApplicationTypeNormal:
// fprintf(stderr,"Delete TypeTable: app %d normal\n",j);
// fprintf(stderr,"Delete TypeTable: app %u normal\n",j);
if(attr_table[i][j].app_name)
delete [] attr_table[i][j].app_name;
break;
case gddApplicationTypeProto:
// fprintf(stderr,"Delete TypeTable: app %d has proto\n",j);
// fprintf(stderr,"Delete TypeTable: app %u has proto\n",j);
if(attr_table[i][j].app_name)
delete [] attr_table[i][j].app_name;
if(attr_table[i][j].proto)
{
// if(attr_table[i][j].free_list)
// fprintf(stderr," app %d has free_list\n",j);
// fprintf(stderr," app %u has free_list\n",j);
// The proto is stored as flattened gdd
blk=(aitUint8*)attr_table[i][j].proto;
@@ -189,7 +192,7 @@ int gddApplicationTypeTable::describeDD(gddContainer* dd, FILE* fd,
void gddApplicationTypeTable::describe(FILE* fd)
{
int i,j;
unsigned i,j;
gdd* dd;
char* tn;
@@ -205,10 +208,10 @@ void gddApplicationTypeTable::describe(FILE* fd)
case gddApplicationTypeNormal:
case gddApplicationTypeProto:
tn=attr_table[i][j].app_name;
fprintf(fd,"#define gddAppType_%s\t%d\n",
fprintf(fd,"#define gddAppType_%s\t%u\n",
tn,i*APPLTABLE_GROUP_SIZE+j);
if(dd=attr_table[i][j].proto)
if( (dd=attr_table[i][j].proto) )
{
fprintf(fd,"#define gddAppTypeIndex_%s 0\n",tn);
if(dd->isContainer())
@@ -231,7 +234,7 @@ gddStatus gddApplicationTypeTable::registerApplicationType(
aitUint32 i,group,app,rapp;
gddStatus rc;
if(new_app=getApplicationType(name))
if( (new_app=getApplicationType(name)) )
{
// gddAutoPrint(gddErrorAlreadyDefined);
return gddErrorAlreadyDefined;
@@ -297,7 +300,7 @@ gddStatus gddApplicationTypeTable::registerApplicationTypeWithProto(
aitUint16 i;
gddStatus rc;
if(rc=registerApplicationType(name,new_app)) return rc;
if( (rc=registerApplicationType(name,new_app)) ) return rc;
rapp=new_app;
protoDD->setApplType(rapp);
@@ -342,7 +345,7 @@ gddStatus gddApplicationTypeTable::registerApplicationTypeWithProto(
aitUint32 gddApplicationTypeTable::getApplicationType(const char* const name) const
{
int i,j,rc;
unsigned i,j,rc;
for(i=0,rc=0;i<max_groups && attr_table[i] && rc==0;i++)
{
@@ -401,7 +404,7 @@ gdd* gddApplicationTypeTable::getDD(aitUint32 rapp)
{
case gddApplicationTypeProto:
attr_table[group][app].sem.take();
if(dd=attr_table[group][app].free_list)
if( (dd=attr_table[group][app].free_list) )
{
//fprintf(stderr,"Popping a proto DD from list! %d %8.8x\n",app,dd);
attr_table[group][app].free_list=dd->next();

View File

@@ -8,6 +8,9 @@
* $Id$
*
* $Log$
* Revision 1.1 1997/03/21 01:56:08 jbk
* *** empty log message ***
*
*/
inline void gdd::setData(void* d) { data.Pointer=d; }
@@ -221,23 +224,25 @@ inline void gdd::set(aitEnum t,const void* v,aitDataFormat f)
inline void gdd::set(aitEnum t,const void* v,aitDataFormat)
#endif
{
if(primitiveType()==aitEnumFixedString)
{
if(dataPointer()==NULL)
data.FString=new aitFixedString;
aitConvert(primitiveType(),dataPointer(),t,v,1);
if (primitiveType()==aitEnumInvalid) {
this->prim_type = t;
if(t==aitEnumFixedString)
{
if(dataPointer()==NULL)
{
data.FString = new aitFixedString;
}
}
}
else
{
#if aitLocalNetworkDataFormatSame == AIT_FALSE
if(f!=aitLocalDataFormat)
aitConvertFromNet(primitiveType(),dataAddress(),t,v,1);
else
#endif
aitConvert(primitiveType(),dataAddress(),t,v,1);
markLocalDataFormat();
}
#if aitLocalNetworkDataFormatSame == AIT_FALSE
if(f!=aitLocalDataFormat)
aitConvertFromNet(primitiveType(),dataVoid(),t,v,1);
else
#endif
aitConvert(primitiveType(),dataVoid(),t,v,1);
markLocalDataFormat();
}
// -------------------getRef(data pointer) functions----------------
@@ -343,7 +348,7 @@ inline gddStatus gdd::put(const aitInt8* const d)
if(primitiveType()==aitEnumString && dim==0)
{
aitString* p = (aitString*)dataAddress();
p->installString((char*)d);
p->copy((char*)d);
}
else if(primitiveType()==aitEnumFixedString && dim==0) {
strncpy(data.FString->fixed_string,(char*)d,
@@ -570,8 +575,6 @@ inline gdd& gdd::operator=(aitUint8 d)
{ data.Uint8=d; setPrimType(aitEnumUint8); return *this; }
inline gdd& gdd::operator=(aitInt8 d)
{ data.Int8=d; setPrimType(aitEnumInt8); return *this; }
inline gdd& gdd::operator=(aitString& d)
{ put(d); return *this; }
inline gdd& gdd::operator=(const aitString& d)
{ put(d); return *this; }

View File

@@ -4,6 +4,9 @@
// $Id$
//
// $Log$
// Revision 1.8 1997/06/25 06:17:38 jhill
// fixed warnings
//
// Revision 1.7 1997/04/23 17:13:05 jhill
// fixed export of symbols from WIN32 DLL
//
@@ -67,8 +70,8 @@ void gdd::dumpInfo(void)
{
unsigned i;
aitIndex f,c;
long sz_tot,sz_data,sz_elem;
const aitIndex max=20;
unsigned long sz_tot,sz_data,sz_elem;
const aitIndex max=20u;
aitIndex prt_tot;
sz_tot = getTotalSizeBytes();
@@ -78,14 +81,14 @@ void gdd::dumpInfo(void)
prt_tot=sz_elem>max?max:sz_elem;
fprintf(stderr,"----------dump This=%p---------\n", this);
fprintf(stderr," dimension=%d ",(int)dimension());
fprintf(stderr,"app-type=%d ",(int)applicationType());
fprintf(stderr," dimension=%u ", dimension());
fprintf(stderr,"app-type=%u ", applicationType());
if(isScalar()) fprintf(stderr,"Scalar\n");
if(isAtomic()) fprintf(stderr,"Atomic\n");
if(isContainer()) fprintf(stderr,"Container\n");
fprintf(stderr," prim-type=%d",(int)primitiveType());
fprintf(stderr," prim-type=%s",aitName[primitiveType()]);
switch(primitiveType())
{
case aitEnumInvalid:
@@ -181,12 +184,12 @@ void gdd::dumpInfo(void)
break;
case aitEnumFloat64:
fprintf(stderr,"(aitEnumFloat64)");
if(isScalar()) fprintf(stderr," value=%lf ",data.Float64);
if(isScalar()) fprintf(stderr," value=%f ",data.Float64);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitFloat64* f64=(aitFloat64*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"%lf ",f64[i]);
for(i=0;i<prt_tot;i++) fprintf(stderr,"%f ",f64[i]);
fprintf(stderr,">\n");
}
break;
@@ -195,7 +198,7 @@ void gdd::dumpInfo(void)
if(isScalar())
{
if(data.FString)
fprintf(stderr," value=<%s>\n",data.FString);
fprintf(stderr," value=<%s>\n",(char *)data.FString);
else
fprintf(stderr," value=<NULL>\n");
}
@@ -246,7 +249,7 @@ void gdd::dumpInfo(void)
for(i=0;i<dimension();i++)
{
getBound(i,f,c);
fprintf(stderr," (%d) %8.8x first=%d count=%d\n",i,&bounds[i],f,c);
fprintf(stderr," (%d) %p first=%d count=%d\n",i,&bounds[i],f,c);
}
if(isManaged()) fprintf(stderr," Managed");
@@ -287,7 +290,7 @@ void gddContainer::dump(void)
// should use a cursor
for(i=1;dd=getDD(i);i++)
for(i=1; (dd=getDD(i)); i++)
{
if(dd->isAtomic()) { add=(gddAtomic*)dd; add->dump(); }
if(dd->isScalar()) { sdd=(gddScalar*)dd; sdd->dump(); }
@@ -345,7 +348,7 @@ public:
void gddAtomicDestr::run(void* v)
{
fprintf(stderr,"**** gddAtomicDestr::run from gddAtomic::test %8.8x\n",v);
fprintf(stderr,"**** gddAtomicDestr::run from gddAtomic::test %p\n",v);
}
#endif
@@ -354,7 +357,7 @@ void gddAtomic::test(void) { }
#else
void gddAtomic::test(void)
{
aitFloat32 f32[6] = { 32.0,2.0,1.0, 7.0,8.0,9.0 };
aitFloat32 f32[6] = { 32.0f,2.0f,1.0f, 7.0f,8.0f,9.0f };
aitFloat64 f64[6] = { 64.0,5.0,4.0, 10.0,11.0,12.0 };
aitInt8 i8[6] = { -8,2,1, 13,14,15 };
aitInt16 i16[6] = { -16,3,2, 16,17,18 };
@@ -412,7 +415,7 @@ void gddScalar::test(void) { }
void gddScalar::test(void)
{
int i;
aitFloat32 fa32,f32 = 32.0;
aitFloat32 fa32,f32 = 32.0f;
aitFloat64 fa64,f64 = 64.0;
aitInt8 ia8,i8 = -8;
aitInt16 ia16,i16 = -16;
@@ -492,14 +495,14 @@ void gddContainer::test(void)
aitInt16 i16 = 5;
aitInt32 i32 = 6;
aitFloat32 f32[3] = { 7.0, 8.0, 9.0 };
aitFloat32 f32[3] = { 7.0f, 8.0f, 9.0f };
aitUint8* buf;
size_t sz;
*sdd1=i32; *sdd2=i16; *add1=f32;
// insert two scalers and an atomic into the container
fprintf(stderr,"*INSERT %8.8x %8.8x %8.8x\n",sdd1,sdd2,add1);
fprintf(stderr,"*INSERT %p %p %p\n",sdd1,sdd2,add1);
clear();
sdd1->reference(); add1->reference(); sdd2->reference();
insert(sdd1); insert(sdd2); insert(add1); dump();
@@ -508,9 +511,9 @@ void gddContainer::test(void)
gddCursor cur = getCursor();
gdd* dd;
int i;
for(i=0;dd=cur[i];i++) fprintf(stderr,"%8.8x ",dd);
for(i=0; (dd=cur[i]); i++) fprintf(stderr,"%p ",dd);
fprintf(stderr,"\n");
for(dd=cur.first();dd;dd=cur.next()) fprintf(stderr,"%8.8x ",dd);
for(dd=cur.first();dd;dd=cur.next()) fprintf(stderr,"%p ",dd);
fprintf(stderr,"\n");
remove(0); remove(0); remove(0); dump();
@@ -520,7 +523,7 @@ void gddContainer::test(void)
sz = getTotalSizeBytes();
buf = new aitUint8[sz];
fprintf(stderr,"=====TESTING FLATTEN FUNCTION BUFFER=%8.8x:\n",buf);
fprintf(stderr,"=====TESTING FLATTEN FUNCTION BUFFER=%p:\n",buf);
flattenWithAddress(buf,sz);
cdd1=(gddContainer*)buf;
cdd1->dump();