Rev 4846 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4846 | Rev 5399 | ||
---|---|---|---|
1 | //INI parser in C--, GPL licence. |
1 | //INI parser in C--, GPL licence. |
2 | //Leency - 2012 |
2 | //Leency - 2012 |
3 | 3 | ||
4 | #define COMMENT 0 |
4 | #define COMMENT 0 |
5 | #define SECTION 1 |
5 | #define SECTION 1 |
6 | #define PARAM 2 |
6 | #define PARAM 2 |
7 | #define OPTION 3 |
7 | #define OPTION 3 |
8 | 8 | ||
9 | 9 | ||
10 | void GetIni(byte onload) |
10 | void GetIni(byte onload) |
11 | { |
11 | { |
12 | byte section[32], parametr[32], option[256], InfType=0; |
12 | byte section[32], parametr[32], option[256], InfType=0; |
13 | char bukva[2]; |
13 | char bukva[2]; |
14 | int errornum, tj; |
14 | int errornum, tj; |
15 | static dword buff, fsize; |
15 | static dword buff, fsize; |
16 | if (onload==1) |
16 | if (onload==1) |
17 | { |
17 | { |
18 | free(buff); |
18 | free(buff); |
19 | if (!GetFile(#buff, #fsize, abspath("Eolite.ini"))) notify("Eolite.ini not found. Defaults will be used."); |
19 | if (!GetFile(#buff, #fsize, abspath("Eolite.ini"))) notify("Eolite.ini not found. Defaults will be used."); |
20 | } |
20 | } |
21 | for (tj=0; tj |
- | |
22 | { |
- | |
23 | bukva = ESBYTE[buff+tj]; |
- | |
24 | switch (bukva) |
- | |
25 | { |
- | |
26 | case ';': InfType=COMMENT; break; |
- | |
27 | case '[': InfType=SECTION; section=NULL; break; |
- | |
28 | case ']': InfType=PARAM; break; |
- | |
29 | case '=': InfType=OPTION; break; |
- | |
30 | case 0x0a: |
- | |
31 | case 0x0d: |
- | |
32 | InfType=PARAM; |
- | |
33 | if (!strcmp(#parametr,"SelectionColor")) edit2.shift_color=col_selec=StrToCol(#option); |
- | |
34 | if (!strcmp(#parametr,"LineHeight")) files.line_h = atoi(#option); |
- | |
35 | if (!strcmp(#parametr,"ShowDeviceName")) show_dev_name=atoi(#option); |
- | |
36 | if (!strcmp(#parametr,"RealFileNamesCase")) real_files_names_case=atoi(#option); |
- | |
37 | if (!strcmp(#parametr,"DrwRamDiskSpace")) drw_ram_disk_space=atoi(#option); |
- | |
38 | 21 | ||
39 | if (parametr) && (!strcmpi(#file_name+strrchr(#file_name,'.'),#parametr)) && (!onload) |
- | |
40 | { |
- | |
41 | errornum = RunProgram(#option,#file_path); |
22 | ini_get_color stdcall (abspath("Eolite.ini"), "Config", "SelectionColor", 0x94AECE); |
42 | if (errornum<0) |
- | |
43 | { |
23 | edit2.shift_color = EAX; |
44 | if (errornum==-5) ShowOpenWithDialog(); else Write_Error(errornum); |
- | |
45 | } |
- | |
46 | return; |
- | |
47 | } |
24 | ini_get_int stdcall (abspath("Eolite.ini"), "Config", "LineHeight", 18); |
48 | parametr=option=NULL; |
- | |
49 | break; |
- | |
50 | default: |
25 | files.line_h = EAX; |
51 | IF (InfType==SECTION) chrcat(#section, bukva); |
26 | ini_get_int stdcall (abspath("Eolite.ini"), "Config", "ShowDeviceName", 1); |
52 | IF (InfType==PARAM) chrcat(#parametr, bukva); |
27 | show_dev_name = EAX; |
53 | IF (InfType==OPTION) chrcat(#option, bukva); |
- | |
54 | } |
- | |
55 | } |
28 | ini_get_int stdcall (abspath("Eolite.ini"), "Config", "RealFileNamesCase", 0); |
56 | if (file_path) && (!onload) |
- | |
57 | { |
- | |
58 | errornum = RunProgram(#file_path,NULL); |
29 | real_files_names_case = EAX; |
59 | if (errornum==-31) menu_action(201); else if (errornum<0) Write_Error(errornum); |
30 | ini_get_int stdcall (abspath("Eolite.ini"), "Config", "DrwRamDiskSpace", 0); |
60 | return; |
- | |
61 | } |
31 | drw_ram_disk_space = EAX; |
62 | } |
32 | } |
63 | 33 | ||
64 | 34 | ||
65 | void Write_Error(int error_number) |
35 | void Write_Error(int error_number) |
66 | { |
36 | { |
67 | char error_message[500]; |
37 | char error_message[500]; |
68 | dword ii; |
38 | dword ii; |
69 | if (files.current>=0) Line_ReDraw(0xFF0000, files.current); |
39 | if (files.current>=0) Line_ReDraw(0xFF0000, files.current); |
70 | pause(5); |
40 | pause(5); |
71 | strcpy(#error_message, "\"Eolite\n"); |
41 | strcpy(#error_message, "\"Eolite\n"); |
72 | ii = get_error(error_number); |
42 | ii = get_error(error_number); |
73 | strcat(#error_message, ii); |
43 | strcat(#error_message, ii); |
74 | strcat(#error_message, "\" -tE"); |
44 | strcat(#error_message, "\" -tE"); |
75 | notify(#error_message); |
45 | notify(#error_message); |
76 | } |
46 | } |
77 | 47 | ||
78 | 48 | ||
79 | dword StrToCol(char* htmlcolor) |
49 | dword StrToCol(char* htmlcolor) |
80 | { |
50 | { |
81 | dword j, color=0; |
51 | dword j, color=0; |
82 | char ch=0x00; |
52 | char ch=0x00; |
83 | 53 | ||
84 | FOR (j=0; j<6; j++) |
54 | FOR (j=0; j<6; j++) |
85 | { |
55 | { |
86 | ch=ESBYTE[htmlcolor+j]; |
56 | ch=ESBYTE[htmlcolor+j]; |
87 | IF ((ch>='0') && (ch<='9')) ch -= '0'; |
57 | IF ((ch>='0') && (ch<='9')) ch -= '0'; |
88 | IF ((ch>='A') && (ch<='F')) ch -= 'A'-10; |
58 | IF ((ch>='A') && (ch<='F')) ch -= 'A'-10; |
89 | IF ((ch>='a') && (ch<='f')) ch -= 'a'-10; |
59 | IF ((ch>='a') && (ch<='f')) ch -= 'a'-10; |
90 | color = color*0x10 + ch; |
60 | color = color*0x10 + ch; |
91 | } |
61 | } |
92 | return color; |
62 | return color; |
93 | }='f'))>='F'))>='9'))>6;>0)>0) |
63 | }='f'))>='F'))>='9'))>6;> |
94 | > |
- |