~ubuntu-branches/ubuntu/precise/mutt/precise

« back to all changes in this revision

Viewing changes to hcache.c

  • Committer: Package Import Robot
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy)
  • Date: 2010-12-17 14:28:28 UTC
  • mfrom: (16.2.3 experimental)
  • Revision ID: package-import@ubuntu.com-20101217142828-ve8yy0xf1zomtnx9
Tags: 1.5.21-1ubuntu1
* Merge with Debian experimental (LP: #691512), remaining changes:
  + debian/control, debian/patches/debian-specific/build_doc_adjustments.diff:
    Use w3m (main) instead of elinks (universe) for generating documentation.
  + Drop libtokyocabinet-dev (universe) from Build-Depends, use always
    libgdbm-dev and also use gdbm for the header cache backend. (lp: #607448)

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include "mx.h"
46
46
#include "lib.h"
47
47
#include "md5.h"
 
48
#include "rfc822.h"
48
49
 
49
50
#if HAVE_QDBM
50
51
static struct header_cache
85
86
typedef union
86
87
{
87
88
  struct timeval timeval;
88
 
  unsigned long uid_validity;
 
89
  unsigned int uidvalidity;
89
90
} validate;
90
91
 
91
92
static void *
231
232
 
232
233
  while (counter)
233
234
  {
234
 
    *a = safe_malloc(sizeof (ADDRESS));
 
235
    *a = rfc822_new_address();
235
236
#ifdef EXACT_ADDRESS
236
237
    restore_char(&(*a)->val, d, off, convert);
237
238
#endif
588
589
 * db_store */
589
590
static void *
590
591
mutt_hcache_dump(header_cache_t *h, HEADER * header, int *off,
591
 
                 unsigned long uid_validity)
 
592
                 unsigned int uidvalidity)
592
593
{
593
594
  unsigned char *d = NULL;
594
595
  HEADER nh;
597
598
  *off = 0;
598
599
  d = lazy_malloc(sizeof (validate));
599
600
 
600
 
  if (uid_validity)
601
 
    memcpy(d, &uid_validity, sizeof (unsigned long));
 
601
  if (uidvalidity)
 
602
    memcpy(d, &uidvalidity, sizeof (uidvalidity));
602
603
  else
603
604
  {
604
605
    struct timeval now;
623
624
  nh.limited = 0;
624
625
  nh.num_hidden = 0;
625
626
  nh.recipient = 0;
 
627
  nh.pair = 0;
626
628
  nh.attach_valid = 0;
627
629
  nh.path = NULL;
628
630
  nh.tree = NULL;
757
759
 
758
760
int
759
761
mutt_hcache_store(header_cache_t *h, const char *filename, HEADER * header,
760
 
                  unsigned long uid_validity,
 
762
                  unsigned int uidvalidity,
761
763
                  size_t(*keylen) (const char *fn))
762
764
{
763
765
  char* data;
767
769
  if (!h)
768
770
    return -1;
769
771
  
770
 
  data = mutt_hcache_dump(h, header, &dlen, uid_validity);
 
772
  data = mutt_hcache_dump(h, header, &dlen, uidvalidity);
771
773
  ret = mutt_hcache_store_raw (h, filename, data, dlen, keylen);
772
774
  
773
775
  FREE(&data);
828
830
#endif
829
831
}
830
832
 
831
 
static char* get_foldername(const char *folder) {
 
833
static char* get_foldername(const char *folder)
 
834
{
832
835
  char *p = NULL;
 
836
  char path[_POSIX_PATH_MAX];
833
837
  struct stat st;
834
838
 
 
839
  mutt_encode_path (path, sizeof (path), folder);
 
840
 
835
841
  /* if the folder is local, canonify the path to avoid
836
842
   * to ensure equivalent paths share the hcache */
837
 
  if (stat (folder, &st) == 0)
 
843
  if (stat (path, &st) == 0)
838
844
  {
839
845
    p = safe_malloc (PATH_MAX+1);
840
 
    if (!realpath (folder, p))
841
 
      mutt_str_replace (&p, folder);
 
846
    if (!realpath (path, p))
 
847
      mutt_str_replace (&p, path);
842
848
  } else
843
 
    p = safe_strdup (folder);
 
849
    p = safe_strdup (path);
844
850
 
845
851
  return p;
846
852
}