1 /***** 2 * 3 * Copyright (C) 2003-2015 CS-SI. All Rights Reserved. 4 * Author: Yoann Vandoorselaere <yoann.v@prelude-ids.com> 5 * 6 * This file is part of the Prelude library. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2, or (at your option) 11 * any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License along 19 * with this program; if not, write to the Free Software Foundation, Inc., 20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 *****/ 23 24 #ifndef _IDMEF_VALUE_TYPE_H 25 #define _IDMEF_VALUE_TYPE_H 26 27 #include "idmef-time.h" 28 #include "idmef-data.h" 29 #include "prelude-string.h" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 typedef enum { 36 IDMEF_VALUE_TYPE_ERROR = -1, 37 IDMEF_VALUE_TYPE_UNKNOWN = 0, 38 IDMEF_VALUE_TYPE_INT8 = 1, 39 IDMEF_VALUE_TYPE_UINT8 = 2, 40 IDMEF_VALUE_TYPE_INT16 = 3, 41 IDMEF_VALUE_TYPE_UINT16 = 4, 42 IDMEF_VALUE_TYPE_INT32 = 5, 43 IDMEF_VALUE_TYPE_UINT32 = 6, 44 IDMEF_VALUE_TYPE_INT64 = 7, 45 IDMEF_VALUE_TYPE_UINT64 = 8, 46 IDMEF_VALUE_TYPE_FLOAT = 9, 47 IDMEF_VALUE_TYPE_DOUBLE = 10, 48 IDMEF_VALUE_TYPE_STRING = 11, 49 IDMEF_VALUE_TYPE_TIME = 12, 50 IDMEF_VALUE_TYPE_DATA = 13, 51 IDMEF_VALUE_TYPE_ENUM = 14, 52 IDMEF_VALUE_TYPE_LIST = 15, 53 IDMEF_VALUE_TYPE_CLASS = 16 54 } idmef_value_type_id_t; 55 56 57 typedef struct { 58 void *object; 59 int class_id; 60 } idmef_value_type_class_t; 61 62 typedef struct { 63 int value; 64 int class_id; 65 } idmef_value_type_enum_t; 66 67 68 typedef union { 69 int8_t int8_val; 70 uint8_t uint8_val; 71 int16_t int16_val; 72 uint16_t uint16_val; 73 int32_t int32_val; 74 uint32_t uint32_val; 75 int64_t int64_val; 76 uint64_t uint64_val; 77 float float_val; 78 double double_val; 79 prelude_string_t *string_val; 80 idmef_time_t *time_val; 81 idmef_data_t *data_val; 82 prelude_list_t list_val; 83 idmef_value_type_enum_t enum_val; 84 idmef_value_type_class_t class_val; 85 } idmef_value_type_data_t; 86 87 88 typedef struct { 89 idmef_value_type_id_t id; 90 idmef_value_type_data_t data; 91 } idmef_value_type_t; 92 93 94 #include "idmef-criteria.h" 95 96 int idmef_value_type_ref(const idmef_value_type_t *src); 97 98 int idmef_value_type_copy(const idmef_value_type_t *src, void *dst); 99 100 int idmef_value_type_read(idmef_value_type_t *dst, const char *buf); 101 102 int idmef_value_type_write(const idmef_value_type_t *src, prelude_string_t *out); 103 104 void idmef_value_type_destroy(idmef_value_type_t *type); 105 106 int idmef_value_type_clone(const idmef_value_type_t *src, idmef_value_type_t *dst); 107 108 int idmef_value_type_compare(const idmef_value_type_t *type1, const idmef_value_type_t *type2, 109 idmef_criterion_operator_t op); 110 111 int idmef_value_type_check_operator(idmef_value_type_id_t type, idmef_criterion_operator_t op); 112 113 int idmef_value_type_get_applicable_operators(idmef_value_type_id_t type, idmef_criterion_operator_t *result); 114 115 const char *idmef_value_type_to_string(idmef_value_type_id_t type); 116 117 #ifdef __cplusplus 118 } 119 #endif 120 121 #endif 122