Open SCAP Library

probe-api.h

Go to the documentation of this file.
00001 
00035 /*
00036  * Copyright 2009 Red Hat Inc., Durham, North Carolina.
00037  * All Rights Reserved.
00038  *
00039  * This library is free software; you can redistribute it and/or
00040  * modify it under the terms of the GNU Lesser General Public
00041  * License as published by the Free Software Foundation; either
00042  * version 2.1 of the License, or (at your option) any later version.
00043  *
00044  * This library is distributed in the hope that it will be useful, 
00045  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00046  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00047  * Lesser General Public License for more details.
00048  *
00049  * You should have received a copy of the GNU Lesser General Public
00050  * License along with this library; if not, write to the Free Software 
00051  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00052  *
00053  * Authors:
00054  *      Daniel Kopecek <dkopecek@redhat.com>
00055  */
00056 
00057 #pragma once
00058 #ifndef PROBE_API_H
00059 #define PROBE_API_H
00060 
00061 #include <seap.h>
00062 #include <stdarg.h>
00063 #include <stdint.h>
00064 #include <stdbool.h>
00065 #include <pthread.h>
00066 #include <oval_definitions.h>
00067 #include <oval_system_characteristics.h>
00068 #include <oval_results.h>
00069 #include <oval_types.h>
00070 
00071 /*
00072  * items
00073  */
00074 
00079 SEXP_t *probe_item_build(const char *fmt, ...);
00080 
00081 /* SEXP_t *probe_item_creat (const char *name, SEXP_t *attrs, ...); */
00093 SEXP_t *probe_item_creat(const char *name, SEXP_t * attrs, ...);
00094 
00100 SEXP_t *probe_item_new(const char *name, SEXP_t * attrs);
00101 
00109 SEXP_t *probe_item_attr_add(SEXP_t * item, const char *name, SEXP_t * val);
00110 
00119 SEXP_t *probe_item_ent_add(SEXP_t * item, const char *name, SEXP_t * attrs, SEXP_t * val);
00120 
00126 int probe_item_setstatus(SEXP_t * obj, oval_syschar_status_t status);
00127 
00135 int probe_itement_setstatus(SEXP_t * obj, const char *name, uint32_t n, oval_syschar_status_t status);
00136 
00140 struct id_desc_t;
00141 
00147 SEXP_t *probe_item_newid(struct id_desc_t *id_desc);
00148 
00153 void probe_item_resetidctr(struct id_desc_t *id_desc);
00154 
00155 #define probe_item_getent(item, name, n) probe_obj_getent (item, name, n)
00156 
00157 /*
00158  * attributes
00159  */
00160 
00168 SEXP_t *probe_attr_creat(const char *name, const SEXP_t * val, ...);
00169 
00170 /*
00171  * objects
00172  */
00173 
00178 SEXP_t *probe_obj_build(const char *fmt, ...);
00179 
00191 SEXP_t *probe_obj_creat(const char *name, SEXP_t * attrs, ...);
00192 
00199 SEXP_t *probe_obj_new(const char *name, SEXP_t * attrs);
00200 
00207 SEXP_t *probe_obj_getent(const SEXP_t * obj, const char *name, uint32_t n);
00208 
00216 SEXP_t *probe_obj_getentval(const SEXP_t * obj, const char *name, uint32_t n);
00217 
00227 int probe_obj_getentvals(const SEXP_t * obj, const char *name, uint32_t n, SEXP_t ** res);
00228 
00234 SEXP_t *probe_obj_getattrval(const SEXP_t * obj, const char *name);
00235 
00241 bool probe_obj_attrexists(const SEXP_t * obj, const char *name);
00242 
00248 int probe_obj_setstatus(SEXP_t * obj, oval_syschar_status_t status);
00249 
00257 int probe_objent_setstatus(SEXP_t * obj, const char *name, uint32_t n, oval_syschar_status_t status);
00258 
00263 char *probe_obj_getname(const SEXP_t * obj);
00264 
00272 size_t probe_obj_getname_r(const SEXP_t * obj, char *buffer, size_t buflen);
00273 
00274 /*
00275  * collected objects
00276  */
00277 
00278 SEXP_t *probe_cobj_new(oval_syschar_collection_flag_t flag, SEXP_t *msg_list, SEXP_t *item_list, SEXP_t *mask_list);
00279 int probe_cobj_add_msg(SEXP_t *cobj, const SEXP_t *msg);
00280 SEXP_t *probe_cobj_get_msgs(const SEXP_t *cobj);
00281 SEXP_t *probe_cobj_get_mask(const SEXP_t *cobj);
00282 int probe_cobj_add_item(SEXP_t *cobj, const SEXP_t *item);
00283 SEXP_t *probe_cobj_get_items(const SEXP_t *cobj);
00284 void probe_cobj_set_flag(SEXP_t *cobj, oval_syschar_collection_flag_t flag);
00285 oval_syschar_collection_flag_t probe_cobj_get_flag(const SEXP_t *cobj);
00286 oval_syschar_collection_flag_t probe_cobj_combine_flags(oval_syschar_collection_flag_t f1,
00287                                                         oval_syschar_collection_flag_t f2,
00288                                                         oval_setobject_operation_t op);
00289 oval_syschar_collection_flag_t probe_cobj_compute_flag(SEXP_t *cobj);
00290 
00291 /*
00292  * messages
00293  */
00294 
00300 SEXP_t *probe_msg_creat(oval_message_level_t level, char *message);
00301 
00308 SEXP_t *probe_msg_creatf(oval_message_level_t level, const char *fmt, ...) __attribute__((format(printf, 2, 3), nonnull(2)));
00309 
00310 /*
00311  * entities
00312  */
00313 
00322 SEXP_t *probe_ent_creat(const char *name, SEXP_t * attrs, SEXP_t * val, ...);
00323 
00331 SEXP_t *probe_ent_creat1(const char *name, SEXP_t * attrs, SEXP_t * val);
00332 
00340 SEXP_t *probe_ent_attr_add(SEXP_t * ent, const char *name, SEXP_t * val);
00341 
00347 SEXP_t *probe_ent_getval(const SEXP_t * ent);
00348 
00356 int probe_ent_getvals(const SEXP_t * ent, SEXP_t ** res);
00357 
00363 SEXP_t *probe_ent_getattrval(const SEXP_t * ent, const char *name);
00364 
00370 bool probe_ent_attrexists(const SEXP_t * ent, const char *name);
00371 
00377 int probe_ent_setdatatype(SEXP_t * ent, oval_datatype_t type);
00378 
00383 oval_datatype_t probe_ent_getdatatype(const SEXP_t * ent);
00384 
00390 int probe_ent_setmask(SEXP_t * ent, bool mask);
00391 
00396 bool probe_ent_getmask(const SEXP_t * ent);
00397 
00403 int probe_ent_setstatus(SEXP_t * ent, oval_syschar_status_t status);
00404 
00409 oval_syschar_status_t probe_ent_getstatus(const SEXP_t * ent);
00410 
00415 char *probe_ent_getname(const SEXP_t * ent);
00416 
00424 size_t probe_ent_getname_r(const SEXP_t * ent, char *buffer, size_t buflen);
00425 
00430 void probe_free(SEXP_t * obj);
00431 
00438 void probe_filebehaviors_canonicalize(SEXP_t **behaviors);
00439 
00446 void probe_tfc54behaviors_canonicalize(SEXP_t **behaviors);
00447 
00448 #define PROBE_EINVAL     1      
00449 #define PROBE_ENOELM     2      
00450 #define PROBE_ENOVAL     3      
00451 #define PROBE_ENOATTR    4      
00452 #define PROBE_EINIT      5      
00453 #define PROBE_ENOMEM     6      
00454 #define PROBE_EOPNOTSUPP 7      
00455 #define PROBE_ERANGE     8      
00456 #define PROBE_EDOM       9      
00457 #define PROBE_EFAULT    10      
00458 #define PROBE_EACCESS   11      
00459 #define PROBE_ESETEVAL  12      
00460 #define PROBE_ENOENT    13      
00461 #define PROBE_ENOOBJ    14      
00462 #define PROBE_ECONNABORTED 15   
00463 #define PROBE_ESYSTEM  253      
00464 #define PROBE_EFATAL   254      
00465 #define PROBE_EUNKNOWN 255      
00467 #define PROBECMD_STE_FETCH 1 
00468 #define PROBECMD_OBJ_EVAL  2 
00469 #define PROBECMD_RESET     3 
00472 void probe_offline_mode(void);
00473 void probe_preload(void);
00474 void *probe_init(void) __attribute__ ((unused));
00475 void probe_fini(void *) __attribute__ ((unused));
00476 
00477 typedef struct probe_ctx probe_ctx;
00478 
00479 int probe_main(probe_ctx *, void *) __attribute__ ((nonnull(1)));
00480 
00481 bool probe_item_filtered(const SEXP_t *item, const SEXP_t *filters);
00482 
00483 int probe_result_additem(SEXP_t *result, SEXP_t *item);
00484 
00492 int probe_item_collect(probe_ctx *ctx, SEXP_t *item);
00493 
00500 SEXP_t *probe_ctx_getobject(probe_ctx *ctx);
00501 
00507 SEXP_t *probe_ctx_getresult(probe_ctx *ctx);
00508 
00509 typedef struct {
00510         oval_datatype_t type;
00511         void           *value;
00512 } probe_elmatr_t;
00513 
00514 SEXP_t *probe_item_create(oval_subtype_t item_subtype, probe_elmatr_t *item_attributes[], ...);
00515 
00516 #define PROBE_ENT_AREF(ent, dst, attr_name, invalid_exp)                \
00517         do {                                                            \
00518                 if (((dst) = probe_ent_getattrval(ent, attr_name)) == NULL) { \
00519                         dE("Attribute `%s' is missing!", attr_name);    \
00520                         invalid_exp                                     \
00521                 }                                                       \
00522         } while(0)
00523 
00524 #define PROBE_ENT_STRVAL(ent, dst, dstlen, invalid_exp, zerolen_exp)    \
00525         do {                                                    \
00526                 SEXP_t *___r;                                   \
00527                                                                 \
00528                 if ((___r = probe_ent_getval(ent)) == NULL) {   \
00529                         dW("Entity has no value!");             \
00530                         invalid_exp                             \
00531                 } else {                                        \
00532                         if (!SEXP_stringp(___r)) {              \
00533                                 dE("Invalid type");             \
00534                                 SEXP_free(___r);                \
00535                                 invalid_exp                     \
00536                         }                                       \
00537                         else if (SEXP_string_length(___r) == 0) { \
00538                                 SEXP_free(___r);                \
00539                                 zerolen_exp                     \
00540                         } else {                                \
00541                                 SEXP_string_cstr_r(___r, dst, dstlen); \
00542                                 SEXP_free(___r);                \
00543                         }                                       \
00544                 }                                               \
00545         } while (0)
00546 
00547 #define PROBE_ENT_I32VAL(ent, dst, invalid_exp, nil_exp)        \
00548         do {                                                    \
00549                 SEXP_t *___r;                                   \
00550                                                                 \
00551                 if ((___r = probe_ent_getval(ent)) == NULL) {   \
00552                         dW("Entity has no value!");             \
00553                         nil_exp;                                \
00554                 } else {                                        \
00555                         if (!SEXP_numberp(___r)) {              \
00556                                 dE("Invalid type");             \
00557                                 SEXP_free(___r);                \
00558                                 invalid_exp;                    \
00559                         } else {                                \
00560                                 dst = SEXP_number_geti_32(___r);        \
00561                                 SEXP_free(___r);                        \
00562                         }                                               \
00563                 }                                                       \
00564         } while (0)
00565 
00566 #endif                          /* PROBE_API_H */
00567 
00568 oval_operation_t probe_ent_getoperation(SEXP_t *entity, oval_operation_t op);
00569 
00570 int probe_item_add_msg(SEXP_t *item, oval_message_level_t msglvl, char *msgfmt, ...);
00571 
00572 SEXP_t *probe_entval_from_cstr(oval_datatype_t type, const char *value, size_t vallen);
00573 SEXP_t *probe_ent_from_cstr(const char *name, oval_datatype_t type, const char *value, size_t vallen);
00574 
00575 OSCAP_DEPRECATED(oval_version_t probe_obj_get_schema_version(const SEXP_t *obj));
00576 oval_schema_version_t probe_obj_get_platform_schema_version(const SEXP_t *obj);
00577 
00582 SEXP_t *probe_obj_getmask(SEXP_t *obj);
00583 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines