Debian Codegraph @

src/OVAL/oval_probe_handler.c

raw symbols SCIP
1 /**
2 * @file oval_probe_handler.c
3 * @brief OVAL probe handler API implementation
4 * @author "Daniel Kopecek" <[email protected]>
5 *
6 * @addtogroup PROBEHANDLERS
7 * @{
8 */
9 /*
10 * Copyright 2010 Red Hat Inc., Durham, North Carolina.
11 * All Rights Reserved.
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 *
27 * Authors:
28 * "Daniel Kopecek" <[email protected]>
29 */
30
31 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
32 #include <config.h>cxx . . $ `<file>/build/config.h`/
33 #endif
34
35 #include <stdlib.h>
36 #include "common/bfind.h"cxx . . $ `<file>/src/common/bfind.h`/
37 #include "_oval_probe_handler.h"cxx . . $ `<file>/src/OVAL/_oval_probe_handler.h`/
38
39 oval_phtbl_tcxx . . $ oval_phtbl_t# *oval_phtbl_newcxx . . $ oval_phtbl_new(b0133460b0177f0a).(void)
40 {
41 oval_phtbl_tcxx . . $ oval_phtbl_t# *phtbl = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(oval_phtbl_tcxx . . $ oval_phtbl_t#));
42 phtbl->phcxx . . $ oval_phtbl#ph. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
43 phtbl->szcxx . . $ oval_phtbl#sz. = 0;
44
45 return(phtbl);
46 }
47
48 void oval_phtbl_freecxx . . $ oval_phtbl_free(39da376fa133fd00).(oval_phtbl_tcxx . . $ oval_phtbl_t# *phtbl)
49 {
50 register uint32_tcxx . . $ uint32_t# i;
51
52 for (i = 0; i < phtbl->szcxx . . $ oval_phtbl#sz.; ++i) {
53 if (phtbl->phcxx . . $ oval_phtbl#ph.[i]->funccxx . . $ oval_ph#func.)
54 phtbl->phcxx . . $ oval_phtbl#ph.[i]->funccxx . . $ oval_ph#func.(phtbl->phcxx . . $ oval_phtbl#ph.[i]->typecxx . . $ oval_ph#type., phtbl->phcxx . . $ oval_phtbl#ph.[i]->uptrcxx . . $ oval_ph#uptr., PROBE_HANDLER_ACT_FREEcxx . . $ `src/OVAL/_oval_probe_handler.h:45:9`!);
55 freecxx . . $ free(5d22bdacc48458e8).(phtbl->phcxx . . $ oval_phtbl#ph.[i]);
56 }
57
58 freecxx . . $ free(5d22bdacc48458e8).(phtbl->phcxx . . $ oval_phtbl#ph.);
59 freecxx . . $ free(5d22bdacc48458e8).(phtbl);
60 }
61
62 static int oval_handler_subtype_cmpcxx . . $ oval_handler_subtype_cmp(ce67ccb376e4e22).(oval_subtype_tcxx . . $ oval_subtype_t# *a, oval_ph_tcxx . . $ oval_ph_t# **b)
63 {
64 return(*a - (*b)->typecxx . . $ oval_ph#type.);
65 }
66
67 static int oval_phtbl_subtype_cmpcxx . . $ oval_phtbl_subtype_cmp(787ba6c19d886b80).(oval_ph_tcxx . . $ oval_ph_t# **a, oval_ph_tcxx . . $ oval_ph_t# **b)
68 {
69 return((*a)->typecxx . . $ oval_ph#type. - (*b)->typecxx . . $ oval_ph#type.);
70 }
71
72 oval_ph_tcxx . . $ oval_ph_t# *oval_probe_handler_getcxx . . $ oval_probe_handler_get(a2b39ae009cb9244).(oval_phtbl_tcxx . . $ oval_phtbl_t# *phtbl, oval_subtype_tcxx . . $ oval_subtype_t# type)
73 {
74 oval_ph_tcxx . . $ oval_ph_t# **ph = oscap_bfindcxx . . $ oscap_bfind(55e9dbee426f048c).((void *)phtbl->phcxx . . $ oval_phtbl#ph., phtbl->szcxx . . $ oval_phtbl#sz., sizeof(oval_ph_tcxx . . $ oval_ph_t# *), &type,
75 (int(*)(void *, void *))oval_handler_subtype_cmpcxx . . $ oval_handler_subtype_cmp(ce67ccb376e4e22).);
76 return (ph != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! ? *ph : NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
77 }
78
79 int oval_probe_handler_setcxx . . $ oval_probe_handler_set(f8ee9472e321c7fd).(oval_phtbl_tcxx . . $ oval_phtbl_t# *phtbl, oval_subtype_tcxx . . $ oval_subtype_t# type, oval_probe_handler_tcxx . . $ oval_probe_handler_t# *handler, void *uptr)
80 {
81 int ret = 0;
82 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! sort = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
83 oval_ph_tcxx . . $ oval_ph_t# *phrec;
84
85 if (phtbl->szcxx . . $ oval_phtbl#sz. > 0) {
86 phrec = oval_probe_handler_getcxx . . $ oval_probe_handler_get(a2b39ae009cb9244).(phtbl, type);
87
88 if (phrec != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
89 if ((ret = phrec->funccxx . . $ oval_ph#func.(type, phrec->uptrcxx . . $ oval_ph#uptr., PROBE_HANDLER_ACT_CLOSEcxx . . $ `src/OVAL/_oval_probe_handler.h:49:9`!)) != 0 ||
90 (ret = phrec->funccxx . . $ oval_ph#func.(type, phrec->uptrcxx . . $ oval_ph#uptr., PROBE_HANDLER_ACT_FREEcxx . . $ `src/OVAL/_oval_probe_handler.h:45:9`!)) != 0)
91 {
92 return(ret);
93 }
94
95 goto fillrec;
96 }
97 }
98
99 void *new_ph = realloccxx . . $ realloc(417ab160f6baadc6).(phtbl->phcxx . . $ oval_phtbl#ph., sizeof(oval_ph_tcxx . . $ oval_ph_t# *) * ++phtbl->szcxx . . $ oval_phtbl#sz.);
100 if (new_ph == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
101 return -1;
102 phtbl->phcxx . . $ oval_phtbl#ph. = new_ph;
103
104 phrec = phtbl->phcxx . . $ oval_phtbl#ph.[phtbl->szcxx . . $ oval_phtbl#sz. - 1] = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(oval_ph_tcxx . . $ oval_ph_t#));
105 sort = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
106 fillrec:
107 if (phrec == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
108 return -1;
109 }
110
111 phrec->typecxx . . $ oval_ph#type. = type;
112 phrec->funccxx . . $ oval_ph#func. = handler;
113 phrec->uptrcxx . . $ oval_ph#uptr. = uptr;
114
115 if ((ret = phrec->funccxx . . $ oval_ph#func.(type, phrec->uptrcxx . . $ oval_ph#uptr., PROBE_HANDLER_ACT_INITcxx . . $ `src/OVAL/_oval_probe_handler.h:44:9`!)) != 0) {
116 phrec->funccxx . . $ oval_ph#func. = PROBE_HANDLER_IGNOREcxx . . $ `src/OVAL/_oval_probe_handler.h:52:9`!;
117 phrec->uptrcxx . . $ oval_ph#uptr. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
118 }
119
120 if (sort)
121 qsortcxx . . $ qsort(ebb60b13a65e77d7).(phtbl->phcxx . . $ oval_phtbl#ph., phtbl->szcxx . . $ oval_phtbl#sz., sizeof(oval_ph_tcxx . . $ oval_ph_t# *),
122 (int(*)(const void *, const void *))oval_phtbl_subtype_cmpcxx . . $ oval_phtbl_subtype_cmp(787ba6c19d886b80).);
123
124 return(ret);
125 }
126
127 /// @}