/usr/include/zorp/zobject.h is in libzorpll-6.0-10-dev 6.0.10.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | /***************************************************************************
*
* This file is covered by a dual licence. You can choose whether you
* want to use it according to the terms of the GNU GPL version 2, or
* under the terms of Zorp Professional Firewall System EULA located
* on the Zorp installation CD.
*
***************************************************************************/
#ifndef ZORP_ZOBJECT_H_INCLUDED
#define ZORP_ZOBJECT_H_INCLUDED
/* this might need to be moved to libzorpll */
#include <zorp/zorplib.h>
#include <zorp/misc.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _ZClass ZClass;
typedef struct _ZObject ZObject;
/**
* struct type to hold ZObject virtual methods.
**/
typedef struct _ZObjectFuncs
{
gint method_count;
void (*free_fn)(ZObject *self);
} ZObjectFuncs;
/**
* Base class.
*
* Not all classes in zorp-lib use it.
**/
struct _ZObject
{
ZRefCount ref_cnt;
ZClass *isa;
};
/**
* The metaclass of the object system.
**/
struct _ZClass
{
ZObject super;
gboolean funcs_resolved; /**< indicates whether method inheritance was already performed */
struct _ZClass *super_class;
const gchar *name;
gsize size;
ZObjectFuncs *funcs;
};
LIBZORPLL_EXTERN ZClass ZClass__class;
LIBZORPLL_EXTERN ZClass ZObject__class;
typedef ZClass ZInterface;
#define Z_OBJECT_HEADER { Z_REFCOUNT_INIT, NULL }
#define Z_CLASS_HEADER Z_OBJECT_HEADER, 0
#define Z_CLASS(class_) (&class_##__class)
#define Z_CLASS_DEF(klass_, super_class, class_methods) \
ZClass klass_##__class = \
{ \
Z_CLASS_HEADER, \
Z_CLASS(super_class), \
#klass_, \
sizeof(klass_), \
(ZObjectFuncs*) &class_methods, \
}
#define Z_CAST(inst, class_) ((class_ *) z_object_check_compatible((ZObject *) inst, Z_CLASS(class_)))
#define Z_FUNCS(inst, class_) ((class_##Funcs *) (z_object_check_compatible((ZObject *) inst, Z_CLASS(class_))->isa->funcs))
#define Z_FUNCS_CALL(inst, class_, func_name, ...) Z_FUNCS(inst, class_)->func_name(inst, ## __VA_ARGS__)
#define Z_SUPER(inst, class_) ((class_##Funcs *) (z_object_check_compatible((ZObject *) inst, Z_CLASS(class_))->isa->super_class->funcs))
#define Z_FUNCS_COUNT(class_) ((sizeof(class_##Funcs)-sizeof(gint))/sizeof(void (*)(void)))
#define Z_NEW(class_) (class_ *) z_object_new(Z_CLASS(class_))
#define Z_NEW_COMPAT(class_, compat) (compat *) z_object_new_compatible(class_, Z_CLASS(compat))
ZObject *z_object_new(ZClass *class_);
ZObject *z_object_new_compatible(ZClass *class_, ZClass *compat);
gboolean z_object_is_compatible(ZObject *self, ZClass *class_);
gboolean z_object_is_subclass(ZClass *class_, ZClass *subclass);
gboolean z_object_is_instance(ZObject *self, ZClass *class_);
#if ZORPLIB_ENABLE_DEBUG
/**
* Check if self is compatible with class, e.g.\ whether it's derived from class.
*
* @param[in] self object
* @param[in] class_ class
*
* Debug version. Asserts that the above assumption is true.
*
* @returns self
**/
static inline ZObject *
z_object_check_compatible(ZObject *self, ZClass *class_)
{
g_assert(!self || z_object_is_compatible(self, class_));
return self;
}
#else
/**
* Check if self is compatible with class, e.g.\ whether it's derived from class.
*
* @param[in] self object
* @param class_ class (unused)
*
* Non-debug version, doesn't really do anything but return self.
*
* @returns self
**/
static inline ZObject *
z_object_check_compatible(ZObject *self, ZClass *class_ G_GNUC_UNUSED)
{
return self;
}
#endif
/* function declaration for virtual functions */
void z_object_free_method(ZObject *s);
/**
* Increment the reference count of self and return a reference.
*
* @param[in,out] self ZObject instance
*
* @returns self
**/
static inline ZObject *
z_object_ref(ZObject *self)
{
if (self)
z_refcount_inc(&self->ref_cnt);
return self;
}
/**
* Decrement the reference count of self and free it if the reference count
* goes down to zero.
*
* @param[in] self ZObject instance
**/
static inline void
z_object_unref(ZObject *self)
{
if (self && z_refcount_dec(&self->ref_cnt))
{
Z_FUNCS(self, ZObject)->free_fn(self);
g_free(self);
}
}
#ifdef __cplusplus
}
#endif
#endif
|