/***************************************************************************** # Copyright (C) 1994-2008 by David Gordon. # All rights reserved. # # This software is part of a beta-test version of the Consed/Autofinish # package. It should not be redistributed or # used for any commercial purpose, including commercially funded # sequencing, without written permission from the author and the # University of Washington. # # This software is provided ``AS IS'' and any express or implied # warranties, including, but not limited to, the implied warranties of # merchantability and fitness for a particular purpose, are disclaimed. # In no event shall the authors or the University of Washington be # liable for any direct, indirect, incidental, special, exemplary, or # consequential damages (including, but not limited to, procurement of # substitute goods or services; loss of use, data, or profits; or # business interruption) however caused and on any theory of liability, # whether in contract, strict liability, or tort (including negligence # or otherwise) arising in any way out of the use of this software, even # if advised of the possibility of such damage. # # Building Consed from source is error prone and not simple which is # why I provide executables. Due to time limitations I cannot # provide any assistance in building Consed. Even if you do not # modify the source, you may introduce errors due to using a # different version of the compiler, a different version of motif, # different versions of other libraries than I used, etc. For this # reason, if you discover Consed bugs, I can only offer help with # those bugs if you first reproduce those bugs with an executable # provided by me--not an executable you have built. # # Modifying Consed is also difficult. Although Consed is modular, # some modules are used by many other modules. Thus making a change # in one place can have unforeseen effects on many other features. # It may takes months for you to notice these other side-effects # which may not seen connected at all. It is not feasable for me to # provide help with modifying Consed sources because of the # potentially huge amount of time involved. # #*****************************************************************************/ #include #include #include #include #include #include #include "rwcstring.h" #include "rwcregexp.h" #include "uGetCRC_9_digits.h" #include "assert.h" void checkLicenseKey() { char* pConsedKey = getenv( "CONSED_KEY" ); if ( !pConsedKey ) { cerr << "this is a version of consed that has a definite expiration date. You must set the environment variable CONSED_KEY. Do this by typing (in csh or tcsh):\nsetenv CONSED_KEY (key)\nWhoever gave you this version of consed should supply you with a key." << endl; exit( EXIT_FAILURE ); } // the key should be of the form: 23-FEB-2000-999-999-999 // where the 9's could be any digit RWCString soKey( pConsedKey ); if ( soKey.length() != strlen( "23-FEB-2000-999-999-999" ) ) { cerr << "The CONSED_KEY environment variable is incorrect. It must be of the form 23-FEB-2000-999-999-999 but instead it is \"" << soKey << "\"" << pConsedKey << endl; exit( EXIT_FAILURE ); } // must get around length limitation of the Rogue Wave RWCRegexp // this was even worse on Linux. if ( ! ( isdigit( soKey[0] ) && isdigit( soKey[1] ) && ( soKey[2] == '-' ) && isupper( soKey[3] ) && isupper( soKey[4] ) && isupper( soKey[5] ) && ( soKey[6] == '-' ) && isdigit( soKey[7] ) && isdigit( soKey[8] ) && isdigit( soKey[9] ) && isdigit( soKey[10] ) && ( soKey[11] == '-' ) && isdigit( soKey[12] ) && isdigit( soKey[13] ) && isdigit( soKey[14] ) && ( soKey[15] == '-' ) && isdigit( soKey[16] ) && isdigit( soKey[17] ) && isdigit( soKey[18] ) && ( soKey[19] == '-' ) && isdigit( soKey[20] ) && isdigit( soKey[21] ) && isdigit( soKey[22] ) ) ) { cerr << "The CONSED_KEY environment variable is incorrect (2). It must be of the form 23-FEB-2000-999-999-999" << endl; exit( EXIT_FAILURE ); } RWCString soMonth = soKey( 3, 3 ); int nMonth; if ( soMonth == "JAN" ) nMonth = 1; else if ( soMonth == "FEB" ) nMonth = 2; else if ( soMonth == "MAR" ) nMonth = 3; else if ( soMonth == "APR" ) nMonth = 4; else if ( soMonth == "MAY" ) nMonth = 5; else if ( soMonth == "JUN" ) nMonth = 6; else if ( soMonth == "JUL" ) nMonth = 7; else if ( soMonth == "AUG" ) nMonth = 8; else if ( soMonth == "SEP" ) nMonth = 9; else if ( soMonth == "OCT" ) nMonth = 10; else if ( soMonth == "NOV" ) nMonth = 11; else if ( soMonth == "DEC" ) nMonth = 12; else { cerr << "Month must be JAN, FEB, MAR, ..., DEC but instead was " << soMonth << endl; exit( EXIT_FAILURE ); } // 99-MMM-9999-999-999-999 // 0 ^ ^ ^ ^ // 1012 16 20 RWCString soDate = soKey(0, 11 ); RWCString soCRCInKey = soKey( 12, 3 ) + soKey( 16, 3) + soKey( 20, 3 ); unsigned int uCRC9 = uGetCRC_9_digits( soDate.data() ); char szCRC9[50]; sprintf( szCRC9, "%09u", uCRC9 ); if ( soCRCInKey != szCRC9 ) { cerr << "sorry--the CONSED_KEY environment variable is not valid. Please contact whoever gave you this key." << endl; exit( EXIT_FAILURE ); } tm tmExpiration; tmExpiration.tm_sec = 59; tmExpiration.tm_min = 59; tmExpiration.tm_hour = 23; RWCString soTemp = soKey( 0, 2 ); tmExpiration.tm_mday = atoi( soTemp ); tmExpiration.tm_mon = nMonth - 1; soTemp = soKey( 7, 4 ); tmExpiration.tm_year = atoi( soTemp ) - 1900; time_t timeExpiration = mktime( &tmExpiration ); time_t timeCurrent = time( NULL ); if ( timeExpiration < timeCurrent ) { cerr << "Sorry. This version of consed has an expired key. You could purchase a permanent copy of consed." << endl; exit( EXIT_FAILURE ); } }