~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to pith/msgno.h

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2007-02-17 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20070217131742-99x5c6cpg1pbkdhw
Tags: upstream-0.82+dfsg
ImportĀ upstreamĀ versionĀ 0.82+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: msgno.h 136 2006-09-22 20:06:05Z hubert@u.washington.edu $
 
3
 *
 
4
 * ========================================================================
 
5
 * Copyright 2006 University of Washington
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * ========================================================================
 
14
 */
 
15
 
 
16
#ifndef PITH_MSGNO_INCLUDED
 
17
#define PITH_MSGNO_INCLUDED
 
18
 
 
19
 
 
20
#include "../pith/sorttype.h"
 
21
 
 
22
 
 
23
/*
 
24
 * Macros to support anything you'd ever want to do with a message
 
25
 * number...
 
26
 */
 
27
#define mn_init(P, m)           msgno_init((P), (m), \
 
28
                                           ps_global->def_sort, ps_global->def_sort_rev)
 
29
 
 
30
#define mn_get_cur(p)           (((p) && (p)->select)                         \
 
31
                                  ? (p)->select[(p)->sel_cur] : -1)
 
32
 
 
33
#define mn_set_cur(p, m)        do{                                           \
 
34
                                  if(p){                                      \
 
35
                                    (p)->select[(p)->sel_cur] = (m);          \
 
36
                                  }                                           \
 
37
                                }while(0)
 
38
 
 
39
#define mn_inc_cur(s, p, f)     msgno_inc(s, p, f)
 
40
 
 
41
#define mn_dec_cur(s, p, f)     msgno_dec(s, p, f)
 
42
 
 
43
#define mn_add_cur(p, m)        do{                                           \
 
44
                                  if(p){                                      \
 
45
                                      if((p)->sel_cnt+1L > (p)->sel_size){    \
 
46
                                          (p)->sel_size += 10L;               \
 
47
                                          fs_resize((void **)&((p)->select),  \
 
48
                                                    (size_t)(p)->sel_size     \
 
49
                                                             * sizeof(long)); \
 
50
                                      }                                       \
 
51
                                      (p)->select[((p)->sel_cnt)++] = (m);    \
 
52
                                  }                                           \
 
53
                                }while(0)
 
54
 
 
55
#define mn_total_cur(p)         ((p) ? (p)->sel_cnt : 0L)
 
56
 
 
57
#define mn_first_cur(p)         (((p) && (p)->sel_cnt > 0L)                   \
 
58
                                  ? (p)->select[(p)->sel_cur = 0] : 0L)
 
59
 
 
60
#define mn_next_cur(p)          (((p) && ((p)->sel_cur + 1) < (p)->sel_cnt)   \
 
61
                                  ? (p)->select[++((p)->sel_cur)] : -1L)
 
62
 
 
63
#define mn_is_cur(p, m)         msgno_in_select((p), (m))
 
64
 
 
65
#define mn_reset_cur(p, m)      do{                                           \
 
66
                                  if(p){                                      \
 
67
                                      (p)->sel_cur  = 0L;                     \
 
68
                                      (p)->sel_cnt  = 1L;                     \
 
69
                                      (p)->sel_size = 8L;                     \
 
70
                                      fs_resize((void **)&((p)->select),      \
 
71
                                        (size_t)(p)->sel_size * sizeof(long));\
 
72
                                      (p)->select[0] = (m);                   \
 
73
                                  }                                           \
 
74
                                }while(0)
 
75
 
 
76
#define mn_m2raw(p, m)          (((p) && (p)->sort && (m) > 0                 \
 
77
                                  && (m) <= mn_get_total(p))                  \
 
78
                                   ? (p)->sort[m] : 0L)
 
79
 
 
80
#define mn_raw2m(p, m)          (((p) && (p)->isort && (m) > 0                \
 
81
                                  && (m) <= mn_get_nmsgs(p))                  \
 
82
                                   ? (p)->isort[m] : 0L)
 
83
 
 
84
#define mn_get_total(p)         ((p) ? (p)->max_msgno : 0L)
 
85
 
 
86
#define mn_set_total(p, m)      do{ if(p) (p)->max_msgno = (m); }while(0)
 
87
 
 
88
#define mn_get_nmsgs(p)         ((p) ? (p)->nmsgs : 0L)
 
89
 
 
90
#define mn_set_nmsgs(p, m)      do{ if(p) (p)->nmsgs = (m); }while(0)
 
91
 
 
92
#define mn_add_raw(p, m)        msgno_add_raw((p), (m))
 
93
 
 
94
#define mn_flush_raw(p, m)      msgno_flush_raw((p), (m))
 
95
 
 
96
#define mn_get_sort(p)          ((p) ? (p)->sort_order : SortArrival)
 
97
 
 
98
#define mn_set_sort(p, t)       msgno_set_sort((p), (t))
 
99
 
 
100
#define mn_get_revsort(p)       ((p) ? (p)->reverse_sort : 0)
 
101
 
 
102
#define mn_set_revsort(p, t)    do{                                           \
 
103
                                  if(p)                                       \
 
104
                                    (p)->reverse_sort = (t);                  \
 
105
                                }while(0)
 
106
 
 
107
#define mn_get_mansort(p)       ((p) ? (p)->manual_sort : 0)
 
108
 
 
109
#define mn_set_mansort(p, t)    do{                                           \
 
110
                                  if(p)                                       \
 
111
                                    (p)->manual_sort = (t);                   \
 
112
                                }while(0)
 
113
 
 
114
#define mn_give(P)              msgno_give(P)
 
115
 
 
116
 
 
117
/*
 
118
 * This is *the* struct that keeps track of the pine message number to
 
119
 * raw c-client sequence number mappings.  The mapping is necessary
 
120
 * because pine may re-sort or even hide (exclude) c-client numbers
 
121
 * from the displayed list of messages.  See mailindx.c:msgno_* and
 
122
 * the mn_* macros above for how this things gets used.  See
 
123
 * mailcmd.c:pseudo_selected for an explanation of the funny business
 
124
 * going on with the "hilited" field...
 
125
 */
 
126
typedef struct msg_nos {
 
127
    long      *select,                          /* selected message array  */
 
128
               sel_cur,                         /* current interesting msg */
 
129
               sel_cnt,                         /* its size                */
 
130
               sel_size,                        /* its size                */
 
131
              *sort,                            /* sorted array of msgno's */
 
132
               sort_size,                       /* its size                */
 
133
              *isort,                           /* inverse of sort array   */
 
134
               isort_size,                      /* its size                */
 
135
               max_msgno,                       /* total messages in table */
 
136
               nmsgs,                           /* total msgs in folder    */
 
137
               hilited,                         /* holder for "current" msg*/
 
138
               top,                             /* message at top of screen*/
 
139
               max_thrdno,
 
140
               top_after_thrd;                  /* top after thrd view     */
 
141
    SortOrder  sort_order;                      /* list's current sort     */
 
142
    unsigned   reverse_sort:1;                  /* whether that's reversed */
 
143
    unsigned   manual_sort:1;                   /* sorted with $ command   */
 
144
    long       flagged_hid,                     /* hidden count            */
 
145
               flagged_exld,                    /* excluded count          */
 
146
               flagged_coll,                    /* collapsed count         */
 
147
               flagged_chid,                    /* collapsed-hidden count  */
 
148
               flagged_chid2,                   /* */
 
149
               flagged_usor,                    /* new unsorted mail       */
 
150
               flagged_tmp,                     /* tmp flagged count       */
 
151
               flagged_stmp,                    /* stmp flagged count      */
 
152
               flagged_invisible,               /* this one's different    */
 
153
               visible_threads;                 /* so is this one          */
 
154
} MSGNO_S;
 
155
 
 
156
 
 
157
#define MSG_EX_DELETE     0x0001        /* part is deleted */
 
158
#define MSG_EX_RECENT     0x0002
 
159
#define MSG_EX_TESTED     0x0004        /* filtering has been run on this msg */
 
160
#define MSG_EX_FILTERED   0x0008        /* msg has actually been filtered away*/
 
161
#define MSG_EX_FILED      0x0010        /* msg has been filed */
 
162
#define MSG_EX_FILTONCE   0x0020
 
163
#define MSG_EX_FILEONCE   0x0040        /* These last two mean that the
 
164
                                           message has been filtered or filed
 
165
                                           already but the filter rule was
 
166
                                           non-terminating so it is still
 
167
                                           possible it will get filtered
 
168
                                           again. When we're done, we flip
 
169
                                           these two to EX_FILTERED and
 
170
                                           EX_FILED, the permanent versions. */
 
171
#define MSG_EX_PEND_EXLD  0x0080        /* pending exclusion */
 
172
#define MSG_EX_MANUNDEL   0x0100        /* has been manually undeleted */
 
173
#define MSG_EX_STATECHG   0x0200        /* state change since filtering */
 
174
 
 
175
/* msgno_include flags */
 
176
#define MI_NONE         0x00
 
177
#define MI_REFILTERING  0x01
 
178
#define MI_STATECHGONLY 0x02
 
179
#define MI_CLOSING      0x04
 
180
 
 
181
 
 
182
/* exported protoypes */
 
183
void        msgno_init(MSGNO_S **, long, SortOrder, int);
 
184
void        msgno_reset_isort(MSGNO_S *);
 
185
void        msgno_give(MSGNO_S **);
 
186
void        msgno_inc(MAILSTREAM *, MSGNO_S *, int);
 
187
void        msgno_dec(MAILSTREAM *, MSGNO_S *, int);
 
188
void        msgno_exclude_deleted(MAILSTREAM *, MSGNO_S *);
 
189
void        msgno_exclude(MAILSTREAM *, MSGNO_S *, long, int);
 
190
int         msgno_include(MAILSTREAM *, MSGNO_S *, int);
 
191
void        msgno_add_raw(MSGNO_S *, long);
 
192
void        msgno_flush_raw(MSGNO_S *, long);
 
193
void        msgno_flush_selected(MSGNO_S *, long);
 
194
void        msgno_set_sort(MSGNO_S *, SortOrder);
 
195
int         msgno_in_select(MSGNO_S *, long);
 
196
int         msgno_exceptions(MAILSTREAM *, long, char *, int *, int);
 
197
int         msgno_any_deletedparts(MAILSTREAM *, MSGNO_S *);
 
198
int         msgno_part_deleted(MAILSTREAM *, long, char *);
 
199
long        get_msg_score(MAILSTREAM *, long);
 
200
void        clear_msg_score(MAILSTREAM *, long);
 
201
void        clear_folder_scores(MAILSTREAM *);
 
202
int         calculate_some_scores(MAILSTREAM *, SEARCHSET *, int);
 
203
void        free_pine_elt(void **);
 
204
 
 
205
 
 
206
#endif /* PITH_MSGNO_INCLUDED */