From 8b97305072cce55921d743cbd4e2ca58da30b437 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 5 Aug 1997 00:51:16 +0000 Subject: [PATCH] fixed problems in aitString and the conversion matrix --- src/gdd/aitConvert.cc | 61 ++++--- src/gdd/aitConvert.h | 23 +-- src/gdd/aitGen.c | 252 +++++++++++----------------- src/gdd/aitHelpers.cc | 76 ++++++++- src/gdd/aitHelpers.h | 360 +++++++++++++++++++++++++--------------- src/gdd/aitTypes.c | 90 ++++++++-- src/gdd/aitTypes.h | 23 ++- src/gdd/dbMapper.cc | 365 ++++++++++++++++++++++++++--------------- src/gdd/dbMapper.h | 16 +- src/gdd/gdd.cc | 129 ++++++--------- src/gdd/gdd.h | 7 +- src/gdd/gddAppDefs.cc | 5 +- src/gdd/gddAppTable.cc | 31 ++-- src/gdd/gddI.h | 39 +++-- src/gdd/gddTest.cc | 39 +++-- 15 files changed, 890 insertions(+), 626 deletions(-) diff --git a/src/gdd/aitConvert.cc b/src/gdd/aitConvert.cc index a71c4dca2..2c06f6893 100644 --- a/src/gdd/aitConvert.cc +++ b/src/gdd/aitConvert.cc @@ -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;icopy((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=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=%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=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=%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 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; +} \ No newline at end of file diff --git a/src/gdd/aitHelpers.h b/src/gdd/aitHelpers.h index c913f809c..c788810df 100644 --- a/src/gdd/aitHelpers.h +++ b/src/gdd/aitHelpers.h @@ -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 diff --git a/src/gdd/aitTypes.c b/src/gdd/aitTypes.c index 44015c572..ff050373c 100644 --- a/src/gdd/aitTypes.c +++ b/src/gdd/aitTypes.c @@ -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 +#include + #define AIT_TYPES_SOURCE 1 #include + #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 +}; \ No newline at end of file diff --git a/src/gdd/aitTypes.h b/src/gdd/aitTypes.h index d19e3c6f9..6ece5daec 100644 --- a/src/gdd/aitTypes.h +++ b/src/gdd/aitTypes.h @@ -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 diff --git a/src/gdd/dbMapper.cc b/src/gdd/dbMapper.cc index d7bc3c0c4..977d51b51 100644 --- a/src/gdd/dbMapper.cc +++ b/src/gdd/dbMapper.cc @@ -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 diff --git a/src/gdd/dbMapper.h b/src/gdd/dbMapper.h index 0b824a3ef..52989a392 100644 --- a/src/gdd/dbMapper.h +++ b/src/gdd/dbMapper.h @@ -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 diff --git a/src/gdd/gdd.cc b/src/gdd/gdd.cc index 57f49464e..e27e10ed9 100644 --- a/src/gdd/gdd.cc +++ b/src/gdd/gdd.cc @@ -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;istring()) { 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;istring(); - 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=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=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); diff --git a/src/gdd/gdd.h b/src/gdd/gdd.h index acca21605..c4802a99a 100644 --- a/src/gdd/gdd.h +++ b/src/gdd/gdd.h @@ -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 #include -#if defined(WIN32) +#if defined(_WIN32) # include #elif defined(vxWorks) # include @@ -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 diff --git a/src/gdd/gddAppDefs.cc b/src/gdd/gddAppDefs.cc index 2c9921be7..5359b93dd 100644 --- a/src/gdd/gddAppDefs.cc +++ b/src/gdd/gddAppDefs.cc @@ -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)*/) { diff --git a/src/gdd/gddAppTable.cc b/src/gdd/gddAppTable.cc index 7a1ccbab8..231eccc6d 100644 --- a/src/gdd/gddAppTable.cc +++ b/src/gdd/gddAppTable.cc @@ -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;iisContainer()) @@ -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;inext(); diff --git a/src/gdd/gddI.h b/src/gdd/gddI.h index aac3549ea..d878c46ad 100644 --- a/src/gdd/gddI.h +++ b/src/gdd/gddI.h @@ -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; } diff --git a/src/gdd/gddTest.cc b/src/gdd/gddTest.cc index 2bcbfd67b..ee1b70a23 100644 --- a/src/gdd/gddTest.cc +++ b/src/gdd/gddTest.cc @@ -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\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=\n"); } @@ -246,7 +249,7 @@ void gdd::dumpInfo(void) for(i=0;iisAtomic()) { 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();