home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
monitors
/
rsys
/
source.lha
/
src
/
RSysMain.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-09
|
7KB
|
261 lines
/*
***************************************************************************
*
* Datei:
* RSysMain.c
*
* Inhalt:
*
* Bemerkungen:
* Startup-Routinen von RSys; ruft das Hauptprogramm auf.
*
* Erstellungsdatum:
* 07-Jul-93 Rolf Böhme
*
* Änderungen:
* 07-Jul-93 Rolf Böhme Erstellung
*
***************************************************************************
*/
#include "RSysfunc.h"
extern long _savsp,
_stkbase;
extern int errno;
extern int Enable_Abort;
extern int _argc,
_arg_len;
extern char **_argv,
*_arg_lin;
extern struct WBStartup *WBenchMsg;
extern struct _dev *_devtab;
extern short _numdev;
extern char hotkey[HOTKEYS][30];
extern UBYTE autocon[];
void _cli_parse(struct Process *pp, long alen, char *aptr);
extern struct Library *IconBase;
int bpc = 0, bgc = 0;
long bpp = 0x00000000L;
int winddetail = 0,windblock = 1,menudetail = 0;
char *RSysName = NULL;
extern char _dir[], _file[];
void
_wb_parse(void)
{
return;
};
static long
ahtoi(char *String)
{
long Value = 0;
char c;
while(c = *String)
{
Value <<= 4;
if(c >= '0' && c <= '9')
Value |= (c & 15);
else
Value |= (c & 15) + 9;
++String;
}
return(Value);
}
void
_icon_parse(char *progname)
{
register char *cp;
register struct DiskObject *dop;
if (IconBase = OpenLibrary((UBYTE *) "icon.library", 0L))
{
if (dop = GetDiskObject((UBYTE *) progname))
{
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "CX_HOTKEY"))
strcpy(&hotkey[0][0], cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "CX_CRYPT"))
strcpy(&hotkey[1][0], cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "CX_FINDFILE"))
strcpy(&hotkey[2][0], cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "CX_FORMAT"))
strcpy(&hotkey[3][0], cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "CX_HUNKLIST"))
strcpy(&hotkey[4][0], cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "CX_CRC"))
strcpy(&hotkey[5][0], cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "CX_SAVEWINDOW"))
strcpy(&hotkey[6][0], cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "NOFASTMODE"))
Flags.fastmode = 0;
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "NOSORT"))
Flags.sortmode = 0;
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "WORKINGBAR"))
Flags.workingbar = 1;
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "AUTOFRONT"))
Flags.autofront = 1;
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "MOUSEWINDOW"))
Flags.mousewindow = 1;
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "TOPAZFONT"))
Flags.sysfont = 1;
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "NOSAVEASKING"))
Flags.saveasking = 0;
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "NOAPPICON"))
Flags.appicon = 0;
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "OUTWINDOW"))
strcpy((char *)autocon,cp);
else
strcpy((char *)autocon,"CON:/40//150/Sys - Window/auto/close");
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "BACKPATTERNCOL"))
bpc = atoi(cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "BACKGROUNDCOL"))
bgc = atoi(cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "BACKPATTERN"))
bpp = ahtoi(cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "DETAILPEN"))
winddetail = atoi(cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "BLOCKPEN"))
windblock = atoi(cp);
if (cp = (char *)FindToolType((UBYTE **) dop->do_ToolTypes,(UBYTE *) "MENUPEN"))
menudetail = atoi(cp);
FreeDiskObject(dop);
}
CloseLibrary(IconBase);
IconBase = NULL;
}
return;
}
void
_main(long alen, char *aptr)
{
register struct Process *pp;
SysBase = *(struct ExecBase **) 4;
if (SysBase->LibNode.lib_Version < 37)
{
if (alen)
PutStr((UBYTE *)"WB 2.0 Only!");
exit(0);
}
if (_devtab = AllocMem(_numdev * (long)sizeof(struct _dev),
MEMF_CLEAR))
{
LastID = SYSTEMINFO;
_devtab[0].mode = O_RDONLY;
_devtab[1].mode = _devtab[2].mode = O_WRONLY;
_stkbase = _savsp - *((long *)_savsp + 1) + 8;
*(long *)_stkbase = 0x4d414e58L;
pp = (struct Process *) FindTask(0L);
strcpy(hotkey[0], "lshift rshift y");
strcpy(hotkey[1], "lshift rshift k");
strcpy(hotkey[2], "lshift rshift s");
strcpy(hotkey[3], "lshift rshift f");
strcpy(hotkey[4], "lshift rshift h");
strcpy(hotkey[5], "lshift rshift c");
strcpy(hotkey[6], "lshift rshift w");
if (pp->pr_CLI)
{
_cli_parse(pp, alen, aptr);
RSysName = AllocVec(MAXFULLNAME, MEMF_CLEAR);
if (RSysName)
{
NameFromLock(GetProgramDir(), (UBYTE *) RSysName, MAXFULLNAME);
strcpy(_dir,RSysName);
strcpy(_file,(char *)FilePart((UBYTE *) _argv[0]));
AddPart((UBYTE *) RSysName, FilePart((UBYTE *) _argv[0]), MAXFULLNAME);
}
Enable_Abort = 1;
_devtab[0].mode |= O_STDIO; /* shouldn't close if CLI */
_devtab[1].mode |= O_STDIO;
}
else
{
WaitPort(&pp->pr_MsgPort);
WBenchMsg = (struct WBStartup *) GetMsg(&pp->pr_MsgPort);
if (WBenchMsg->sm_ArgList)
{
NameFromLock(WBenchMsg->sm_ArgList->wa_Lock,
(UBYTE *) _dir, MAXFULLNAME);
strcpy(_file,
(char *)FilePart((UBYTE *)WBenchMsg->sm_ArgList->wa_Name));
RSysName = AllocVec(strlen(WBenchMsg->sm_ArgList->wa_Name) + 1, MEMF_CLEAR);
if (RSysName)
strcpy(RSysName, WBenchMsg->sm_ArgList->wa_Name);
CurrentDir(WBenchMsg->sm_ArgList->wa_Lock);
}
_argv = (char **)WBenchMsg;
}
if (RSysName)
_icon_parse(RSysName);
_devtab[0].fd = Input();
_devtab[1].fd = Output();
if (pp->pr_ConsoleTask)
_devtab[2].fd = Open((UBYTE *) "*", (long)MODE_OLDFILE);
main(_argc, _argv);
}
else
Alert(AG_NoMemory);
return;
}