From: Adrian S. <a3s...@us...> - 2005-07-27 18:41:17
|
Update of /cvsroot/sblim/sfcb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1283 Modified Files: fileRepository.c internalProvider.c Log Message: Fixed [ 1246249 ] sfcb fails to correctly locate repository Added getRepDir() routine. Index: internalProvider.c =================================================================== RCS file: /cvsroot/sblim/sfcb/internalProvider.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- internalProvider.c 26 Apr 2005 14:11:19 -0000 1.4 +++ internalProvider.c 27 Jul 2005 18:41:01 -0000 1.5 @@ -467,7 +467,7 @@ if (addBlob(nss,cns,key,blob,(int)len)) { CMPIStatus st = { CMPI_RC_ERR_FAILED, NULL }; - st.msg=native_new_CMPIString("Unable to write to repsoitory",NULL); + st.msg=native_new_CMPIString("Unable to write to repository",NULL); return st; } Index: fileRepository.c =================================================================== RCS file: /cvsroot/sblim/sfcb/fileRepository.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- fileRepository.c 26 Apr 2005 21:58:47 -0000 1.2 +++ fileRepository.c 27 Jul 2005 18:41:01 -0000 1.3 @@ -28,13 +28,38 @@ #include <string.h> #include <ctype.h> #include <unistd.h> + +#include <sys/types.h> +#include <dirent.h> #include <errno.h> + #include "fileRepository.h" #include "mlog.h" #define BASE "repository" +static char *repfn=NULL; + +char *getRepDir() +{ + int keyl; + char *dir; + + if (repfn) return repfn; + + if (getControlChars("registrationDir",&dir)) { + dir = "/var/lib/sfcb/registration"; + } + keyl=strlen(BASE)+strlen(dir); + repfn=(char*)malloc(keyl+64); + + strcpy(repfn,dir); + strcat(repfn,"/"); + strcat(repfn,BASE); + strcat(repfn,"/"); + return repfn; +} void freeBlobIndex(BlobIndex **bip, int all) { @@ -192,13 +217,19 @@ int getIndex(char *ns, char *cls, int elen, int mki, BlobIndex **bip) { BlobIndex *bi; - char *fn=alloca(elen); + char *fn; char *p; + char *dir; + int keyl; + dir=getRepDir(); + + keyl=strlen(dir)+elen; + fn=alloca(elen); + bi=NEW(BlobIndex); - strcpy(fn,BASE); - strcat(fn,"/"); + strcpy(fn,dir); p=fn+strlen(fn); strcat(fn,ns); strcat(fn,"/"); @@ -376,26 +407,31 @@ int existingNameSpace(char *ns) { - int keyl=strlen(ns)+strlen(BASE); - char *fn=alloca(keyl+64),*p; - FILE *ft=NULL; + int keyl; + char *fn,*p; + char *dir; + DIR *d; - strcpy(fn,BASE); - strcat(fn,"/"); + dir=getRepDir(); + + keyl=strlen(ns)+strlen(dir); + fn=alloca(keyl+64); + + strcpy(fn,dir); p=fn+strlen(fn); strcat(fn,ns); - strcat(fn,"/"); - strcat(fn,"__test__"); while (*p) { *p=tolower(*p); p++; } #ifdef __MAIN__ printf("--- testing %s \n",fn); #endif - ft=fopen(fn,"w"); - if (ft==NULL) return 0; - fclose(ft); - remove(fn); + + if ((d=opendir(fn))==NULL) { + perror("opendir"); + return 0; + } + closedir(d); return 1; } |