/*-------------------------------------------------------------------------------------------------------
Purpose: Skeleton PUPS/PSRP application
Authors: M.A. O'Neill
Digital Vision
Didcot
Oxfordshire
OX11 8QY
Dated: 8th May 1999
Version: 1.00
E-mail: mao@@ermine.ox.ac.uk
-------------------------------------------------------------------------------------------------------*/
#include <me.h>
#include <utils.h>
#include <netlib.h>
#include <psrp.h>
#include <hipl_hdr.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#ifdef CKPT_SUPPORT
#include <libckpt.h>
#include <checkpoint.h>
#endif /* CKPT_SUPPORT */
/*------------------------------------------------------------------------------------------------------
Get application information for slot manager ...
------------------------------------------------------------------------------------------------------*/
/* Slot information function */
_PRIVATE void $APPNAME(int level)
{ fprintf(stderr,"int dynamic [PUPS/PSRP] application $APPNAME 1.10: [ANSI C]\n");
if(level > 1)
{ fprintf(stderr,"(c) $DATE Digital Vision, Didcot\n");
fprintf(stderr,"Author: M.A. O'Neill\n");
fprintf(stderr,"$APPDES (PUPS format)\n\n");
}
else
fprintf(stderr,"\n");
fflush(stderr);
}
/* Application usage function */
_PRIVATE void $APPNAME_usage()
{ /* Put your usage information here - see for example embryo.c */
/* to look at the format for this */
/* Standard blurb about the signals required to support */
/* CKPT and PSRP protocols */
fprintf(stderr,"\n\nSignals\n\n");
#ifdef PSRP_ENABLED
fprintf(stderr,"SIGINIT SIGCHAN SIGPSRP: Process status [PSRP] request (protocol %2.2f)\n",PSRP_PROTOCOL_VERSION);
fprintf(stderr,"SICLIENT: tell client server is about to segment\n");
#ifdef THREAD_SUPPORT
fprintf(stderr,"SIGTHREAD: tell client its service thread (on PSRP server) has been terminated\n");
#endif /* THREAD_SUPPORT */
fprintf(stderr,"SIGALIVE: check for existence of client on signal dispatch host\n");
#ifdef CKPT
if(checkpointing == TRUE)
fprintf(stderr,"SIGCHECK SIGVACATE: CKPT job control\n");
#endif /* CKPT_SUPPORT */
#endif /* PSRP_ENABLED */
fprintf(stderr,"\n");
fflush(stderr);
}
#ifdef SLOT
#include <slotman.h>
_EXTERN void (* SLOT)() = $APPNAME_slot;
_EXTERN void (* USE )() = $APPNAME_usage;
#endif /* SLOT */
/*-------------------------------------------------------------------------------------------------------
Public variables and function pointers used by this application ...
-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------
Functions which are private to this application ...
-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------
Variables which are private to this module ...
-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------
Software I.D. tag (used if CKPT support enabled to discard stale dynamic
checkpoint files) ...
-------------------------------------------------------------------------------------------------------*/
#define VTAG 1
extern int appl_vtag = VTAG;
#ifdef CKPT_SUPPORT
extern int checkpointing;
#endif /* CKPT_SUPPORT */
/*------------------------------------------------------------------------------------------------------
Main - decode command tail then interpolate using parameters supplied by user ...
------------------------------------------------------------------------------------------------------*/
_PUBLIC int pups_main(int argc, char *argv[])
{
#ifdef PSRP_ENABLED
/* Ignore any clients who may be trying to attach to us until we are intialised */
psrp_ignore_requests();
#endif /* PSRP_ENABLED */
/*------------------------------------------------------------------------------------------------------
Get standard items form the command tail ...
------------------------------------------------------------------------------------------------------*/
std_init(TRUE,
&argc,
"1.00",
$AUTHOR,
"$APPNAME",
"$DATE",
argv);
/* Application specific arguments should go here */
/* embryo.c has some examples of how it should be done */
/* Complain about any unparsed arguments */
t_arg_errs(argc,argd,args);
#ifdef PSRP_ENABLED
/* Initialise the PSRP system here using psrp_init() */
/* Note any PSRP dyanmic load option you do not want */
/* is simply excluded from the first set of OR'd args */
/* If you don't want homeostasis protection for the */
/* server messaging channels omit PSRP_HOMEOSTATIC_STREAMS */
psrp_init(PSRP_STATIC_FUNCTION | PSRP_STATIC_DATABAG | PSRP_HOMEOSTATIC_STREAMS,NULL);
/* Load default dispatch table for this applications (loads */
/* dynamic objects which have been previously attached to this */
/* application and remembers any aliases we may have had for */
/* dispatch table objects */
(void)psrp_load_default_dispatch_table(stderr);
/* Once we have initialised the PSRP system, attached any dynamic objects */
/* and loaded any alias tables lets tell the world we are open for business */
psrp_accept_requests();
#endif /* PSRP_ENABLED */
/* Any payload functions which attach or create objects like files and shared heaps */
/* should register an exit function here, so that any temporary objects are destroyed */
/* by pups_exit() */
/*----------------------------------------------------------------------------------------------------
Static payload of application here - dynamic payloads are loaded using the PSRP
bind functions ...
----------------------------------------------------------------------------------------------------*/
/* Exit nicely clearing up and mess we have made */
pups_exit(0);
}