dthelp: Change to ANSI function definitions
[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 #include <DtMail/DtMail.hh>
49
50 class MsgStruct {
51   public:
52     MsgStruct() : indexNumber(0), sessionNumber(0), message_handle(NULL), is_deleted(false) {};
53     ~MsgStruct() {};
54     
55     int indexNumber;
56     int sessionNumber;
57     DtMailMessageHandle message_handle;
58     Boolean is_deleted;
59 };
60
61 class MsgHndArray {
62   protected:
63     int _size;
64     MsgStruct **_contents;
65     int _length;
66
67   public:
68     MsgHndArray(int sz = 1024, int zeroed = 1)
69       {
70           _contents = (MsgStruct**) malloc(sizeof(MsgStruct*)*sz);
71           _size = sz;
72           if (zeroed) memset(_contents, 0, sizeof(MsgStruct *)*sz);
73
74           _length = 0;
75
76       }
77
78     ~MsgHndArray()
79       {
80 //        for (int ent = 0; ent < _length; ent++) {
81 //            delete _contents[ent];
82 //        }
83
84           free((void*) _contents);
85       }
86
87     int         length();
88     MsgStruct*  at(int a_number);
89     int         insert(MsgStruct* a_msg_struct);
90     void        clear();
91     int         indexof(MsgStruct* a_msg_struct);
92     int         indexof(DtMailMessageHandle a_msg_handle);
93     void        remove_entry(int position);
94     void        remove_entry(MsgStruct *ms);
95     void        append(MsgStruct *a_msg_struct);
96     void        mark_for_delete(int position);
97     void        compact(int start_pos);
98     void        replace(int postition, MsgStruct *a_msg_struct);
99 };
100
101 #endif
102     
103