+struct heap_cread_info {
+ char prev_name[INP_NAME_MAX];
+ char cur_name[INP_NAME_MAX];
+ char *key;
+ struct heap_info *hi;
+ int mode;
+ int more;
+};
+
+int heap_cread_item (void *vp, char **dst, int *insertMode)
+{
+ struct heap_cread_info *p = (struct heap_cread_info *) vp;
+ struct heap_info *hi = p->hi;
+
+ if (p->mode == 1)
+ {
+ *insertMode = p->key[0];
+ memcpy (*dst, p->key+1, sizeof(struct it_key));
+ (*dst) += sizeof(struct it_key);
+ p->mode = 2;
+ return 1;
+ }
+ strcpy (p->prev_name, p->cur_name);
+ if (!(p->more = heap_read_one (hi, p->cur_name, p->key)))
+ return 0;
+ if (*p->cur_name && strcmp (p->cur_name, p->prev_name))
+ {
+ p->mode = 1;
+ return 0;
+ }
+ *insertMode = p->key[0];
+ memcpy (*dst, p->key+1, sizeof(struct it_key));
+ (*dst) += sizeof(struct it_key);
+ return 1;
+}
+
+int heap_inpc (struct heap_info *hi)
+{
+ struct heap_cread_info hci;
+ ISAMC_I isamc_i = (ISAMC_I) xmalloc (sizeof(*isamc_i));
+
+ hci.key = (char *) xmalloc (KEY_SIZE);
+ hci.mode = 1;
+ hci.hi = hi;
+ hci.more = heap_read_one (hi, hci.cur_name, hci.key);
+
+ isamc_i->clientData = &hci;
+ isamc_i->read_item = heap_cread_item;
+
+ while (hci.more)
+ {
+ char this_name[INP_NAME_MAX];
+ ISAMC_P isamc_p, isamc_p2;
+ char *dict_info;
+
+ strcpy (this_name, hci.cur_name);
+ assert (hci.cur_name[1]);
+ no_diffs++;
+ if ((dict_info = dict_lookup (hi->dict, hci.cur_name)))
+ {
+ memcpy (&isamc_p, dict_info+1, sizeof(ISAMC_P));
+ isamc_p2 = isc_merge (hi->isamc, isamc_p, isamc_i);
+ if (!isamc_p2)
+ {
+ no_deletions++;
+ if (!dict_delete (hi->dict, this_name))
+ abort();
+ }
+ else
+ {
+ no_updates++;
+ if (isamc_p2 != isamc_p)
+ dict_insert (hi->dict, this_name,
+ sizeof(ISAMC_P), &isamc_p2);
+ }
+ }
+ else
+ {
+ isamc_p = isc_merge (hi->isamc, 0, isamc_i);
+ no_insertions++;
+ dict_insert (hi->dict, this_name, sizeof(ISAMC_P), &isamc_p);
+ }
+ }
+ xfree (isamc_i);
+ return 0;
+}
+
+int heap_inps (struct heap_info *hi)
+{
+ struct heap_cread_info hci;
+ ISAMS_I isams_i = (ISAMS_I) xmalloc (sizeof(*isams_i));
+
+ hci.key = (char *) xmalloc (KEY_SIZE);
+ hci.mode = 1;
+ hci.hi = hi;
+ hci.more = heap_read_one (hi, hci.cur_name, hci.key);
+
+ isams_i->clientData = &hci;
+ isams_i->read_item = heap_cread_item;
+
+ while (hci.more)
+ {
+ char this_name[INP_NAME_MAX];
+ ISAMS_P isams_p;
+ char *dict_info;
+
+ strcpy (this_name, hci.cur_name);
+ assert (hci.cur_name[1]);
+ no_diffs++;
+ if (!(dict_info = dict_lookup (hi->dict, hci.cur_name)))
+ {
+ isams_p = isams_merge (hi->isams, isams_i);
+ no_insertions++;
+ dict_insert (hi->dict, this_name, sizeof(ISAMS_P), &isams_p);
+ }
+ else
+ abort();
+ }
+ xfree (isams_i);
+ return 0;
+}
+
+int heap_inph (struct heap_info *hi)
+{
+ struct heap_cread_info hci;
+ ISAMH_I isamh_i = (ISAMH_I) xmalloc (sizeof(*isamh_i));
+
+ hci.key = (char *) xmalloc (KEY_SIZE);
+ hci.mode = 1;
+ hci.hi = hi;
+ hci.more = heap_read_one (hi, hci.cur_name, hci.key);
+
+ isamh_i->clientData = &hci;
+ isamh_i->read_item = heap_cread_item;
+
+ while (hci.more)
+ {
+ char this_name[INP_NAME_MAX];
+ ISAMH_P isamh_p, isamh_p2;
+ char *dict_info;
+
+ strcpy (this_name, hci.cur_name);
+ assert (hci.cur_name[1]);
+ no_diffs++;
+ if ((dict_info = dict_lookup (hi->dict, hci.cur_name)))
+ {
+ memcpy (&isamh_p, dict_info+1, sizeof(ISAMH_P));
+ isamh_p2 = isamh_append (hi->isamh, isamh_p, isamh_i);
+ if (!isamh_p2)
+ {
+ no_deletions++;
+ if (!dict_delete (hi->dict, this_name))
+ abort();
+ }
+ else
+ {
+ no_updates++;
+ if (isamh_p2 != isamh_p)
+ dict_insert (hi->dict, this_name,
+ sizeof(ISAMH_P), &isamh_p2);
+ }
+ }
+ else
+ {
+ isamh_p = isamh_append (hi->isamh, 0, isamh_i);
+ no_insertions++;
+ dict_insert (hi->dict, this_name, sizeof(ISAMH_P), &isamh_p);
+ }
+ }
+ xfree (isamh_i);
+ return 0;
+}
+
+int heap_inpd (struct heap_info *hi)
+{
+ struct heap_cread_info hci;
+ ISAMD_I isamd_i = (ISAMD_I) xmalloc (sizeof(*isamd_i));
+
+ hci.key = (char *) xmalloc (KEY_SIZE);
+ hci.mode = 1;
+ hci.hi = hi;
+ hci.more = heap_read_one (hi, hci.cur_name, hci.key);
+
+ isamd_i->clientData = &hci;
+ isamd_i->read_item = heap_cread_item;
+
+ while (hci.more)
+ {
+ char this_name[INP_NAME_MAX];
+ ISAMD_P isamd_p, isamd_p2;
+ char *dict_info;
+
+ strcpy (this_name, hci.cur_name);
+ assert (hci.cur_name[1]);
+ no_diffs++;
+ if ((dict_info = dict_lookup (hi->dict, hci.cur_name)))
+ {
+ memcpy (&isamd_p, dict_info+1, sizeof(ISAMD_P));
+ isamd_p2 = isamd_append (hi->isamd, isamd_p, isamd_i);
+ if (!isamd_p2)
+ {
+ no_deletions++;
+ if (!dict_delete (hi->dict, this_name))
+ abort();
+ }
+ else
+ {
+ no_updates++;
+ if (isamd_p2 != isamd_p)
+ dict_insert (hi->dict, this_name,
+ sizeof(ISAMD_P), &isamd_p2);
+ }
+ }
+ else
+ {
+ isamd_p = isamd_append (hi->isamd, 0, isamd_i);
+ no_insertions++;
+ dict_insert (hi->dict, this_name, sizeof(ISAMD_P), &isamd_p);
+ }
+ }
+ xfree (isamd_i);
+ return 0;
+}
+
+
+
+
+int heap_inp (struct heap_info *hi)