Open SCAP Library: probe-api.h Source File

Open SCAP Library

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

probe-api.h
Go to the documentation of this file.
1
35 /*
36 * Copyright 2009 Red Hat Inc., Durham, North Carolina.
37 * All Rights Reserved.
38 *
39 * This library is free software; you can redistribute it and/or
40 * modify it under the terms of the GNU Lesser General Public
41 * License as published by the Free Software Foundation; either
42 * version 2.1 of the License, or (at your option) any later version.
43 *
44 * This library is distributed in the hope that it will be useful,
45 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
47 * Lesser General Public License for more details.
48 *
49 * You should have received a copy of the GNU Lesser General Public
50 * License along with this library; if not, write to the Free Software
51 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
52 *
53 * Authors:
54 * Daniel Kopecek <dkopecek@redhat.com>
55 */
56
57 #pragma once
58 #ifndef PROBE_API_H
59 #define PROBE_API_H
60
61 #include <seap.h>
62 #include <stdarg.h>
63 #include <stdint.h>
64 #include <stdbool.h>
65 #include <pthread.h>
66 #include <oval_definitions.h>
67 #include <oval_system_characteristics.h>
68 #include <oval_results.h>
69 #include <oval_types.h>
70
71 /*
72 * items
73 */
74
79 SEXP_t *probe_item_build(const char *fmt, ...);
80
81 /* SEXP_t *probe_item_creat (const char *name, SEXP_t *attrs, ...); */
93 SEXP_t *probe_item_creat(const char *name, SEXP_t * attrs, ...);
94
100 SEXP_t *probe_item_new(const char *name, SEXP_t * attrs);
101
109 SEXP_t *probe_item_attr_add(SEXP_t * item, const char *name, SEXP_t * val);
110
119 SEXP_t *probe_item_ent_add(SEXP_t * item, const char *name, SEXP_t * attrs, SEXP_t * val);
120
126 int probe_item_setstatus(SEXP_t * obj, oval_syschar_status_t status);
127
135 int probe_itement_setstatus(SEXP_t * obj, const char *name, uint32_t n, oval_syschar_status_t status);
136
140 struct id_desc_t;
141
147 SEXP_t *probe_item_newid(struct id_desc_t *id_desc);
148
153 void probe_item_resetidctr(struct id_desc_t *id_desc);
154
155 #define probe_item_getent(item, name, n) probe_obj_getent (item, name, n)
156
157 /*
158 * attributes
159 */
160
168 SEXP_t *probe_attr_creat(const char *name, const SEXP_t * val, ...);
169
170 /*
171 * objects
172 */
173
178 SEXP_t *probe_obj_build(const char *fmt, ...);
179
191 SEXP_t *probe_obj_creat(const char *name, SEXP_t * attrs, ...);
192
199 SEXP_t *probe_obj_new(const char *name, SEXP_t * attrs);
200
207 SEXP_t *probe_obj_getent(const SEXP_t * obj, const char *name, uint32_t n);
208
216 SEXP_t *probe_obj_getentval(const SEXP_t * obj, const char *name, uint32_t n);
217
227 int probe_obj_getentvals(const SEXP_t * obj, const char *name, uint32_t n, SEXP_t ** res);
228
234 SEXP_t *probe_obj_getattrval(const SEXP_t * obj, const char *name);
235
241 bool probe_obj_attrexists(const SEXP_t * obj, const char *name);
242
248 int probe_obj_setstatus(SEXP_t * obj, oval_syschar_status_t status);
249
257 int probe_objent_setstatus(SEXP_t * obj, const char *name, uint32_t n, oval_syschar_status_t status);
258
263 char *probe_obj_getname(const SEXP_t * obj);
264
272 size_t probe_obj_getname_r(const SEXP_t * obj, char *buffer, size_t buflen);
273
274 /*
275 * collected objects
276 */
277
278 SEXP_t *probe_cobj_new(oval_syschar_collection_flag_t flag, SEXP_t *msg_list, SEXP_t *item_list, SEXP_t *mask_list);
279 int probe_cobj_add_msg(SEXP_t *cobj, const SEXP_t *msg);
280 SEXP_t *probe_cobj_get_msgs(const SEXP_t *cobj);
281 SEXP_t *probe_cobj_get_mask(const SEXP_t *cobj);
282 int probe_cobj_add_item(SEXP_t *cobj, const SEXP_t *item);
283 SEXP_t *probe_cobj_get_items(const SEXP_t *cobj);
284 void probe_cobj_set_flag(SEXP_t *cobj, oval_syschar_collection_flag_t flag);
285 oval_syschar_collection_flag_t probe_cobj_get_flag(const SEXP_t *cobj);
286 oval_syschar_collection_flag_t probe_cobj_combine_flags(oval_syschar_collection_flag_t f1,
287 oval_syschar_collection_flag_t f2,
288 oval_setobject_operation_t op);
289 oval_syschar_collection_flag_t probe_cobj_compute_flag(SEXP_t *cobj);
290
291 /*
292 * messages
293 */
294
300 SEXP_t *probe_msg_creat(oval_message_level_t level, char *message);
301
308 SEXP_t *probe_msg_creatf(oval_message_level_t level, const char *fmt, ...) __attribute__((format(printf, 2, 3), nonnull(2)));
309
310 /*
311 * entities
312 */
313
322 SEXP_t *probe_ent_creat(const char *name, SEXP_t * attrs, SEXP_t * val, ...);
323
331 SEXP_t *probe_ent_creat1(const char *name, SEXP_t * attrs, SEXP_t * val);
332
340 SEXP_t *probe_ent_attr_add(SEXP_t * ent, const char *name, SEXP_t * val);
341
347 SEXP_t *probe_ent_getval(const SEXP_t * ent);
348
356 int probe_ent_getvals(const SEXP_t * ent, SEXP_t ** res);
357
363 SEXP_t *probe_ent_getattrval(const SEXP_t * ent, const char *name);
364
370 bool probe_ent_attrexists(const SEXP_t * ent, const char *name);
371
377 int probe_ent_setdatatype(SEXP_t * ent, oval_datatype_t type);
378
383 oval_datatype_t probe_ent_getdatatype(const SEXP_t * ent);
384
390 int probe_ent_setmask(SEXP_t * ent, bool mask);
391
396 bool probe_ent_getmask(const SEXP_t * ent);
397
403 int probe_ent_setstatus(SEXP_t * ent, oval_syschar_status_t status);
404
409 oval_syschar_status_t probe_ent_getstatus(const SEXP_t * ent);
410
415 char *probe_ent_getname(const SEXP_t * ent);
416
424 size_t probe_ent_getname_r(const SEXP_t * ent, char *buffer, size_t buflen);
425
430 void probe_free(SEXP_t * obj);
431
438 void probe_filebehaviors_canonicalize(SEXP_t **behaviors);
439
446 void probe_tfc54behaviors_canonicalize(SEXP_t **behaviors);
447
448 #define PROBE_EINVAL 1
449 #define PROBE_ENOELM 2
450 #define PROBE_ENOVAL 3
451 #define PROBE_ENOATTR 4
452 #define PROBE_EINIT 5
453 #define PROBE_ENOMEM 6
454 #define PROBE_EOPNOTSUPP 7
455 #define PROBE_ERANGE 8
456 #define PROBE_EDOM 9
457 #define PROBE_EFAULT 10
458 #define PROBE_EACCESS 11
459 #define PROBE_ESETEVAL 12
460 #define PROBE_ENOENT 13
461 #define PROBE_ENOOBJ 14
462 #define PROBE_ECONNABORTED 15
463 #define PROBE_ESYSTEM 253
464 #define PROBE_EFATAL 254
465 #define PROBE_EUNKNOWN 255
467 #define PROBECMD_STE_FETCH 1
468 #define PROBECMD_OBJ_EVAL 2
469 #define PROBECMD_RESET 3
471 void probe_preload(void);
472 void *probe_init(void) __attribute__ ((unused));
473 void probe_fini(void *) __attribute__ ((unused));
474
475 typedef struct probe_ctx probe_ctx;
476
477 int probe_main(probe_ctx *, void *) __attribute__ ((nonnull(1)));
478
479 bool probe_item_filtered(const SEXP_t *item, const SEXP_t *filters);
480
481 int probe_result_additem(SEXP_t *result, SEXP_t *item);
482
490 int probe_item_collect(probe_ctx *ctx, SEXP_t *item);
491
498 SEXP_t *probe_ctx_getobject(probe_ctx *ctx);
499
505 SEXP_t *probe_ctx_getresult(probe_ctx *ctx);
506
507 typedef struct {
508 oval_datatype_t type;
509 void *value;
510 } probe_elmatr_t;
511
512 SEXP_t *probe_item_create(oval_subtype_t item_subtype, probe_elmatr_t *item_attributes[], ...);
513
514 #define PROBE_ENT_AREF(ent, dst, attr_name, invalid_exp) \
515 do { \
516 if (((dst) = probe_ent_getattrval(ent, attr_name)) == NULL) { \
517 dE("Attribute `%s' is missing!", attr_name); \
518 invalid_exp \
519 } \
520 } while(0)
521
522 #define PROBE_ENT_STRVAL(ent, dst, dstlen, invalid_exp, zerolen_exp) \
523 do { \
524 SEXP_t *___r; \
525 \
526 if ((___r = probe_ent_getval(ent)) == NULL) { \
527 dW("Entity has no value!"); \
528 invalid_exp \
529 } else { \
530 if (!SEXP_stringp(___r)) { \
531 dE("Invalid type"); \
532 SEXP_free(___r); \
533 invalid_exp \
534 } \
535 else if (SEXP_string_length(___r) == 0) { \
536 SEXP_free(___r); \
537 zerolen_exp \
538 } else { \
539 SEXP_string_cstr_r(___r, dst, dstlen); \
540 SEXP_free(___r); \
541 } \
542 } \
543 } while (0)
544
545 #define PROBE_ENT_I32VAL(ent, dst, invalid_exp, nil_exp) \
546 do { \
547 SEXP_t *___r; \
548 \
549 if ((___r = probe_ent_getval(ent)) == NULL) { \
550 dW("Entity has no value!"); \
551 nil_exp; \
552 } else { \
553 if (!SEXP_numberp(___r)) { \
554 dE("Invalid type"); \
555 SEXP_free(___r); \
556 invalid_exp; \
557 } else { \
558 dst = SEXP_number_geti_32(___r); \
559 SEXP_free(___r); \
560 } \
561 } \
562 } while (0)
563
564 #endif /* PROBE_API_H */
565
566 oval_operation_t probe_ent_getoperation(SEXP_t *entity, oval_operation_t op);
567
568 int probe_item_add_msg(SEXP_t *item, oval_message_level_t msglvl, char *msgfmt, ...);
569
570 SEXP_t *probe_entval_from_cstr(oval_datatype_t type, const char *value, size_t vallen);
571 SEXP_t *probe_ent_from_cstr(const char *name, oval_datatype_t type, const char *value, size_t vallen);
572
573 OSCAP_DEPRECATED(oval_version_t probe_obj_get_schema_version(const SEXP_t *obj));
574 oval_schema_version_t probe_obj_get_platform_schema_version(const SEXP_t *obj);
575
580 SEXP_t *probe_obj_getmask(SEXP_t *obj);
581
probe_msg_creat
SEXP_t * probe_msg_creat(oval_message_level_t level, char *message)
Create a new message that can be added to a collected object.
Definition: probe-api.c:918
probe_ent_getdatatype
oval_datatype_t probe_ent_getdatatype(const SEXP_t *ent)
Get the OVAL data type of an entity.
Definition: probe-api.c:1154
probe_item_attr_add
SEXP_t * probe_item_attr_add(SEXP_t *item, const char *name, SEXP_t *val)
Add a new attribute to an item.
Definition: probe-api.c:128
oval_operation_t
oval_operation_t
Operations.
Definition: oval_definitions.h:84
probe_obj_getentvals
int probe_obj_getentvals(const SEXP_t *obj, const char *name, uint32_t n, SEXP_t **res)
Get the list of values of an object's entity.
Definition: probe-api.c:459
oval_subtype_t
oval_subtype_t
Unknown subtypes.
Definition: oval_types.h:120
probe_init
void * probe_init(void) __attribute__((unused))
Dummy probe_fini function.
Definition: family.c:57
probe_obj_build
SEXP_t * probe_obj_build(const char *fmt,...)
Build a new object according to the specified format.
probe_ent_getstatus
oval_syschar_status_t probe_ent_getstatus(const SEXP_t *ent)
Get entity status.
Definition: probe-api.c:1202
oval_types.h
probe_itement_setstatus
int probe_itement_setstatus(SEXP_t *obj, const char *name, uint32_t n, oval_syschar_status_t status)
Set status of an item's entity.
Definition: probe-api.c:200
OSCAP_DEPRECATED
#define OSCAP_DEPRECATED(func)
This macro will warn, when a deprecated function is used.
Definition: oscap.h:50
probe_ent_attr_add
SEXP_t * probe_ent_attr_add(SEXP_t *ent, const char *name, SEXP_t *val)
Add a new attribute to an entity.
Definition: probe-api.c:1009
probe_item_creat
SEXP_t * probe_item_creat(const char *name, SEXP_t *attrs,...)
Create a new item consisting of a name, optional attributes argument and an arbitrary number of entit...
Definition: probe-api.c:59
oval_syschar_status_t
oval_syschar_status_t
System characteristics status.
Definition: oval_system_characteristics.h:60
probe_obj_creat
SEXP_t * probe_obj_creat(const char *name, SEXP_t *attrs,...)
Create a new object consisting of a name, optional attributes argument and an arbitrary number of ent...
Definition: probe-api.c:337
probe_obj_attrexists
bool probe_obj_attrexists(const SEXP_t *obj, const char *name)
Check whether the specified attribute exists.
Definition: probe-api.c:549
probe_ent_creat1
SEXP_t * probe_ent_creat1(const char *name, SEXP_t *attrs, SEXP_t *val)
Create a new entity.
Definition: probe-api.c:981
probe_item_new
SEXP_t * probe_item_new(const char *name, SEXP_t *attrs)
Create a new item with just a name and optional attributes argument.
Definition: probe-api.c:103
probe_ent_setstatus
int probe_ent_setstatus(SEXP_t *ent, oval_syschar_status_t status)
Set entity's status.
Definition: probe-api.c:1192
probe_ctx_getobject
SEXP_t * probe_ctx_getobject(probe_ctx *ctx)
Return reference to the input object.
Definition: probe.c:31
__attribute__
Definition: _sexp-value.h:42
oval_datatype_t
oval_datatype_t
Datatypes.
Definition: oval_definitions.h:149
probe_obj_getent
SEXP_t * probe_obj_getent(const SEXP_t *obj, const char *name, uint32_t n)
Get an entity from an object.
Definition: probe-api.c:404
probe_ctx
Definition: probe.h:67
probe_filebehaviors_canonicalize
void probe_filebehaviors_canonicalize(SEXP_t **behaviors)
Set all of the missing attributes of the 'behaviors' entity to default values.
Definition: probe-api.c:1312
probe_ent_getname_r
size_t probe_ent_getname_r(const SEXP_t *ent, char *buffer, size_t buflen)
Get the name of an entity.
Definition: probe-api.c:1263
probe_fini
void probe_fini(void *) __attribute__((unused))
Dummy probe_fini function.
Definition: filehash.c:204
probe_obj_getname_r
size_t probe_obj_getname_r(const SEXP_t *obj, char *buffer, size_t buflen)
Get the name of an object.
Definition: probe-api.c:611
probe_obj_getname
char * probe_obj_getname(const SEXP_t *obj)
Get the name of an object.
Definition: probe-api.c:606
probe_obj_getmask
SEXP_t * probe_obj_getmask(SEXP_t *obj)
Get object entity mask.
Definition: probe-api.c:1749
probe_objent_setstatus
int probe_objent_setstatus(SEXP_t *obj, const char *name, uint32_t n, oval_syschar_status_t status)
Set status of an object's entity.
probe_item_resetidctr
void probe_item_resetidctr(struct id_desc_t *id_desc)
Reset the item id generator.
Definition: probe-api.c:216
probe_tfc54behaviors_canonicalize
void probe_tfc54behaviors_canonicalize(SEXP_t **behaviors)
Set all of the missing attributes of the 'behaviors' entity to default values.
Definition: probe-api.c:1348
probe_ent_setdatatype
int probe_ent_setdatatype(SEXP_t *ent, oval_datatype_t type)
Set the OVAL data type of an entity.
Definition: probe-api.c:1108
probe_ent_getattrval
SEXP_t * probe_ent_getattrval(const SEXP_t *ent, const char *name)
Get the value of an entity's attribute.
Definition: probe-api.c:1058
probe_item_setstatus
int probe_item_setstatus(SEXP_t *obj, oval_syschar_status_t status)
Set item's status.
Definition: probe-api.c:188
probe_msg_creatf
SEXP_t * probe_msg_creatf(oval_message_level_t level, const char *fmt,...)
Create a new message that can be added to a collected object.
Definition: probe-api.c:931
probe_attr_creat
SEXP_t * probe_attr_creat(const char *name, const SEXP_t *val,...)
Create a new list of attributes.
Definition: probe-api.c:304
probe_ctx_getresult
SEXP_t * probe_ctx_getresult(probe_ctx *ctx)
Return reference to the output object (aka collected object).
Definition: probe.c:36
probe_obj_new
SEXP_t * probe_obj_new(const char *name, SEXP_t *attrs)
Create a new object with just a name and optional attributes argument.
Definition: probe-api.c:380
probe_obj_getattrval
SEXP_t * probe_obj_getattrval(const SEXP_t *obj, const char *name)
Get the value of an object's attribute.
Definition: probe-api.c:503
probe_item_collect
int probe_item_collect(probe_ctx *ctx, SEXP_t *item)
Collect generated item (i.e.
Definition: icache.c:500
probe_ent_getval
SEXP_t * probe_ent_getval(const SEXP_t *ent)
Get the value of an entity.
Definition: probe-api.c:1033
probe_item_newid
SEXP_t * probe_item_newid(struct id_desc_t *id_desc)
Get a new unique id (within a probe) for an item.
oval_setobject_operation_t
oval_setobject_operation_t
Set operations.
Definition: oval_definitions.h:184
probe_obj_getentval
SEXP_t * probe_obj_getentval(const SEXP_t *obj, const char *name, uint32_t n)
Get the value of an object's entity.
Definition: probe-api.c:447
probe_item_build
SEXP_t * probe_item_build(const char *fmt,...)
Build a new item according to the specified format.
probe_ent_getname
char * probe_ent_getname(const SEXP_t *ent)
Get the name of an entity.
Definition: probe-api.c:1219
probe_ent_attrexists
bool probe_ent_attrexists(const SEXP_t *ent, const char *name)
Check whether the specified attribute exists.
Definition: probe-api.c:1103
probe_ent_getmask
bool probe_ent_getmask(const SEXP_t *ent)
Get entity's mask.
Definition: probe-api.c:1186
probe_ent_getvals
int probe_ent_getvals(const SEXP_t *ent, SEXP_t **res)
Get the list of values of an entity.
Definition: probe-api.c:1014
oval_system_characteristics.h
oval_syschar_collection_flag_t
oval_syschar_collection_flag_t
System characteristics result flag.
Definition: oval_system_characteristics.h:49
SEXP
Definition: sexp-types.h:82
oval_schema_version_t
Definition: oval_schema_version.h:39
oval_message_level_t
oval_message_level_t
Message level.
Definition: oval_system_characteristics.h:69
oval_definitions.h
id_desc_t
Holds information for item ids generation.
Definition: _probe-api.h:44
probe_elmatr_t
Definition: probe-api.h:507
probe_obj_setstatus
int probe_obj_setstatus(SEXP_t *obj, oval_syschar_status_t status)
Set objects's status.
Definition: probe-api.c:596
probe_ent_setmask
int probe_ent_setmask(SEXP_t *ent, bool mask)
Set entity's mask.
Definition: probe-api.c:1180
oval_results.h
probe_free
void probe_free(SEXP_t *obj)
Free the memory allocated by the probe_* functions.
Definition: probe-api.c:1307
probe_ent_creat
SEXP_t * probe_ent_creat(const char *name, SEXP_t *attrs, SEXP_t *val,...)
Create a new list of entities.
Definition: probe-api.c:957
probe_item_ent_add
SEXP_t * probe_item_ent_add(SEXP_t *item, const char *name, SEXP_t *attrs, SEXP_t *val)
Add a new entity to an item.
Definition: probe-api.c:177