From: Adrian S. <a3s...@us...> - 2005-06-13 23:37:42
|
Update of /cvsroot/sblim/sfcb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13003 Modified Files: array.c array.h cimXmlGen.c cimXmlRequest.c classProvider.c constClass.c constClass.h objectImpl.c objectImpl.h objectpath.c providerMgr.c Log Message: Fixed [ 1219651 ] Qualifiers with array values not correctly handled This is a large fix, most of the changes are because of statement reformatting. to have an effect, repositories must be rebuild. Index: cimXmlRequest.c =================================================================== RCS file: /cvsroot/sblim/sfcb/cimXmlRequest.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- cimXmlRequest.c 3 Jun 2005 10:31:56 -0000 1.11 +++ cimXmlRequest.c 13 Jun 2005 23:37:31 -0000 1.12 @@ -535,7 +535,7 @@ closeProviderContext(&binCtx); free(sreq); resp->rc--; - if (resp->rc == CMPI_RC_OK) { + if (resp->rc == CMPI_RC_OK) { cls = relocateSerializedConstClass(resp->object[0].data); sb = UtilFactory->newStrinBuffer(1024); cls2xml(cls, sb,binCtx.bHdr->flags); Index: cimXmlGen.c =================================================================== RCS file: /cvsroot/sblim/sfcb/cimXmlGen.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- cimXmlGen.c 30 May 2005 01:32:24 -0000 1.8 +++ cimXmlGen.c 13 Jun 2005 23:37:31 -0000 1.9 @@ -450,10 +450,11 @@ char *type; - if (data->type & CMPI_ARRAY) { + if (data->type & CMPI_ARRAY) { CMPIArray *ar = data->value.array; CMPIData d; int j, ac = CMGetArrayCount(ar, NULL); + sb->ft->appendChars(sb, bTag); sb->ft->appendChars(sb, (char *) name->hdl); if (param) sb->ft->appendChars(sb, "\" PARAMTYPE=\""); @@ -475,6 +476,7 @@ else { type = dataType(data->type); if (*type == '*') { + char *cn; sb->ft->appendChars(sb, bTag); sb->ft->appendChars(sb, (char *) name->hdl); sb->ft->appendChars(sb, "\" REFERENCECLASS=\""); @@ -657,8 +659,15 @@ "</PROPERTY.ARRAY>\n", sb, qsb, 0,0); else { type = dataType(data.type); - if (*type == '*') data2xml(&data,cls,name,"<PROPERTY.REFERENCE NAME=\"", - "</PROPERTY.REFERENCE>\n", sb, qsb, 0,0); + if (*type == '*') { + if (data.state &CMPI_nullValue) { + sb->ft->appendChars(sb, "<PROPERTY.REFERENCE NAME=\""); + sb->ft->appendChars(sb, (char*)name->hdl); + sb->ft->appendChars(sb, "\"</PROPERTY.REFERENCE>\n"); + } + else data2xml(&data,cls,name,"<PROPERTY.REFERENCE NAME=\"", + "</PROPERTY.REFERENCE>\n", sb, qsb, 0,0); + } else data2xml(&data,cls,name,"<PROPERTY NAME=\"", "</PROPERTY>\n", sb, qsb, 0,0); } Index: classProvider.c =================================================================== RCS file: /cvsroot/sblim/sfcb/classProvider.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- classProvider.c 27 May 2005 14:29:02 -0000 1.14 +++ classProvider.c 13 Jun 2005 23:37:31 -0000 1.15 @@ -250,7 +250,7 @@ cr->assocs++; if (cc->ft->getCharSuperClassName(cc) == NULL) cr->topAssocs++; } - } + } } else { mlogf(M_ERROR,M_SHOW,"--- %s contains invalid record(s) - directory skipped\n",fin); Index: providerMgr.c =================================================================== RCS file: /cvsroot/sblim/sfcb/providerMgr.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- providerMgr.c 3 Jun 2005 10:31:57 -0000 1.11 +++ providerMgr.c 13 Jun 2005 23:37:31 -0000 1.12 @@ -876,7 +876,7 @@ ((BinRequestHdr *) buf)->object[i].data = (void *) l; l += ol; break; - case MSG_SEG_CONSTCLASS: + case MSG_SEG_CONSTCLASS: getSerializedConstClass((CMPIConstClass *) hdr->object[i].data, buf + l); ((BinRequestHdr *) buf)->object[i].data = (void *) l; Index: objectImpl.h =================================================================== RCS file: /cvsroot/sblim/sfcb/objectImpl.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- objectImpl.h 25 Apr 2005 14:40:42 -0000 1.3 +++ objectImpl.h 13 Jun 2005 23:37:31 -0000 1.4 @@ -126,7 +126,7 @@ typedef struct { short iUsed, iMax; long iOffset; - long *index; + long *aIndex; long bUsed, bMax; CMPIData buf[1]; } ClArrayBuf; @@ -134,7 +134,7 @@ typedef struct { short iUsed, iMax; long iOffset; - long *index; + long *sIndex; long bUsed, bMax; char buf[1]; } ClStrBuf; Index: constClass.h =================================================================== RCS file: /cvsroot/sblim/sfcb/constClass.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- constClass.h 21 Mar 2005 14:22:38 -0000 1.2 +++ constClass.h 13 Jun 2005 23:37:31 -0000 1.3 @@ -41,10 +41,10 @@ struct _CMPIConstClass_FT { int version; CMPIStatus(*release) (CMPIConstClass * cc); - CMPIConstClass *(*clone) (CMPIConstClass * cc, CMPIStatus * rc); - void (*relocate) (CMPIConstClass * cc); - const char *(*getCharClassName) (CMPIConstClass * br); - const char *(*getCharSuperClassName) (CMPIConstClass * br); + CMPIConstClass *(*clone) (CMPIConstClass * cc, CMPIStatus * rc); + void (*relocate) (CMPIConstClass * cc); + const char *(*getCharClassName) (CMPIConstClass * br); + const char *(*getCharSuperClassName) (CMPIConstClass * br); CMPIBoolean(*isAssociation) (CMPIConstClass * cc); CMPIBoolean(*isAbstract) (CMPIConstClass * cc); CMPIBoolean(*isIndication) (CMPIConstClass * cc); Index: array.h =================================================================== RCS file: /cvsroot/sblim/sfcb/array.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- array.h 9 Mar 2005 12:25:09 -0000 1.1.1.1 +++ array.h 13 Jun 2005 23:37:31 -0000 1.2 @@ -34,7 +34,7 @@ CMPIArray array; int mem_state; - CMPICount size,max; + CMPICount size,max,dynamic; CMPIType type; struct native_array_item *data; }; Index: objectImpl.c =================================================================== RCS file: /cvsroot/sblim/sfcb/objectImpl.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- objectImpl.c 30 May 2005 01:32:24 -0000 1.7 +++ objectImpl.c 13 Jun 2005 23:37:31 -0000 1.8 @@ -95,30 +95,25 @@ { ClStrBuf *buf; - if (id->id == 0) - return NULL; - if MALLOCED - (hdr->strBufOffset) buf = (ClStrBuf *) hdr->strBufOffset; - else - buf = (ClStrBuf *) ((char *) hdr + abs(hdr->strBufOffset)); - return &(buf->buf[buf->index[id->id - 1]]); + if (id->id == 0) return NULL; + if MALLOCED (hdr->strBufOffset) buf = (ClStrBuf *) hdr->strBufOffset; + else buf = (ClStrBuf *) ((char *) hdr + abs(hdr->strBufOffset)); + return &(buf->buf[buf->sIndex[id->id - 1]]); } const CMPIData *ClObjectGetClArray(ClObjectHdr * hdr, ClArray * id) { ClArrayBuf *buf; - if MALLOCED (hdr->arrayBufOffset) - buf = (ClArrayBuf *) hdr->arrayBufOffset; - else - buf = (ClArrayBuf *) ((char *) hdr + abs(hdr->arrayBufOffset)); - return &(buf->buf[buf->index[id->id - 1]]); + if (id->id == 0) return NULL; + if MALLOCED(hdr->arrayBufOffset) buf = (ClArrayBuf *) hdr->arrayBufOffset; + else buf = (ClArrayBuf *) ((char *) hdr + abs(hdr->arrayBufOffset)); + return &(buf->buf[buf->aIndex[id->id - 1]]); } void *ClObjectGetClSection(ClObjectHdr * hdr, ClSection * s) { - if MALLOCED(s->offset) - return (void *) s->offset; + if MALLOCED(s->offset) return (void *) s->offset; return (void *) ((char *) hdr + abs(s->offset)); } @@ -170,35 +165,30 @@ buf->bMax = nmax; buf->bUsed = buf->iUsed = 0; buf->iOffset = (long) - (buf->index = (long *) malloc(sizeof(long) * 16)); + (buf->sIndex = (long *) malloc(sizeof(long) * 16)); buf->iMax = 16; hdr->flags |= HDR_Rebuild; } else { int malloced = MALLOCED(hdr->strBufOffset); - if (malloced) - buf = (ClStrBuf *) hdr->strBufOffset; - else - buf = (ClStrBuf *) (((char *) hdr) + abs(hdr->strBufOffset)); + if (malloced) buf = (ClStrBuf *) hdr->strBufOffset; + else buf = (ClStrBuf *) (((char *) hdr) + abs(hdr->strBufOffset)); if (buf->iUsed >= abs(buf->iMax)) { nmax = abs(buf->iMax) * 2; if (buf->iMax > 0) { if (!malloced) { - void *idx = (void *) buf->index; + void *idx = (void *) buf->sIndex; buf->iOffset = (long) - (buf->index = (long *) malloc(nmax * sizeof(long))); - memcpy((void *) buf->index, idx, buf->iMax * sizeof(long)); + (buf->sIndex = (long *) malloc(nmax * sizeof(long))); + memcpy((void *) buf->sIndex, idx, buf->iMax * sizeof(long)); } - else - buf->iOffset = (long) (buf->index = (long *) - realloc((void *) buf->index, - nmax * sizeof(long))); + else buf->iOffset = (long) (buf->sIndex = (long *) + realloc((void *) buf->sIndex,nmax * sizeof(long))); } - else - buf->iOffset = (long) - (buf->index = (long *) malloc(nmax * sizeof(long))); + else buf->iOffset = (long) + (buf->sIndex = (long *) malloc(nmax * sizeof(long))); buf->iMax = nmax; hdr->flags |= HDR_Rebuild; } @@ -210,16 +200,12 @@ if (!malloced) { hdr->strBufOffset = (long) malloc(((nmax - 1) * sizeof(char)) + sizeof(ClStrBuf)); - memcpy((void *) hdr->strBufOffset, buf, - buf->bMax + sizeof(ClStrBuf)); + memcpy((void *) hdr->strBufOffset, buf, buf->bMax + sizeof(ClStrBuf)); } - else - hdr->strBufOffset = (long) (realloc((void *) hdr->strBufOffset, - ((nmax - 1) * sizeof(char)) + - sizeof(ClStrBuf))); + else hdr->strBufOffset = (long) (realloc((void *) hdr->strBufOffset, + ((nmax - 1) * sizeof(char)) + sizeof(ClStrBuf))); } - else - hdr->strBufOffset = (long) + else hdr->strBufOffset = (long) malloc(((nmax - 1) * sizeof(char)) + sizeof(ClStrBuf)); buf = (ClStrBuf *) hdr->strBufOffset; buf->bMax = nmax; @@ -228,7 +214,7 @@ } strcpy(buf->buf + buf->bUsed, str); - buf->index[buf->iUsed++] = buf->bUsed; + buf->sIndex[buf->iUsed++] = buf->bUsed; buf->bUsed += l; _SFCB_RETURN(buf->iUsed); @@ -248,40 +234,37 @@ nmax = 16; for (; nmax <= l; nmax *= 2); buf = (ClArrayBuf *) (hdr->arrayBufOffset = (long) - malloc(((nmax - 1) * sizeof(CMPIData)) + - sizeof(ClArrayBuf))); + malloc(((nmax - 1) * sizeof(CMPIData)) + sizeof(ClArrayBuf))); buf->bMax = nmax; buf->bUsed = buf->iUsed = 0; - buf->iOffset = (long) - (buf->index = (long *) malloc(sizeof(long) * 16)); + buf->iOffset = (long) (buf->aIndex = (long *) malloc(sizeof(long) * 16)); buf->iMax = 16; hdr->flags |= HDR_Rebuild; } else { int malloced = MALLOCED(hdr->arrayBufOffset); - if (malloced) - buf = (ClArrayBuf *) hdr->arrayBufOffset; - else - buf = (ClArrayBuf *) (((char *) hdr) + abs(hdr->strBufOffset)); + if (malloced) buf = (ClArrayBuf *) hdr->arrayBufOffset; + else buf = (ClArrayBuf *) (((char *) hdr) + abs(hdr->arrayBufOffset)); if (buf->iUsed >= abs(buf->iMax)) { nmax = abs(buf->iMax) * 2; if (buf->iMax > 0) { if (!malloced) { - void *idx = (void *) buf->index; + void *idx = (void *) buf->aIndex; buf->iOffset = (long) - (buf->index = (long *) malloc(nmax * sizeof(long))); - memcpy((void *) buf->index, idx, buf->iMax * sizeof(long)); + (buf->aIndex = (long *) malloc(nmax * sizeof(long))); + memcpy((void *) buf->aIndex, idx, buf->iMax * sizeof(long)); } - else - buf->iOffset = (long) (buf->index = (long *) - realloc((void *) buf->index, - nmax * sizeof(long))); + else { + buf->iOffset = (long) + (buf->aIndex = (long *)realloc((void *) buf->aIndex, nmax * sizeof(long))); + } } - else - buf->iOffset = (long) - (buf->index = (long *) malloc(nmax * sizeof(long))); + else { + buf->iOffset = (long) + (buf->aIndex = (long *) malloc(nmax * sizeof(long))); + } buf->iMax = nmax; hdr->flags |= HDR_Rebuild; } @@ -296,15 +279,10 @@ memcpy((void *) hdr->arrayBufOffset, buf, buf->bMax + sizeof(ClArrayBuf)); } - else - hdr->arrayBufOffset = - (long) (realloc - ((void *) hdr->arrayBufOffset, - ((nmax - 1) * sizeof(CMPIArray)) + - sizeof(ClArrayBuf))); + else hdr->arrayBufOffset = (long) (realloc ((void *) hdr->arrayBufOffset, + ((nmax - 1) * sizeof(CMPIData)) + sizeof(ClArrayBuf))); } - else - hdr->arrayBufOffset = (long) + else hdr->arrayBufOffset = (long) malloc(((nmax - 1) * sizeof(CMPIData)) + sizeof(ClArrayBuf)); buf = (ClArrayBuf *) hdr->arrayBufOffset; buf->bMax = nmax; @@ -314,25 +292,27 @@ td.state = 0; td.type = (ar->type == CMPI_string) ? CMPI_chars : ar->type; - td.value.sint32 = ar->size; - buf->index[buf->iUsed++] = buf->bUsed; + td.value.sint32 = ar->size; + buf->aIndex[buf->iUsed++] = buf->bUsed; buf->buf[buf->bUsed++] = td; for (i = 0, dp = buf->buf + buf->bUsed, m = ar->size; i < m; i++) { td.state = ar->data[i].state; - if (ar->type == CMPI_chars && (td.state & CMPI_nullValue) == 0) { + if (ar->type == CMPI_chars && ((td.state & CMPI_nullValue) == 0)) { td.value.chars = (char *) addClString(hdr, ar->data[i].value.chars); + td.type = CMPI_string; } - if (ar->type == CMPI_string && (td.state & CMPI_nullValue) == 0) { - td.value.chars = - (char *) addClString(hdr, ar->data[i].value.string->hdl); - td.type = CMPI_chars; + else if (ar->type == CMPI_string && ((td.state & CMPI_nullValue) == 0)) { + td.value.chars = (char *) addClString(hdr, ar->data[i].value.string->hdl); + td.type = CMPI_string; } - else + else { td.value = ar->data[i].value; + td.type =ar->type&~CMPI_ARRAY; + } dp[i] = td; } -// buf->index[buf->iUsed++]=buf->bUsed; + buf->bUsed += m; _SFCB_RETURN(buf->iUsed); @@ -392,7 +372,7 @@ else buf = (ClStrBuf *) (((char *) hdr) + abs(hdr->strBufOffset)); - sz = sizeof(*buf) + buf->bUsed + (buf->iUsed * sizeof(*buf->index)); + sz = sizeof(*buf) + buf->bUsed + (buf->iUsed * sizeof(*buf->sIndex)); DEB(printf("--- sizeStringBuf: %lu-%p\n", sz, (void *) sz)); _SFCB_RETURN(sz); @@ -407,13 +387,12 @@ if (hdr->arrayBufOffset == 0) _SFCB_RETURN(0); - if MALLOCED - (hdr->arrayBufOffset) buf = (ClArrayBuf *) hdr->arrayBufOffset; - else - buf = (ClArrayBuf *) (((char *) hdr) + abs(hdr->arrayBufOffset)); + if MALLOCED(hdr->arrayBufOffset) buf = (ClArrayBuf *) hdr->arrayBufOffset; + else buf = (ClArrayBuf *) (((char *) hdr) + abs(hdr->arrayBufOffset)); sz = sizeof(*buf) + (buf->bUsed * sizeof(CMPIData)) + - (buf->iUsed * sizeof(*buf->index)); + (buf->iUsed * sizeof(*buf->aIndex)); + DEB(printf("--- sizeArrayBuf: %lu-%p\n", sz, (void *) sz)); _SFCB_RETURN(sz); @@ -427,19 +406,17 @@ long i, l, u; ClStrBuf *fb; - if MALLOCED - (hdr->strBufOffset) fb = (ClStrBuf *) hdr->strBufOffset; - else - fb = (ClStrBuf *) (((char *) hdr) + abs(hdr->strBufOffset)); + if MALLOCED(hdr->strBufOffset) fb = (ClStrBuf *) hdr->strBufOffset; + else fb = (ClStrBuf *) (((char *) hdr) + abs(hdr->strBufOffset)); ts = (char *) malloc(fb->bUsed); fs = &fb->buf[0]; for (u = i = 0; i < fb->iUsed; i++) { if (i != id - 1) { - char *f = fs + fb->index[i]; + char *f = fs + fb->sIndex[i]; l = strlen(f) + 1; - fb->index[i] = u; + fb->sIndex[i] = u; memcpy(ts + u, f, l); u += l; } @@ -453,7 +430,7 @@ else fb = (ClStrBuf *) (((char *) hdr) + abs(hdr->strBufOffset)); fb->iUsed--; - fb->index[id - 1] = fb->index[i-1]; + fb->sIndex[id - 1] = fb->sIndex[i-1]; _SFCB_EXIT(); } @@ -466,19 +443,17 @@ long i, l, u; ClArrayBuf *fb; - if MALLOCED - (hdr->arrayBufOffset) fb = (ClArrayBuf *) hdr->arrayBufOffset; - else - fb = (ClArrayBuf *) (((char *) hdr) + abs(hdr->arrayBufOffset)); + if MALLOCED (hdr->arrayBufOffset) fb = (ClArrayBuf *) hdr->arrayBufOffset; + else fb = (ClArrayBuf *) (((char *) hdr) + abs(hdr->arrayBufOffset)); ts = (CMPIData *) malloc(fb->bUsed * sizeof(CMPIData)); fs = &fb->buf[0]; for (u = i = 0; i < fb->iUsed; i++) { if (i != id - 1) { - CMPIData *f = fs + fb->index[i]; + CMPIData *f = fs + fb->aIndex[i]; l = (f->value.sint32 + 1) * sizeof(CMPIData); - fb->index[i] = u; + fb->aIndex[i] = u; memcpy(ts + u, f, l); u += f->value.sint32 + 1; } @@ -488,13 +463,11 @@ free(ts); i = addClArray(hdr, d); - if MALLOCED - (hdr->arrayBufOffset) fb = (ClArrayBuf *) hdr->arrayBufOffset; - else - fb = (ClArrayBuf *) (((char *) hdr) + abs(hdr->arrayBufOffset)); + if MALLOCED(hdr->arrayBufOffset) fb = (ClArrayBuf *) hdr->arrayBufOffset; + else fb = (ClArrayBuf *) (((char *) hdr) + abs(hdr->arrayBufOffset)); fb->iUsed--; - fb->index[id - 1] = i; + fb->aIndex[id - 1] = i; _SFCB_EXIT(); } @@ -506,26 +479,25 @@ ClStrBuf *fb, *tb; long l, il; - if (fh->strBufOffset == 0) - _SFCB_RETURN(ofs); + + if (fh->strBufOffset == 0) _SFCB_RETURN(ofs); tb = (ClStrBuf *) (((char *) th) + ofs); - if MALLOCED (fh->strBufOffset) - fb = (ClStrBuf *) fh->strBufOffset; + if MALLOCED (fh->strBufOffset) fb = (ClStrBuf *) fh->strBufOffset; else fb = (ClStrBuf *) (((char *) fh) + abs(fh->strBufOffset)); l = sizeof(*fb) + fb->bUsed; - il = fb->iUsed * sizeof(*fb->index); + il = fb->iUsed * sizeof(*fb->sIndex); memcpy(tb, fb, l); tb->bMax = tb->bUsed; th->strBufOffset = -ofs; ofs += l; - memcpy(((char *) th) + ofs, fb->index, il); + memcpy(((char *) th) + ofs, fb->sIndex, il); tb->iMax = tb->iUsed; tb->iOffset = -ofs; - tb->index = (long *) (((char *) th) + ofs); + tb->sIndex = (long *) (((char *) th) + ofs); _SFCB_RETURN(l + il); } @@ -537,31 +509,30 @@ ClArrayBuf *fb, *tb; long l, il; - if (fh->arrayBufOffset == 0) - _SFCB_RETURN(ofs); + if (fh->arrayBufOffset == 0) _SFCB_RETURN(ofs); tb = (ClArrayBuf *) (((char *) th) + ofs); - if MALLOCED - (fh->arrayBufOffset) fb = (ClArrayBuf *) fh->arrayBufOffset; - else - fb = (ClArrayBuf *) (((char *) fh) + abs(fh->arrayBufOffset)); - + if MALLOCED(fh->arrayBufOffset) fb = (ClArrayBuf *) fh->arrayBufOffset; + else fb = (ClArrayBuf *) (((char *) fh) + abs(fh->arrayBufOffset)); + l = sizeof(*fb) + (fb->bUsed * sizeof(CMPIData)); - fb->bMax = fb->bUsed; - il = fb->iUsed * sizeof(*fb->index); - fb->iMax = fb->iUsed; - + il = fb->iUsed * sizeof(*fb->aIndex); + memcpy(tb, fb, l); + tb->bMax = tb->bUsed; th->arrayBufOffset = -ofs; ofs += l; - - memcpy(((char *) th) + ofs, fb->index, il); + + memcpy(((char *) th) + ofs, fb->aIndex, il); + tb->iMax = tb->iUsed; tb->iOffset = -ofs; - tb->index = (long *) (((char *) th) + ofs); + tb->aIndex = (long *) (((char *) th) + ofs); _SFCB_RETURN(l + il); } + + //string concatenation static char *cat2string(stringControl * sc, const char *str) @@ -696,6 +667,9 @@ d.type = CMPI_chars; d.value.chars = (char *) addClString(hdr, (char *) d.value.string->hdl); } + else if ((d.type & CMPI_ARRAY) && (d.state & CMPI_nullValue) == 0) { + d.value.chars = (char *) addClArray(hdr, d); + } q.data = d; return q; @@ -813,6 +787,10 @@ data->value.string = native_new_CMPIString(str, NULL); data->type = CMPI_string; } + else if (data->type & CMPI_ARRAY) { + data->value.dataPtr.ptr = (void *) ClObjectGetClArray(&cls->hdr, + (ClArray *) & data->value.array); + } if (name) *name = strdup(ClObjectGetClString(&cls->hdr, &(q + id)->id)); return 0; } @@ -1343,24 +1321,18 @@ static void ClObjectRelocateStringBuffer(ClObjectHdr * hdr, ClStrBuf * buf) { - if (buf == NULL) - return; - if MALLOCED - (hdr->strBufOffset) buf = (ClStrBuf *) hdr->strBufOffset; - else - buf = (ClStrBuf *) ((char *) hdr + abs(hdr->strBufOffset)); - buf->index = (long *) ((char *) hdr + abs(buf->iOffset)); + if (buf == NULL) return; + if MALLOCED(hdr->strBufOffset) buf = (ClStrBuf *) hdr->strBufOffset; + else buf = (ClStrBuf *) ((char *) hdr + abs(hdr->strBufOffset)); + buf->sIndex = (long *) ((char *) hdr + abs(buf->iOffset)); } static void ClObjectRelocateArrayBuffer(ClObjectHdr * hdr, ClArrayBuf * buf) { - if (buf == NULL) - return; - if MALLOCED - (hdr->arrayBufOffset) buf = (ClArrayBuf *) hdr->arrayBufOffset; - else - buf = (ClArrayBuf *) ((char *) hdr + abs(hdr->arrayBufOffset)); - buf->index = (long *) ((char *) hdr + abs(buf->iOffset)); + if (buf == NULL) return; + if MALLOCED(hdr->arrayBufOffset) buf = (ClArrayBuf *) hdr->arrayBufOffset; + else buf = (ClArrayBuf *) ((char *) hdr + abs(hdr->arrayBufOffset)); + buf->aIndex = (long *) ((char *) hdr + abs(buf->iOffset)); } @@ -1374,9 +1346,8 @@ static ClClass *newClassH(ClObjectHdr * hdr, const char *cn, const char *pa) { ClClass *cls = (ClClass *) malloc(sizeof(ClClass)); - if (hdr == NULL) - hdr = &cls->hdr; - + if (hdr == NULL) hdr = &cls->hdr; + memset(cls, 0, sizeof(ClClass)); hdr->type = HDR_Class; if (cn) cls->name.id = addClString(hdr, cn); @@ -1446,6 +1417,9 @@ ofs += copyStringBuf(ofs, sz, &nc->hdr, hdr); ofs += copyArrayBuf(ofs, sz, &nc->hdr, hdr); + + //printArrayBuf(&nc->hdr); + nc->hdr.size = sz; return nc; @@ -1458,9 +1432,10 @@ void ClClassRelocateClass(ClClass * cls) { + _SFCB_ENTER(TRACE_OBJECTIMPL, "ClClassRelocateClass"); ClObjectRelocateStringBuffer(&cls->hdr, (ClStrBuf *) cls->hdr.strBufOffset); - ClObjectRelocateArrayBuffer(&cls->hdr, - (ClArrayBuf *) cls->hdr.arrayBufOffset); + ClObjectRelocateArrayBuffer(&cls->hdr, (ClArrayBuf *) cls->hdr.arrayBufOffset); + _SFCB_EXIT(); } void ClClassFreeClass(ClClass * cls) @@ -1586,6 +1561,7 @@ { ClProperty *p; ClQualifier *q; + p = (ClProperty *) ClObjectGetClSection(&cls->hdr, &cls->properties); if (id < 0 || id > cls->properties.used) return 1; p = p + id; @@ -1728,24 +1704,9 @@ void ClInstanceRelocateInstance(ClInstance * inst) { -// ClObjectRelocateStringBuffer(&inst->hdr,(ClStrBuf*)inst->hdr.strBufOffset); -// ClObjectRelocateArrayBuffer(&inst->hdr,(ClArrayBuf*)inst->hdr.arrayBufOffset); - _SFCB_ENTER(TRACE_OBJECTIMPL, "ClArgsRelocateArgs"); - if (inst->hdr.strBufOffset) { - ClStrBuf *buf; - if MALLOCED (inst->hdr.strBufOffset) - buf = (ClStrBuf *) inst->hdr.strBufOffset; - else buf = (ClStrBuf *) ((char *) inst + abs(inst->hdr.strBufOffset)); - buf->index = (long *) ((char *) inst + abs(buf->iOffset)); - } - - if (inst->hdr.arrayBufOffset) { - ClArrayBuf *buf; - if MALLOCED (inst->hdr.arrayBufOffset) - buf = (ClArrayBuf *) inst->hdr.arrayBufOffset; - else buf = (ClArrayBuf *) ((char *) inst + abs(inst->hdr.arrayBufOffset)); - buf->index = (long *) ((char *) inst + abs(buf->iOffset)); - } + _SFCB_ENTER(TRACE_OBJECTIMPL, "ClInstanceRelocateInstance"); + ClObjectRelocateStringBuffer(&inst->hdr,(ClStrBuf*)inst->hdr.strBufOffset); + ClObjectRelocateArrayBuffer(&inst->hdr,(ClArrayBuf*)inst->hdr.arrayBufOffset); _SFCB_EXIT(); } @@ -1931,8 +1892,10 @@ void ClObjectPathRelocateObjectPath(ClObjectPath * op) { + _SFCB_ENTER(TRACE_OBJECTIMPL, "ClObjectPathRelocateObjectPath"); ClObjectRelocateStringBuffer(&op->hdr, (ClStrBuf *) op->hdr.strBufOffset); ClObjectRelocateArrayBuffer(&op->hdr, (ClArrayBuf *) op->hdr.arrayBufOffset); + _SFCB_EXIT(); } void ClObjectPathFree(ClObjectPath * op) @@ -2109,25 +2072,9 @@ void ClArgsRelocateArgs(ClArgs * arg) { _SFCB_ENTER(TRACE_OBJECTIMPL, "ClArgsRelocateArgs"); - if (arg->hdr.strBufOffset) { - ClStrBuf *buf; - if MALLOCED - (arg->hdr.strBufOffset) - buf = (ClStrBuf *) arg->hdr.strBufOffset; - else - buf = (ClStrBuf *) ((char *) arg + abs(arg->hdr.strBufOffset)); - buf->index = (long *) ((char *) arg + abs(buf->iOffset)); - } - - if (arg->hdr.arrayBufOffset) { - ClArrayBuf *buf;; - if MALLOCED - (arg->hdr.arrayBufOffset) - buf = (ClArrayBuf *) arg->hdr.arrayBufOffset; - else - buf = (ClArrayBuf *) ((char *) arg + abs(arg->hdr.arrayBufOffset)); - buf->index = (long *) ((char *) arg + abs(buf->iOffset)); - } + + ClObjectRelocateStringBuffer(&arg->hdr,(ClStrBuf*)arg->hdr.strBufOffset); + ClObjectRelocateArrayBuffer(&arg->hdr,(ClArrayBuf*)arg->hdr.arrayBufOffset); _SFCB_EXIT(); } @@ -2185,6 +2132,17 @@ _SFCB_RETURN(addObjectPropertyH(&arg->hdr, prps, id, d)); } +void dumpClass(char *msg, CMPIConstClass *cls) +{ + ClClass *cl=(ClClass*)cls->hdl; + char *buf=(char*)cl; + printf("classDump: %s\n",msg); + printf("strBuf: %p arrayBuf %p\n",buf+abs(cl->hdr.strBufOffset),buf+abs(cl->hdr.arrayBufOffset)); + dump("strBuf",buf+abs(cl->hdr.strBufOffset),sizeof(ClStrBuf)); + dump("arrayBuf",buf+abs(cl->hdr.arrayBufOffset),sizeof(ClArrayBuf)); + dump(msg, buf, cl->hdr.size); +} + /* char *ClArgToString(ClArg * cls) { @@ -2207,6 +2165,7 @@ return sc.str; } */ +//#define MAIN_TEST #ifdef MAIN_TEST extern CMPIArray *NewCMPIArray(CMPICount size, CMPIType type, CMPIStatus * rc); Index: array.c =================================================================== RCS file: /cvsroot/sblim/sfcb/array.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- array.c 9 Mar 2005 12:25:09 -0000 1.1.1.1 +++ array.c 13 Jun 2005 23:37:31 -0000 1.2 @@ -140,13 +140,17 @@ return result; } - +/* static CMPIStatus __aft_setElementAt(CMPIArray * array, CMPICount index, CMPIValue * val, CMPIType type) { struct native_array *a = (struct native_array *) array; + if ( a->dynamic && index==a->size ) { + native_array_increase_size(array, 1); + } + if (index < a->size) { CMPIValue v; @@ -182,6 +186,49 @@ CMReturn(CMPI_RC_ERR_FAILED); } +*/ +static CMPIStatus setElementAt ( CMPIArray * array, CMPICount index, CMPIValue * val, + CMPIType type, int opt ) +{ + struct native_array * a = (struct native_array *) array; + + if ( a->dynamic && index==a->size ) { + native_array_increase_size(array, 1); + } + + if ( index < a->size ) { + CMPIValue v; + + if ( type == CMPI_chars && a->type == CMPI_string ) { + v.string = native_new_CMPIString ( (char *) val, NULL ); + type = CMPI_string; + val = &v; + } + + if ( opt || type == a->type ) { + CMPIStatus rc = {CMPI_RC_OK, NULL}; + a->data[index].state = 0; + if (opt) a->data[index].value = *val; + else a->data[index].value = ( a->mem_state == TOOL_MM_ADD )? *val: + native_clone_CMPIValue ( type, val, &rc ); + return rc; + } + + if ( type == CMPI_null ) { + if ( ! ( a->data[index].state & CMPI_nullValue ) ) { + __make_NULL ( a, index, index, a->mem_state == TOOL_MM_NO_ADD ); + } + CMReturn ( CMPI_RC_OK ); + } + } + CMReturn ( CMPI_RC_ERR_FAILED ); +} + +static CMPIStatus __aft_setElementAt ( CMPIArray * array, CMPICount index, CMPIValue * val, + CMPIType type ) +{ + return setElementAt(array,index,val,type,0); +} CMPIStatus arraySetElementNotTrackedAt(CMPIArray * array, CMPICount index, @@ -193,29 +240,22 @@ CMPIValue v; if (type == CMPI_chars && a->type == CMPI_string) { - v.string = native_new_CMPIString((char *) val, NULL); type = CMPI_string; val = &v; } if (type == a->type) { - CMPIStatus rc = { CMPI_RC_OK, NULL }; - a->data[index].state = 0; a->data[index].value =*val; - return rc; } if (type == CMPI_null) { - if (!(a->data[index].state & CMPI_nullValue)) { - __make_NULL(a, index, index, a->mem_state == TOOL_MM_NO_ADD); } - CMReturn(CMPI_RC_OK); } } @@ -271,11 +311,21 @@ array->array = a; array->mem_state = mm_add; - type &= ~CMPI_ARRAY; - array->type = (type == CMPI_chars) ? CMPI_string : type; - array->max = array->size = size; + type &= ~CMPI_ARRAY; + array->type = ( type == CMPI_chars )? CMPI_string: type; + array->size = size; + + if (array->size==0) { + array->max=8; + array->dynamic=1; + } + else { + array->max=array->size; + array->dynamic=0; + } + array->data = (struct native_array_item *) - tool_mm_alloc(mm_add, size * sizeof(struct native_array_item)); + tool_mm_alloc ( mm_add, array->max * sizeof ( struct native_array_item ) ); __make_NULL(array, 0, size - 1, 0); @@ -310,20 +360,31 @@ void *array = __new_empty_array(TOOL_MM_NO_ADD, av->value.sint32, av->type, rc); int i, m; -//asm("int $3"); + for (i = 0, m = (int) av->value.sint32; i < m; i++) - if (av->type == CMPI_chars) { - char *chars = av[i + 1].value.chars; - chars = (char *) ClObjectGetClString(hdr, (ClString *) & chars); - __aft_setElementAt((CMPIArray *) array, i, (CMPIValue *) chars, - av[i + 1].type); + if (av[i + 1].type == CMPI_string) { + char *chars = (char *) ClObjectGetClString(hdr, (ClString *) & av[i + 1].value.chars); + __aft_setElementAt((CMPIArray *) array, i, (CMPIValue *) chars, CMPI_chars); } - else - __aft_setElementAt((CMPIArray *) array, i, &av[i + 1].value, - av[i + 1].type); + else __aft_setElementAt((CMPIArray *) array, i, &av[i + 1].value, + av[i + 1].type); + return (CMPIArray *) array; } +CMPIStatus simpleArrayAdd(CMPIArray * array, CMPIValue * val, CMPIType type) +{ + struct native_array * a = (struct native_array *) array; + if (a->dynamic) { + if (a->size==0) { + a->type=type; + if (a->type==CMPI_chars) a->type=CMPI_string; + } + return setElementAt(array,a->size,val,type,1); + } + CMReturn ( CMPI_RC_ERR_FAILED ); +} + /****************************************************************************/ Index: constClass.c =================================================================== RCS file: /cvsroot/sblim/sfcb/constClass.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- constClass.c 13 Jun 2005 10:59:21 -0000 1.5 +++ constClass.c 13 Jun 2005 23:37:31 -0000 1.6 @@ -48,7 +48,7 @@ extern unsigned long ClSizeClass(ClClass * cls); extern ClClass *ClClassRebuildClass(ClClass * cls, void *area); extern void ClClassRelocateClass(ClClass * cls); -extern CMPIArray *native_make_CMPIArray(CMPIData * av, CMPIStatus * rc); +extern CMPIArray *native_make_CMPIArray(CMPIData * av, CMPIStatus * rc, ClObjectHdr * hdr); extern CMPIObjectPath *getObjectPath(char *path, char **msg); unsigned long getConstClassSerializedSize(CMPIConstClass * cl); @@ -63,14 +63,7 @@ static void relocate(CMPIConstClass * cc) { - ClClass *cls = (ClClass *) cc->hdl; - ClStrBuf *buf; - if MALLOCED - (cls->hdr.strBufOffset) - buf = (ClStrBuf *) cls->hdr.strBufOffset; - else - buf = (ClStrBuf *) ((char *) cls + abs(cls->hdr.strBufOffset)); - buf->index = (long *) ((char *) cls + abs(buf->iOffset)); + ClClassRelocateClass((ClClass *) cc->hdl); } static const char *getCharClassName(CMPIConstClass * cc) @@ -144,7 +137,7 @@ } if (rv.type & CMPI_ARRAY) { rv.value.array = - native_make_CMPIArray((CMPIData *) & rv.value.array, NULL); + native_make_CMPIArray((CMPIData *) & rv.value.array, NULL, &cls->hdr); } if (name) { *name = native_new_CMPIString(n, NULL); @@ -162,27 +155,23 @@ char *n; CMPIData rv = { 0, CMPI_notFound, {0} }; if (ClClassGetQualifierAt(cls, i, &rv, name ? &n : NULL)) { - if (rc) - CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + if (rc) CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); return rv; } if (rv.type == CMPI_chars) { - rv.value.string = - native_new_CMPIString(ClObjectGetClString - (&cls->hdr, (ClString *) & rv.value.chars), - NULL); + rv.value.string = native_new_CMPIString(ClObjectGetClString + (&cls->hdr, (ClString *) & rv.value.chars), NULL); rv.type = CMPI_string; } if (rv.type & CMPI_ARRAY) { - rv.value.array = - native_make_CMPIArray((CMPIData *) & rv.value.array, NULL); + rv.value.array = native_make_CMPIArray((CMPIData *) & rv.value.array, + NULL, &cls->hdr); } if (name) { *name = native_new_CMPIString(n, NULL); free(n); } - if (rc) - CMSetStatus(rc, CMPI_RC_OK); + if (rc) CMSetStatus(rc, CMPI_RC_OK); return rv; } @@ -192,28 +181,25 @@ ClClass *cls = (ClClass *) cc->hdl; char *n; CMPIData rv = { 0, CMPI_notFound, {0} }; + if (ClClassGetPropQualifierAt(cls, p, i, &rv, name ? &n : NULL)) { - if (rc) - CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + if (rc) CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); return rv; } if (rv.type == CMPI_chars) { - rv.value.string = - native_new_CMPIString(ClObjectGetClString - (&cls->hdr, (ClString *) & rv.value.chars), - NULL); + rv.value.string = native_new_CMPIString(ClObjectGetClString + (&cls->hdr, (ClString *) & rv.value.chars), NULL); rv.type = CMPI_string; } if (rv.type & CMPI_ARRAY) { - rv.value.array = - native_make_CMPIArray((CMPIData *) & rv.value.array, NULL); + rv.value.array = native_make_CMPIArray((CMPIData *) rv.value.dataPtr.ptr, + NULL, &cls->hdr); } if (name) { *name = native_new_CMPIString(n, NULL); free(n); } - if (rc) - CMSetStatus(rc, CMPI_RC_OK); + if (rc) CMSetStatus(rc, CMPI_RC_OK); return rv; } Index: objectpath.c =================================================================== RCS file: /cvsroot/sblim/sfcb/objectpath.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- objectpath.c 17 May 2005 13:04:21 -0000 1.5 +++ objectpath.c 13 Jun 2005 23:37:31 -0000 1.6 @@ -31,7 +31,7 @@ #include "native.h" #include "msgqueue.h" -extern CMPIArray *native_make_CMPIArray(CMPIData * av, CMPIStatus * rc); +extern CMPIArray *native_make_CMPIArray(CMPIData * av, CMPIStatus * rc,ClObjectHdr * hdr); extern CMPIObjectPath *interal_new_CMPIObjectPath(int mode, const char *, const char *, CMPIStatus *); extern CMPIBroker *Broker; @@ -161,7 +161,7 @@ } else if (rv.type & CMPI_ARRAY) { // should nor occcur rv.value.array = - native_make_CMPIArray((CMPIData *) & rv.value.array, NULL); + native_make_CMPIArray((CMPIData *) & rv.value.array, NULL,&cop->hdr); } if (rc) |