Index: ossp-pkg/l2/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/l2/Makefile.in,v rcsdiff -q -kk '-r1.6' '-r1.7' -u '/v/ossp/cvs/ossp-pkg/l2/Makefile.in,v' 2>/dev/null --- Makefile.in 2001/05/19 20:08:30 1.6 +++ Makefile.in 2001/05/22 18:47:31 1.7 @@ -63,10 +63,8 @@ # list of library object files OBJS = \ - l2_log.lo \ l2_stream.lo \ l2_channel.lo \ - l2_param.lo \ l2_ch_fd.lo \ l2_ch_file.lo \ l2_ch_pipe.lo \ Index: ossp-pkg/l2/l2.h RCS File: /v/ossp/cvs/ossp-pkg/l2/Attic/l2.h,v rcsdiff -q -kk '-r1.3' '-r1.4' -u '/v/ossp/cvs/ossp-pkg/l2/Attic/l2.h,v' 2>/dev/null --- l2.h 2001/05/19 20:08:30 1.3 +++ l2.h 2001/05/22 18:47:31 1.4 @@ -151,17 +151,17 @@ extern l2_handler_t l2_handler_buffer; /* parameter operations */ -int l2_param_parse (l2_param_t p[], const char *fmt, va_list ap); /* channel operations */ l2_channel_t *l2_channel_create (l2_handler_t *h); -l2_channel_t *l2_channel_stack (l2_channel_t *ch1, l2_channel_t *ch2); int l2_channel_configure(l2_channel_t *ch, const char *fmt, ...); int l2_channel_open (l2_channel_t *ch); int l2_channel_write (l2_channel_t *ch, const char *buf, size_t bufsize); int l2_channel_flush (l2_channel_t *ch); int l2_channel_close (l2_channel_t *ch); int l2_channel_destroy (l2_channel_t *ch); +l2_channel_t *l2_channel_stack (l2_channel_t *ch1, l2_channel_t *ch2); +int l2_channel_setparams(l2_param_t p[], const char *fmt, va_list ap); /* stream operations */ l2_stream_t *l2_stream_create (void); Index: ossp-pkg/l2/l2_ch_file.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_ch_file.c,v rcsdiff -q -kk '-r1.4' '-r1.5' -u '/v/ossp/cvs/ossp-pkg/l2/l2_ch_file.c,v' 2>/dev/null --- l2_ch_file.c 2001/05/21 20:15:11 1.4 +++ l2_ch_file.c 2001/05/22 18:47:31 1.5 @@ -79,7 +79,7 @@ L2_PARAM_SET(pa[1], append, INT, &cfg->append); L2_PARAM_SET(pa[1], perm, LONG, &cfg->perm); L2_PARAM_END(pa[2]); - rv = l2_param_parse(pa, fmt, ap); + rv = l2_channel_setparams(pa, fmt, ap); return rv; } Index: ossp-pkg/l2/l2_channel.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_channel.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/l2/l2_channel.c,v' 2>/dev/null --- l2_channel.c 2001/05/10 19:46:01 1.1 +++ l2_channel.c 2001/05/22 18:47:31 1.2 @@ -134,3 +134,71 @@ return rv; } +int l2_channel_setparams(l2_param_t pa[], const char *fmt, va_list ap) +{ + const char *cpB, *cpE; + const char *cpC, *cpG; + int ok; + int i; + + cpE = fmt; + while (*cpE != '\0') { + /* determine begin of parameter name */ + cpB = cpE; + while (*cpB == ',') + cpB++; + + /* determine end of parameter name */ + cpE = cpB; + while (*cpE != ',' && *cpE != '\0') + cpE++; + + /* try to match with configured parameters */ + ok = FALSE; + for (i = 0; pa[i].name != NULL; i++) { + cpC = pa[i].name; + cpG = cpB; + while (*cpC != '\0' && cpG < cpE) { + if (*cpC != *cpG) + break; + cpC++; + cpG++; + } + if (*cpC == '\0' && cpG == cpE) { + /* parameter matched, so store value */ + switch (pa[i].type) { + case L2_TYPE_CHAR: + *(char *)(pa[i].store) = va_get(ap, char); + break; + case L2_TYPE_SHORT: + *(short *)(pa[i].store) = va_get(ap, short); + break; + case L2_TYPE_INT: + *(int *)(pa[i].store) = va_get(ap, int); + break; + case L2_TYPE_LONG: + *(long *)(pa[i].store) = va_get(ap, long); + break; + case L2_TYPE_FLOAT: + *(float *)(pa[i].store) = va_get(ap, float); + break; + case L2_TYPE_DOUBLE: + *(double *)(pa[i].store) = va_get(ap, double); + break; + case L2_TYPE_CHARPTR: + *(char **)(pa[i].store) = va_get(ap, charptr); + break; + case L2_TYPE_VOIDPTR: + *(void **)(pa[i].store) = va_get(ap, voidptr); + break; + } + ok = TRUE; + break; + } + } + if (!ok) + return L2_ERROR; + } + return L2_OK; +} + Index: ossp-pkg/l2/l2_log.c RCS File: /v/ossp/cvs/ossp-pkg/l2/Attic/l2_log.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/l2/Attic/l2_log.c,v' | diff -u - /dev/null -L'ossp-pkg/l2/l2_log.c' 2>/dev/null --- ossp-pkg/l2/l2_log.c +++ /dev/null 2024-04-27 01:55:00.000000000 +0200 @@ -1,50 +0,0 @@ -/* -** L2 - OSSP Logging Library -** Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) -** Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) -** -** This file is part of OSSP L2, a flexible logging library which -** can be found at http://www.ossp.com/pkg/l2/. -** -** Permission to use, copy, modify, and distribute this software for -** any purpose with or without fee is hereby granted, provided that -** the above copyright notice and this permission notice appear in all -** copies. -** -** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR -** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -** SUCH DAMAGE. -** -** l2.c: internal C implementation -** -*/ - -#include "l2.h" -#include "l2_p.h" - -void l2_stream_log(l2_stream_t *st, unsigned int log_level, const char* fmt, ...) - { - va_list ap; - va_start(ap, fmt); - l2_stream_vlog(st, log_level, fmt, ap); - va_end(ap); - } - -void l2_stream_vlog(l2_stream_t *st, unsigned int log_level, const char* fmt, va_list ap) - { - size_t i, len; - len = vsnprintf(st->message, L2_MAX_MSGSIZE, fmt, ap); - for (i = 0; i <= L2_MAX_CHANNELS && st->channels[i]; ++i) - st->channels[i]->handler.write(&st->channels[i]->context, - st->channels[i]->below, - st->message, len); - } Index: ossp-pkg/l2/l2_param.c RCS File: /v/ossp/cvs/ossp-pkg/l2/Attic/l2_param.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/l2/Attic/l2_param.c,v' | diff -u - /dev/null -L'ossp-pkg/l2/l2_param.c' 2>/dev/null --- ossp-pkg/l2/l2_param.c +++ /dev/null 2024-04-27 01:55:00.000000000 +0200 @@ -1,101 +0,0 @@ -/* -** L2 - OSSP Logging Library -** Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) -** Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) -** -** This file is part of OSSP L2, a flexible logging library which -** can be found at http://www.ossp.com/pkg/l2/. -** -** Permission to use, copy, modify, and distribute this software for -** any purpose with or without fee is hereby granted, provided that -** the above copyright notice and this permission notice appear in all -** copies. -** -** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR -** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -** SUCH DAMAGE. -** -** l2_param.c: parameter handling -** -*/ - -#include "l2.h" -#include "l2_p.h" - -int l2_param_parse(l2_param_t pa[], const char *fmt, va_list ap) -{ - const char *cpB, *cpE; - const char *cpC, *cpG; - int ok; - int i; - - cpE = fmt; - while (*cpE != '\0') { - /* determine begin of parameter name */ - cpB = cpE; - while (*cpB == ',') - cpB++; - - /* determine end of parameter name */ - cpE = cpB; - while (*cpE != ',' && *cpE != '\0') - cpE++; - - /* try to match with configured parameters */ - ok = FALSE; - for (i = 0; pa[i].name != NULL; i++) { - cpC = pa[i].name; - cpG = cpB; - while (*cpC != '\0' && cpG < cpE) { - if (*cpC != *cpG) - break; - cpC++; - cpG++; - } - if (*cpC == '\0' && cpG == cpE) { - /* parameter matched, so store value */ - switch (pa[i].type) { - case L2_TYPE_CHAR: - *(char *)(pa[i].store) = va_get(ap, char); - break; - case L2_TYPE_SHORT: - *(short *)(pa[i].store) = va_get(ap, short); - break; - case L2_TYPE_INT: - *(int *)(pa[i].store) = va_get(ap, int); - break; - case L2_TYPE_LONG: - *(long *)(pa[i].store) = va_get(ap, long); - break; - case L2_TYPE_FLOAT: - *(float *)(pa[i].store) = va_get(ap, float); - break; - case L2_TYPE_DOUBLE: - *(double *)(pa[i].store) = va_get(ap, double); - break; - case L2_TYPE_CHARPTR: - *(char **)(pa[i].store) = va_get(ap, charptr); - break; - case L2_TYPE_VOIDPTR: - *(void **)(pa[i].store) = va_get(ap, voidptr); - break; - } - ok = TRUE; - break; - } - } - if (!ok) - return L2_ERROR; - } - return L2_OK; -} - Index: ossp-pkg/l2/l2_stream.c RCS File: /v/ossp/cvs/ossp-pkg/l2/Attic/l2_stream.c,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/l2/Attic/l2_stream.c,v' 2>/dev/null --- l2_stream.c 2001/05/17 14:43:26 1.2 +++ l2_stream.c 2001/05/22 18:47:31 1.3 @@ -31,32 +31,67 @@ #include "l2.h" #include "l2_p.h" -l2_stream_t* l2_stream_create(void) - { +l2_stream_t *l2_stream_create(void) +{ l2_stream_t *st; - st = (l2_stream_t *)malloc(sizeof(l2_stream_t)); - if (!st) + + if ((st = (l2_stream_t *)malloc(sizeof(l2_stream_t))) == NULL) return NULL; memset(st, 0, sizeof(l2_stream_t)); return st; - } +} -void l2_stream_destroy(l2_stream_t* st) - { +l2_stream_t *l2_stream_channel(l2_stream_t *st, l2_channel_t *ch, unsigned int levelmask) +{ size_t i; - for (i = 0; i <= L2_MAX_CHANNELS && st->channels[i]; ++i) - l2_channel_destroy(st->channels[i]); - for (i = 0; i <= L2_MAX_FORMATTERS && st->formatters[i]; ++i) - free(st->formatters[i]); - } -l2_stream_t* l2_stream_channel(l2_stream_t *st, l2_channel_t *ch, unsigned int levelmask) - { - size_t i; - for (i = 0; i <= L2_MAX_CHANNELS && st->channels[i]; ++i) - ; + for (i = 0; i <= L2_MAX_CHANNELS && st->channels[i] != NULL; i++) + ; if (i == L2_MAX_CHANNELS) - return 0; /* Array is full. */ + return NULL; st->channels[i] = ch; return st; - } +} + +l2_stream_t *l2_stream_formatter(l2_stream_t *st, l2_formatter_t *cb, l2_context_t *ctx) +{ + return NULL; +} + +unsigned int l2_stream_levels(l2_stream_t *st, unsigned int levelmask) +{ + return 0; +} + +void l2_stream_log(l2_stream_t *st, unsigned int log_level, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + l2_stream_vlog(st, log_level, fmt, ap); + va_end(ap); + return; +} + +void l2_stream_vlog(l2_stream_t *st, unsigned int log_level, const char *fmt, va_list ap) +{ + size_t i, len; + + len = vsnprintf(st->message, L2_MAX_MSGSIZE, fmt, ap); + for (i = 0; i <= L2_MAX_CHANNELS && st->channels[i] != NULL; i++) + st->channels[i]->handler.write(&st->channels[i]->context, + st->channels[i]->below, + st->message, len); + return; +} + +void l2_stream_destroy(l2_stream_t *st) +{ + size_t i; + + for (i = 0; i <= L2_MAX_CHANNELS && st->channels[i] != NULL; i++) + l2_channel_destroy(st->channels[i]); + for (i = 0; i <= L2_MAX_FORMATTERS && st->formatters[i] != NULL; i++) + free(st->formatters[i]); + return; +} +