no need for storing 1, 2 or 3 all the time.
add_attr (s, entry, nv);
}
+void
+add_attr_special_int (Attrstore *s, unsigned int entry, Id name, unsigned int val)
+{
+ if (val > (TYPE_ATTR_SPECIAL_END - TYPE_ATTR_SPECIAL_START))
+ add_attr_int (s, entry, name, val);
+ else
+ {
+ LongNV nv;
+ nv.key = add_key (s, name, TYPE_ATTR_SPECIAL_START + val, 0);
+ add_attr (s, entry, nv);
+ }
+}
+
static void
add_attr_chunk (Attrstore *s, unsigned int entry, Id name, unsigned int ofs, unsigned int len)
{
}
break;
default:
+ if (type >= TYPE_ATTR_SPECIAL_START && type <= TYPE_ATTR_SPECIAL_END)
+ {
+ add_attr_special_int (s, entry, name, type - TYPE_ATTR_SPECIAL_START);
+ break;
+ }
pool_debug(pool, SAT_FATAL, "unknown type %d\n", type);
exit(0);
}
break;
}
default:
+ if (ai.type >= TYPE_ATTR_SPECIAL_START
+ && ai.type <= TYPE_ATTR_SPECIAL_END)
+ add_attr_special_int (s, i, ai.name, ai.type - TYPE_ATTR_SPECIAL_START);
break;
}
}
const char * localid2str(Attrstore *s, LocalId id);
void add_attr_int (Attrstore *s, unsigned int entry, Id name, unsigned int val);
+void add_attr_special_int (Attrstore *s, unsigned int entry, Id name, unsigned int val);
void add_attr_blob (Attrstore *s, unsigned int entry, Id name, const void *ptr, unsigned int len);
void add_attr_string (Attrstore *s, unsigned int entry, Id name, const char *val);
void add_attr_intlist_int (Attrstore *s, unsigned int entry, Id name, int val);
break;
}
default:
+ /* ??? Convert TYPE_ATTR_SPECIAL_* to _INT type with the right value? */
break;
}
return 1;
#define TYPE_COUNT_NAMED 11
#define TYPE_COUNTED 12
-#define TYPE_ATTR_TYPE_MAX 12
#define TYPE_IDVALUEARRAY 13
#define TYPE_IDVALUEVALUEARRAY 14
+/* The special types are usable to encode one-valued attributes, they have
+ no associated data. This is useful to encode values which many solvables
+ have in common, and whose overall set is relatively limited. A prime
+ example would be the media number. Be warned: careless use of this
+ leads to combinatoric explosion of number of schemas. */
+#define TYPE_ATTR_SPECIAL_START 15
+#define TYPE_ATTR_SPECIAL_END (TYPE_ATTR_SPECIAL_START + 31)
+#define TYPE_ATTR_TYPE_MAX TYPE_ATTR_SPECIAL_END
+
//-----------------------------------------------
break;
}
default:
+ if (ai.type >= TYPE_ATTR_SPECIAL_START
+ && ai.type <= TYPE_ATTR_SPECIAL_END)
+ fprintf (stdout, "spec %d", ai.type - TYPE_ATTR_SPECIAL_START);
fprintf (stdout, "\n");
break;
}
{
/* medianr filename dir
don't optimize this one */
- add_attr_int (attr, entry, str2id (pool, "medianr", 1), atoi (sp[0]));
+ add_attr_special_int (attr, entry, str2id (pool, "medianr", 1), atoi (sp[0]));
add_attr_localids_id (attr, entry, str2id (pool, "mediadir", 1), str2localid (attr, sp[2], 1));
add_attr_string (attr, entry, str2id (pool, "mediafile", 1), sp[1]);
return;
break;
if (*n2 || strcmp (n1, ".rpm"))
goto nontrivial;
- add_attr_int (attr, entry, str2id (pool, "medianr", 1), medianr);
+ add_attr_special_int (attr, entry, str2id (pool, "medianr", 1), medianr);
add_attr_void (attr, entry, str2id (pool, "mediafile", 1));
return;
nontrivial:
- add_attr_int (attr, entry, str2id (pool, "medianr", 1), medianr);
+ add_attr_special_int (attr, entry, str2id (pool, "medianr", 1), medianr);
add_attr_string (attr, entry, str2id (pool, "mediafile", 1), sp[1]);
return;
}