1 /*
2     httperf -- a tool for measuring web server performance
3     Copyright 2000-2007 Hewlett-Packard Company
4 
5     This file is part of httperf, a web server performance measurment
6     tool.
7 
8     This program is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License as
10     published by the Free Software Foundation; either version 2 of the
11     License, or (at your option) any later version.
12 
13     In addition, as a special exception, the copyright holders give
14     permission to link the code of this work with the OpenSSL project's
15     "OpenSSL" library (or with modified versions of it that use the same
16     license as the "OpenSSL" library), and distribute linked combinations
17     including the two.  You must obey the GNU General Public License in
18     all respects for all of the code used other than "OpenSSL".  If you
19     modify this file, you may extend this exception to your version of the
20     file, but you are not obligated to do so.  If you do not wish to do
21     so, delete this exception statement from your version.
22 
23     This program is distributed in the hope that it will be useful,
24     but WITHOUT ANY WARRANTY; without even the implied warranty of
25     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26     General Public License for more details.
27 
28     You should have received a copy of the GNU General Public License
29     along with this program; if not, write to the Free Software
30     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31     02110-1301, USA
32 */
33 #ifndef object_h
34 #define object_h
35 
36 #ifdef DEBUG
37 # define object_is_conn(o)	(((Object *) (o))->type == OBJ_CONN)
38 # define object_is_call(o)	(((Object *) (o))->type == OBJ_CALL)
39 # define object_is_sess(o)	(((Object *) (o))->type == OBJ_SESS)
40 #else
41 # define object_is_conn(o)	1
42 # define object_is_call(o)	1
43 # define object_is_sess(o)	1
44 #endif
45 
46 typedef enum Object_Type
47   {
48     OBJ_CONN,			/* connection object */
49     OBJ_CALL,			/* call object */
50     OBJ_SESS,			/* session object */
51     OBJ_NUM_TYPES
52   }
53 Object_Type;
54 
55 typedef struct Object
56   {
57     Object_Type type;
58     u_int ref_count;			/* # of references to this object */
59   }
60 Object;
61 
62 /* This may be called during httperf initialize to reserve SIZE
63    "private" bytes in objects of type TYPE.  The return value is the
64    offset of the private area.  */
65 
66 extern size_t object_expand (Object_Type type, size_t size);
67 
68 /* Create a new object of type TYPE.  */
69 extern Object *object_new (Object_Type type);
70 
71 /* Create a new reference for object OBJ.  */
72 #define object_inc_ref(o)	(++(o)->ref_count)
73 
74 /* Decrement the reference for object OBJ.  If the reference count
75    reaches zero, the object's destroy function is called.  */
76 extern void object_dec_ref (Object *obj);
77 
78 #endif /* object_h */
79