Rev 7792 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1665 | Nasarus | 1 | |
2 | |||
8827 | rgimad | 3 | char buf[4]; |
4 | |||
5 | k70.p00 = 0; |
||
1665 | Nasarus | 6 | |
8827 | rgimad | 7 | //k70.p08 = 0; |
8 | k70.p12 = 4; // read 4 bytes |
||
9 | k70.p16 = (unsigned) buf; |
||
10 | k70.p20 = 0; |
||
11 | k70.p21 = file; |
||
12 | |||
13 | kol_file_70(&k70); |
||
1665 | Nasarus | 14 | |
8827 | rgimad | 15 | if ( !strcmp(buf, script_sign) ) // if we found the script signature |
1665 | Nasarus | 16 | |
8827 | rgimad | 17 | else |
18 | return FALSE; |
||
19 | } |
||
20 | |||
1665 | Nasarus | 21 | |
22 | |||
23 | |||
8827 | rgimad | 24 | kol_struct_BDVK bdvk; |
25 | unsigned result, i; |
||
26 | unsigned long long filesize, pos; |
||
27 | char *buf; // buffer, where script is copied |
||
28 | |||
29 | k70.p00 = 5; |
||
1665 | Nasarus | 30 | |
8827 | rgimad | 31 | //k70.p08 = 0; |
32 | k70.p16 = (unsigned) &bdvk; |
||
33 | k70.p20 = 0; |
||
34 | k70.p21 = exec; |
||
35 | |||
36 | result = kol_file_70(&k70); // get file info |
||
1665 | Nasarus | 37 | |
8827 | rgimad | 38 | return FALSE; |
39 | |||
40 | filesize = bdvk.p32; // get file size |
||
1665 | Nasarus | 41 | |
8827 | rgimad | 42 | buf = malloc(filesize+256); // may fail for over 4Gb file, but impossible case |
1665 | Nasarus | 43 | |
8827 | rgimad | 44 | return FALSE; |
45 | |||
46 | buf[filesize]=0; |
||
1665 | Nasarus | 47 | |
8827 | rgimad | 48 | k70.p00 = 0; |
1665 | Nasarus | 49 | |
8827 | rgimad | 50 | //k70.p08 = 0; |
51 | k70.p12 = filesize; |
||
52 | k70.p16 = (unsigned) buf; |
||
53 | k70.p20 = 0; |
||
54 | k70.p21 = exec; |
||
55 | |||
56 | result = kol_file_70(&k70); // read file to the buffer |
||
1665 | Nasarus | 57 | |
8827 | rgimad | 58 | { |
59 | free(buf); |
||
60 | return FALSE; |
||
61 | } |
||
62 | |||
63 | pos = 0; |
||
1665 | Nasarus | 64 | |
8827 | rgimad | 65 | for (;;) // script processing |
1665 | Nasarus | 66 | |
8827 | rgimad | 67 | if (pos > filesize) |
68 | break; |
||
69 | |||
70 | for (i=0;;i++) // reading a string |
||
1665 | Nasarus | 71 | |
8827 | rgimad | 72 | if ((0x0A == buf[pos])||(0x0D == buf[pos])||(0 == buf[pos])) |
73 | { |
||
74 | pos++; |
||
75 | CMD[i] = '\0'; |
||
76 | break; |
||
77 | } |
||
78 | CMD[i] = buf[pos]; |
||
79 | pos++; |
||
80 | } |
||
81 | |||
82 | if ( 0 == strlen(CMD) ) // empty string |
||
1665 | Nasarus | 83 | |
8827 | rgimad | 84 | |
85 | if ('#' == CMD[0]) // comment |
||
1665 | Nasarus | 86 | |
8827 | rgimad | 87 | |
88 | command_execute(); |
||
1665 | Nasarus | 89 | |
8827 | rgimad | 90 | } |
1665 | Nasarus | 91 | |
8827 | rgimad | 92 | free(buf); |
1665 | Nasarus | 93 | |
8827 | rgimad | 94 | } |
95 |