1616#include <stdlib.h>
1717#include <string.h>
1818#include <assert.h>
19+ #include <stdbool.h>
1920
2021#include "pool.h"
2122#include "repo.h"
2930 * TODO:
3031 *
3132 * what's the difference between group/category?
32- * handle "default" and "langonly".
3333 *
3434 * maybe handle REL_COND in solver recommends handling?
3535 */
@@ -101,6 +101,21 @@ struct parsedata {
101101};
102102
103103
104+ const bool COMPS_DEFAULT_USERVISIBLE = true;
105+ const bool COMPS_DEFAULT_DEFAULT = false;
106+
107+
108+ /* Return true if "true", false if "false", default_value otherwise */
109+ bool
110+ parse_boolean (char * content , bool default_value )
111+ {
112+ if (!strcmp (content , "true" ))
113+ return true;
114+ if (!strcmp (content , "false" ))
115+ return false;
116+ return default_value ;
117+ }
118+
104119
105120static void
106121startElement (struct solv_xmlparser * xmlp , int state , const char * name , const char * * atts )
@@ -116,6 +131,10 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
116131 s = pd -> solvable = pool_id2solvable (pool , repo_add_solvable (pd -> repo ));
117132 pd -> handle = s - pool -> solvables ;
118133 pd -> kind = state == STATE_GROUP ? "group" : "category" ;
134+ if (COMPS_DEFAULT_USERVISIBLE )
135+ repodata_set_void (pd -> data , pd -> handle , SOLVABLE_ISVISIBLE );
136+ if (COMPS_DEFAULT_DEFAULT )
137+ repodata_set_void (pd -> data , pd -> handle , SOLVABLE_ISDEFAULT );
119138 break ;
120139
121140 case STATE_NAME :
@@ -194,7 +213,25 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
194213 break ;
195214
196215 case STATE_USERVISIBLE :
197- repodata_set_void (pd -> data , pd -> handle , SOLVABLE_ISVISIBLE );
216+ if (parse_boolean (content , COMPS_DEFAULT_USERVISIBLE ))
217+ repodata_set_void (pd -> data , pd -> handle , SOLVABLE_ISVISIBLE );
218+ else
219+ repodata_unset (pd -> data , pd -> handle , SOLVABLE_ISVISIBLE );
220+ break ;
221+
222+ case STATE_DEFAULT :
223+ if (parse_boolean (content , COMPS_DEFAULT_DEFAULT ))
224+ repodata_set_void (pd -> data , pd -> handle , SOLVABLE_ISDEFAULT );
225+ else
226+ repodata_unset (pd -> data , pd -> handle , SOLVABLE_ISDEFAULT );
227+ break ;
228+
229+ case STATE_LANG_ONLY :
230+ repodata_set_str (pd -> data , pd -> handle , SOLVABLE_LANGONLY , content );
231+ break ;
232+
233+ case STATE_LANGONLY :
234+ repodata_set_str (pd -> data , pd -> handle , SOLVABLE_LANGONLY , content );
198235 break ;
199236
200237 case STATE_DISPLAY_ORDER :
0 commit comments