home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d8xx
/
d812
/
ppmc.lha
/
PPMC
/
Source
/
PPMC1.2b_source.lha
/
setup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-27
|
5KB
|
189 lines
/*
----------------------
setup.c
© 1992,1993 REELSOFT
----------------------
*/
#include <proto/asl.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <proto/graphics.h>
#include <proto/powerpacker.h>
#include <proto/reqtools.h>
#include <proto/utility.h>
#include <proto/wb.h>
#include <clib/locale_protos.h>
#include <pragmas/locale_pragmas.h>
#include <libraries/dos.h>
#include <libraries/ppbase.h>
#include <libraries/reqtools.h>
#include <graphics/gfxbase.h>
#include <stdlib.h>
#include "protos.h"
#include "macros.h"
#include "debug.h"
#include "ppmc.h"
#include "setup.h"
#include "locale.h"
//""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
VOID __regargs _CXBRK (VOID)
{
Printf("\n\033[32mPPMC:\033[31m \033[1m%s...\033[0m\n",LOC(MSG_CLI_BREAK)) ;
FreeCrMem() ;
Cleanup (EXIT_SUCCESS) ;
}
//""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
VOID Setup (VOID)
{
// opening the locale.library if available,
// and reading all the translated strings :
if (LocaleBase = (struct LocaleBase *)OpenLibrary ("locale.library",38L)) {
struct Catalog *catalog = OpenCatalog (NULL,"ppmc.catalog",OC_Language,sup.language,TAG_DONE) ;
if (catalog) {
UBYTE n ;
for (n=0 ; n<=MSG_PER_PACKED ; n++)
AppStrings[n].as_Str = GetCatalogStr (catalog,n,AppStrings[n].as_Str) ;
CloseCatalog (catalog) ;
}
}
// opening reqtools.library :
if (NOT sup.cli) {
if (NOT (ReqToolsBase = (struct ReqToolsBase *)OpenLibrary (REQTOOLSNAME,REQTOOLSVERSION)))
Cleanup (EXIT_FAILURE) ;
REQTITLE = (ULONG)LOC(MSG_TITLE_WARNING) ;
}
// opening the powerpacker.library :
if (NOT (PPBase = (struct PPBase *)OpenLibrary (PPNAME,PPVERSION))) {
if (sup.cli)
Printf ("\033[32mPPMC:\033[31m \033[1m%s !\033[0m\n",LOC(MSG_PPACKER_VER)) ;
else
rtEZRequest ("%s !",LOC(MSG_OK_ABORT),NULL,rttags,LOC(MSG_PPACKER_VER)) ;
Cleanup (EXIT_FAILURE) ;
}
// open the utility.library :
if (NOT (UtilityBase = OpenLibrary ("utility.library",37L))) {
if (sup.cli)
Printf ("\033[32mPPMC:\033[31m \033[1m%s !\033[0m\n",LOC(MSG_OS_VER)) ;
else
rtEZRequest ("%s !",LOC(MSG_OK_ABORT),NULL,rttags,LOC(MSG_OS_VER)) ;
Cleanup (EXIT_FAILURE) ;
}
password[0] = 0x00 ;
pac.eff = (pac.eff>0&&pac.eff<=5)?(pac.eff-1):4 ;
pac.buf = (pac.buf>0&&pac.buf<=3)?(pac.buf-1):0 ;
pac.dec = (pac.dec>0&&pac.dec<=5)?(pac.dec-1):4 ;
// invoked from CLI ? well, we have all we need, let's return to main()..
if (sup.cli)
return ;
// otherwise, we have to open several other libraries :
if ( NOT(IntuitionBase = (struct IntuitionBase *)OpenLibrary ("intuition.library",37L))
|| NOT(GfxBase = (struct GfxBase *)OpenLibrary (GRAPHICSNAME,37L))
|| NOT(WorkbenchBase = OpenLibrary (WORKBENCH_NAME,37L))
|| NOT(GadToolsBase = OpenLibrary ("gadtools.library",37L)) )
Cleanup (RETURN_ERROR) ;
// try to open the asl.library for the file requester :
if (sup.asl)
AslBase = OpenLibrary (AslName,37L) ;
// initializing and Adding the custom font :
FontInit() ;
sup.font = TRUE ;
// locking the `sup.pubscreen' screen (Workbench by default) :
if (SetupScreen()) {
rtEZRequest ("%s !",LOC (MSG_OK_ABORT),NULL,rttags,LOC(MSG_LOCK_SCREEN)) ;
Cleanup (EXIT_FAILURE) ;
}
// opening PPMC Window :
if (SetupWindow()) {
rtEZRequest ("%s !",LOC(MSG_OK_ABORT),NULL,rttags,LOC(MSG_OPEN_WINDOW)) ;
Cleanup (EXIT_FAILURE) ;
}
else {
struct Process *process = (struct Process *) FindTask(0) ;
process->pr_WindowPtr = Wnd ;
}
// creating a Message Port :
MsgPort = CreateMsgPort() ;
if (NOT MsgPort) {
DEBUG_MSG (MSG_MSGPORT_DEBUG) ;
Cleanup (EXIT_FAILURE) ;
}
else { // adding an AppWindow :
AppWin = AddAppWindow (1,0,Wnd,MsgPort,NULL) ;
if (NOT AppWin) {
DEBUG_MSG (MSG_APPWIN_DEBUG) ;
DeleteMsgPort (MsgPort) ;
MsgPort = NULL ;
}
}
// getting the Gadgets short-cut key code :
key.save = ShCutKey (MSG_SAVE_GAD, 'S') ;
key.pack = ShCutKey (MSG_PACK_GAD, 'P') ;
key.unpack = ShCutKey (MSG_UNPACK_GAD, 'U') ;
key.encrypt = ShCutKey (MSG_ENCRYPT_GAD,'E') ;
name.old[0] = name.new[0] = 0x00 ;
}
//""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
VOID Cleanup (UBYTE errcode)
{
FreeCrMem() ;
if (NOT sup.cli) {
if (AppWin)
RemoveAppWindow (AppWin) ;
if (MsgPort)
DeleteMsgPort (MsgPort) ;
CloseDownWindow() ;
CloseDownScreen() ;
if (sup.font)
RemFont (&Font) ;
// closing opened libraries :
if (GadToolsBase) // gadtools.library
CloseLibrary (GadToolsBase) ;
if (AslBase) // asl.library
CloseLibrary (AslBase) ;
if (WorkbenchBase) // workbench.library
CloseLibrary (WorkbenchBase) ;
if (GfxBase) // graphics.library
CloseLibrary ((struct Library *)GfxBase) ;
if (IntuitionBase) // intuition.library
CloseLibrary ((struct Library *)IntuitionBase) ;
}
if (UtilityBase) // utility.library
CloseLibrary (UtilityBase) ;
if (PPBase) // powerpacker.library
CloseLibrary ((struct Library *)PPBase) ;
if (ReqToolsBase) // reqtools.library
CloseLibrary ((struct Library *)ReqToolsBase) ;
if (LocaleBase) // locale.library
CloseLibrary ((struct Library *)LocaleBase) ;
exit (errcode) ;
}
// ...