2 * $XConsortium: valBase.C /main/5 1996/10/29 21:14:58 cde-hal $
4 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
5 * All rights reserved. Unpublished -- rights reserved under
6 * the Copyright Laws of the United States. USE OF A COPYRIGHT
7 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
10 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
11 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
12 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
13 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
16 * RESTRICTED RIGHTS LEGEND
17 * Use, duplication, or disclosure by the Government is subject
18 * to the restrictions as set forth in subparagraph (c)(l)(ii)
19 * of the Rights in Technical Data and Computer Software clause
20 * at DFARS 252.227-7013.
22 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
34 #include "oliasdb/mmdb.h"
35 #include "oliasdb/asciiIn_filters.h"
43 #define DBG(level) if ( dbgLevel >= level )
45 #define DBG(level) if (0)
48 //------------------------------------------------
53 dbgStr = getenv("OL_DEBUG");
54 return ( dbgStr ? atoi ( dbgStr ) : 0 );
57 //------------------------------------------------
58 main(int argc, char **argv)
66 char checkVersionStr [ 16 ];
67 char installVersionStr [ 16 ];
75 cerr << "Usage : valBase checkBase installBase\n";
79 char *checkBaseStr = argv[1];
80 char *installBaseStr = argv[2];
82 DBG(10) cerr << "(DEBUG) checkBase = " << checkBaseStr << endl;
83 DBG(10) cerr << "(DEBUG) installBase = " << installBaseStr << endl;
85 // first construct the info_base ptr for installBase
87 InfoLib = mmdb_handle.openInfoLib(getenv("MMDB_PATH"));
88 assert ( InfoLib != NULL );
90 info_base *installBase = InfoLib->get_info_base ( installBaseStr );
92 throw(stringException("NULL infobase ptr for installation infobase"));
94 // construct the info_base ptr for checkBase
96 info_base *checkBase = InfoLib->get_info_base ( checkBaseStr );
98 throw(stringException("NULL infobase ptr for check infobase"));
100 // check the data version number
102 mm_version &checkVersion = checkBase->data_version();
103 short major_version_check = checkVersion.major_version();
104 short minor_version_check = checkVersion.minor_version();
106 sprintf ( checkVersionStr, "%d%d", major_version_check,
107 minor_version_check );
109 int checkVersionNum = atoi ( checkVersionStr );
111 DBG(10) cerr << "(DEBUG) checkBaseVersion = " << checkVersionNum << endl;
113 mm_version &installVersion = installBase->data_version();
114 short major_version_install = installVersion.major_version();
115 short minor_version_install = installVersion.minor_version();
117 sprintf ( installVersionStr, "%d%d", major_version_install,
118 minor_version_install );
119 int installVersionNum = atoi ( installVersionStr );
121 DBG(10) cerr << "(DEBUG) installVersionNum = " << installVersionNum << endl;
123 // Now perform the version checking
125 if ( installVersionNum == 10 ) {
126 if ( checkVersionNum >= 11 ) {
127 cerr << "(ERROR) Data version mismatch\n";
128 cerr << " " << checkBaseStr << " version = "
129 << major_version_check << "." << minor_version_check << endl;
130 cerr << " " << installBaseStr << " version = "
131 << major_version_install << "." << minor_version_install << endl;
135 else if ( checkVersionNum == 10 ) {
136 if ( installVersionNum >= 11 ) {
137 cerr << "(ERROR) Data version mismatch\n";
138 cerr << " " << checkBaseStr << " version = "
139 << major_version_check << "." << minor_version_check << endl;
140 cerr << " " << installBaseStr << " version = "
141 << major_version_install << "." << minor_version_install << endl;
146 // Now to check locators
148 iterator *it = checkBase->first(LOCATOR_SET_NAME, LOCATOR_CODE );
154 locator_smart_ptr x(checkBase, checkBase->get_oid(*it));
156 strcpy ( locatorStr, x.inside_node_locator_str() );
158 DBG(10) cerr << "(DEBUG) locatorStr = " << locatorStr
161 // check this locator value with the installation infobase
162 locator_smart_ptr loc(installBase, locatorStr);
164 if (! strcmp(loc.inside_node_locator_str(), locatorStr))
166 cerr << "(ERROR) Duplicate locator [ " << locatorStr
167 << " ] found in " << installBaseStr << endl;
171 checkBase->next(*it);
185 catch ( mmdbException &, e )