blob: 5d04a5e741dd07ccfcaa7668981251fb0660475e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
//
// InstallerSecionSection.mm
// InstallerPane
//
// Created by Trenton Schulz on 7/27/05.
// Copyright 2005 __MyCompanyName__. All rights reserved.
//
#import "InstallerSecionSection.h"
#import "helpfulfunc.h"
#import <stdio.h>
#import <string.h>
static BOOL checkForLicenseFile()
{
static const int LICENSESIZE = 42;
int value = -1;
static NSString *qtLicense = [NSHomeDirectory() stringByAppendingPathComponent: @".qt-license"];
NSData *fileContents = [[NSFileManager defaultManager] contentsAtPath: qtLicense];
if (fileContents != nil) {
const char *charBuffer = (const char *)[fileContents bytes];
int length = [fileContents length];
char *location = strnstr(charBuffer, LicenseKeyExtString, length);
if (location) {
location += strlen(LicenseKeyExtString);
char licenseString[LICENSESIZE];
strncpy(licenseString, location, LICENSESIZE);
licenseString[LICENSESIZE - 1] = '\0';
while (location = strstr(licenseString, "\n"))
*location = '\0';
value = validateLicense(licenseString);
}
}
return value == LicenseOK;
}
@implementation InstallerSecionSection
- (BOOL)shouldLoad
{
return !checkForLicenseFile();
}
@end
|