2008-12-29 01:49:26 +00:00
|
|
|
|
//INI parser in C--, GPL licence.
|
2012-03-22 13:33:15 +00:00
|
|
|
|
//Leency - 2012
|
2008-12-29 01:49:26 +00:00
|
|
|
|
|
|
|
|
|
#define COMMENT 0
|
|
|
|
|
#define SECTION 1
|
|
|
|
|
#define PARAM 2
|
|
|
|
|
#define OPTION 3
|
|
|
|
|
|
2012-06-23 12:42:40 +00:00
|
|
|
|
unsigned char *ERROR_TEXT[]={
|
|
|
|
|
"Code #0 - No error",
|
|
|
|
|
"Error #1 - Base or partition of a hard disk is not defined",
|
|
|
|
|
"Error #2 - Function isn't supported for this file system",
|
|
|
|
|
"Error #3 - Unknown file system",
|
|
|
|
|
"Error #4 - Reserved, is never returned",
|
|
|
|
|
"Error #5 - File or folder not found",
|
|
|
|
|
"Error #6 - End of file, EOF",
|
|
|
|
|
"Error #7 - Pointer lies outside of application memory",
|
|
|
|
|
"Error #8 - FAT table is destroyed",
|
|
|
|
|
"Error #9 - FAT table is destroyed",
|
|
|
|
|
"Error #10 - Access denied",
|
|
|
|
|
"Error #11 - Device error",
|
2013-01-06 17:18:53 +00:00
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
2012-06-23 12:42:40 +00:00
|
|
|
|
"Error #30 - Not enough memory",
|
|
|
|
|
"Error #31 - File is not executable",
|
|
|
|
|
"Error #32 - Too many processes",
|
|
|
|
|
0};
|
|
|
|
|
|
2011-07-30 14:59:48 +00:00
|
|
|
|
void GetIni(byte onload)
|
2008-12-29 01:49:26 +00:00
|
|
|
|
{
|
|
|
|
|
byte section[32]='', parametr[32]='', option[256]='', InfType=0;
|
2012-12-15 14:11:03 +00:00
|
|
|
|
char bukva[2];
|
2011-07-30 14:59:48 +00:00
|
|
|
|
int errornum;
|
2012-12-15 14:11:03 +00:00
|
|
|
|
dword fsize, tj;
|
|
|
|
|
static dword buff;
|
2008-12-29 01:49:26 +00:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
2012-12-15 14:11:03 +00:00
|
|
|
|
IF (onload==1)
|
|
|
|
|
{
|
|
|
|
|
free(buff);
|
|
|
|
|
buff = malloc(12000);
|
|
|
|
|
copystr(".ini", #program_path+strlen(#program_path));
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-02 17:41:55 +00:00
|
|
|
|
ReadFile(0, 12000, buff, #program_path);
|
2012-12-15 14:11:03 +00:00
|
|
|
|
IF (EAX<>6) ReadFile(0, 12000, buff, "/sys/File managers/Eolite.ini");
|
2011-08-18 13:32:06 +00:00
|
|
|
|
IF (EAX<>6) //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2011-07-30 14:59:48 +00:00
|
|
|
|
{
|
2012-11-16 16:51:04 +00:00
|
|
|
|
IF (onload==1) notify("Eolite.ini not found. Defaults will be used.");
|
2011-07-30 14:59:48 +00:00
|
|
|
|
IF (onload==0) goto RUN_AS_PROGRAM;
|
|
|
|
|
}
|
2008-12-29 01:49:26 +00:00
|
|
|
|
fsize=EBX;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
|
|
|
|
|
for (tj=0; tj<fsize; tj++;)
|
|
|
|
|
{
|
|
|
|
|
bukva = ESBYTE[buff+tj];
|
|
|
|
|
switch (bukva)
|
|
|
|
|
{
|
|
|
|
|
case ';':
|
|
|
|
|
InfType=COMMENT;
|
|
|
|
|
break;
|
|
|
|
|
case '[':
|
|
|
|
|
InfType=SECTION;
|
|
|
|
|
section='';
|
|
|
|
|
break;
|
|
|
|
|
case ']':
|
|
|
|
|
InfType=PARAM;
|
|
|
|
|
break;
|
|
|
|
|
case '=':
|
|
|
|
|
InfType=OPTION;
|
|
|
|
|
break;
|
|
|
|
|
case 0x0a:
|
|
|
|
|
case 0x0d:
|
|
|
|
|
InfType=PARAM;
|
2012-12-17 00:11:34 +00:00
|
|
|
|
IF (!strcmp(#parametr,"SelectionColor")) col_selec=StrToCol(#option);
|
2012-05-13 11:42:55 +00:00
|
|
|
|
IF (!strcmp(#parametr,"LineHeight")) BUTTON_HEIGHT=StrToInt(#option);
|
|
|
|
|
IF (!strcmp(#parametr,"ShowDeviceName")) show_dev_name=StrToInt(#option);
|
|
|
|
|
|
|
|
|
|
/*if (!strcmp(#section,"UserDirectories")) && (parametr) && (onload)
|
|
|
|
|
{
|
|
|
|
|
copystr(#parametr, #disk_list[disc_num].Item);
|
|
|
|
|
disc_num++;
|
|
|
|
|
}*/
|
2012-04-04 22:18:49 +00:00
|
|
|
|
|
2012-07-16 11:58:24 +00:00
|
|
|
|
IF (parametr) && (!strcmp(#file_name+strchr(#file_name,'.'),#parametr)) {
|
2011-07-30 14:59:48 +00:00
|
|
|
|
errornum=RunProgram(#option,#file_path);
|
|
|
|
|
IF (errornum<0) //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
2011-08-22 00:17:55 +00:00
|
|
|
|
//WriteDebug(#option);
|
2012-06-20 22:51:10 +00:00
|
|
|
|
Write_Error(errornum);
|
2011-07-30 14:59:48 +00:00
|
|
|
|
}
|
2010-02-15 01:23:03 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2013-02-28 13:52:59 +00:00
|
|
|
|
parametr=option=NULL;
|
2008-12-29 01:49:26 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2013-02-28 13:52:59 +00:00
|
|
|
|
IF (InfType==SECTION) chrcat(#section, bukva);
|
|
|
|
|
IF (InfType==PARAM) chrcat(#parametr, bukva);
|
|
|
|
|
IF (InfType==OPTION) chrcat(#option, bukva);
|
2008-12-29 01:49:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-30 14:59:48 +00:00
|
|
|
|
RUN_AS_PROGRAM:
|
|
|
|
|
IF (file_path) errornum=RunProgram(#file_path,'');
|
|
|
|
|
IF (errornum<0) //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
2012-06-20 22:51:10 +00:00
|
|
|
|
Write_Error(errornum);
|
2011-07-30 14:59:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-06-20 22:51:10 +00:00
|
|
|
|
void Write_Error(int error_number)
|
2011-09-05 12:54:42 +00:00
|
|
|
|
{
|
2012-06-20 22:51:10 +00:00
|
|
|
|
char error[256];
|
2012-06-23 12:42:40 +00:00
|
|
|
|
|
2011-09-05 12:54:42 +00:00
|
|
|
|
if (error_number<0) error_number=-1*error_number;
|
2012-06-23 12:42:40 +00:00
|
|
|
|
|
|
|
|
|
if (error_number<33)
|
|
|
|
|
copystr(ERROR_TEXT[error_number], #error);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
copystr(IntToStr(error_number), #error);
|
|
|
|
|
copystr(" - Unknown error number O_o", #error+strlen(#error));
|
|
|
|
|
}
|
2012-06-20 22:51:10 +00:00
|
|
|
|
if (curbtn>=0) Line_ReDraw(0xFF0000, curbtn);
|
|
|
|
|
Pause(5);
|
2012-11-16 16:51:04 +00:00
|
|
|
|
notify(#error);
|
2012-06-20 22:51:10 +00:00
|
|
|
|
//DrawBar(192,onTop(0, BUTTON_HEIGHT+7),onLeft(27,192),BUTTON_HEIGHT,0xFF0000);
|
|
|
|
|
//WriteText(205,onTop(-5, BUTTON_HEIGHT+7),0x80,0xFFFFFF,#error,0);
|
2012-06-23 12:42:40 +00:00
|
|
|
|
}
|