Open SCAP Library
|
00001 /* 00002 * Copyright 2009 Red Hat Inc., Durham, North Carolina. 00003 * All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 * Authors: 00020 * "Daniel Kopecek" <dkopecek@redhat.com> 00021 */ 00022 00023 #pragma once 00024 #ifndef _SEXP_DATATYPE 00025 #define _SEXP_DATATYPE 00026 00027 #include "public/sexp-datatype.h" 00028 #include "generic/rbt/rbt.h" 00029 #include "../../../common/util.h" 00030 00031 OSCAP_HIDDEN_START; 00032 00033 struct SEXP_datatype { 00034 uint16_t dt_flg; 00035 uint8_t _dt[]; 00036 }; 00037 00038 #define SEXP_DTFLG_LOCALDATA 0x01 /* whether a extended pointer should be used */ 00039 #define SEXP_DTFLG_HAVEDTOPS 0x02 /* whether there are defined some operations */ 00040 00041 struct SEXP_datatype_ops { 00042 uint16_t dt_opcnt; 00043 SEXP_datatypeOP_t *dt_op; 00044 }; 00045 00046 struct SEXP_datatypeTbl { 00047 rbt_t *tree; 00048 }; 00049 00050 /* 00051 * Datatype pointer 00052 */ 00053 typedef struct rbt_str_node SEXP_datatypePtr_t; 00054 00055 /* 00056 * Extended datatype pointer 00057 */ 00058 struct SEXP_datatype_extptr { 00059 struct rbt_str_node *n; /* datatype tree node */ 00060 void *l; /* local data related to an S-exp reference */ 00061 }; 00062 00063 typedef struct SEXP_datatype_extptr SEXP_datatypeExtptr_t; 00064 00065 00066 const char *SEXP_datatype_name(SEXP_datatypePtr_t *p); 00067 00068 void SEXP_datatype_once(void); 00069 void SEXP_datatypeGlobalTbl_init(void); 00070 void SEXP_datatypeGlobalTbl_free(void); 00071 00072 SEXP_datatypeTbl_t *SEXP_datatypeTbl_new (void); 00073 int SEXP_datatypeTbl_init(SEXP_datatypeTbl_t *t); 00074 void SEXP_datatypeTbl_free(SEXP_datatypeTbl_t *t); 00075 00076 SEXP_datatypePtr_t *SEXP_datatype_get(SEXP_datatypeTbl_t *t, const char *name); 00077 SEXP_datatypePtr_t *SEXP_datatype_add(SEXP_datatypeTbl_t *t, char *name, SEXP_datatype_t *d, void *l); 00078 int SEXP_datatype_del(SEXP_datatypeTbl_t *t, const char *name); 00079 00080 #define SEXP_OP_CONTINUE 0 /* continue with the default handler */ 00081 #define SEXP_OP_ABORT 1 /* abort with an error status */ 00082 #define SEXP_OP_RETURN 2 /* return success, don't execute default handler */ 00083 00084 #define SEXP_DATATYPEPTR_MASK (UINTPTR_MAX << 2) 00085 #define SEXP_DATATYPEPTR_ALIGN (4 > sizeof(void *) ? 4 : sizeof (void *)) 00086 00087 OSCAP_HIDDEN_END; 00088 00089 #endif /* _SEXP_DATATYPE */