1 /* libcomps - C alternative to yum.comps library 2 * Copyright (C) 2013 Jindrich Luza 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 17 * USA 18 */ 19 20 #ifndef COMPS_ELEM_H 21 #define COMPS_ELEM_H 22 23 #include <stdlib.h> 24 25 #include "comps_dict.h" 26 #include "comps_parse.h" 27 28 typedef enum {COMPS_ELEM_UNKNOWN, 29 COMPS_ELEM_DOC, 30 COMPS_ELEM_GROUP, 31 COMPS_ELEM_ID, 32 COMPS_ELEM_NAME, 33 COMPS_ELEM_DESC, 34 COMPS_ELEM_DEFAULT, 35 COMPS_ELEM_LANGONLY, 36 COMPS_ELEM_USERVISIBLE, 37 COMPS_ELEM_BIARCHONLY, //RHEL-4.9 38 COMPS_ELEM_PACKAGELIST, 39 COMPS_ELEM_PACKAGEREQ, 40 COMPS_ELEM_CATEGORY, 41 COMPS_ELEM_GROUPLIST, 42 COMPS_ELEM_GROUPID, 43 COMPS_ELEM_DISPLAYORDER, 44 COMPS_ELEM_ENV, 45 COMPS_ELEM_OPTLIST, 46 COMPS_ELEM_IGNOREDEP, 47 COMPS_ELEM_WHITEOUT, 48 COMPS_ELEM_BLACKLIST, 49 COMPS_ELEM_PACKAGE, 50 COMPS_ELEM_LANGPACKS, 51 COMPS_ELEM_MATCH, 52 COMPS_ELEM_NONE, 53 COMPS_ELEM_SENTINEL} COMPS_ElemType; 54 55 typedef struct { 56 char *name; 57 char *val; 58 } COMPS_ElemAttr; 59 60 typedef struct COMPS_Elem COMPS_Elem; 61 62 struct COMPS_Elem{ 63 char *name; 64 char valid; 65 COMPS_Elem *ancestor; 66 COMPS_ElemType type; 67 COMPS_Dict *attrs; 68 }; 69 70 typedef struct COMPS_ElemAttrInfo { 71 char *name; 72 signed char (*val_check)(const char*); 73 } COMPS_ElemAttrInfo; 74 75 typedef struct COMPS_ElemInfo { 76 char *name; 77 const COMPS_ElemType *ancestors; 78 const COMPS_ElemAttrInfo **attributes; 79 void (*preproc)(COMPS_Parsed*, COMPS_Elem *elem); 80 void (*postproc)(COMPS_Parsed*, COMPS_Elem *elem); 81 } COMPS_ElemInfo; 82 83 extern const COMPS_ElemInfo* COMPS_ElemInfos[]; 84 85 char * comps_elem_get_name(const COMPS_ElemType type); 86 void comps_elem_attr_destroy(void *attr); 87 COMPS_ElemAttr * comps_elem_attr_create(const char *name, const char *val); 88 COMPS_Elem* comps_elem_create(const char * s, const char ** attrs, 89 COMPS_ElemType type); 90 COMPS_ElemType comps_elem_get_type(const char * name); 91 92 void comps_elem_destroy(void * elem); 93 94 COMPS_PackageType comps_package_get_type(char *s); 95 96 void comps_elem_doc_preproc(COMPS_Parsed* parsed, COMPS_Elem *elem); 97 void comps_elem_group_preproc(COMPS_Parsed* parsed, COMPS_Elem *elem); 98 void comps_elem_group_postproc(COMPS_Parsed* parsed, COMPS_Elem *elem); 99 void comps_elem_category_preproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 100 void comps_elem_category_postproc(COMPS_Parsed* parsed, COMPS_Elem *elem); 101 void comps_elem_env_preproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 102 void comps_elem_env_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 103 void comps_elem_packagereq_preproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 104 void comps_elem_packagereq_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 105 void comps_elem_groupid_preproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 106 void comps_elem_groupid_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 107 void comps_elem_match_preproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 108 void comps_elem_package_preproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 109 void comps_elem_ignoredep_preproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 110 void comps_elem_idnamedesc_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 111 void comps_elem_default_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 112 void comps_elem_langonly_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 113 void comps_elem_uservisible_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 114 void comps_elem_biarchonly_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 115 116 void comps_elem_grouplist_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 117 void comps_elem_optionlist_preproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 118 void comps_elem_optionlist_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 119 void comps_elem_packagelist_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 120 void comps_elem_display_order_postproc(COMPS_Parsed *parsed, COMPS_Elem *elem); 121 122 extern const COMPS_ElemAttrInfo COMPS_REQUIRES_ElemAttrInfo; 123 extern const COMPS_ElemAttrInfo COMPS_TYPE_ElemAttrInfo; 124 extern const COMPS_ElemAttrInfo COMPS_BAO_ElemAttrInfo; 125 extern const COMPS_ElemAttrInfo COMPS_DEFAULT_ElemAttrInfo; 126 extern const COMPS_ElemAttrInfo COMPS_NAME_ElemAttrInfo; 127 extern const COMPS_ElemAttrInfo COMPS_INSTALL_ElemAttrInfo; 128 extern const COMPS_ElemAttrInfo COMPS_ARCH_ElemAttrInfo; 129 extern const COMPS_ElemAttrInfo COMPS_C_ARCH_ElemAttrInfo; 130 extern const COMPS_ElemAttrInfo COMPS_PACKAGE_ElemAttrInfo; 131 extern const COMPS_ElemAttrInfo COMPS_XMLLANG_ElemAttrInfo; 132 133 #endif 134