Added headerAddOrAppendEntry()
authormarc <devnull@localhost>
Fri, 17 Oct 1997 04:14:06 +0000 (04:14 +0000)
committermarc <devnull@localhost>
Fri, 17 Oct 1997 04:14:06 +0000 (04:14 +0000)
Allow more NULL args to getEntry(), etc

CVS patchset: 1863
CVS date: 1997/10/17 04:14:06

lib/header.c
lib/header.h

index a1ad35c..c28e4b8 100644 (file)
@@ -195,8 +195,10 @@ int headerNextIterator(HeaderIterator iter,
        return 0;
     }
     iter->next_index++;
-    
-    *tag = h->index[slot].info.tag;
+
+    if (tag) {
+       *tag = h->index[slot].info.tag;
+    }
     copyEntry(h->index + slot, type, p, c);
 
     return 1;
@@ -657,6 +659,8 @@ static void copyEntry(struct indexEntry * entry,
        *type = entry->info.type;
     if (c) 
        *c = entry->info.count;
+    if (!p)
+       return;
 
     /* Now look it up */
     switch (entry->info.type) {
@@ -1035,6 +1039,16 @@ int headerModifyEntry(Header h, int_32 tag, int_32 type, void *p, int_32 c)
     return 1;
 }
 
+int headerAddOrAppendEntry(Header h, int_32 tag, int_32 type,
+                          void * p, int_32 c)
+{
+    if (findEntry(h, tag, type)) {
+       return headerAppendEntry(h, tag, type, p, c);
+    } else {
+       return headerAddEntry(h, tag, type, p, c);
+    }
+}
+
 int headerAppendEntry(Header h, int_32 tag, int_32 type, void * p, int_32 c) {
     struct indexEntry *entry;
     int length;
index c291457..18dfb09 100644 (file)
@@ -116,6 +116,8 @@ int headerAddI18NString(Header h, int_32 tag, char * string, char * lang);
    RPM_STRING_TYPE. Any pointers from headerGetEntry() for this entry
    are invalid after this call has been made! */
 int headerAppendEntry(Header h, int_32 tag, int_32 type, void * p, int_32 c);
+int headerAddOrAppendEntry(Header h, int_32 tag, int_32 type,
+                          void * p, int_32 c);
 
 /* Will never return RPM_I18NSTRING_TYPE! RPM_STRING_TYPE elements w/
    RPM_I18NSTRING_TYPE equivalent enreies are translated (if HEADER_I18NTABLE