-fpermissive to allow GCC to compile old C++
[oweals/cde.git] / cde / programs / dtmail / dtmail / MsgHndArray.hh
1 /*
2  *+SNOTICE
3  *
4  *      $TOG: MsgHndArray.hh /main/9 1998/09/02 15:54:58 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 _MSGHNDARRAY_HH
22 #define _MSGHNDARRAY_HH
23
24 #include <stdlib.h>
25 #include <string.h>
26 #if defined(USL) && (OSMAJORVERSION == 2)
27 extern "C" {
28 #endif
29 #include <malloc.h>
30 #if defined(USL) && (OSMAJORVERSION == 2)
31 };
32 #endif
33 #include <DtMail/DtMail.hh>
34
35 class MsgStruct {
36   public:
37     MsgStruct() {};
38     ~MsgStruct() {};
39     
40     int indexNumber;
41     int sessionNumber;
42     DtMailMessageHandle message_handle;
43     Boolean is_deleted;
44 };
45
46 class MsgHndArray {
47   protected:
48     int _size;
49     MsgStruct **_contents;
50     int _length;
51
52   public:
53     MsgHndArray(int sz = 1024, int zeroed = 1)
54       {
55           _contents = (MsgStruct**) malloc(sizeof(MsgStruct*)*sz);
56           _size = sz;
57           if (zeroed) memset(_contents, 0, sizeof(MsgStruct *)*sz);
58
59           _length = 0;
60
61       }
62
63     ~MsgHndArray()
64       {
65 //        for (int ent = 0; ent < _length; ent++) {
66 //            delete _contents[ent];
67 //        }
68
69           free((void*) _contents);
70       }
71
72     int         length();
73     MsgStruct*  at(int a_number);
74     int         insert(MsgStruct* a_msg_struct);
75     void        clear();
76     int         indexof(MsgStruct* a_msg_struct);
77     int         indexof(DtMailMessageHandle a_msg_handle);
78     void        remove_entry(int position);
79     void        remove_entry(MsgStruct *ms);
80     void        append(MsgStruct *a_msg_struct);
81     void        mark_for_delete(int position);
82     void        compact(int start_pos);
83     void        replace(int postition, MsgStruct *a_msg_struct);
84 };
85
86 #endif
87     
88