* Create help for explaining how encrypted password file support
[alpine.git] / pith / search.c
blob23e2f353a0d4817d2c94b6ee9da38a1566a4dd4d
1 #if !defined(lint) && !defined(DOS)
2 static char rcsid[] = "$Id: search.c 854 2007-12-07 17:44:43Z hubert@u.washington.edu $";
3 #endif
5 /*
6 * ========================================================================
7 * Copyright 2006 University of Washington
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * ========================================================================
18 #include "../pith/headers.h"
19 #include "../pith/search.h"
22 SEARCHSET *
23 build_searchset(MAILSTREAM *stream)
25 long i, run;
26 SEARCHSET *ret_s = NULL, **set;
27 MESSAGECACHE *mc;
29 if(!stream)
30 return(NULL);
32 for(i = 1L, set = &ret_s, run = 0L; i <= stream->nmsgs; i++){
33 if(!((mc = mail_elt(stream, i)) && mc->sequence)){ /* end of run */
34 if(run){ /* run in progress */
35 set = &(*set)->next;
36 run = 0L;
39 else if(run++){ /* next in run */
40 (*set)->last = i;
42 else{ /* start of new run */
43 *set = mail_newsearchset();
45 * Leave off (*set)->last until we get more than one msg
46 * in the run, to avoid 607:607 in SEARCH.
48 (*set)->first = (*set)->last = i;
52 return(ret_s);
56 int
57 in_searchset(SEARCHSET *srch, long unsigned int num)
59 SEARCHSET *s;
60 unsigned long i;
62 if(srch)
63 for(s = srch; s; s = s->next)
64 for(i = s->first; i <= s->last; i++){
65 if(i == num)
66 return 1;
69 return 0;