- Improvements to Hipadaba
- New chopper driver for MARS Juelich chopper system - New docbook based SANS manual SKIPPED: psi/amorcomp.c psi/amordrive.h psi/amorset.c psi/amorset.h psi/amorset.tex psi/amorset.w psi/julcho.c psi/libpsi.a psi/make_gen psi/psi.c
This commit is contained in:
35
hipadaba.c
35
hipadaba.c
@@ -268,6 +268,7 @@ hdbValue makeHdbValue(int datatype, int length){
|
||||
|
||||
switch(datatype){
|
||||
case HIPINTAR:
|
||||
case HIPINTVARAR:
|
||||
val.arrayLength = length;
|
||||
val.v.intArray = malloc(length*sizeof(long));
|
||||
if(val.v.intArray != NULL){
|
||||
@@ -275,6 +276,7 @@ hdbValue makeHdbValue(int datatype, int length){
|
||||
}
|
||||
break;
|
||||
case HIPFLOATAR:
|
||||
case HIPFLOATVARAR:
|
||||
val.arrayLength = length;
|
||||
val.v.floatArray = malloc(length*sizeof(double));
|
||||
if(val.v.floatArray != NULL){
|
||||
@@ -312,7 +314,7 @@ hdbValue MakeHdbText(char *initText){
|
||||
return result;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
hdbValue MakeHdbIntArrray(int length, long *data){
|
||||
hdbValue MakeHdbIntArray(int length, long *data){
|
||||
hdbValue result;
|
||||
|
||||
result.dataType = HIPINTAR;
|
||||
@@ -338,11 +340,13 @@ void ReleaseHdbValue(hdbValue *v){
|
||||
}
|
||||
break;
|
||||
case HIPINTAR:
|
||||
case HIPINTVARAR:
|
||||
if(v->v.intArray != NULL){
|
||||
free(v->v.intArray);
|
||||
}
|
||||
break;
|
||||
case HIPFLOATAR:
|
||||
case HIPFLOATVARAR:
|
||||
if(v->v.floatArray != NULL){
|
||||
free(v->v.floatArray);
|
||||
}
|
||||
@@ -382,6 +386,7 @@ int compareHdbValue(hdbValue v1, hdbValue v2){
|
||||
}
|
||||
break;
|
||||
case HIPINTAR:
|
||||
case HIPINTVARAR:
|
||||
if(v1.arrayLength != v2.arrayLength){
|
||||
return 0;
|
||||
}
|
||||
@@ -393,6 +398,7 @@ int compareHdbValue(hdbValue v1, hdbValue v2){
|
||||
return 1;
|
||||
break;
|
||||
case HIPFLOATAR:
|
||||
case HIPFLOATVARAR:
|
||||
if(v1.arrayLength != v2.arrayLength){
|
||||
return 0;
|
||||
}
|
||||
@@ -430,6 +436,7 @@ pHdb MakeHipadabaNode(char *name, int datatype, int length){
|
||||
pNew->value.dataType = datatype;
|
||||
switch(datatype){
|
||||
case HIPINTAR:
|
||||
case HIPINTVARAR:
|
||||
pNew->value.arrayLength = length;
|
||||
pNew->value.v.intArray = malloc(length*sizeof(long));
|
||||
if(pNew->value.v.intArray == NULL){
|
||||
@@ -438,6 +445,7 @@ pHdb MakeHipadabaNode(char *name, int datatype, int length){
|
||||
memset(pNew->value.v.intArray,0,length*sizeof(long));
|
||||
break;
|
||||
case HIPFLOATAR:
|
||||
case HIPFLOATVARAR:
|
||||
pNew->value.arrayLength = length;
|
||||
pNew->value.v.floatArray = malloc(length*sizeof(double));
|
||||
if(pNew->value.v.floatArray == NULL){
|
||||
@@ -498,13 +506,25 @@ int isHdbNodeValid(pHdb node){
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
pHdb GetHipadabaNode(pHdb root, char *path){
|
||||
pHdb GetHipadabaNode(pHdb root, char *puth){
|
||||
pHdb resultNode = NULL;
|
||||
char *separator = NULL;
|
||||
char *path = NULL, *pathData;
|
||||
|
||||
/*
|
||||
* I need to make a copy in order to get the path in writable memory.
|
||||
* Otherwise we SEGFAULT in hdbTrim when this function is called with
|
||||
* a string constant in puth
|
||||
*/
|
||||
pathData = strdup(puth);
|
||||
path = pathData;
|
||||
if(path == NULL){
|
||||
return NULL;
|
||||
}
|
||||
path = hdbTrim(path);
|
||||
|
||||
if(strcmp(path,"/") == 0 || strlen(path) == 0){
|
||||
free(pathData);
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -514,15 +534,20 @@ pHdb GetHipadabaNode(pHdb root, char *path){
|
||||
|
||||
separator = strchr(path,'/');
|
||||
if(separator == NULL){
|
||||
return locateChild(root,path);
|
||||
resultNode = locateChild(root,path);
|
||||
free(pathData);
|
||||
return resultNode;
|
||||
} else {
|
||||
*separator = '\0';
|
||||
resultNode = locateChild(root, path);
|
||||
if(resultNode == NULL){
|
||||
free(pathData);
|
||||
return NULL;
|
||||
} else {
|
||||
separator++;
|
||||
return GetHipadabaNode(resultNode,separator);
|
||||
resultNode = GetHipadabaNode(resultNode,separator);
|
||||
free(pathData);
|
||||
return resultNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -715,6 +740,7 @@ int copyHdbValue(hdbValue *source, hdbValue *target){
|
||||
target->v.text = strdup(source->v.text);
|
||||
break;
|
||||
case HIPINTAR:
|
||||
case HIPINTVARAR:
|
||||
if(target->arrayLength != source->arrayLength){
|
||||
if(target->v.intArray != NULL){
|
||||
free(target->v.intArray);
|
||||
@@ -731,6 +757,7 @@ int copyHdbValue(hdbValue *source, hdbValue *target){
|
||||
}
|
||||
break;
|
||||
case HIPFLOATAR:
|
||||
case HIPFLOATVARAR:
|
||||
if(target->arrayLength != source->arrayLength){
|
||||
if(target->v.floatArray != NULL){
|
||||
free(target->v.floatArray);
|
||||
|
||||
Reference in New Issue
Block a user