~noskcaj/ubuntu/saucy/xinetd/2.3.15

« back to all changes in this revision

Viewing changes to libs/src/xlog/impl.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Seyrat
  • Date: 2004-04-18 13:33:57 UTC
  • Revision ID: james.westby@ubuntu.com-20040418133357-czeqeju37433xvdd
Tags: upstream-2.3.13
ImportĀ upstreamĀ versionĀ 2.3.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
 
3
 * All rights reserved.  The file named COPYRIGHT specifies the terms 
 
4
 * and conditions for redistribution.
 
5
 */
 
6
 
 
7
 
 
8
/*
 
9
 * $Id: impl.h,v 1.1.1.1 2003/02/19 17:29:27 bbraun Exp $
 
10
 */
 
11
 
 
12
#ifndef __XLOG_IMPL_H
 
13
#define __XLOG_IMPL_H
 
14
 
 
15
#include <stdlib.h>     /* For malloc() & free() prototypes */
 
16
#include <stdarg.h>
 
17
#define DEFINE_LINK_TYPE( type, name )          struct { type *next, *prev ; } name
 
18
 
 
19
 
 
20
#define NEXT( obj, field )              (obj)->field.next
 
21
#define PREV( obj, field )              (obj)->field.prev
 
22
 
 
23
#define INIT_LINKS( obj, field )                        \
 
24
        {                                               \
 
25
                NEXT( obj, field ) = obj ;              \
 
26
                PREV( obj, field ) = obj ;              \
 
27
        }
 
28
 
 
29
/*
 
30
 * Link new object after object using the specified field
 
31
 */
 
32
#define LINK( obj, new_obj, field )                     \
 
33
        {                                               \
 
34
                NEXT( new_obj, field ) = NEXT( obj, field ) ;   \
 
35
                PREV( new_obj, field ) = obj ;                  \
 
36
                NEXT( obj, field ) = new_obj ;                  \
 
37
                PREV( NEXT( obj, field ), field ) = new_obj ;   \
 
38
        }
 
39
 
 
40
#define UNLINK( obj, field )                            \
 
41
        {                                               \
 
42
                NEXT( PREV( obj, field ), field ) = NEXT( obj, field ) ;        \
 
43
                PREV( NEXT( obj, field ), field ) = PREV( obj, field ) ;        \
 
44
        }
 
45
 
 
46
 
 
47
/*
 
48
 * xlog linking:
 
49
 *      When xlog1 is linked to xlog2 (i.e. errors on xlog1 are reported to 
 
50
 *              xlog2) we use the xl_clients field on xlog2 and the xl_other_users 
 
51
 *              field on xlog1
 
52
 */
 
53
struct xlog
 
54
{
 
55
        xlog_e                  xl_type ;
 
56
        char                            *xl_id ;
 
57
        int                             xl_flags ;
 
58
        void                            (*xl_callback)() ;
 
59
        void                            *xl_callback_arg ;
 
60
        struct xlog     *xl_use ;       /* xlog we report errors to             */
 
61
        struct xlog     *xl_clients ;   /* linked list of xlogs that use */
 
62
                                                                                                        /* this xlog to report errors   */
 
63
        DEFINE_LINK_TYPE( struct xlog, xl_other_users ) ;
 
64
        struct xlog_ops
 
65
        {
 
66
                int     (*init)         ( struct xlog *, va_list ) ;
 
67
                void    (*fini)         ( struct xlog * ) ;
 
68
                int     (*write)        ( struct xlog *, const char *, int, int, va_list ) ;
 
69
                int     (*control)      ( struct xlog *, xlog_cmd_e, va_list ) ;
 
70
                int     (*parms)        ( xlog_e, va_list ) ;
 
71
        }       *xl_ops ;
 
72
        void    *xl_data ;
 
73
} ;
 
74
 
 
75
#define XL_INIT( xp, ap )               (*(xp)->xl_ops->init)( (xp), (ap) )
 
76
#define XL_FINI( xp )                   (*(xp)->xl_ops->fini)( xp )
 
77
#define XL_WRITE( xp, buf, size, flags, ap ) \
 
78
                (*(xp)->xl_ops->write)( (xp), (buf), (size), (flags), (ap ) )
 
79
#define XL_CONTROL( xp, cmd, ap ) \
 
80
                (*(xp)->xl_ops->control)( (xp), (cmd), (ap) )
 
81
 
 
82
typedef struct xlog xlog_s ;
 
83
 
 
84
typedef void (*voidfunc)() ;
 
85
typedef int bool_int ;
 
86
 
 
87
#define XP( p )                 ((struct xlog *)(p))
 
88
 
 
89
#define XLOG_NULL               XP( NULL )
 
90
 
 
91
#ifndef FALSE
 
92
#define FALSE           0
 
93
#define TRUE            1
 
94
#endif
 
95
 
 
96
#ifndef NULL
 
97
#define NULL            0
 
98
#endif
 
99
 
 
100
#define NEW( type )             (type *) malloc( sizeof( type ) )
 
101
 
 
102
int __xlog_add_errno(const char *, int) ;
 
103
char *__xlog_explain_errno(char *, unsigned *) ;
 
104
char *__xlog_new_string(const char *) ;
 
105
 
 
106
#endif
 
107