| 1 | /* |
| 2 | * Copyright 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Authors: |
| 20 | * Daniel Kopecek <[email protected]> |
| 21 | */ |
| 22 | #ifndef PROBE_NCACHE_H |
| 23 | #define PROBE_NCACHE_Hcxx . . $ `src/OVAL/probes/probe/ncache.h:23:9`! |
| 24 | |
| 25 | #include <stddef.h> |
| 26 | #include <pthread.h> |
| 27 | #include <sexp.h>cxx . . $ `<file>/src/OVAL/probes/SEAP/public/sexp.h`/ |
| 28 | |
| 29 | #define PROBE_NCACHE_INIT_SIZEcxx . . $ `src/OVAL/probes/probe/ncache.h:29:9`! 24 |
| 30 | #define PROBE_NCACHE_ADD_SIZEcxx . . $ `src/OVAL/probes/probe/ncache.h:30:9`! 8 |
| 31 | |
| 32 | /** |
| 33 | * Element name cache structure. This structure contains an array |
| 34 | * of cached string S-exps representing the names of elements. |
| 35 | */ |
| 36 | typedef structcxx . . $ $anonymous_type_d167a6ed189dc5d9_0# { |
| 37 | pthread_rwlock_tcxx . . $ pthread_rwlock_t# lockcxx . . $ $anonymous_type_d167a6ed189dc5d9_0#lock.; /**< pthread read-write lock */ |
| 38 | SEXP_tcxx . . $ SEXP_t# **namecxx . . $ $anonymous_type_d167a6ed189dc5d9_0#name.; /**< array of S-exp refs */ |
| 39 | size_t realcxx . . $ $anonymous_type_d167a6ed189dc5d9_0#real.; /**< number of cached names */ |
| 40 | size_t sizecxx . . $ $anonymous_type_d167a6ed189dc5d9_0#size.; /**< pre-allocated size */ |
| 41 | } probe_ncache_tcxx . . $ probe_ncache_t#; |
| 42 | |
| 43 | /** |
| 44 | * Create new element name cache |
| 45 | * @return an empty element name cache |
| 46 | */ |
| 47 | probe_ncache_tcxx . . $ probe_ncache_t# *probe_ncache_newcxx . . $ probe_ncache_new(e2066d1f01a5893b). (void); |
| 48 | |
| 49 | /** |
| 50 | * Free memory used by the element name cache. |
| 51 | * The S-exp objects stored in the cache are |
| 52 | * also freed. However, if they are referenced |
| 53 | * somewhere else, the memory won't be freed, just |
| 54 | * the reference count will be decremented. |
| 55 | * @param cache the cache to be freed |
| 56 | */ |
| 57 | void probe_ncache_freecxx . . $ probe_ncache_free(c0ad2c06e7dc4d8f). (probe_ncache_tcxx . . $ probe_ncache_t# *cache); |
| 58 | |
| 59 | /** |
| 60 | * Mark memory used by the element name cache as |
| 61 | * free, effectively emptying the cache (but not |
| 62 | * altering the amount of memomory allocated for it). |
| 63 | * The S-exp objects stored in the cache are |
| 64 | * also freed. However, if they are referenced |
| 65 | * somewhere else, the memory won't be freed, just |
| 66 | * the reference count will be decremented. |
| 67 | * @param cache the cache to be emptied |
| 68 | */ |
| 69 | void probe_ncache_clearcxx . . $ probe_ncache_clear(c0ad2c06e7dc4d8f). (probe_ncache_tcxx . . $ probe_ncache_t# *cache); |
| 70 | |
| 71 | /** |
| 72 | * Add a name to the cache. This will create a new S-exp |
| 73 | * object and return a reference to it. Reference count |
| 74 | * of such object will be 2 because the cache hold it's |
| 75 | * own reference to the object. |
| 76 | * @param cache element name cache |
| 77 | * @param name name string |
| 78 | * @return S-exp reference to the name string |
| 79 | */ |
| 80 | SEXP_tcxx . . $ SEXP_t# *probe_ncache_addcxx . . $ probe_ncache_add(be2a40239769fba4). (probe_ncache_tcxx . . $ probe_ncache_t# *cache, const char *name); |
| 81 | |
| 82 | /** |
| 83 | * Get a reference to an already cached S-exp object. If the |
| 84 | * object is not found in the cache, it won't be created and |
| 85 | * NULL will be returned to the caller. |
| 86 | * @param cache element name cache |
| 87 | * @param name name string |
| 88 | * @return S-exp reference to the name string or NULL if not found |
| 89 | */ |
| 90 | SEXP_tcxx . . $ SEXP_t# *probe_ncache_getcxx . . $ probe_ncache_get(be2a40239769fba4). (probe_ncache_tcxx . . $ probe_ncache_t# *cache, const char *name); |
| 91 | |
| 92 | /** |
| 93 | * Get a reference to a cached S-exp object. If the object is |
| 94 | * not found in the cache, it will be created and the reference |
| 95 | * this newly created object will be returned to the caller. |
| 96 | * @param cache element name cache |
| 97 | * @param name name string |
| 98 | * @return S-exp reference to the name string |
| 99 | */ |
| 100 | SEXP_tcxx . . $ SEXP_t# *probe_ncache_refcxx . . $ probe_ncache_ref(be2a40239769fba4). (probe_ncache_tcxx . . $ probe_ncache_t# *cache, const char *name); |
| 101 | |
| 102 | #endif /* PROBE_NCACHE_H */ |