- Fixed bugs in sinqhttp.c, most notatbly the unknown error on hm init

- Added first slit to amorset
- Added untested code for the POLDI strees machine
This commit is contained in:
koennecke
2006-11-24 15:52:51 +00:00
parent d01758de72
commit 8a1a808fe5
17 changed files with 591 additions and 88 deletions

View File

@@ -131,7 +131,7 @@ static int sinqHttpGet(pSinqHttp self, char *request){
if(httpStatus != ghttp_done){
ghttp_close(self->syncRequest);
sinqHttpGetPrepare(self,request);
ghttp_prepare(self->syncRequest);
ghttp_prepare(self->syncRequest);
httpStatus = ghttp_process(self->syncRequest);
}
if(httpStatus != ghttp_done){
@@ -151,6 +151,7 @@ static int SinqHttpConfigure(pHistDriver self, SConnection *pCon,
pSinqHttp pPriv = NULL;
int status, iInit;
float fVal;
int i;
char *confData = NULL;
ghttp_status httpStatus;
@@ -199,58 +200,69 @@ static int SinqHttpConfigure(pHistDriver self, SConnection *pCon,
actually do configure
*/
if(iInit == 1){
memset(confCommand,0,512*sizeof(char));
if(StringDictGet(pOpt,"hmconfigscript",confCommand,511) != 1){
SCWrite(pCon,
"ERROR: required parameter hmconfigscript not found!",
eError);
return 0;
}
status = Tcl_Eval(pSics->pTcl,confCommand);
if(status != TCL_OK){
snprintf(confCommand,511,
"ERROR: Tcl reported %s while evaluating hmconfigscript",
Tcl_GetStringResult(pSics->pTcl));
SCWrite(pCon,confCommand,eError);
return 0;
} else {
/*
uplod new configuration to HM
*/
ghttp_clean(pPriv->syncRequest);
snprintf(url,511,"%s%s",pPriv->hmAddress,configure);
status = ghttp_set_uri(pPriv->syncRequest,url);
if(status < 0){
SCWrite(pCon,"ERROR: invalid URI for HM request",eError);
for(i = 0; i < 2; i++){
memset(confCommand,0,512*sizeof(char));
if(StringDictGet(pOpt,"hmconfigscript",confCommand,511) != 1){
SCWrite(pCon,
"ERROR: required parameter hmconfigscript not found!",
eError);
return 0;
}
status = ghttp_set_type(pPriv->syncRequest,ghttp_type_post);
confData = (char *)Tcl_GetStringResult(pSics->pTcl);
/* puts(confData); */
status = ghttp_set_body(pPriv->syncRequest,confData,
strlen(confData));
ghttp_set_authinfo(pPriv->syncRequest, pPriv->userName,
pPriv->passWord);
ghttp_set_sync(pPriv->syncRequest,ghttp_sync);
status = ghttp_prepare(pPriv->syncRequest);
httpStatus = ghttp_process(pPriv->syncRequest);
confData = (char *)ghttp_get_body(pPriv->syncRequest);
if(httpStatus != ghttp_done){
confData = (char *)ghttp_get_error(pPriv->syncRequest);
snprintf(confCommand,511,"ERROR: http error %s occurred",
confData);
status = Tcl_Eval(pSics->pTcl,confCommand);
if(status != TCL_OK){
snprintf(confCommand,511,
"ERROR: Tcl reported %s while evaluating hmconfigscript",
Tcl_GetStringResult(pSics->pTcl));
SCWrite(pCon,confCommand,eError);
return 0;
} else if(confData != NULL){
if(strstr(confData,"ERROR") != NULL){
snprintf(confCommand,511,"%s",confData);
SCWrite(pCon,confCommand,eError);
} else {
/*
uplod new configuration to HM
*/
ghttp_clean(pPriv->syncRequest);
snprintf(url,511,"%s%s",pPriv->hmAddress,configure);
status = ghttp_set_uri(pPriv->syncRequest,url);
if(status < 0){
SCWrite(pCon,"ERROR: invalid URI for HM request",eError);
return 0;
}
if(strstr(confData,"Authentication Error") != NULL){
snprintf(confCommand,511,"%s",confData);
status = ghttp_set_type(pPriv->syncRequest,ghttp_type_post);
confData = (char *)Tcl_GetStringResult(pSics->pTcl);
/* puts(confData); */
status = ghttp_set_body(pPriv->syncRequest,confData,
strlen(confData));
ghttp_set_authinfo(pPriv->syncRequest, pPriv->userName,
pPriv->passWord);
ghttp_set_sync(pPriv->syncRequest,ghttp_sync);
status = ghttp_prepare(pPriv->syncRequest);
httpStatus = ghttp_process(pPriv->syncRequest);
confData = (char *)ghttp_get_body(pPriv->syncRequest);
if(httpStatus != ghttp_done){
/* we may need to reconnect.....
*/
if(i == 0){
ghttp_close(pPriv->syncRequest);
continue;
}
/*
* no we have a real error
*/
confData = (char *)ghttp_get_error(pPriv->syncRequest);
snprintf(confCommand,511,"ERROR: http error %s occurred",
confData);
SCWrite(pCon,confCommand,eError);
return 0;
} else if(confData != NULL){
if(strstr(confData,"ERROR") != NULL){
snprintf(confCommand,511,"%s",confData);
SCWrite(pCon,confCommand,eError);
return 0;
}
if(strstr(confData,"Authentication Error") != NULL){
snprintf(confCommand,511,"%s",confData);
SCWrite(pCon,confCommand,eError);
return 0;
}
}
}
}