# HG changeset patch # User etisserant # Date 1206002839 -3600 # Node ID f63ce68a8239a0353942aac3458b440b1d288361 # Parent 64a8c24b61a5b67a0eec08d61b4a8f3c3fc89ee7 Added support for null terminated strings as VISIBLE_STRING. diff -r 64a8c24b61a5 -r f63ce68a8239 src/objacces.c --- a/src/objacces.c Wed Mar 19 16:08:12 2008 +0100 +++ b/src/objacces.c Thu Mar 20 09:47:19 2008 +0100 @@ -154,13 +154,25 @@ ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1]; } } - else /* It it is a visible string no endianisation to perform */ - memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData); -# else - memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData); + else /* no endianisation change */ # endif - - *pExpectedSize = szData; + if(*pDataType < visible_string) { + memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData); + *pExpectedSize = szData; + }else{ + /* TODO : CONFORM TO DS-301 : + * - stop using NULL terminated strings + * - store string size in td_subindex + * */ + /* Copy null terminated string to user, and return discovered size */ + UNS8 *ptr = (UNS8*)ptrTable->pSubindex[bSubindex].pObject; + UNS8 *ptr_start = ptr; + UNS8 *ptr_end = ptr + *pExpectedSize; /* *pExpectedSize IS < szData */ + while( *ptr && ptr < ptr_end){ + *((UNS8*)pDestData++) = *(ptr++); + } + *pExpectedSize = ptr - ptr_start; + } return OD_SUCCESSFUL; }