--- psiconv/trunk/lib/psiconv/parse_simple.c 2001/01/30 23:57:28 101 +++ psiconv/trunk/lib/psiconv/parse_simple.c 2001/03/04 22:10:45 110 @@ -305,6 +305,61 @@ return NULL; } +psiconv_string_t psiconv_read_short_string(const psiconv_buffer buf, + int lev, + psiconv_u32 off,int *length, int *status) +{ + int stringlen,i,len,localstatus; + psiconv_string_t result; + char *res_copy; + + psiconv_progress(lev+1,off,"Going to read a short string"); + + stringlen = psiconv_read_u8(buf,lev+2,off,&localstatus); + if (localstatus) + goto ERROR1; + psiconv_debug(lev+2,off,"Length: %i",stringlen); + len = 1; + + result = malloc(stringlen + 1); + if (!result) + goto ERROR1; + for (i = 0; (i < stringlen) && !localstatus; i++) + result[i] = psiconv_read_u8(buf,lev,off+i+len,&localstatus); + if (localstatus) + goto ERROR2; + result[stringlen] = 0; + len += stringlen; + + res_copy = psiconv_make_printable(result); + if (!res_copy) + goto ERROR2; + psiconv_debug(lev+2,off,"Contents: `%s'",res_copy); + free(res_copy); + + if (length) + *length = len; + + if (status) + *status = 0; + + psiconv_progress(lev+1,off+len-1,"End of short string (total length: %08x)", + len); + + return result; + + +ERROR2: + free(result); +ERROR1: + psiconv_warn(lev+1,off,"Reading of short string failed"); + if (status) + *status = localstatus; + if (length) + *length = 0; + return NULL; +} + psiconv_float_t psiconv_read_float(const psiconv_buffer buf, int lev, psiconv_u32 off, int *length, int *status) {