- Removed slit 5 from amorset.c

- poldizug now sends all codes all the time
- polterwrite writes the filename again
- sanswave has been modifed to support the new second generation velocity
  selector
- sinqhttprot has been mdified to copy data to nodes, this for the second
  generation HM object
- tasscan suppressed some output
This commit is contained in:
koennecke
2009-05-15 13:24:02 +00:00
parent 5d30c7b5b9
commit caf59ef8eb
12 changed files with 225 additions and 87 deletions

View File

@ -7,6 +7,11 @@
* copyright: see file COPYRIGHT
*
* Mark Koennecke, June 2008
*
* Expanded to handle post:url:data style and node:path:data syntax
* in preparation for a full second generation HM object.
*
* Mark Koennecke, May 2009
*/
#include <stdio.h>
#include <ascon.h>
@ -15,12 +20,14 @@
#include <sicsdata.h>
#include <HistMem.h>
#include "uselect.h"
#include "sicshipadaba.h"
/*---------------------------------------------------------------------*/
typedef struct {
ghttp_request *request;
char *userName;
char *password;
pSICSData binData;
pHdb node;
} HttpProt, *pHttpProt;
/*---------------------------------------------------------------------*/
static int configRequest(Ascon * a)
@ -28,6 +35,11 @@ static int configRequest(Ascon * a)
pHttpProt pHttp = (pHttpProt) a->private;
pDynString request;
char *uri = NULL;
char *data, *pPtr, *path;
pHttp->node = NULL;
ghttp_clean(pHttp->request);
ghttp_set_header(pHttp->request, "connection", "keep-alive");
request = CreateDynString(64, 64);
if (request == NULL) {
@ -37,12 +49,29 @@ static int configRequest(Ascon * a)
DynStringConcat(request, "http://");
DynStringConcat(request, a->hostport);
DynStringConcatChar(request, '/');
DynStringConcat(request, GetCharArray(a->wrBuffer));
data = GetCharArray(a->wrBuffer);
if(strstr(data,"node:") == data){
path = strchr(data,':')+1;
uri = strchr(path,':');
*uri = '\0';
uri++;
pHttp->node = FindHdbNode(NULL,path,pServ->dummyCon);
DynStringConcat(request,uri);
ghttp_set_type(pHttp->request, ghttp_type_get);
} else if(strstr(data,"post:") == data){
uri = strchr(data,':') + 1;
pPtr = strchr(uri,':');
*pPtr = '\0';
ghttp_set_type(pHttp->request, ghttp_type_post);
DynStringConcat(request,uri);
pPtr++;
ghttp_set_body(pHttp->request,pPtr, strlen(pPtr));
} else {
ghttp_set_type(pHttp->request, ghttp_type_get);
DynStringConcat(request, GetCharArray(a->wrBuffer));
}
uri = GetCharArray(request);
ghttp_clean(pHttp->request);
ghttp_set_type(pHttp->request, ghttp_type_get);
ghttp_set_header(pHttp->request, "connection", "keep-alive");
if (ghttp_set_uri(pHttp->request, uri) < 0) {
AsconError(a, "Bad URL", 0);
return 0;
@ -82,14 +111,31 @@ static void handleReply(Ascon * a)
}
} else {
hmData = (HistInt *) pPtr;
clearSICSData(pHttp->binData);
len = len / sizeof(HistInt);
dataPtr = getSICSDataPointer(pHttp->binData, 0, len);
for (i = 0; i < len; i++) {
dataPtr[i] = htonl(hmData[i]);
if(pHttp->node == NULL){
clearSICSData(pHttp->binData);
dataPtr = getSICSDataPointer(pHttp->binData, 0, len);
for (i = 0; i < len; i++) {
dataPtr[i] = htonl(hmData[i]);
}
assignSICSType(pHttp->binData, 0, len, INTTYPE);
DynStringCopy(a->rdBuffer, "SICSDATA");
} else {
if(pHttp->node->value.arrayLength != len){
if(pHttp->node->value.v.intArray != NULL){
free(pHttp->node->value.v.intArray);
}
pHttp->node->value.v.intArray = malloc(len*sizeof(int));
if(pHttp->node->value.v.intArray == NULL){
AsconError(a,"Out of memory ",0);
return;
}
pHttp->node->value.arrayLength = len;
}
for(i = 0; i < len; i++){
pHttp->node->value.v.intArray[i] = htonl(hmData[i]);
}
}
assignSICSType(pHttp->binData, 0, len, INTTYPE);
DynStringCopy(a->rdBuffer, "SICSDATA");
}
}
}
@ -133,7 +179,7 @@ static int HttpHandler(Ascon * a)
procStatus = ghttp_get_status(pHttp->request);
if (procStatus.proc == ghttp_proc_response_hdrs
|| procStatus.proc == ghttp_proc_response) {
a->state = AsconWriteDone;
a->state = AsconWriteDone;
}
}
a->start = DoubleTime();
@ -159,12 +205,14 @@ static int HttpHandler(Ascon * a)
break;
case AsconReading:
socke = ghttp_get_socket(pHttp->request);
/*
FD_ZERO(&rmask);
FD_SET(socke, &rmask);
selStat = select(socke + 1, &rmask, NULL, NULL, &tmo);
selStat = uselect(socke + 1, &rmask, NULL, NULL, &tmo);
if (selStat == 0) {
return 1;
}
*/
status = ghttp_process(pHttp->request);
switch (status) {
case ghttp_not_done: