• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

/home/pvrabec/project/openscap/openscap-0.6.4/src/OVAL/probes/SEAP/public/sexp-manip.h

Go to the documentation of this file.
00001 
00013 /*
00014  * Copyright 2009 Red Hat Inc., Durham, North Carolina.
00015  * All Rights Reserved.
00016  *
00017  * This library is free software; you can redistribute it and/or
00018  * modify it under the terms of the GNU Lesser General Public
00019  * License as published by the Free Software Foundation; either
00020  * version 2.1 of the License, or (at your option) any later version.
00021  *
00022  * This library is distributed in the hope that it will be useful, 
00023  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025  * Lesser General Public License for more details.
00026  *
00027  * You should have received a copy of the GNU Lesser General Public
00028  * License along with this library; if not, write to the Free Software 
00029  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00030  *
00031  * Authors:
00032  *      Daniel Kopecek <dkopecek@redhat.com>
00033  */
00034 
00035 #pragma once
00036 #ifndef SEXP_MANIP_H
00037 #define SEXP_MANIP_H
00038 
00039 #include <stdarg.h>
00040 #include <stddef.h>
00041 #include <stdint.h>
00042 #include <stdbool.h>
00043 #include <sexp-types.h>
00044 
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048 
00049 /*
00050  * number
00051  */
00052 
00058 SEXP_t *SEXP_number_new (SEXP_numtype_t t, const void *n) __attribute__ ((nonnull (2)));
00059 
00064 SEXP_t *SEXP_number_newb (bool n);
00065 
00070 SEXP_t *SEXP_number_newi_8 (int8_t n);
00071 
00076 SEXP_t *SEXP_number_newu_8 (uint8_t n);
00077 
00082 uint8_t SEXP_number_getu_8 (const SEXP_t *s_exp);
00083 
00088 SEXP_t *SEXP_number_newi_16 (int16_t n);
00089 
00094 SEXP_t *SEXP_number_newu_16 (uint16_t n);
00095 
00100 #define SEXP_number_newi SEXP_number_newi_32
00101 
00106 SEXP_t *SEXP_number_newi_32 (int32_t n);
00107 
00112 #define SEXP_number_geti SEXP_number_geti_32
00113 
00118 int32_t SEXP_number_geti_32 (const SEXP_t *s_exp);
00119 
00124 bool SEXP_number_getb (const SEXP_t *s_exp);
00125 
00130 #define SEXP_number_newu SEXP_number_newu_32
00131 
00136 SEXP_t *SEXP_number_newu_32 (uint32_t n);
00137 
00142 #define  SEXP_number_getu SEXP_number_getu_32
00143 
00148 uint32_t SEXP_number_getu_32 (const SEXP_t *s_exp);
00149 
00154 SEXP_t *SEXP_number_newi_64 (int64_t n);
00155 
00160 int64_t SEXP_number_geti_64 (const SEXP_t *s_exp);
00161 
00166 SEXP_t *SEXP_number_newu_64 (uint64_t n);
00167 
00172 uint64_t SEXP_number_getu_64 (const SEXP_t *s_exp);
00173 
00178 SEXP_t *SEXP_number_newf (double n);
00179 
00184 double  SEXP_number_getf (const SEXP_t *s_exp);
00185 
00192 int SEXP_number_get (const SEXP_t *s_exp, void *dst, SEXP_numtype_t type);
00193 
00198 uint16_t SEXP_number_getu_16 (const SEXP_t *s_exp);
00199 
00204 void    SEXP_number_free (SEXP_t *s_exp);
00205 
00210 bool    SEXP_numberp (const SEXP_t *s_exp);
00211 
00216 SEXP_numtype_t SEXP_number_type (const SEXP_t *sexp);
00217 
00218 /*
00219  * string
00220  */
00221 
00227 SEXP_t *SEXP_string_new  (const void *string, size_t strlen) __attribute__ ((nonnull (1)));
00228 
00234 SEXP_t *SEXP_string_newf (const char *format, ...) __attribute__ ((format (printf, 1, 2), nonnull (1)));
00235 
00240 void SEXP_string_free (SEXP_t *s_exp);
00241 
00246 bool SEXP_stringp (const SEXP_t *s_exp);
00247 
00252 size_t SEXP_string_length (const SEXP_t *s_exp);
00253 
00259 int SEXP_strcmp (const SEXP_t *s_exp, const char *str) __attribute__ ((nonnull (2)));
00260 
00267 int SEXP_strncmp (const SEXP_t *s_exp, const char *str, size_t n) __attribute__ ((nonnull (2)));
00268 
00274 int SEXP_string_nth (const SEXP_t *s_exp, size_t n);
00275 
00279 char  *SEXP_string_cstr (const SEXP_t *s_exp);
00280 
00288 size_t SEXP_string_cstr_r (const SEXP_t *s_exp, char *buf, size_t len) __attribute__ ((nonnull (2)));
00289 
00293 char  *SEXP_string_cstrp (const SEXP_t *s_exp);
00294 
00301 char *SEXP_string_subcstr (const SEXP_t *s_exp, size_t beg, size_t len);
00302 
00308 int SEXP_string_cmp (const SEXP_t *str_a, const SEXP_t *str_b);
00309 
00310 /*
00311  * list
00312  */
00313 
00320 SEXP_t *SEXP_list_new (SEXP_t *memb, ...);
00321 
00326 void    SEXP_list_free (SEXP_t *s_exp);
00327 
00332 bool    SEXP_listp (const SEXP_t *s_exp);
00333 
00338 size_t  SEXP_list_length (const SEXP_t *s_exp);
00339 
00345 SEXP_t *SEXP_list_first (const SEXP_t *list);
00346 
00352 SEXP_t *SEXP_list_rest  (const SEXP_t *list);
00353 
00359 SEXP_t *SEXP_list_last (const SEXP_t *list);
00360 
00367 SEXP_t *SEXP_list_nth (const SEXP_t *list, uint32_t n);
00368 
00375 SEXP_t *SEXP_list_add (SEXP_t *list, const SEXP_t *s_exp);
00376 
00383 SEXP_t *SEXP_list_join (const SEXP_t *list_a, const SEXP_t *list_b);
00384 
00391 SEXP_t *SEXP_list_push (SEXP_t *list, const SEXP_t *s_exp);
00392 
00398 SEXP_t *SEXP_list_pop (SEXP_t *list);
00399 
00408 SEXP_t *SEXP_list_replace (SEXP_t *list, uint32_t n, const SEXP_t *s_exp);
00409 
00415 SEXP_t *SEXP_listref_first (SEXP_t *list);
00416 
00422 SEXP_t *SEXP_listref_rest (SEXP_t *list);
00423 
00429 SEXP_t *SEXP_listref_last (SEXP_t *list);
00430 
00437 SEXP_t *SEXP_listref_nth (SEXP_t *list, uint32_t n);
00438 
00439 typedef struct SEXP_it SEXP_it_t;
00440 
00441 #define SEXP_IT_RECURSIVE 0x01
00442 #define SEXP_IT_HARDREF   0x02
00443 
00444 SEXP_it_t *SEXP_listit_new (const SEXP_t *list, int flags);
00445 SEXP_t    *SEXP_listit_next(SEXP_it_t *it);
00446 SEXP_t    *SEXP_listit_prev (SEXP_it_t *it);
00447 SEXP_t    *SEXP_listit_length (SEXP_it_t *it);
00448 SEXP_t    *SEXP_listit_seek (SEXP_it_t *it, uint32_t n);
00449 void       SEXP_listit_free (SEXP_it_t *it);
00450 
00451 #if __STDC_VERSION__ >= 199901L
00452 # include <common/util.h>
00453 
00454 /* TODO: use alloca & softref_r here */
00460 #define SEXP_list_foreach(var, list)                                    \
00461         for (uint32_t OSCAP_CONCAT(i,__LINE__) = 1; ((var) = SEXP_list_nth (list, OSCAP_CONCAT(i,__LINE__))) != NULL; ++OSCAP_CONCAT(i,__LINE__), SEXP_free (var))
00462 
00470 #define SEXP_sublist_foreach(var, list, beg, end)                       \
00471         for (uint32_t OSCAP_CONCAT(i,__LINE__) = (beg); OSCAP_CONCAT(i,__LINE__) <= ((size_t)(end)) && ((var) = SEXP_list_nth (list, OSCAP_CONCAT(i,__LINE__))) != NULL; ++OSCAP_CONCAT(i,__LINE__), SEXP_free (var))
00472 
00473 #define SEXP_LIST_END (UINT32_MAX - 1)
00474 
00475 #endif /* __STDC_VERSION__ >= 199901L */
00476 
00477 /*
00478  * generic
00479  */
00480 SEXP_t *SEXP_new (void);
00481 
00486 SEXP_t *SEXP_ref (const SEXP_t *s_exp);
00487 
00488 SEXP_t *SEXP_unref (SEXP_t *s_exp_o);
00489 
00494 SEXP_t *SEXP_softref (SEXP_t *s_exp);
00495 
00500 bool SEXP_softrefp(const SEXP_t *s_exp);
00501 
00506 uint32_t SEXP_refs (const SEXP_t *ref);
00507 
00508 bool SEXP_eq (const SEXP_t *a, const SEXP_t *b);
00509 
00510 #if defined(NDEBUG)
00511 
00515 void     SEXP_free (SEXP_t *s_exp);
00516 
00523 void     SEXP_vfree (SEXP_t *s_exp, ...);
00524 #else
00525 # define SEXP_free(ptr) __SEXP_free (ptr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
00526 void     __SEXP_free (SEXP_t *s_exp, const char *file, uint32_t line, const char *func);
00527 # define SEXP_vfree(...) __SEXP_vfree (__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
00528 void     __SEXP_vfree (const char *file, uint32_t line, const char *func, SEXP_t *s_exp, ...);
00529 #endif
00530 
00535 const char *SEXP_datatype (const SEXP_t *s_exp);
00536 
00541 int SEXP_datatype_set (SEXP_t *s_exp, const char *name) __attribute__ ((nonnull (2)));
00542 
00549 int SEXP_datatype_set_nth (SEXP_t *list, uint32_t n, const char *name) __attribute__ ((nonnull (3)));
00550 
00555 SEXP_type_t SEXP_typeof (const SEXP_t *s_exp);
00556 
00561 const char *SEXP_strtype (const SEXP_t *s_exp);
00562 
00563 SEXP_t *SEXP_build (const char *s_str, ...);
00564 
00565 size_t SEXP_sizeof (const SEXP_t *s_exp);
00566 
00567 #if !defined(NDEBUG)
00568 # define SEXP_VALIDATE(s) __SEXP_VALIDATE(s, __FILE__, __LINE__, __PRETTY_FUNCTION__)
00569 # include <stdlib.h>
00570 
00571 void __SEXP_VALIDATE(const SEXP_t *s_exp, const char *file, uint32_t line, const char *func);
00572 
00573 #else
00574 # define SEXP_VALIDATE(s)
00575 #endif
00576 
00577 #ifdef __cplusplus
00578 }
00579 #endif
00580 
00581 #endif /* SEXP_MANIP_H */
00582 /* @}@}@} */

Generated on Wed Oct 20 2010 for Open SCAP Library by  doxygen 1.7.1