2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
26 * $TOG: Sort.hh /main/6 1998/09/02 18:26:17 mgreess $
28 * RESTRICTED CONFIDENTIAL INFORMATION:
30 * The information in this document is subject to special
31 * restrictions in a confidential disclosure agreement between
32 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
33 * document outside HP, IBM, Sun, USL, SCO, or Univel without
34 * Sun's specific written approval. This document and all copies
35 * and derivative works thereof must be returned or destroyed at
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
46 #include <DtMail/DtMail.hh>
47 #include "FindDialog.h"
48 #include "MsgScrollingList.hh"
51 // What method to use to sort the message list.
63 // Used for sorting the mailbox.
71 // Sorts the array of message handles.
73 int sortMessages(MsgScrollingList *display_list,
74 DtMail::MailBox *mbox,
80 // This is the message record that is sorted (not returned). It
81 // is for internal use only and is never passed up to the calling
82 // public member functions.
84 // The variable 'link' is used to sort the array in place. After
85 // msort() (below) is called, the 'link' variable is set to the
86 // link-order (1,2,...,N). Un-like qsort(), msort() sorts in place
87 // and does not do memcpy(), msort() - updates the 'link' variable.
90 struct messageRecord {
91 int link; // Needed by msort(). (see source).
92 char *primary_key_str;
94 int secondary_key_int;
95 MsgStruct *msg_struct;
99 // Similar to qsort().
101 int _msort(char * base, // Base of array.
102 int nel, // Number of elements in array.
103 int width, // Size of each element.
104 int offset, // Offset to'link'(see source).
107 int (*compar)(char ** one, char ** two));
110 // This is the function that msort() calls to compare two records.
112 static int _sortCmp(char **one, char **two);