fixed missing short-form reply handling in lib/main-c.c

This commit is contained in:
hyung-hwan 2018-04-09 02:42:05 +00:00
parent 480fd879ee
commit f73bd64bc7
2 changed files with 35 additions and 1 deletions

View File

@ -233,6 +233,7 @@ static HCL_INLINE int is_token_integer (hcl_client_t* client, hcl_oow_t* value)
static HCL_INLINE hcl_ooch_t unescape (hcl_ooch_t c) static HCL_INLINE hcl_ooch_t unescape (hcl_ooch_t c)
{ {
#if 0
/* as of this writing, the server side only escapes \ and ". /* as of this writing, the server side only escapes \ and ".
* i don't know if n, r, f, t, v should be supported here */ * i don't know if n, r, f, t, v should be supported here */
switch (c) switch (c)
@ -244,6 +245,9 @@ static HCL_INLINE hcl_ooch_t unescape (hcl_ooch_t c)
case 'v': return '\v'; case 'v': return '\v';
default: return c; default: return c;
} }
#else
return c;
#endif
} }
static int handle_char (hcl_client_t* client, hcl_ooci_t c, hcl_oow_t nbytes) static int handle_char (hcl_client_t* client, hcl_ooci_t c, hcl_oow_t nbytes)

View File

@ -462,6 +462,8 @@ static int start_reply (hcl_client_t* client, hcl_client_reply_type_t type, cons
hcl_bch_t bcs[256]; hcl_bch_t bcs[256];
hcl_oow_t bcslen; hcl_oow_t bcslen;
/* NOTE: the error may get truncated without looping */
bcslen = HCL_COUNTOF(bcs);
hcl_conv_uchars_to_bchars_with_cmgr (dptr, &dlen, bcs, &bcslen, hcl_client_getcmgr(client)); hcl_conv_uchars_to_bchars_with_cmgr (dptr, &dlen, bcs, &bcslen, hcl_client_getcmgr(client));
printf ("\nERROR - [%.*s]\n", (int)bcslen, bcs); printf ("\nERROR - [%.*s]\n", (int)bcslen, bcs);
#else #else
@ -470,8 +472,36 @@ static int start_reply (hcl_client_t* client, hcl_client_reply_type_t type, cons
} }
else else
{ {
printf ("\nTOTAL DATA %lu bytes\n", (unsigned long int)client_xtn->data_length); #if defined(HCL_OOCH_IS_UCH)
hcl_oow_t drem = dlen;
while (drem > 0)
{
hcl_bch_t bcs[256];
hcl_oow_t ucslen, bcslen;
ucslen = drem;
bcslen = HCL_COUNTOF(bcs);
hcl_conv_uchars_to_bchars_with_cmgr(dptr, &ucslen, bcs, &bcslen, hcl_client_getcmgr(client));
client_xtn->data_length += bcslen;
if (write_all(0, bcs, bcslen) <= -1)
{
hcl_client_seterrbfmt (client, HCL_EIOERR, "unable to write data");
return -1;
}
drem -= ucslen;
dptr += ucslen;
}
#else
client_xtn->data_length += dlen;
if (write_all(0, dptr, dlen) <= -1)
{
hcl_client_seterrbfmt (client, HCL_EIOERR, "unable to write data");
return -1;
}
#endif
} }
printf ("\nTOTAL DATA %lu bytes\n", (unsigned long int)client_xtn->data_length);
/*fflush (stdout);*/ /*fflush (stdout);*/
client_xtn->reply_count++; client_xtn->reply_count++;