Open SCAP Library
sexp-handler.h
1 /*
2  * Copyright 2009 Red Hat Inc., Durham, North Carolina.
3  * All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors:
20  * "Daniel Kopecek" <dkopecek@redhat.com>
21  */
22 
23 #pragma once
24 #ifndef SEXP_HANDLER_H
25 #define SEXP_HANDLER_H
26 
27 #if defined(SEAP_THREAD_SAFE)
28 # include <pthread.h>
29 #endif
30 
31 #include <stdint.h>
32 #include <stddef.h>
33 #include "_sexp-datatype.h"
34 #include "../../../common/util.h"
35 
36 
37 typedef struct {
38  char *typestr;
39  uint16_t typelen;
40 
41  SEXP_dtype_op_t *op;
42  size_t op_cnt;
43 
45 
46 #include "generic/redblack.h"
47 DEFRBTREE(handlers, SEXP_handler_t handler);
48 
49 typedef struct {
50 #if defined(SEAP_THREAD_SAFE)
51  pthread_rwlock_t rwlock;
52 #endif
53  TREETYPE(handlers) tree;
54  uint8_t init;
56 
57 extern SEXP_handlertbl_t gSEXP_handlers;
58 
59 void SEXP_handlertbl_init (SEXP_handlertbl_t *htbl);
60 SEXP_handler_t *SEXP_gethandler (SEXP_handlertbl_t *htbl, const char *typestr, size_t typelen);
61 SEXP_handler_t *SEXP_reghandler (SEXP_handlertbl_t *htbl, SEXP_handler_t *handler);
62 int SEXP_delhandler (SEXP_handlertbl_t *htbl, const char *typestr, size_t typelen);
63 
64 #define SEXP_gethandler_g(s, l) SEXP_gethandler (&gSEXP_handlers, s, l)
65 #define SEXP_reghandler_g(h) SEXP_reghandler (&gSEXP_handlers, h)
66 #define SEXP_delhandler_g(s, l) SEXP_delhandler (&gSEXP_handlers, s, l)
67 
68 
69 #endif /* SEXP_HANDLER_H */
Definition: sexp-handler.h:49
Definition: sexp-handler.h:37