e5c1605e936fdb901b946661d8652c0ec12f8c69
[oweals/cde.git] / cde / programs / dtmail / dtmail / MsgHndArray.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /*
24  *+SNOTICE
25  *
26  *      $TOG: MsgHndArray.hh /main/9 1998/09/02 15:54:58 mgreess $
27  *
28  *      RESTRICTED CONFIDENTIAL INFORMATION:
29  *      
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
36  *      Sun's request.
37  *
38  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
39  *
40  *+ENOTICE
41  */
42
43 #ifndef _MSGHNDARRAY_HH
44 #define _MSGHNDARRAY_HH
45
46 #include <stdlib.h>
47 #include <string.h>
48 #if defined(USL) && (OSMAJORVERSION == 2)
49 extern "C" {
50 #endif
51 #if defined(USL) && (OSMAJORVERSION == 2)
52 };
53 #endif
54 #include <DtMail/DtMail.hh>
55
56 class MsgStruct {
57   public:
58     MsgStruct() : indexNumber(0), sessionNumber(0), message_handle(NULL), is_deleted(false) {};
59     ~MsgStruct() {};
60     
61     int indexNumber;
62     int sessionNumber;
63     DtMailMessageHandle message_handle;
64     Boolean is_deleted;
65 };
66
67 class MsgHndArray {
68   protected:
69     int _size;
70     MsgStruct **_contents;
71     int _length;
72
73   public:
74     MsgHndArray(int sz = 1024, int zeroed = 1)
75       {
76           _contents = (MsgStruct**) malloc(sizeof(MsgStruct*)*sz);
77           _size = sz;
78           if (zeroed) memset(_contents, 0, sizeof(MsgStruct *)*sz);
79
80           _length = 0;
81
82       }
83
84     ~MsgHndArray()
85       {
86 //        for (int ent = 0; ent < _length; ent++) {
87 //            delete _contents[ent];
88 //        }
89
90           free((void*) _contents);
91       }
92
93     int         length();
94     MsgStruct*  at(int a_number);
95     int         insert(MsgStruct* a_msg_struct);
96     void        clear();
97     int         indexof(MsgStruct* a_msg_struct);
98     int         indexof(DtMailMessageHandle a_msg_handle);
99     void        remove_entry(int position);
100     void        remove_entry(MsgStruct *ms);
101     void        append(MsgStruct *a_msg_struct);
102     void        mark_for_delete(int position);
103     void        compact(int start_pos);
104     void        replace(int postition, MsgStruct *a_msg_struct);
105 };
106
107 #endif
108     
109