2008-12-29 02:49:26 +01:00
|
|
|
|
//INI parser in C--, GPL licence.
|
2012-03-22 14:33:15 +01:00
|
|
|
|
//Leency - 2012
|
2008-12-29 02:49:26 +01:00
|
|
|
|
|
|
|
|
|
#define COMMENT 0
|
|
|
|
|
#define SECTION 1
|
|
|
|
|
#define PARAM 2
|
|
|
|
|
#define OPTION 3
|
|
|
|
|
|
2011-08-18 15:32:06 +02:00
|
|
|
|
char NOTIFY_PATH[7]="@notify";
|
|
|
|
|
|
2011-07-30 16:59:48 +02:00
|
|
|
|
void GetIni(byte onload)
|
2008-12-29 02:49:26 +01:00
|
|
|
|
{
|
|
|
|
|
byte section[32]='', parametr[32]='', option[256]='', InfType=0;
|
|
|
|
|
word bukva[1];
|
2011-07-30 16:59:48 +02:00
|
|
|
|
int errornum;
|
2008-12-29 02:49:26 +01:00
|
|
|
|
dword buff, fsize, tj;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
buff = malloc(1048576);
|
2012-06-21 00:51:10 +02:00
|
|
|
|
IF (onload==1) copystr(".ini", #program_path+strlen(#program_path));
|
2011-08-18 15:32:06 +02:00
|
|
|
|
ReadFile(0, 1048576, buff, #program_path);
|
|
|
|
|
IF (EAX<>6) //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ReadFile(0, 1048576, buff, "/sys/File managers/Eolite.ini");
|
|
|
|
|
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 16:59:48 +02:00
|
|
|
|
{
|
2011-08-18 15:32:06 +02:00
|
|
|
|
IF (onload==1) RunProgram(#NOTIFY_PATH, "Eolite.ini not found. Defaults will be used.");
|
2011-07-30 16:59:48 +02:00
|
|
|
|
IF (onload==0) goto RUN_AS_PROGRAM;
|
|
|
|
|
}
|
2008-12-29 02:49:26 +01: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-05-13 13:42:55 +02:00
|
|
|
|
IF (!strcmp(#parametr,"SelectionColor")) videlenie=StrToCol(#option);
|
|
|
|
|
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-05 00:18:49 +02:00
|
|
|
|
|
2010-02-15 02:23:03 +01:00
|
|
|
|
IF (parametr) && (!strcmp(#file_name+find_symbol(#file_name,'.'),#parametr)) {
|
2011-07-30 16:59:48 +02: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 02:17:55 +02:00
|
|
|
|
//WriteDebug(#option);
|
2012-06-21 00:51:10 +02:00
|
|
|
|
Write_Error(errornum);
|
2011-07-30 16:59:48 +02:00
|
|
|
|
}
|
2010-02-15 02:23:03 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2008-12-29 02:49:26 +01:00
|
|
|
|
parametr=option='';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
IF (InfType==SECTION) copystr(#bukva,#section+strlen(#section));
|
|
|
|
|
IF (InfType==PARAM) copystr(#bukva,#parametr+strlen(#parametr));
|
|
|
|
|
IF (InfType==OPTION) copystr(#bukva,#option+strlen(#option));
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-30 16:59:48 +02: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-21 00:51:10 +02:00
|
|
|
|
Write_Error(errornum);
|
2011-07-30 16:59:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ///
|
|
|
|
|
///////////////////////////////////////////
|
|
|
|
|
|
2012-06-21 00:51:10 +02:00
|
|
|
|
void Write_Error(int error_number)
|
2011-09-05 14:54:42 +02:00
|
|
|
|
{
|
2012-06-21 00:51:10 +02:00
|
|
|
|
char error[256];
|
2011-09-05 14:54:42 +02:00
|
|
|
|
if (error_number<0) error_number=-1*error_number;
|
2012-06-21 00:51:10 +02:00
|
|
|
|
switch (error_number)
|
2011-07-30 16:59:48 +02:00
|
|
|
|
{
|
2012-06-21 00:51:10 +02:00
|
|
|
|
case 2: copystr("Error #2 - Function isn't supported for this file system", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 3: copystr("Error #3 - Unknown file system", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 5: copystr("Error #5 - File or folder not found", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 6: copystr("Error #6 - End of file, EOF", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 7: copystr("Error #7 - Pointer lies outside of application memory", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 8: copystr("Error #8 - FAT table is destroyed", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 9: copystr("Error #9 - FAT table is destroyed", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 10:copystr("Error #10 - Access denied", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 11:copystr("Error #11 - Device error", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 30:copystr("Error #30 - Not enough memory", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 31:copystr("Error #31 - File is not executable", #error);
|
|
|
|
|
break;
|
|
|
|
|
case 32:copystr("Error #32 - Too many processes", #error);
|
|
|
|
|
break;
|
|
|
|
|
default:copystr(IntToStr(error_number), #error);
|
|
|
|
|
copystr(" - Unknown error number O_o", #error+strlen(#error));
|
2011-07-30 16:59:48 +02:00
|
|
|
|
}
|
2012-06-21 00:51:10 +02:00
|
|
|
|
if (curbtn>=0) Line_ReDraw(0xFF0000, curbtn);
|
|
|
|
|
Pause(5);
|
|
|
|
|
RunProgram(#NOTIFY_PATH, #error);
|
|
|
|
|
//DrawBar(192,onTop(0, BUTTON_HEIGHT+7),onLeft(27,192),BUTTON_HEIGHT,0xFF0000);
|
|
|
|
|
//WriteText(205,onTop(-5, BUTTON_HEIGHT+7),0x80,0xFFFFFF,#error,0);
|
|
|
|
|
|
|
|
|
|
|
2008-12-29 02:49:26 +01:00
|
|
|
|
}
|