b5897f9c55b878f237adb82c05b1a1ceb28f7f8b
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / timebomb.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "timebomb.h"\r
23 #include <stdio.h>\r
24 #include <sys/stat.h>\r
25 #include <stdlib.h>\r
26 \r
27 #define LASTYEAR 2001\r
28 #define LASTDAY 1\r
29 #define LASTMONTH 10\r
30 #define EXCUSE \\r
31 "To reduce support liability this release had an expiration date.\n" \\r
32 "The expiration date of this release has expired.\n"\r
33 \r
34 static char *files[] = \r
35 {\r
36         "/usr/lib/libcinelerra.so",\r
37         "/usr/bin/cinelerra"\r
38 };\r
39 \r
40 TimeBomb::TimeBomb()\r
41 {\r
42         struct stat fileinfo;\r
43         time_t system_time;\r
44         int result;\r
45 \r
46         result = stat("/etc", &fileinfo);\r
47         system_time = time(0);\r
48 \r
49 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
50 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
51 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
52 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
53 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
54 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
55 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
56 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
57 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
58 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
59 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
60 printf("This release expires %d/%d/%d\n", LASTMONTH, LASTDAY, LASTYEAR);\r
61 \r
62         if(test_time(fileinfo.st_mtime) ||\r
63                 test_time(system_time))\r
64         {\r
65                 printf(EXCUSE);\r
66                 disable_system();\r
67                 exit(1);\r
68         }\r
69 }\r
70 \r
71 \r
72 int TimeBomb::test_time(time_t testtime)\r
73 {\r
74         struct tm *currenttime;\r
75         currenttime = localtime(&testtime);\r
76 \r
77         if(currenttime->tm_year >= LASTYEAR - 1900 &&\r
78                 currenttime->tm_mday >= LASTDAY &&\r
79                 currenttime->tm_mon >= LASTMONTH - 1) return 1;\r
80         else return 0;\r
81 }\r
82 \r
83 void TimeBomb::disable_system()\r
84 {\r
85 //printf("TimeBomb::disable_system %d\n", sizeof(files));\r
86         for(int i = 0; i < sizeof(files) / sizeof(char*); i++)\r
87         {\r
88                 remove((const char*)files[i]);\r
89         }\r
90 }\r
91 \r
92 TimeBomb::~TimeBomb()\r
93 {\r
94 }\r
95 \r