remove antiquated cruft: please, who use MMDF's nowadays ?!
[apps/madmutt.git] / lib-mx / mh.c
index c3b671b..7c2f7e2 100644 (file)
@@ -86,19 +86,6 @@ static short mhs_set (struct mh_sequences *mhs, int i, short f)
   return mhs->flags[i];
 }
 
-#if 0
-
-/* unused */
-
-static short mhs_unset (struct mh_sequences *mhs, int i, short f)
-{
-  mhs_alloc (mhs, i);
-  mhs->flags[i] &= ~f;
-  return mhs->flags[i];
-}
-
-#endif
-
 static void mh_read_token (char *t, int *first, int *last)
 {
   char *p;
@@ -177,7 +164,7 @@ static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
 
   for (;;) {
     snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%d",
-              dest->path, NONULL (Hostname), (int) getpid (), Counter++);
+              dest->path, NONULL(MCore.shorthost), (int) getpid (), Counter++);
     umask (Umask);
     if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
       if (errno != EEXIST) {
@@ -743,7 +730,7 @@ static void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md)
   int count;
 
 #ifdef USE_HCACHE
-  void *hc = NULL;
+  hcache_t *hc = NULL;
   void *data;
   struct timeval *when = NULL;
   struct stat lastchanged;
@@ -766,19 +753,11 @@ static void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md)
     snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path);
 
 #ifdef USE_HCACHE
-    if (option (OPTHCACHEVERIFY)) {
-      ret = stat (fn, &lastchanged);
-    }
-    else {
-      lastchanged.st_mtime = 0;
-      ret = 0;
-    }
-
-    if (data != NULL && !ret && lastchanged.st_mtime <= when->tv_sec) {
-      p->h = mutt_hcache_restore ((unsigned char *) data, &p->h);
+    ret = stat(fn, &lastchanged);
+    if (data && !ret && lastchanged.st_mtime <= when->tv_sec) {
+      p->h = mutt_hcache_restore(data, &p->h);
       maildir_parse_flags (p->h, fn);
-    }
-    else
+    } else
 #endif
     if (maildir_parse_message (ctx->magic, fn, p->h->old, p->h)) {
       p->header_parsed = 1;
@@ -786,15 +765,15 @@ static void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md)
 #ifdef USE_HCACHE
       mutt_hcache_store (hc, p->h->path + 3, p->h, 0, &maildir_hcache_keylen);
 #endif
-    }
-    else
+    } else {
       header_delete(&p->h);
+    }
 #ifdef USE_HCACHE
     p_delete(&data);
 #endif
   }
 #ifdef USE_HCACHE
-  mutt_hcache_close (hc);
+  mutt_hcache_close (&hc);
 #endif
 }
 
@@ -932,7 +911,7 @@ static int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr
   for (;;) {
     snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%u_%d.%s%s",
               dest->path, subdir, (long) time (NULL),
-              (unsigned int) getpid (), Counter++, NONULL (Hostname), suffix);
+              (unsigned int) getpid (), Counter++, NONULL (MCore.shorthost), suffix);
 
     umask (Umask);
     if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
@@ -1005,7 +984,7 @@ static int maildir_commit_message (MESSAGE * msg, CONTEXT * ctx, HEADER * hdr)
   for (;;) {
     snprintf (path, _POSIX_PATH_MAX, "%s/%ld.%u_%d.%s%s", subdir,
               (long) time (NULL), (unsigned int) getpid (), Counter++,
-              NONULL (Hostname), suffix);
+              NONULL (MCore.shorthost), suffix);
     snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path);
 
     if (safe_rename (msg->path, full) == 0) {
@@ -1444,7 +1423,7 @@ static int maildir_check_mailbox (CONTEXT * ctx, int *index_hint, int unused __a
   struct maildir *md;           /* list of messages in the mailbox */
   struct maildir **last, *p;
   int i;
-  HASH *fnames;                 /* hash table for quickly looking up the base filename
+  hash_t *fnames;                 /* hash table for quickly looking up the base filename
                                    for a maildir message */
 
   if (!option (OPTCHECKNEW))
@@ -1485,12 +1464,12 @@ static int maildir_check_mailbox (CONTEXT * ctx, int *index_hint, int unused __a
    * of each message we scanned.  This is used in the loop over the
    * existing messages below to do some correlation.
    */
-  fnames = hash_create (1031);
+  fnames = hash_new (1031, 0);
 
   for (p = md; p; p = p->next) {
     maildir_canon_filename (buf, p->h->path, sizeof (buf));
     p->canon_fname = m_strdup(buf);
-    hash_insert (fnames, p->canon_fname, p, 0);
+    hash_insert (fnames, p->canon_fname, p);
   }
 
   /* check for modifications and adjust flags */
@@ -1543,7 +1522,7 @@ static int maildir_check_mailbox (CONTEXT * ctx, int *index_hint, int unused __a
   }
 
   /* destroy the file name hash */
-  hash_destroy (&fnames, NULL);
+  hash_delete (&fnames, NULL);
 
   /* If we didn't just get new mail, update the tables. */
   if (occult)
@@ -1577,7 +1556,7 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint, int unused __attrib
   struct maildir *md, *p;
   struct maildir **last = NULL;
   struct mh_sequences mhs;
-  HASH *fnames;
+  hash_t *fnames;
   int i;
 
   if (!option (OPTCHECKNEW))
@@ -1623,10 +1602,10 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint, int unused __attrib
   mhs_free_sequences (&mhs);
 
   /* check for modifications and adjust flags */
-  fnames = hash_create (1031);
+  fnames = hash_new (1031, 0);
 
   for (p = md; p; p = p->next)
-    hash_insert (fnames, p->h->path, p, 0);
+    hash_insert (fnames, p->h->path, p);
 
   for (i = 0; i < ctx->msgcount; i++) {
     ctx->hdrs[i]->active = 0;
@@ -1646,7 +1625,7 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint, int unused __attrib
 
   /* destroy the file name hash */
 
-  hash_destroy (&fnames, NULL);
+  hash_delete (&fnames, NULL);
 
   /* If we didn't just get new mail, update the tables. */
   if (occult)
@@ -1693,7 +1672,7 @@ static FILE *_maildir_open_find_message (const char *folder, const char *unique,
     if (!m_strcmp(tunique, unique)) {
       snprintf (fname, sizeof (fname), "%s/%s/%s", folder, subfolder,
                 de->d_name);
-      fp = fopen (fname, "r");  /* __FOPEN_CHECKED__ */
+      fp = fopen(fname, "r");
       oe = errno;
       break;
     }