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_0_1_6:1.32
FSL_0_1_5:1.32
FSL_0_1_1:1.32
LMTP2NNTP_1_2a5:1.32
LMTP2NNTP_1_2a4:1.32
LMTP2NNTP_1_2a3:1.32
LMTP2NNTP_1_2a1:1.31
LMTP2NNTP_1_1_1:1.24
LMTP2NNTP_1_1_0:1.24
LMTP2NNTP_1_1b4:1.24
LMTP2NNTP_1_1b3:1.24
L2_CHANNEL_ONLY_REVAMPING_BEFORE:1.24
LMTP2NNTP_1_1b2:1.24
LMTP2NNTP_1_1b1:1.24
L2_0_1_0:1.16
L2NGATE:1.7.0.2
START_MICHAEL:1.5
L2_INITIAL:1.1.1.1
OSSP:1.1.1;
locks; strict;
comment @ * @;
1.37
date 2005.10.03.08.08.11; author rse; state Exp;
branches;
next 1.36;
1.36
date 2005.01.24.15.03.17; author rse; state Exp;
branches;
next 1.35;
1.35
date 2003.11.06.15.31.47; author thl; state Exp;
branches;
next 1.34;
1.34
date 2003.01.06.11.41.52; author rse; state Exp;
branches;
next 1.33;
1.33
date 2002.07.30.19.08.25; author rse; state Exp;
branches;
next 1.32;
1.32
date 2002.01.02.17.07.38; author rse; state Exp;
branches;
next 1.31;
1.31
date 2001.11.16.19.40.55; author ms; state Exp;
branches;
next 1.30;
1.30
date 2001.11.07.11.37.18; author rse; state Exp;
branches;
next 1.29;
1.29
date 2001.11.04.13.55.06; author rse; state Exp;
branches;
next 1.28;
1.28
date 2001.11.04.13.46.25; author rse; state Exp;
branches;
next 1.27;
1.27
date 2001.11.04.13.45.03; author rse; state Exp;
branches;
next 1.26;
1.26
date 2001.11.04.13.21.17; author rse; state Exp;
branches;
next 1.25;
1.25
date 2001.11.03.22.51.36; author rse; state Exp;
branches;
next 1.24;
1.24
date 2001.10.06.14.33.09; author rse; state Exp;
branches;
next 1.23;
1.23
date 2001.10.02.14.11.51; author thl; state Exp;
branches;
next 1.22;
1.22
date 2001.09.25.15.22.21; author ms; state Exp;
branches;
next 1.21;
1.21
date 2001.09.24.15.36.23; author rse; state Exp;
branches;
next 1.20;
1.20
date 2001.09.24.14.37.36; author ms; state Exp;
branches;
next 1.19;
1.19
date 2001.09.21.17.30.58; author ms; state Exp;
branches;
next 1.18;
1.18
date 2001.09.14.10.12.48; author rse; state Exp;
branches;
next 1.17;
1.17
date 2001.09.13.19.18.34; author rse; state Exp;
branches;
next 1.16;
1.16
date 2001.09.12.13.50.46; author rse; state Exp;
branches;
next 1.15;
1.15
date 2001.09.11.10.37.04; author thl; state Exp;
branches;
next 1.14;
1.14
date 2001.09.10.10.15.11; author thl; state Exp;
branches;
next 1.13;
1.13
date 2001.09.09.15.42.25; author rse; state Exp;
branches;
next 1.12;
1.12
date 2001.09.06.16.28.38; author rse; state Exp;
branches;
next 1.11;
1.11
date 2001.09.04.14.52.28; author rse; state Exp;
branches;
next 1.10;
1.10
date 2001.09.04.13.52.59; author rse; state Exp;
branches;
next 1.9;
1.9
date 2001.09.03.13.43.33; author rse; state Exp;
branches;
next 1.8;
1.8
date 2001.09.03.12.16.44; author rse; state Exp;
branches;
next 1.7;
1.7
date 2001.09.02.13.18.36; author ms; state Exp;
branches;
next 1.6;
1.6
date 2001.08.26.13.01.45; author ms; state Exp;
branches;
next 1.5;
1.5
date 2001.08.15.10.36.03; author rse; state Exp;
branches;
next 1.4;
1.4
date 2001.05.24.09.40.28; author rse; state Exp;
branches;
next 1.3;
1.3
date 2001.05.19.20.08.30; author rse; state Exp;
branches;
next 1.2;
1.2
date 2001.05.17.14.41.30; author simons; state Exp;
branches;
next 1.1;
1.1
date 2001.05.10.19.46.01; author rse; state Exp;
branches
1.1.1.1;
next ;
1.1.1.1
date 2001.05.10.19.46.01; author rse; state Exp;
branches;
next ;
desc
@@
1.37
log
@Adjust copyright messages for new year 2005.
@
text
@/*
** OSSP l2 - Flexible Logging
** Copyright (c) 2001-2005 Cable & Wireless
** Copyright (c) 2001-2005 The OSSP Project
** Copyright (c) 2001-2005 Ralf S. Engelschall
**
** This file is part of OSSP l2, a flexible logging library which
** can be found at http://www.ossp.org/pkg/lib/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_p.h: private C API
*/
#ifndef __L2_P_H__
#define __L2_P_H__
/* include standard headers */
#include
#include
#include
#include
/* include private headers */
#include "l2.h"
#include "l2_config.h"
#include "l2_ut_format.h"
#include "l2_ut_pcre.h"
#include "l2_ut_sa.h"
#ifdef HAVE_SYS_TIME_H /* must come after include l2_config.h */
#include
#endif
/* assertion and tracing support */
#ifndef DEBUG
#define NDEBUG
#endif
#include
#ifndef NDEBUG
#define TRACE(str) fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, str)
#else
#define TRACE(expr) ((void)0)
#endif
/* memory debugging support */
#if defined(HAVE_DMALLOC_H) && defined(WITH_DMALLOC)
#include "dmalloc.h"
#endif
/* handy cleanup macros */
#define cu(value) \
do { rv = value; \
goto cus; } while (0)
#define cu_on(expr,value) \
if (expr) \
cu(value)
/* some hard-coded sizes :-( */
#define L2_MAX_OUTSIZE 4098 /* this value is for compatiblity with previous versions of L2 */
#define L2_MAX_MSGSIZE L2_MAX_OUTSIZE - 2 /* leave room for CR/LF although OSSP/UNIX use LF only */
#define L2_MSG_BUFSIZE L2_MAX_OUTSIZE + 1 /* reserve space for convenient trailing NUL */
#define L2_MAX_FORMATTERS 128
#define L2_MAX_HANDLERS 128
#define L2_BROKEN_TIMER -1
#define L2_BUFFER_TIMER ITIMER_REAL /* for [s|g]etitimer() and alarm() */
/* internal channel state */
typedef enum {
L2_CHSTATE_CREATED,
L2_CHSTATE_OPENED
} l2_chstate_t;
/* channel object structure */
struct l2_channel_st {
l2_env_t *env;
l2_chstate_t state;
l2_channel_t *parent;
l2_channel_t *sibling;
l2_channel_t *child;
l2_context_t context;
l2_handler_t handler;
unsigned int levelmask;
unsigned int flushmask;
};
/* formatter entry structure */
typedef struct {
l2_formatter_t cb;
void *ctx;
char id;
} l2_formatter_entry_t;
/* environment object structure */
struct l2_env_st {
unsigned int levelmask;
unsigned int flushmask;
int interval;
l2_formatter_entry_t formatters[L2_MAX_FORMATTERS];
l2_handler_t *handlers[L2_MAX_HANDLERS];
char message[L2_MSG_BUFSIZE];
char szError[1024];
char szErrorInfo[512];
l2_result_t rvErrorInfo;
};
/* variable argument handling taking care on argument passing conventions */
#define _va_type_recv_char int
#define _va_type_cast_char char
#define _va_type_recv_short int
#define _va_type_cast_short short
#define _va_type_recv_int int
#define _va_type_cast_int int
#define _va_type_recv_long long
#define _va_type_cast_long long
#define _va_type_recv_float double
#define _va_type_cast_float double
#define _va_type_recv_double double
#define _va_type_cast_double double
#define _va_type_recv_charptr void *
#define _va_type_cast_charptr char *
#define _va_type_recv_voidptr void *
#define _va_type_cast_voidptr void *
#define va_get(ap,type) (_va_type_cast_##type)va_arg((ap),_va_type_recv_##type)
#endif /* __L2_P_H__ */
@
1.36
log
@Adjust copyright messages for new year 2005.
@
text
@d3 3
a5 3
** Copyright (c) 2001-2004 Cable & Wireless
** Copyright (c) 2001-2004 The OSSP Project
** Copyright (c) 2001-2004 Ralf S. Engelschall
@
1.35
log
@fix PR#23: l2 does not terminate a message when it contains a newline
@
text
@d3 3
a5 3
** Copyright (c) 2001-2003 Cable & Wireless Deutschland GmbH
** Copyright (c) 2001-2003 The OSSP Project (http://www.ossp.org/)
** Copyright (c) 2001-2003 Ralf S. Engelschall
@
1.34
log
@- remove trailing whitespaces
- adjust copyright messages
- consistently use "OSSP l2"
- consistently talk about "Flexible Logging"
- use standard OSSP ASCII-art
@
text
@d76 3
a78 1
#define L2_MAX_MSGSIZE 4096
d117 1
a117 1
char message[L2_MAX_MSGSIZE];
@
1.33
log
@polish for release
@
text
@d2 4
a5 2
** OSSP l2 - Logging Library
** Copyright (c) 2001-2002 Cable & Wireless Deutschland GmbH
d7 1
a7 1
** This file is part of OSSP L2, a flexible logging library which
d79 1
a79 1
#define L2_BROKEN_TIMER -1
@
1.32
log
@bump copyright year
@
text
@d2 1
a2 1
** L2 - OSSP Logging Library
d6 1
a6 1
** can be found at http://www.ossp.org/pkg/l2/.
@
1.31
log
@Mostly finished phase in of timer code to l2_env. Buffer needs work.
@
text
@d3 1
a3 1
** Copyright (c) 2001 Cable & Wireless Deutschland GmbH
@
1.30
log
@More preparations for forthcoming channel tree specification parser
(especially to allow the parser to determine the handler structure
from a handler name without introducing another and this way redundant
sub-API):
- add "char *name" to l2_handler_t in order to tag each
handler structure with the corresponding channel name
- add l2_env_handler() function to add handler to
l2_env_t objects. All l2_handler_xxxx are automatically
pre-configured there after l2_env_create().
- change l2_channel_create() to take a "const char *name"
(handler name) instead of the "l2_handler_t *h" (handler
pointer) to make the stuff consistent and more clear.
- adjust l2_test.c to reflect the changes.
@
text
@d45 4
d74 5
a78 3
#define L2_MAX_MSGSIZE 4096
#define L2_MAX_FORMATTERS 128
#define L2_MAX_HANDLERS 128
d110 1
@
1.29
log
@code cleanups
@
text
@d72 1
d105 1
@
1.28
log
@remove no longer used definition
@
text
@d35 1
d69 1
d73 1
d79 1
d92 1
d99 1
@
1.27
log
@Cleanup formatting stuff by making stand-alone.
@
text
@a68 1
#define L2_MAX_CHANNELS 128
@
1.26
log
@Channel-Only Revamping Step 2:
- moved code of l2_stream.c into (new) l2_env.c and l2_channel.c
- created new l2_env_t and l2_env_xxx()
- changed l2_xx_create() functions to also return l2_result_t
- moved error handling into l2_env_t
- replaced l2_channel_stack() with two new and more flexible
l2_channel_link() and l2_channel_unlink() functions
- rewritten test stuff in l2_test.c to use new structure
- added new l2_channel_env() function for retriving l2_env_t
Puhhh....
@
text
@d32 1
d37 8
d49 5
d55 1
a55 5
#include "l2.h"
#include "l2_config.h"
#include "l2_ut_pcre.h"
#include "l2_ut_sa.h"
d60 1
a67 12
#ifndef NDEBUG
#define TRACE(str)\
do {\
fprintf(stderr, "%s:%d: ", __FILE__, __LINE__);\
fprintf(stderr, str);\
fputc('\n', stderr);\
}\
while (0)
#else
#define TRACE(expr) ((void)0)
#endif
a122 41
struct l2_util_format_st {
/* the output buffer */
char *curpos; /* start of output buffer (first pos) */
char *endpos; /* end of output buffer (last pos) */
/* callback for flushing the output buffer */
int (*flush)(
struct l2_util_format_st *spec /* this l2_util_format_t specification */
);
/* callback for formatting unknown %-constructs */
void (*format)(
struct l2_util_format_st *spec, /* this l2_util_format_t specification */
char *prefix_char, /* output arg: prefix character */
char *pad_char, /* output arg: padding character */
char **s_buf, /* output arg: string buffer */
size_t *s_len, /* output arg: string len */
char *num_buf, /* input arg: temporary buffer */
int num_buf_size, /* input arg: temporary buffer len */
char *extinfo, /* input arg: extension information */
char fmt_char, /* input arg: current formatting character */
va_list *ap /* in/out arg: variable argument pointer */
);
/* arbitrary passed-through application data */
union {
int i;
long l;
double d;
void *vp;
} data[6];
};
typedef struct l2_util_format_st l2_util_format_t;
int l2_util_format (l2_util_format_t *vbuff, const char *fmt, va_list ap);
int l2_util_vsprintf (char *s, size_t n, const char *fmt, va_list ap);
char *l2_util_vasprintf (const char *fmt, va_list ap);
int l2_util_sprintf (char *s, size_t n, const char *fmt, ...);
char *l2_util_asprintf (const char *fmt, ...);
@
1.25
log
@Channel-Only Revamping Step 1:
allow multiple downstream channels in order to
approach the later tree-like channel-only structure.
@
text
@d79 1
a85 3
char szError[1024];
char szErrorInfo[512];
l2_result_t rvErrorInfo;
a90 6
l2_channel_t *ch;
unsigned int levelmask;
unsigned int flushmask;
} l2_channel_entry_t;
typedef struct {
d96 1
a96 1
struct l2_stream_st {
d99 1
d101 3
a103 2
l2_channel_entry_t channels[L2_MAX_CHANNELS];
l2_formatter_entry_t formatters[L2_MAX_FORMATTERS];
@
1.24
log
@Upgrade to latest OSSP SA snapshot.
This time by using SA_PREFIX to hide SA inside the l2_util_ namespace prefix.
@
text
@d80 3
a82 1
l2_channel_t *downstream;
d88 2
@
1.23
log
@- upgrade to latest SA
- use SA_PREFIX feature for library embedding without conflicts
@
text
@a43 1
#define SA_PREFIX l2_ut_
@
1.22
log
@Got rid of compile warnings and made minor TRACE modifications. Sorry, but
there is no way to use a va_list in a TRACE call. TRACE is a macro that
expands anywhere in source, so a va_list declaraction will sometimes violate
ANSI c decl specs.
@
text
@d44 1
@
1.21
log
@Provide convinient channel error handling functions.
@
text
@d59 5
a63 2
do\
fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, str);\
@
1.20
log
@Debugged TRACE.
@
text
@d80 3
@
1.19
log
@Added more homebrewed TRACE elements.
@
text
@d59 1
a59 1
do {\
a60 2
exit(1);\
}\
@
1.18
log
@provide cleanup macros
@
text
@d57 11
@
1.17
log
@use assert(3) instead of home-brewn stuff
@
text
@d50 7
@
1.16
log
@First cut for flush mask support.
@
text
@d36 5
@
1.15
log
@add Dmalloc support to L2
@
text
@d64 1
d75 1
@
1.14
log
@no need to double-declare the version stuff
@
text
@d36 2
d40 4
@
1.13
log
@make sure the version is available internally
@
text
@a38 4
#define _L2_VERSION_C_AS_HEADER_
#include "l2_version.c"
#undef _L2_VERSION_C_AS_HEADER_
@
1.12
log
@Add a copy of our SA library to L2 in order to simplify socket channel
and socket monitor program.
@
text
@d39 4
@
1.11
log
@Add (automatically) stripped down version of PCRE 3.5 for
use in the filter channel.
@
text
@d37 1
@
1.10
log
@Wohhooooo! Here comes the underlying message formatting support:
1. renamed l2_channel_setparam() to l2_util_setparam() because it
is just a utility function and is not tied to any channel.
2. moved l2_util_setparam() to its own l2_ut_param.c source file.
3. added l2_ut_format.c which contains a slightly adjusted version
of Str's str_format() stuff under the name l2_util_format().
4. use l2_util_format() in l2_stream.c instead of vsnprintf()
and this way finally support l2_formatter_t callbacks.
5. cleanup adjustments to the l2_stream_formatter() API.
Let's rock...
@
text
@d36 2
@
1.9
log
@- replace "int" with "l2_result_t" in L2 channel API
- use a 2^n for L2_LEVEL_XXX in order to be able to create mask
- remember loglevel for each channel
- rewrite test suite
@
text
@d60 1
a60 1
char *name;
d88 41
@
1.8
log
@revamped L2 stream API
@
text
@d52 8
a59 1
typedef struct l2_format_st {
d61 1
a61 3
void *context;
l2_formatter_t callback;
} l2_format_t;
d64 4
a67 4
unsigned int levelmask;
char message[L2_MAX_MSGSIZE];
l2_channel_t *channels[L2_MAX_CHANNELS];
l2_format_t formatters[L2_MAX_FORMATTERS];
@
1.7
log
@Revert to last version due to new design of l2_ch_socket_t.
@
text
@d62 1
a62 1
l2_format_t *formatters[L2_MAX_FORMATTERS];
@
1.6
log
@Added unsigned short type to PARAMETER macros for sockaddr_in struct.
@
text
@a38 1
#define L2_MAX_STRING 256
a69 2
#define _va_type_recv_ushort int
#define _va_type_cast_ushort short
@
1.5
log
@Fix more ossp.com references by replacing with the
correct domain name ossp.org.
@
text
@d39 1
d71 2
@
1.4
log
@o rename l2_error_t to l2_result_t
o introduce internal channel state for API robustness
@
text
@d6 1
a6 1
** can be found at http://www.ossp.com/pkg/l2/.
@
1.3
log
@the "int l2_channel_configure(l2_channel_t *ch, const char *fmt,
...);" beast was my idea, so it is fair to also provide the necessary
tool for implementing the underlying handler functions. Here it is,
l2_param_parse().
@
text
@d40 5
d46 2
a47 1
l2_channel_t *below;
@
1.2
log
@Added missing "_st" suffix to the declaration of the l2_stream structure.
@
text
@d59 19
@
1.1
log
@Initial revision
@
text
@d52 1
a52 1
struct l2_stream {
@
1.1.1.1
log
@L2 initial source tree
@
text
@@