head 1.6; access; symbols; locks; strict; comment @ * @; 1.6 date 99.05.07.14.27.37; author alexis; state Exp; branches; next 1.5; 1.5 date 99.04.28.09.44.32; author alexis; state Exp; branches; next 1.4; 1.4 date 99.01.07.13.04.37; author alexis; state Exp; branches; next 1.3; 1.3 date 98.10.07.16.20.22; author alexis; state Exp; branches; next 1.2; 1.2 date 98.08.28.17.39.26; author alexis; state Exp; branches; next 1.1; 1.1 date 98.08.28.13.09.07; author alexis; state Exp; branches; next ; desc @GENERIC MESSAGE READER @ 1.6 log @calls to lookup_msginfo() changed to calls to smf_msginfo() @ text @#define MAIN /*@@unused@@*/ static char *getmsg_c_rcs_id = "$Header: /diskb/home/alexis/dev/supported/ppplc/bin/RCS/getmsg.c,v 1.5 1999/04/28 09:44:32 alexis Exp alexis $"; /******************************************************************************* * * System Includes * *******************************************************************************/ #include /* for time_t */ #include /* for printf and NULL */ #include /* for strrchr(),strtok(),strerror() */ #include /* for SIGINT, SIG_IGN etc */ #include /* for errno in strerror() */ #include /* for exit() */ /******************************************************************************* * * Application Includes * *******************************************************************************/ #include "utils.h" #include "patchlevel.h" #include "ppplc_msgids.h" /* for MSGID_* */ #include "sm.h" /* for smf_*() */ #include "ppplc.h" /* for MSGTO_* */ /******************************************************************************* * * Symbol Definitions * *******************************************************************************/ /******************************************************************************* * * Structure Definitions * *******************************************************************************/ /******************************************************************************* * * Static Functions Forward Declarations * *******************************************************************************/ static void sigintterm_handler(int); static int process_info_message(int *); static int usage(void); /******************************************************************************* * * Static Data Definitions * *******************************************************************************/ static struct mhflkuprec getmsg_mhf_data[] = { { MSGID_INFO_DATA, process_info_message }, { MSGID_PSEUDO_LAST, NULL } }; /******************************************************************************* * * Global Data Definitions * *******************************************************************************/ /******************************************************************************* * * Functions: main() and usage() and gen_lockfile_name() * *******************************************************************************/ static int usage() { debug(DBG_FUNCS, "usage: sof"); fprintf(stderr, "Usage: %s [ -d ]\n", progname); exit(EXIT_FAILURE); } main( int argc, char *argv[]) { progname = mybasename(argv[0], ""); while (argc>1 && argv[1][0] == '-') { if (strcmp(argv[1], "-V") ==0) { printf("%s version %s\n", progname, patchlevel); exit(EXIT_SUCCESS); } else if (strcmp(argv[1], "-d") == 0) { (argc<3) && usage(); (sscanf(argv[2], "%lu", &debug_level)!=1) && usage(); argc--; argv++; } else (void) usage(); argv++; argc--; } (argc != 1) && usage(); debug(DBG_FUNCS, "main: sof (proper)"); debug(DBG_SIGEXEC, "main: setting up signal handlers"); signal(SIGINT, sigintterm_handler); signal(SIGTERM, sigintterm_handler); if (smf_init(SMS_MCMODE_CLIENT, NULL, NULL) != 0) error("initialisation of client-mode state machine failed"); if (smf_engine(MSGTO_GETMSG, svrmsginfo_data, getmsg_mhf_data) != 0) error("state machine error"); return(0); } static void sigintterm_handler( /*@@unused@@*/ int signumber) { debug(DBG_FUNCS, "sigint_handler: sof"); info("exiting on SIGINT/SIGTERM"); exit(EXIT_FAILURE); } static int process_info_message( int *parp) { int i, parc; debug(DBG_FUNCS, "process_info_message: sof"); /* * This function is to handle data dump messages only, but since the * number of numbers returned in the parameter block changes as I * develop this program, it is more resiliant to actually look this * number up each time, rather than wind up shooting over the end of * the array, or not reading to the end of it. */ for (i=0,parc=svrmsginfo_data[smf_msginfo(svrmsginfo_data, MSGID_INFO_DATA)].argc; i d11 1 a11 1 #include /* for strrchr(), strtok(), strerror() */ a12 3 #include /* for wait() par types */ #include /* for time() */ #include /* for setpgrp() */ d52 3 a54 2 void sigintterm_handler( int unknown) d58 1 a58 1 exit(1); d61 1 a61 1 usage() d66 1 a66 1 exit(1); d69 2 a70 1 int process_info_message( d79 2 a80 2 error(exit, 1, "received unexpected message: %d (%s)", msgid, (svrmsginfo_data+lookup_msginfo(svrmsginfo_data, msgid))->cmt); for (i=0,parc=(svrmsginfo_data+lookup_msginfo(svrmsginfo_data, msgid))->argc; i