2000-07-15 09:12:11 +00:00
|
|
|
/*
|
|
|
|
GEOSLib example
|
|
|
|
|
|
|
|
This small application removes GEOS disk write protection tag.
|
|
|
|
e.g. boot disk is always protected after boot-up
|
|
|
|
|
2003-01-10 21:09:13 +00:00
|
|
|
Maciej 'YTM/Elysium' Witkowiak
|
|
|
|
<ytm@elysium.pl>
|
2000-07-15 09:12:11 +00:00
|
|
|
|
|
|
|
21.03.2000
|
|
|
|
*/
|
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
|
2000-07-15 09:12:11 +00:00
|
|
|
#include <geos.h>
|
|
|
|
|
|
|
|
char diskName[17] = "";
|
|
|
|
|
|
|
|
static const graphicStr clearScreen = {
|
2012-02-09 12:32:53 +00:00
|
|
|
MOVEPENTO(0, 0),
|
|
|
|
NEWPATTERN(2),
|
2012-02-28 21:57:45 +00:00
|
|
|
RECTANGLETO(SC_PIX_WIDTH-1, SC_PIX_HEIGHT-1),
|
2012-02-09 12:32:53 +00:00
|
|
|
GSTR_END
|
2000-07-15 09:12:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const dlgBoxStr mainDialog = {
|
2012-02-09 12:32:53 +00:00
|
|
|
DB_DEFPOS(1),
|
|
|
|
DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y,
|
|
|
|
CBOLDON "Remove protection on:" CPLAINTEXT),
|
|
|
|
DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, diskName),
|
|
|
|
DB_ICON(OK, DBI_X_0, DBI_Y_2),
|
|
|
|
DB_ICON(DISK, DBI_X_1, DBI_Y_2),
|
|
|
|
DB_ICON(CANCEL, DBI_X_2, DBI_Y_2),
|
|
|
|
DB_END
|
2000-07-15 09:12:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const dlgBoxStr changeDiskDlg = {
|
2012-02-09 12:32:53 +00:00
|
|
|
DB_DEFPOS(1),
|
|
|
|
DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, CBOLDON "Insert new disk"),
|
|
|
|
DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, "into drive." CPLAINTEXT),
|
|
|
|
DB_ICON(OK, DBI_X_0, DBI_Y_2),
|
|
|
|
DB_ICON(CANCEL, DBI_X_2, DBI_Y_2),
|
|
|
|
DB_END
|
2000-07-15 09:12:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const dlgBoxStr errorDialog = {
|
2012-02-09 12:32:53 +00:00
|
|
|
DB_DEFPOS(1),
|
|
|
|
DB_TXTSTR(TXT_LN_X, TXT_LN_2_Y, CBOLDON "Error happened..."),
|
|
|
|
DB_TXTSTR(TXT_LN_X, TXT_LN_3_Y, "exiting..." CPLAINTEXT),
|
|
|
|
DB_ICON(OK, DBI_X_0, DBI_Y_2),
|
|
|
|
DB_END
|
2000-07-15 09:12:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void Error(void)
|
|
|
|
{
|
2012-02-09 12:32:53 +00:00
|
|
|
DoDlgBox(&errorDialog);
|
|
|
|
EnterDeskTop();
|
2000-07-15 09:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
2012-02-09 12:32:53 +00:00
|
|
|
// Here we clear the screen. Not really needed anyway...
|
|
|
|
GraphicsString(&clearScreen);
|
|
|
|
|
|
|
|
// Get the name of current disk to show it in dialog box
|
|
|
|
GetPtrCurDkNm(diskName);
|
2000-07-15 09:12:11 +00:00
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
while (1) {
|
|
|
|
switch (DoDlgBox(&mainDialog)) {
|
2000-07-15 09:12:11 +00:00
|
|
|
|
2012-02-09 12:32:53 +00:00
|
|
|
// What's the result of dialog box? which icon was pressed?
|
|
|
|
case OK:
|
|
|
|
if (GetDirHead())
|
|
|
|
Error();
|
|
|
|
curDirHead[OFF_GS_DTYPE] = 0;
|
|
|
|
if (PutDirHead())
|
|
|
|
Error();
|
|
|
|
break;
|
|
|
|
case DISK:
|
|
|
|
DoDlgBox(&changeDiskDlg);
|
|
|
|
GetPtrCurDkNm(diskName);
|
|
|
|
break;
|
|
|
|
default: // CANCEL is the third option
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-07-15 09:12:11 +00:00
|
|
|
}
|