home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
230.lha
/
ArexxFunctionHost
/
rh_demo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-04-03
|
5KB
|
232 lines
/* ARexx_Host module Demo */
/* Copyright © 1989 by Donald T. Meyer
* All Rights Reserved
*
* This source code may be compiled and used in any software
* product.
* No portion of this source code is to be
* re-distributed or sold for profit without the written
* permission of the author, Donald T. Meyer.
*
* Donald T. Meyer
* Stormgate Software
* 4 Rustic Creek Court
* St. Peters, MO 63376
*
* BIX: donmeyer
* GEnie: D.MEYER
* PLINK: Stormgate
*/
#include <intuition/intuition.h>
#include <proto/intuition.h>
#include <proto/exec.h>
#include "rexxfunchost.h"
/*------------------------------------------------------------------*/
/* External Function Declarations */
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* Local Function Declarations */
/*------------------------------------------------------------------*/
/* Declare all of the host function functions */
void func_rats( struct RexxMsg * );
void func_dbeep( struct RexxMsg * );
void func_bigword( struct RexxMsg * );
void func_myerror( struct RexxMsg * );
/*------------------------------------------------------------------*/
/* Variable Definitions */
/*------------------------------------------------------------------*/
char *hostname = "DEMO_FUNC_HOST";
int hostpri = 5;
/* This is the stuff to let us become detached... */
long _stack = 4096;
long _priority = 0;
char *_procname = "Demo_ARexxHost";
char *hello_string = "Demo ARexx Function Host Version 0.0\n\
Copyright \xA9 by Don Meyer, Stormgate Software\n\n";
char *success_string = "Function Host installation successful!\n";
char *removal_string = "Removing existing demo function host!\n";
char *redundant_string =
"Oops, we already are running. No action taken.\n";
char *noclone_string = "No existing demo host to remove!\n";
char *console_def_string = "CON:30/30/500/60/ARexx Function Host";
struct RexxFunction func_table[] = {
{ "rats", &func_rats, 0, FALSE },
{ "dbeep", &func_dbeep, 0, FALSE },
{ "bigword", &func_bigword, 1, FALSE },
{ "myerror", &func_myerror, -1, FALSE },
/* Mark end-of-table */
{ NULL, NULL, 0, FALSE }
};
/* These are needed only if these librarys will be opened and used. */
struct IntuitionBase *IntuitionBase = NULL;
struct GfxBase *GfxBase = NULL;
/*------------------------------------------------------------------*/
/* Functions */
/*------------------------------------------------------------------*/
/*****************************************
** **
** The Host Functions **
** **
****************************************/
/* A function which returns nothing */
/*
* call dbeep()
*/
void func_dbeep( struct RexxMsg *rexxmsg )
{
DisplayBeep( NULL );
rexxmsg->rm_Result1 = RC_OK;
rexxmsg->rm_Result2 = 0;
}
/* A function which returns a string */
/*
* say rats()
*/
void func_rats( struct RexxMsg *rexxmsg )
{
SetResultString( rexxmsg, "Large Rodents!" );
/* "manual" method -----v */
/* */
/* rexxmsg->rm_Result1 = RC_OK; */
/* rexxmsg->rm_Result2 = */
/* (ULONG)CreateArgstring( "Large Rodents!", (LONG)14 ); */
/* */
}
/* A function which takes one argument and returns a boolean */
/*
* say bigword( "Supercalifragilisticexpaladouchs" )
*/
void func_bigword( struct RexxMsg *rexxmsg )
{
if( LengthArgstring( (struct RexxArg *)ARG1(rexxmsg) ) > 15 )
{
SetResultString( rexxmsg, "1" );
}
else
{
SetResultString( rexxmsg, "0" );
}
}
/* Returns a function error no matter what */
void func_myerror( struct RexxMsg *rexxmsg )
{
SetResultString( rexxmsg, NULL );
/* "manual" method -----v */
/* */
/* rexxmsg->rm_Result1 = RC_OK; */
/* rexxmsg->rm_Result2 = ERR10_012 */
}
/*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
/* These two functions will be called by the startup and cleanup.
* Typical use is to open librarys, etc.
*/
/* This should return a pointer to an error message string to
* indicate failure
*/
char *client_init( void )
{
/* Intuition */
if( ! ( IntuitionBase = (struct IntuitionBase *)
OpenLibrary("intuition.library", LIBRARY_VERSION) ) )
{
return( "Unable to open the Intuition Library" );
}
/* Graphics */
if( ! ( GfxBase = (struct GfxBase *)
OpenLibrary("graphics.library", LIBRARY_VERSION) ) )
{
return( "Unable to open the Graphics Library" );
}
return( NULL );
}
/* This will be called prior to exiting. Note that this will be
* called no matter what the reason for exiting is (normal completion
* or termination due to error).
*/
void client_cleanup( void )
{
if( IntuitionBase )
CloseLibrary( (struct Library *)IntuitionBase );
if( GfxBase )
CloseLibrary( (struct Library *)GfxBase );
}