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: olias_funcs.cc /main/5 1996/07/18 14:48:42 drk $
26 * Copyright (c) 1992 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.
51 #include "oliasdb/olias_funcs.h"
52 #include "oliasdb/asciiIn_filters.h"
53 #include "oliasdb/olias_consts.h"
54 #include "oliasdb/node_hd.h"
55 #include "oliasdb/doc_hd.h"
56 #include "oliasdb/dlp_hd.h"
60 #define BB_STRING "%%BoundingBox:"
61 int bb_string_leng = strlen(BB_STRING);
65 /////////////////////////////////////////////////
66 // load sgml node data. This will cluster them.
67 /////////////////////////////////////////////////
69 //extern char base_str[PATHSIZ];
73 c_code_t instance_class_code;
74 handler* collection_hd;
77 struct map_record set_map[]=
79 {(char*)"loc", LOCATOR_CODE, 0},
80 {(char*)"toc", TOC_CODE, 0 },
81 {(char*)"doc", DOC_CODE, 0 },
82 {(char*)"graphic", GRAPHIC_CODE, 0 },
83 // {(char*)"stylesheet", STYLESHEET_CODE, 0 },
86 struct map_record list_map[]=
88 {(char*)"dlp", DLP_CODE, 0},
91 //#define SET_MAP_SZ 5
95 /////////////////////////////////////////////////
96 // load mixed stream of infobase data from stdin.
97 /////////////////////////////////////////////////
98 void insert_to_collection(c_code_t ccode, istream& in)
100 enum coll_type { VOID, SET, LIST };
102 coll_type obj_type = VOID;
104 abs_storage* store = 0;
108 for ( i = 0; i<SET_MAP_SZ ; i++ ) {
109 if ( set_map[i].instance_class_code == ccode ) {
111 store = set_map[i].collection_hd -> its_store();
112 // hd = set_map[i].collection_hd;
117 if ( obj_type == VOID )
118 for ( i = 0; i<LIST_MAP_SZ ; i++ ) {
119 if ( list_map[i].instance_class_code == ccode ) {
121 store = list_map[i].collection_hd -> its_store();
122 // hd = set_map[i].collection_hd;
128 throw(stringException(form("unknown class code %d", ccode)));
131 handler* root_hd_ptr = new handler(ccode, store);
133 (*root_hd_ptr) ->asciiIn(in);
134 root_hd_ptr -> commit();
136 switch ( obj_type ) {
138 (*(cset_handlerPtr)(set_map[i].collection_hd)) ->
139 insert_object(*root_hd_ptr);
142 (*(dl_list_handlerPtr)(list_map[i].collection_hd)) ->
143 insert_as_tail(*(dl_list_cell_handler*)root_hd_ptr);
146 cerr << "bad ccode = " << ccode << "\n";
147 throw(stringException("bad ccode"));
154 static char locator[LBUFSIZ];
156 void sgml_content_load(info_base* x, istream& in)
158 in.getline(locator, LBUFSIZ);
160 char* locator_string = strchr(locator, '\t') + 1;
161 if ( locator_string == (char*)1 )
162 throw(formatException("bad sgml data format"));
164 node_smart_ptr y(x, locator_string);
166 if ( y.update_data(in) == false )
167 throw(formatException("can't update sgml data"));
171 void _connectNodeToDoc(info_base* x_base);
173 int _load_mixed_objects_from_cin(info_base* base_ptr)
175 return _load_mixed_objects(base_ptr, cin);
178 int _load_mixed_objects(info_base* base_ptr, istream& in)
181 for ( i = 0; i<SET_MAP_SZ ; i++ ) {
182 cset_handlerPtr x = base_ptr -> get_set(set_map[i].col_name);
185 throw(stringException("null cset_handler pointer"));
187 (*x) -> batch_index_begin();
188 set_map[i].collection_hd = x;
191 for ( i = 0; i<LIST_MAP_SZ ; i++ ) {
192 dl_list_handlerPtr x = base_ptr -> get_list(list_map[i].col_name);
195 throw(stringException("null cset_handler pointer"));
197 (*x) -> batch_index_begin();
198 list_map[i].collection_hd = x;
202 char ccode_buf[LBUFSIZ];
205 while ( in.getline(ccode_buf, LBUFSIZ) ) {
206 sscanf(ccode_buf, "%u", &ccode);
207 //debug(cerr, ccode);
209 if ( ccode == SGML_CONTENT_CODE )
210 sgml_content_load(base_ptr, in);
212 insert_to_collection(ccode, in);
215 for ( i = 0; i<SET_MAP_SZ ; i++ ) {
216 cset_handlerPtr x = (cset_handlerPtr)(set_map[i].collection_hd);
217 (*x) -> batch_index_end();
220 for ( i = 0; i<LIST_MAP_SZ ; i++ ) {
221 dl_list_handlerPtr x = (dl_list_handlerPtr)(list_map[i].collection_hd);
222 (*x) -> batch_index_end();
228 int load_mixed_objects_from_cin(info_base* base_ptr)
230 return load_mixed_objects(base_ptr, cin);
233 int load_mixed_objects(info_base* base_ptr, istream& in)
235 _load_mixed_objects(base_ptr, in);
236 _connectNodeToDoc(base_ptr);
240 void _connectNodeToDoc(info_base* x_base)
242 int docs = x_base -> num_of_docs();
244 doc_smart_ptr* doc = 0;
246 node_smart_ptr* first_node = 0, *node = 0;
247 dlp_smart_ptr* x = 0, *dlp_cell = 0;
249 for ( int i=0; i<docs; i++ ) {
250 doc = new doc_smart_ptr(x_base, i+1);
252 debug(cerr, doc -> its_oid());
253 debug(cerr, doc -> long_title());
256 first_node = new node_smart_ptr(x_base, doc -> locator_id());
258 dlp_cell = new dlp_smart_ptr(x_base, first_node -> its_oid());
263 //debug(cerr, dlp_cell -> node_id());
265 node = new node_smart_ptr(x_base, dlp_cell -> node_id());
266 //debug(cerr, node -> doc_id());
267 node -> update_doc_id(doc -> its_oid());
268 //debug(cerr, node -> doc_id());
271 x = dlp_cell -> next();
284 void connectNodeToDoc(info_lib* x_lib)
287 throw(stringException("connectNodeToDoc: can't find infolib"));
289 info_base* x_base = 0;
291 long ind = x_lib -> first();
294 x_base = (*x_lib)(ind);
297 throw(stringException("connectNodeToDoc: null base pointer"));
299 _connectNodeToDoc(x_base);