From bf3ad3915bb9977c7c84b913efcca3ed1dba6269 Mon Sep 17 00:00:00 2001 From: Mark Koennecke Date: Fri, 9 May 2014 16:48:59 +0200 Subject: [PATCH] Some fixed to astriumnet - Recognize the closing tag - Convert , to . and vice versa --- astriumnet.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/astriumnet.c b/astriumnet.c index 47ecc41..2b86d5f 100644 --- a/astriumnet.c +++ b/astriumnet.c @@ -48,6 +48,28 @@ const char *AstriumWS(mxml_node_t* node, int where) 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) { char *pPtr, *equal, *close; @@ -71,6 +93,7 @@ static void encodeXML(Ascon *a) if(equal != NULL){ *equal = '\0'; equal++; + ptToKomma(equal); mxmlElementSetAttr(param,token,equal); } else { mxmlElementSetAttr(param,token,NULL); @@ -122,6 +145,7 @@ static int decodeXML(Ascon *a) DynStringConcat(a->rdBuffer,attr.name); if(attr.value != NULL){ DynStringConcat(a->rdBuffer,"="); + kommaToPt(attr.value); DynStringConcat(a->rdBuffer,attr.value); } DynStringConcat(a->rdBuffer,":"); @@ -169,13 +193,11 @@ static int doWaitHash(Ascon *a) if(ret == 1 && (int)chr != 0x16) { DynStringConcatChar(a->rdBuffer,chr); } - if(GetDynStringLength(a->rdBuffer) >= 23) { - if(strstr(GetCharArray(a->rdBuffer), "") == NULL){ - AsconError(a,"Invalid response when trying to get hash",0); - return 0; - } + if(strstr(GetCharArray(a->rdBuffer),"") != NULL ) { pPtr = GetCharArray(a->rdBuffer); pPtr += 6; + endptr = strchr(pPtr,(int)'<'); + *endptr = '\0'; hash = strtoll(pPtr, &endptr,0); hash = calculateToken(priv->password,hash); DynStringCopy(priv->buffer,"");