eudora-mac/timebomb.c

1 line
16 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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. */ // // DEMO JDB June 28, 1996 // // Added this file and altered it slightly to incorporate the TimeBomb demo Feature. // All related Eudora code changes are commented or #ifdef'ed with DEMO // //------------------------------------------------------------------------- // timebomb.c (was Timebomb.c) // Source for implementing a timebomb function on the Macintosh // // Usage: // Call GetTimeStampData. This will set up the global with the relevant data. // Call timeStampValid it a value from GetDateTime or LMGetTime. To help thwart // hackers, put a little separation between the getting of the date and the check. // If TimeStampValid does not pass, send a message or apple event back to the app // to decouple the cause and effect. // // To make things a little harder for hackers, let's introduce another global // called today. We will set today to the current date every time we call "SetYesterday". // Note, Yesterday is the number of seconds since the beginning of the current day. // We make a call to get the current time there, so that's why I choose to set today there. //------------------------------------------------------------------------- #include "timebomb.h" #ifdef DEMO void QuitExpiredEudora(void); //quit Eudora after it has expired. TimeBombDataRecord gTimeBombData; long today; //------------------------------------------------------------------------- // TimeBomb // // This routine installs the timebomb resource in the right place. It should // only be called once per program execution. // // the time bomb resource should only be installed if it doesn't already exist. // // The initial call to GetTimeStampData will see if there is a timebomb resource // already installed. //------------------------------------------------------------------------- void TimeBomb(void) { OSErr timeBombErr = noErr; gTimeBombData.creator = 'CSOm'; gTimeBombData.version = (MAJOR_VERSION<<8)|MINOR_VERSION; gTimeBombData.days = 0; gTimeBombData.date = 0; timeBombErr = GetTimeStampData(); if ((timeBombErr == resNotFound) || (timeBombErr == fnfErr) || (gTimeBombData.date == 0)) { //the resource was not found, or the date was bad. Install a new one. gTimeBombData.creator = 'CSOm'; gTimeBombData.version = (MAJOR_VERSION<<8)|MINOR_VERSION; gTimeBombData.date = today; gTimeBombData.days = DEMO; SetTimeStampData(); } } //--------------------------------------