+
+/* store a value in the binary tree */
+void seenit_store(struct seenit **si, long msgnum) {
+ struct seenit *this_si;
+
+ if (*si == NULL) { /* store now */
+ *si = malloc(sizeof(struct seenit));
+ this_si = *si;
+ this_si->l = NULL;
+ this_si->r = NULL;
+ this_si->msgnum = msgnum;
+ return;
+ }
+
+ this_si = *si;
+ if (msgnum < this_si->msgnum) {
+ seenit_store(&this_si->l, msgnum);
+ }
+ else if (msgnum > this_si->msgnum) {
+ seenit_store(&this_si->r, msgnum);
+ }
+ else {
+ return;
+ }
+}
+
+
+/* search for a value in the binary tree */
+int seenit_isthere(struct seenit *si, long msgnum) {
+ if (!si) return(0); /* not there */
+ if (msgnum < si->msgnum) return(seenit_isthere(si->l, msgnum));
+ if (msgnum > si->msgnum) return(seenit_isthere(si->r, msgnum));
+ return(1); /* found it */
+}
+
+
+/* free the binary tree */
+void seenit_free(struct seenit **si) {
+ struct seenit *this_si = *si;
+ if (!this_si) return;
+ seenit_free(&this_si->l);
+ seenit_free(&this_si->r);
+ free(this_si);
+ *si = NULL;
+}
+
+
+
+
+