2013-03-11 19:16:24 +01:00
|
|
|
//INI parser in C--, GPL licence.
|
|
|
|
//Leency - 2012
|
|
|
|
|
|
|
|
#define COMMENT 0
|
|
|
|
#define SECTION 1
|
|
|
|
#define PARAM 2
|
|
|
|
#define OPTION 3
|
|
|
|
|
|
|
|
|
|
|
|
void GetIni(byte onload)
|
|
|
|
{
|
|
|
|
byte section[32], parametr[32], option[256], InfType=0;
|
|
|
|
char bukva[2];
|
|
|
|
int errornum, tj;
|
|
|
|
static dword buff, fsize;
|
|
|
|
if (onload==1)
|
|
|
|
{
|
|
|
|
free(buff);
|
2013-03-30 01:52:50 +01:00
|
|
|
if (!GetFile(#buff, #fsize, abspath("Eolite.ini"))) notify("Eolite.ini not found. Defaults will be used.");
|
2013-03-11 19:16:24 +01:00
|
|
|
}
|
|
|
|
for (tj=0; tj<fsize; tj++;)
|
|
|
|
{
|
|
|
|
bukva = ESBYTE[buff+tj];
|
|
|
|
switch (bukva)
|
|
|
|
{
|
2013-10-17 23:02:47 +02:00
|
|
|
case ';': InfType=COMMENT; break;
|
|
|
|
case '[': InfType=SECTION; section=NULL; break;
|
|
|
|
case ']': InfType=PARAM; break;
|
|
|
|
case '=': InfType=OPTION; break;
|
2013-03-11 19:16:24 +01:00
|
|
|
case 0x0a:
|
|
|
|
case 0x0d:
|
|
|
|
InfType=PARAM;
|
|
|
|
IF (!strcmp(#parametr,"SelectionColor")) edit2.shift_color=col_selec=StrToCol(#option);
|
2013-03-31 22:25:54 +02:00
|
|
|
IF (!strcmp(#parametr,"LineHeight")) files.line_h = atoi(#option);
|
2013-03-11 19:16:24 +01:00
|
|
|
IF (!strcmp(#parametr,"ShowDeviceName")) show_dev_name=atoi(#option);
|
2013-11-14 01:22:55 +01:00
|
|
|
IF (!strcmp(#parametr,"RealFileNamesCase")) real_files_names_case=atoi(#option);
|
2013-03-11 19:16:24 +01:00
|
|
|
|
|
|
|
IF (parametr) && (!strcmp(#file_name+strrchr(#file_name,'.'),#parametr)) && (!onload)
|
|
|
|
{
|
2013-11-14 01:22:55 +01:00
|
|
|
errornum = RunProgram(#option,#file_path);
|
|
|
|
if (errornum<0)
|
|
|
|
{
|
|
|
|
if (errornum==-5) ShowOpenWithDialog(); else Write_Error(errornum);
|
|
|
|
}
|
2013-03-11 19:16:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
parametr=option=NULL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
IF (InfType==SECTION) chrcat(#section, bukva);
|
|
|
|
IF (InfType==PARAM) chrcat(#parametr, bukva);
|
|
|
|
IF (InfType==OPTION) chrcat(#option, bukva);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (file_path) && (!onload)
|
|
|
|
{
|
2013-11-14 01:22:55 +01:00
|
|
|
errornum = RunProgram(#file_path,NULL);
|
2013-10-17 23:02:47 +02:00
|
|
|
if (errornum==-31) menu_action(201); else if (errornum<0) Write_Error(errornum);
|
|
|
|
return;
|
2013-03-11 19:16:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Write_Error(int error_number)
|
|
|
|
{
|
2013-03-31 22:25:54 +02:00
|
|
|
if (files.current>=0) Line_ReDraw(0xFF0000, files.current);
|
2013-03-11 19:16:24 +01:00
|
|
|
pause(5);
|
2013-03-31 22:25:54 +02:00
|
|
|
notify(get_error(error_number));
|
2013-03-11 19:16:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dword StrToCol(char* htmlcolor)
|
|
|
|
{
|
2013-03-30 15:08:01 +01:00
|
|
|
dword j, color=0;
|
|
|
|
char ch=0x00;
|
|
|
|
|
|
|
|
FOR (j=0; j<6; j++)
|
|
|
|
{
|
|
|
|
ch=ESBYTE[htmlcolor+j];
|
|
|
|
IF ((ch>='0') && (ch<='9')) ch -= '0';
|
|
|
|
IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
|
|
|
|
IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
|
|
|
|
color = color*0x10 + ch;
|
|
|
|
}
|
|
|
|
return color;
|
2013-03-11 19:16:24 +01:00
|
|
|
}
|