home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
workbench
/
stickit2
/
source.lha
/
source
/
general.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-09
|
6KB
|
274 lines
/************************************************
************** general.c ******************
************************************************/
#define INTUI_V36_NAMES_ONLY
#include <exec/exec.h>
#include <intuition/intuition.h>
#include <workbench/startup.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/icon_protos.h>
#include <clib/dos_protos.h>
#include <clib/alib_protos.h>
#include <clib/utility_protos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "consts.h"
#include "structs.h"
#include "proto.h"
extern prj_p prj;
extern BOOL fromwb;
extern struct IOClipReq *clipio;
#ifdef _DCC
__chip UWORD WaitPointer[] = {
#else
UWORD __chip WaitPointer[] = {
#endif
0x0000, 0x0000, /* reserved, must be NULL */
0x0400, 0x07C0,
0x0000, 0x07C0,
0x0100, 0x0380,
0x0000, 0x07E0,
0x07C0, 0x1FF8,
0x1FF0, 0x3FEC,
0x3FF8, 0x7FDE,
0x3FF8, 0x7FBE,
0x7FFC, 0xFF7F,
0x7EFC, 0xFFFF,
0x7FFC, 0xFFFF,
0x3FF8, 0x7FFE,
0x3FF8, 0x7FFE,
0x1FF0, 0x3FFC,
0x07C0, 0x1FF8,
0x0000, 0x07E0,
0x0000, 0x0000, /* reserved, must be NULL */
};
/*
Function : void startup(int argc,char **argv)
Purpose : Sets up the program before start.
*/
void startup(int argc,char **argv)
{
char *toolstring;
UBYTE **tooltypes;
int l;
/* Set default preferences values */
prj->prefs.backcolour = DEFAULT_BACKCOLOUR;
prj->prefs.textcolour = DEFAULT_TEXTCOLOUR;
prj->prefs.caratcolour = DEFAULT_CARATCOLOUR;
prj->prefs.noteheight = DEFAULT_NOTEHEIGHT;
prj->prefs.notewidth = DEFAULT_NOTEWIDTH;
prj->prefs.font = NULL;
prj->prefs.notefont[0] = '\0';
prj->prefs.textattr.ta_Name = prj->prefs.notefont;
prj->prefs.textattr.ta_YSize = DEFAULT_FONTSIZE;
prj->prefs.textattr.ta_Style = NULL;
prj->prefs.textattr.ta_Flags = NULL;
strncpy(prj->prefs.notefile,DEFAULT_NOTEFILE,STRLEN_FNAME);
prj->prefs.cx_priority = DEFAULT_CXPRIORITY;
prj->prefs.cx_popup = DEFAULT_CXPOPUP;
strncpy(prj->prefs.cx_popkey,DEFAULT_CXPOPKEY,STRLEN_CXPOPKEY);
strcpy(prj->prefs.pubscreen,DEFAULT_PUBSCREEN);
prj->prefs.clipunit = DEFAULT_CLIPUNIT;
prj->prefs.delay = DEFAULT_DELAY;
prj->prefs.emptyquit = DEFAULT_EMPTYQUIT;
prj->prefs.hidewarn = DEFAULT_HIDEWARN;
/* Project not changed */
prj->projectchanged = FALSE;
/* Flag set on quit */
prj->abouttoquit = FALSE;
/* Clear all notes */
for (l = 0; l < NO_NOTES; l++)
prj->notes[l] = NULL;
prj->curr_note = NULL;
/* Set NULL pointers */
prj->main_msg_port = NULL;
prj->broker = NULL;
prj->filter = NULL;
prj->sender = NULL;
prj->translate = NULL;
prj->broker_msg_port = NULL;
/* Set up the linked list for the commodities gadget */
NewList(&prj->commodlist);
/* Set the cycle gadget to background */
prj->commodcolour = COLOUR_BACKGROUND;
/* Set the double click values */
prj->lastclicked = 0;
prj->doubleclickseconds = 0;
prj->doubleclickmicros = 0;
/* Clear blank requester */
InitRequester(&prj->blockreq);
/* Set up the broker message port */
prj->broker_msg_port = CreateMsgPort();
if (!prj->broker_msg_port)
error("Can't create broker message port",ERR_FATAL,__LINE__,
__FILE__);
/* Set up the main message port */
prj->main_msg_port = CreateMsgPort();
if (!prj->main_msg_port)
error("Can't create main message port",ERR_FATAL,__LINE__,
__FILE__);
/*** Read the tooltypes ***/
tooltypes = ArgArrayInit(argc,argv);
if (!tooltypes)
return;
/* Read the tooltypes */
/* The notefile */
toolstring = ArgString(tooltypes,"NOTEFILE",DEFAULT_NOTEFILE);
strncpy(prj->prefs.notefile,toolstring,STRLEN_FNAME);
/* Note colours (English and American !)*/
prj->prefs.backcolour = (UBYTE)ArgInt(tooltypes,"BACKCOLOR",DEFAULT_BACKCOLOUR);
prj->prefs.textcolour = (UBYTE)ArgInt(tooltypes,"TEXTCOLOR",DEFAULT_TEXTCOLOUR);
prj->prefs.caratcolour = (UBYTE)ArgInt(tooltypes,"CARATCOLOR",DEFAULT_CARATCOLOUR);
prj->prefs.backcolour = (UBYTE)ArgInt(tooltypes,"BACKCOLOUR",DEFAULT_BACKCOLOUR);
prj->prefs.textcolour = (UBYTE)ArgInt(tooltypes,"TEXTCOLOUR",DEFAULT_TEXTCOLOUR);
prj->prefs.caratcolour = (UBYTE)ArgInt(tooltypes,"CARATCOLOUR",DEFAULT_CARATCOLOUR);
/* Note sizes */
prj->prefs.noteheight = (WORD)ArgInt(tooltypes,"NOTEHEIGHT",DEFAULT_NOTEHEIGHT);
prj->prefs.notewidth = (WORD)ArgInt(tooltypes,"NOTEWIDTH",DEFAULT_NOTEWIDTH);
/* Note font */
toolstring = ArgString(tooltypes,"NOTEFONT","");
strncpy(prj->prefs.notefont,toolstring,STRLEN_FONTNAME);
prj->prefs.textattr.ta_YSize = (UWORD)ArgInt(tooltypes,"FONTSIZE",DEFAULT_FONTSIZE);
/* Commodities info */
prj->prefs.cx_priority = (BYTE)ArgInt(tooltypes,"CX_PRIORITY",DEFAULT_CXPRIORITY);
toolstring = ArgString(tooltypes,"CX_POPUP","YES");
prj->prefs.cx_popup = Stricmp(toolstring,"NO") ? TRUE : FALSE;
toolstring = ArgString(tooltypes,"CX_POPKEY",DEFAULT_CXPOPKEY);
strncpy(prj->prefs.cx_popkey,toolstring,STRLEN_CXPOPKEY);
/* Public screen */
toolstring = ArgString(tooltypes,"PUBSCREEN",DEFAULT_PUBSCREEN);
strncpy(prj->prefs.pubscreen,toolstring,STRLEN_PUBSCREEN);
/* Clipboard unit */
prj->prefs.clipunit = (LONG)ArgInt(tooltypes,"CLIPUNIT",DEFAULT_CLIPUNIT);
/* Startup delay */
prj->prefs.delay = (ULONG)ArgInt(tooltypes,"DELAY",DEFAULT_DELAY);
/* Do we quit on startup if no notes read in ? */
toolstring = ArgString(tooltypes,"EMPTYQUIT","NO");
prj->prefs.emptyquit = Stricmp(toolstring,"NO") ? TRUE : FALSE;
/* Do we warn the user if they hide the commodities window when */
/* the project has been changed ? */
toolstring = ArgString(tooltypes,"HIDEWARN","YES");
prj->prefs.hidewarn = Stricmp(toolstring,"NO") ? TRUE : FALSE;
/* Free mem */
if (tooltypes)
ArgArrayDone();
}
/*
Function : void error(const char *msg,error_e err_no,int line,const char *file);
Purpose : Pops up a requester informing user of an error. If err_no >
ERR_FATAL, the function calls cleanup() and the program will
exit.
*/
void error(const char *msg,error_e err_no,int line,const char *file)
{
struct EasyStruct easyreq_error = {
sizeof(struct EasyStruct),
0,
"StickIt2",
"FATAL ERROR : %s\nLine %ld in file \"%s\"",
"Quit"
};
struct EasyStruct easyreq_warn = {
sizeof(struct EasyStruct),
0,
"StickIt2",
"WARNING : %s",
"Continue"
};
LONG return_val;
if (err_no >= ERR_FATAL) {
return_val = EasyRequest(NULL,&easyreq_error,NULL,msg,line,
file);
cleanup();
}
else
return_val = EasyRequest(NULL,&easyreq_warn,NULL,msg);
}