Some fixed to astriumnet

- Recognize the </hash> closing tag
- Convert , to . and vice versa
This commit is contained in:
2014-05-09 16:48:59 +02:00
parent 414bf2a148
commit bf3ad3915b

View File

@ -48,6 +48,28 @@ const char *AstriumWS(mxml_node_t* node, int where)
return NULL; return NULL;
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
void ptToKomma(char *txt)
{
int i;
for(i = 0; i < strlen(txt); i++){
if(txt[i] == '.'){
txt[i] = ',';
}
}
}
/*-----------------------------------------------------------------------*/
void kommaToPt(char *txt)
{
int i;
for(i = 0; i < strlen(txt); i++){
if(txt[i] == ','){
txt[i] = '.';
}
}
}
/*-----------------------------------------------------------------------*/
static void encodeXML(Ascon *a) static void encodeXML(Ascon *a)
{ {
char *pPtr, *equal, *close; char *pPtr, *equal, *close;
@ -71,6 +93,7 @@ static void encodeXML(Ascon *a)
if(equal != NULL){ if(equal != NULL){
*equal = '\0'; *equal = '\0';
equal++; equal++;
ptToKomma(equal);
mxmlElementSetAttr(param,token,equal); mxmlElementSetAttr(param,token,equal);
} else { } else {
mxmlElementSetAttr(param,token,NULL); mxmlElementSetAttr(param,token,NULL);
@ -122,6 +145,7 @@ static int decodeXML(Ascon *a)
DynStringConcat(a->rdBuffer,attr.name); DynStringConcat(a->rdBuffer,attr.name);
if(attr.value != NULL){ if(attr.value != NULL){
DynStringConcat(a->rdBuffer,"="); DynStringConcat(a->rdBuffer,"=");
kommaToPt(attr.value);
DynStringConcat(a->rdBuffer,attr.value); DynStringConcat(a->rdBuffer,attr.value);
} }
DynStringConcat(a->rdBuffer,":"); DynStringConcat(a->rdBuffer,":");
@ -169,13 +193,11 @@ static int doWaitHash(Ascon *a)
if(ret == 1 && (int)chr != 0x16) { if(ret == 1 && (int)chr != 0x16) {
DynStringConcatChar(a->rdBuffer,chr); DynStringConcatChar(a->rdBuffer,chr);
} }
if(GetDynStringLength(a->rdBuffer) >= 23) { if(strstr(GetCharArray(a->rdBuffer),"</Hash>") != NULL ) {
if(strstr(GetCharArray(a->rdBuffer), "<Hash>") == NULL){
AsconError(a,"Invalid response when trying to get hash",0);
return 0;
}
pPtr = GetCharArray(a->rdBuffer); pPtr = GetCharArray(a->rdBuffer);
pPtr += 6; pPtr += 6;
endptr = strchr(pPtr,(int)'<');
*endptr = '\0';
hash = strtoll(pPtr, &endptr,0); hash = strtoll(pPtr, &endptr,0);
hash = calculateToken(priv->password,hash); hash = calculateToken(priv->password,hash);
DynStringCopy(priv->buffer,"<AuthToken>"); DynStringCopy(priv->buffer,"<AuthToken>");