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 librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: MarkBase.cc /main/3 1996/06/11 16:29:11 cde-hal $
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
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
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.
44 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
62 static xList<MarkBase::open_func_t> *g_open_func_list;
63 static xList<MarkBase::mb_create_func_t> *g_create_func_list;
64 static xList<const char *> *g_create_format_list;
71 // /////////////////////////////////////////////////////////////////
72 // register a MarkBase creation function
73 // /////////////////////////////////////////////////////////////////
76 MarkBase::register_open_func (open_func_t open_func)
78 ON_DEBUG (printf ("Registered MarkBase open func\n"));
79 static xList<open_func_t> open_func_list;
80 if (g_open_func_list == NULL)
81 g_open_func_list = &open_func_list;
83 open_func_list.append (open_func);
88 MarkBase::register_create_func (mb_create_func_t create_func, const char *format)
90 ON_DEBUG (printf ("Registered `%s' creation func\n", format));
91 static xList<mb_create_func_t> create_func_list;
92 static xList<const char *> create_format_list;
94 if (g_create_func_list == NULL)
96 g_create_func_list = &create_func_list;
97 g_create_format_list = &create_format_list;
100 create_func_list.append (create_func);
101 create_format_list.append (format);
106 // /////////////////////////////////////////////////////////////////
107 // create a new mark base by calling the registered functions
108 // /////////////////////////////////////////////////////////////////
111 MarkBase::open (const char *filename, bool read_only)
113 MarkBase *base = NULL;
114 List_Iterator<open_func_t> open_func (g_open_func_list);
118 base = open_func.item() (filename, read_only);
128 MarkBase::create (const char *filename, bool read_only, const char *format)
130 MarkBase *base = NULL;
131 List_Iterator<const char *> fmt (g_create_format_list);
132 List_Iterator<mb_create_func_t> create_func (g_create_func_list);
134 // Find a matching format creation function.
137 if (strcmp (fmt.item(), format) == 0)
143 // Create the base if a matching format was found.
145 base = create_func.item() (filename, read_only);