blob: 1154a657513467f65d67aedb16ba56abc191601a (
plain) (
blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "lzqlp.h"
static char* lcase(char* str) {
while(*str != 0x00) {
*str = tolower(*str);
str++;
}
return(str);
}
int qlpFileCount(const QLP_HEAD* qlpfile) {
if (strncmp(qlpfile->id, "QLP", 3) != 0)
return(PACK_ERR_INVALID);
return(qlpfile->numfiles);
}
const QLP_FILE* qlpFileEntry(int index, const QLP_HEAD* qlpfile) {
if (strncmp(qlpfile->id, "QLP", 3) != 0)
return(NULL);
if (index > qlpfile->numfiles)
return(NULL);
return(&((QLP_FILE*)(((const char*)qlpfile)+sizeof(QLP_HEAD)))[index]);
}
const void* qlpFileAddr(int index, const QLP_HEAD* qlpfile) {
return( ((const char*)qlpfile)+((QLP_FILE*)(((const char*)qlpfile)+sizeof(QLP_HEAD)))[index].offs );
}
int qlpFindFile(char* fileName, const QLP_HEAD* qlpfile) {
int i;
char nameBuff[2][16];
strcpy(nameBuff[0], fileName);
lcase(nameBuff[0]);
for(i=0; i<(qlpfile->numfiles); i++) {
strcpy(nameBuff[1], ((QLP_FILE*)(((const char*)qlpfile)+sizeof(QLP_HEAD)))[i].name);
lcase(nameBuff[1]);
if (strcmp(nameBuff[0], nameBuff[1]) == 0)
return(i);
}
return(PACK_ERR_NOTFOUND);
}
|