work in progress to implement the builtin printf function
This commit is contained in:
parent
a5fe90597c
commit
7e6b16e153
@ -266,6 +266,11 @@ void hcl_fini (hcl_t* hcl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hcl_clear (hcl_t* hcl, int flags)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
}
|
||||||
|
|
||||||
int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
|
int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
|
||||||
{
|
{
|
||||||
switch (id)
|
switch (id)
|
||||||
|
19
lib/logfmt.c
19
lib/logfmt.c
@ -477,23 +477,34 @@ hcl_ooi_t hcl_logufmt (hcl_t* hcl, hcl_oow_t mask, const hcl_uch_t* fmt, ...)
|
|||||||
static int put_prch (hcl_t* hcl, hcl_oow_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
static int put_prch (hcl_t* hcl, hcl_oow_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||||
{
|
{
|
||||||
/* TODO: better error handling, buffering.
|
/* TODO: better error handling, buffering.
|
||||||
* buffer should be done by the printer callback? */
|
* should buffering be done by the printer callback? */
|
||||||
hcl_ooi_t n;
|
hcl_ooi_t n;
|
||||||
|
hcl_ooch_t str[256];
|
||||||
|
hcl_oow_t seglen, i;
|
||||||
|
|
||||||
hcl->c->outarg.ptr = &ch;
|
while (len > 0)
|
||||||
hcl->c->outarg.len = 1;
|
{
|
||||||
|
seglen = (len > HCL_COUNTOF(str))? len = HCL_COUNTOF(str): len;
|
||||||
|
for (i = 0; i < seglen; i++) str[i] = ch;
|
||||||
|
|
||||||
|
hcl->c->outarg.ptr = str;
|
||||||
|
hcl->c->outarg.len = seglen;
|
||||||
|
|
||||||
n = hcl->c->printer(hcl, HCL_IO_WRITE, &hcl->c->outarg);
|
n = hcl->c->printer(hcl, HCL_IO_WRITE, &hcl->c->outarg);
|
||||||
|
|
||||||
if (n <= -1) return -1;
|
if (n <= -1) return -1;
|
||||||
if (n == 0) return 0;
|
if (n == 0) return 0;
|
||||||
|
|
||||||
|
len -= seglen;
|
||||||
|
}
|
||||||
|
|
||||||
return 1; /* success */
|
return 1; /* success */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put_prcs (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
static int put_prcs (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||||
{
|
{
|
||||||
/* TODO: better error handling, buffering
|
/* TODO: better error handling, buffering
|
||||||
* buffer should be done by the printer callback? */
|
* should buffering be done by the printer callback? */
|
||||||
hcl_ooi_t n;
|
hcl_ooi_t n;
|
||||||
|
|
||||||
hcl->c->outarg.ptr = (hcl_ooch_t*)ptr;
|
hcl->c->outarg.ptr = (hcl_ooch_t*)ptr;
|
||||||
|
@ -137,10 +137,17 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
|
|||||||
}
|
}
|
||||||
PUT_OOCS (checkpoint, fmt - checkpoint - 1);
|
PUT_OOCS (checkpoint, fmt - checkpoint - 1);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
while ((ch = *fmt++) != '%' || stop)
|
while ((ch = *fmt++) != '%' || stop)
|
||||||
{
|
{
|
||||||
if (ch == '\0') goto done;
|
if (ch == '\0') goto done;
|
||||||
|
|
||||||
|
#if defined(HCL_OOCH_IS_UCH)
|
||||||
|
/* ooch is uch. fmtchar is bch */
|
||||||
|
/* TODO: convert bch to uch */
|
||||||
|
#else
|
||||||
|
/* ooch is bch. fmtchar is uch */
|
||||||
|
/* TODO: convert uch to bch */
|
||||||
|
#endif
|
||||||
PUT_OOCH (ch, 1);
|
PUT_OOCH (ch, 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
967
lib/prim.c
967
lib/prim.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user