xar_ea_t xar_ea_new(xar_file_t f, const char *name) { xar_ea_t ret; ret = calloc(sizeof(struct __xar_ea_t), 1); if( !ret ) return NULL; XAR_EA(ret)->prop = xar_prop_new(f, NULL); if( !XAR_EA(ret)->prop ) { free(ret); return NULL; } xar_prop_setkey(XAR_EA(ret)->prop, "ea"); xar_prop_setvalue(XAR_EA(ret)->prop, NULL); XAR_PROP(XAR_EA(ret)->prop)->attrs = xar_attr_new(); XAR_ATTR(XAR_PROP(XAR_EA(ret)->prop)->attrs)->key = strdup("id"); asprintf((char **)&XAR_ATTR(XAR_PROP(XAR_EA(ret)->prop)->attrs)->value, "%lld", XAR_FILE(f)->nexteaid++); xar_prop_pset(f, XAR_EA(ret)->prop, "name", name); return ret; }
/* xar_check_prop * x: xar archive * name: name of property to check * Description: If XAR_OPT_PROPINCLUDE is set at all, only properties * specified for inclusion will be added. * If XAR_OPT_PROPINCLUDE is not set, and XAR_OPT_PROPEXCLUDE is set, * properies specified by XAR_OPT_PROPEXCLUDE will be omitted. * Returns: 0 for not to include, 1 for include. */ int32_t xar_check_prop(xar_t x, const char *name) { xar_attr_t i; char includeset = 0; for(i = XAR(x)->attrs; i; i = XAR_ATTR(i)->next) { if( strcmp(XAR_ATTR(i)->key, XAR_OPT_PROPINCLUDE) == 0 ) { if( strcmp(XAR_ATTR(i)->value, name) == 0 ) return 1; includeset = 1; } } if( includeset ) return 0; for(i = XAR(x)->attrs; i; i = XAR_ATTR(i)->next) { if( strcmp(XAR_ATTR(i)->key, XAR_OPT_PROPEXCLUDE) == 0 ) { if( strcmp(XAR_ATTR(i)->value, name) == 0 ) return 0; } } return 1; }