-fpermissive to allow GCC to compile old C++
[oweals/cde.git] / cde / programs / dtmail / dtmail / Sort.hh
1 /*
2  *+SNOTICE
3  *
4  *      $TOG: Sort.hh /main/6 1998/09/02 18:26:17 mgreess $
5  *
6  *      RESTRICTED CONFIDENTIAL INFORMATION:
7  *      
8  *      The information in this document is subject to special
9  *      restrictions in a confidential disclosure agreement between
10  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
11  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
12  *      Sun's specific written approval.  This document and all copies
13  *      and derivative works thereof must be returned or destroyed at
14  *      Sun's request.
15  *
16  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
17  *
18  *+ENOTICE
19  */
20
21 #ifndef SORT_HH
22 #define SORT_HH
23
24 #include <DtMail/DtMail.hh>
25 #include "FindDialog.h"
26 #include "MsgScrollingList.hh"
27
28 //
29 // What method to use to sort the message list.
30 //
31 typedef enum sortBy {
32     SortTimeDate = 1,
33     SortSender,
34     SortSubject,        
35     SortSize,
36     SortStatus,
37     SortMsgNum
38 } SortBy;
39
40 //
41 // Used for sorting the mailbox.
42 //
43 class Sort {
44
45 public:
46
47
48   //
49   // Sorts the array of message handles.
50   //
51   int sortMessages(MsgScrollingList     *display_list,
52                     DtMail::MailBox     *mbox,
53                     sortBy              howToSort);
54
55 private:
56
57   //
58   // This is the message record that is sorted (not returned). It
59   // is for internal use only and is never passed up to the calling
60   // public member functions.
61   //
62   // The variable 'link' is used to sort the array in place. After
63   // msort() (below) is called, the 'link' variable is set to the
64   // link-order (1,2,...,N). Un-like qsort(), msort() sorts in place
65   // and does not do memcpy(), msort() - updates the 'link' variable.
66   // 
67   
68   struct messageRecord {
69     int          link;          // Needed by msort(). (see source).
70     char        *primary_key_str;
71     int          primary_key_int;
72     int          secondary_key_int;
73     MsgStruct   *msg_struct;
74   };
75
76   //
77   // Similar to qsort().
78   //
79   int   _msort(char             * base,         // Base of array.
80                int                nel,          // Number of elements in array.
81                int                width,        // Size of each element.
82                int                offset,       // Offset to'link'(see source).
83
84                // Compare function.
85                int              (*compar)(char ** one, char ** two));
86
87   //
88   // This is the function that msort() calls to compare two records.
89   //
90   static int    _sortCmp(char **one, char **two);
91 };
92
93 #endif // SORT_HH