diff options
author | Miloslav Trmač <mitr@redhat.com> | 2012-06-21 20:43:20 +0200 |
---|---|---|
committer | Gergely Nagy <algernon@balabit.hu> | 2012-07-19 13:14:44 +0200 |
commit | 48c00e2a5edaaeebc94d8fa3193981cff2a39c44 (patch) | |
tree | 2f1fd779c3b42f545fb38d3242cd0f2e2fe5fa1c /lib | |
parent | 32e918922da9cecf4ebd9013fe64e57503ad44cc (diff) | |
download | libumberlog-48c00e2a5edaaeebc94d8fa3193981cff2a39c44.tar.gz libumberlog-48c00e2a5edaaeebc94d8fa3193981cff2a39c44.tar.xz libumberlog-48c00e2a5edaaeebc94d8fa3193981cff2a39c44.zip |
Handle more types in printf()-like specifiers
Recognize more length modifiers. Document that positional parameters
are not supported (it should be possible, I'm just lazy :)).
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/umberlog.c | 47 | ||||
-rw-r--r-- | lib/umberlog.rst | 3 |
2 files changed, 48 insertions, 2 deletions
diff --git a/lib/umberlog.c b/lib/umberlog.c index 9c497ea..011d48b 100644 --- a/lib/umberlog.c +++ b/lib/umberlog.c @@ -33,6 +33,8 @@ #include <unistd.h> #include <stdio.h> #include <dlfcn.h> +#include <stddef.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <syslog.h> @@ -204,7 +206,13 @@ _ul_va_spin (const char *fmt, va_list *pap) else (void)va_arg (*pap, long int); } - else + else if (fmt[i - 1] == 'j') + (void)va_arg (*pap, intmax_t); + else if (fmt[i - 1] == 'z') + (void)va_arg (*pap, ssize_t); + else if (fmt[i - 1] == 't') + (void)va_arg (*pap, ptrdiff_t); + else /* Also handles h, hh */ (void)va_arg (*pap, int); eof = 1; break; @@ -229,6 +237,10 @@ _ul_va_spin (const char *fmt, va_list *pap) (void)va_arg (*pap, int); eof = 1; break; + case 'C': + (void)va_arg (*pap, wint_t); + eof = 1; + break; case 's': if (fmt [i - 1] == 'l') (void)va_arg (*pap, wchar_t *); @@ -236,10 +248,43 @@ _ul_va_spin (const char *fmt, va_list *pap) (void)va_arg (*pap, char *); eof = 1; break; + case 'S': + (void)va_arg (*pap, wchar_t *); + eof = 1; + break; case 'p': (void)va_arg (*pap, void *); eof = 1; break; + case 'n': + if (fmt[i - 1] == 'l') + { + if (i - 2 > 0 && fmt[i - 2] == 'l') + (void)va_arg (*pap, long long *); + else + (void)va_arg (*pap, long int *); + } + else if (fmt[i - 1] == 'h') + { + if (i - 2 > 0 && fmt[i - 2] == 'h') + (void)va_arg (*pap, signed char *); + else + (void)va_arg (*pap, short int *); + } + else if (fmt[i - 1] == 'j') + (void)va_arg (*pap, intmax_t *); + else if (fmt[i - 1] == 'z') + (void)va_arg (*pap, ssize_t *); + else if (fmt[i - 1] == 't') + (void)va_arg (*pap, ptrdiff_t *); + else + (void)va_arg (*pap, int *); + eof = 1; + break; + case '*': + (void)va_arg (*pap, int); + i++; + break; /* eof stays set to 0 */ case '%': eof = 1; break; diff --git a/lib/umberlog.rst b/lib/umberlog.rst index d2cd354..704a5e3 100644 --- a/lib/umberlog.rst +++ b/lib/umberlog.rst @@ -57,7 +57,8 @@ the emitted message. After the *msg_format* format string, and any other parameters it refers to, there must be a NULL-terminated list of *key*, *value format*, *format parameters*. Each of these pairs, constructed from the *key* and the **printf(3)**-style *value format* -will be added to the generated message. +will be added to the generated message. Note that position specifiers +(e.g. **%2$**) are not currently supported. **ul_format()** and **ul_vformat()** do the same as the syslog variants above, except the formatted payload is not sent to syslog, |