Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / mgrs / misc.C
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 librararies 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  * $XConsortium: misc.cc /main/4 1996/07/18 14:39:26 drk $
25  *
26  * Copyright (c) 1993 HAL Computer Systems International, Ltd.
27  * All rights reserved.  Unpublished -- rights reserved under
28  * the Copyright Laws of the United States.  USE OF A COPYRIGHT
29  * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
30  * OR DISCLOSURE.
31  * 
32  * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33  * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.  USE,
34  * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35  * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
36  * INTERNATIONAL, LTD.
37  * 
38  *                         RESTRICTED RIGHTS LEGEND
39  * Use, duplication, or disclosure by the Government is subject
40  * to the restrictions as set forth in subparagraph (c)(l)(ii)
41  * of the Rights in Technical Data and Computer Software clause
42  * at DFARS 252.227-7013.
43  *
44  *          HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
45  *                  1315 Dell Avenue
46  *                  Campbell, CA  95008
47  * 
48  */
49
50
51 #include "mgrs/misc.h"
52
53 Boolean name_oid_ls(const void* o1, const void* o2)
54 {
55    name_oid_t *x = (name_oid_t*)o1;
56    name_oid_t *y = (name_oid_t*)o2;
57
58 /*
59 MESSAGE(cerr, "in name_oid_ls");
60 debug(cerr, x -> v_name);
61 debug(cerr, y -> v_name);
62 */
63
64
65    return ( x -> v_name.string_LS(y -> v_name) );
66 }
67
68 Boolean name_oid_eq(const void* o1, const void* o2)
69 {
70    name_oid_t *x = (name_oid_t*)o1;
71    name_oid_t *y = (name_oid_t*)o2;
72
73 /*
74 MESSAGE(cerr, "in name_oid_eq");
75 debug(cerr, x -> v_name);
76 debug(cerr, y -> v_name);
77 */
78    return ( x -> v_name.string_EQ(y -> v_name) );
79 }
80
81 Boolean oid_ls(const void* o1, const void* o2)
82 {
83    const oid_t& x = ((handler*)o1) -> its_oid();
84    const oid_t& y = ((handler*)o2) -> its_oid();
85
86 /*
87 MESSAGE(cerr, "<<<<<<<<<<<<");
88 x.asciiOut(cerr); cerr << "\n";
89 y.asciiOut(cerr); cerr << "\n";
90 MESSAGE(cerr, "<<<<<<<<<<<<");
91 */
92
93    return x.ls(y);
94 }
95
96 Boolean oid_eq(const void* o1, const void* o2)
97 {
98    const oid_t& x = ((handler*)o1) -> its_oid();
99    const oid_t& y = ((handler*)o2) -> its_oid();
100
101 /*
102 MESSAGE(cerr, "==========");
103 x.asciiOut(cerr); cerr << "\n";
104 y.asciiOut(cerr); cerr << "\n";
105 MESSAGE(cerr, "==========");
106 */
107
108    return x.eq(y);
109 }
110
111 Boolean oid_storage_ls(const void* o1, const void* o2)
112 {
113    name_oid_t* x = (name_oid_t*)o1;
114    name_oid_t* y = (name_oid_t*)o2;
115
116    if ( x->v_oid.ls(y->v_oid) == true )
117       return true;
118
119  
120    if ( x->v_oid.eq(y->v_oid) == true )
121        if ( long(x->v_store) < long(y->v_store) )
122           return true;
123
124    return false;
125 }
126
127 Boolean oid_storage_eq(const void* o1, const void* o2)
128 {
129    name_oid_t* x = (name_oid_t*)o1;
130    name_oid_t* y = (name_oid_t*)o2;
131
132    return (x->v_oid.eq(y->v_oid) == true && x->v_store && y->v_store ) ? 
133           true : false;
134 }
135
136 void delete_name_oid_rec_f(const void* name_oid_ptr)
137 {
138    name_oid_t* x = (name_oid_t*)name_oid_ptr;
139 //debug(cerr, x -> v_name.get());
140    delete x;
141 }
142
143 // ***************************************************
144 //
145 //
146 // ***************************************************
147
148 mark_t::mark_t(char* marks) : ostring(strlen(marks))
149 {
150    set(marks);
151 }
152
153 istream& operator >>(istream& in, mark_t& m)
154 {
155    char c ;
156    char* ptr = m.get();
157    Boolean read_marks = false;
158
159    while ( in && in.get(c) ) {
160
161       if ( strchr(ptr, c) == NULL ) {
162          in.putback(c);
163          if ( read_marks == false ) {
164             debug(cerr, c); 
165             throw(formatException("bad mark to read"));
166          } 
167          return in;
168       } else {
169          read_marks = true;
170       }
171    }
172
173    return in;
174 }
175
176 ostream& operator <<(ostream& out, mark_t& m)
177 {
178    out << m.get();
179    return out ;
180 }
181