head 1.21; access; symbols new_system:1.15 old_system:1.14; locks; strict; comment @ * @; 1.21 date 99.05.07.14.41.41; author alexis; state Exp; branches; next 1.20; 1.20 date 99.04.28.09.44.34; author alexis; state Exp; branches; next 1.19; 1.19 date 99.01.07.13.09.30; author alexis; state Exp; branches; next 1.18; 1.18 date 98.10.07.16.27.37; author alexis; state Exp; branches; next 1.17; 1.17 date 98.08.30.22.03.48; author alexis; state Exp; branches; next 1.16; 1.16 date 98.08.28.13.13.39; author alexis; state Exp; branches; next 1.15; 1.15 date 98.08.08.09.47.47; author alexis; state Exp; branches; next 1.14; 1.14 date 98.08.07.11.28.42; author alexis; state Exp; branches; next 1.13; 1.13 date 98.03.01.14.25.19; author alexis; state Exp; branches; next 1.12; 1.12 date 97.11.11.12.01.56; author alexis; state Exp; branches; next 1.11; 1.11 date 97.10.26.12.12.31; author alexis; state Exp; branches; next 1.10; 1.10 date 97.10.22.16.38.44; author alexis; state Exp; branches; next 1.9; 1.9 date 97.10.20.16.58.17; author alexis; state Exp; branches; next 1.8; 1.8 date 97.09.22.17.58.20; author alexis; state Exp; branches; next 1.7; 1.7 date 97.02.21.17.13.02; author alexis; state Exp; branches; next 1.6; 1.6 date 97.02.16.14.43.27; author alexis; state Exp; branches; next 1.5; 1.5 date 97.02.09.16.00.50; author alexis; state Exp; branches; next 1.4; 1.4 date 97.02.01.21.52.17; author alexis; state Exp; branches; next 1.3; 1.3 date 97.01.31.14.43.34; author alexis; state Exp; branches; next 1.2; 1.2 date 97.01.31.10.22.48; author alexis; state Exp; branches; next 1.1; 1.1 date 97.01.22.10.34.49; author alexis; state Exp; branches; next ; desc @@ 1.21 log @lookup_msginfo() changed to smf_msginfo() @ text @#define MAIN /*@@unused@@*/ static char *sndmsg_c_rcs_id = "$Header: /diskb/home/alexis/dev/supported/ppplc/bin/RCS/sndmsg.c,v 1.20 1999/04/28 09:44:34 alexis Exp alexis $"; /******************************************************************************* * * System Includes * *******************************************************************************/ #include /* for NULL */ #include /* for calloc() */ #include /* for errno */ #include /* for strerror() */ /******************************************************************************* * * Application Includes * *******************************************************************************/ #include "utils.h" #include "patchlevel.h" #include "ppplc.h" /* for MSGTO_* */ #include "sm.h" /* smf_*() */ #include "ppplc_msgids.h" /* for svrmsginfo_data[] */ /******************************************************************************* * * Symbol Definitions * *******************************************************************************/ /******************************************************************************* * * Structure Definitions * *******************************************************************************/ /******************************************************************************* * * Static Functions Forward Declarations * *******************************************************************************/ static int gen_lockfile_name(char *, char *); /* write filename into buffer */ static int usage(void); /******************************************************************************* * * Static Data Definitions * *******************************************************************************/ /******************************************************************************* * * Global Data Definitions * *******************************************************************************/ char *progname; /******************************************************************************* * * Functions: main() and usage() and gen_lockfile_name() * *******************************************************************************/ /* * We make usage() return an int in the declaration, although it actually * returns nothing, so that callers can use a construct like: * * (argc == 3) || usage(); * * which would otherwise return an error. */ static int usage() { fprintf(stderr, "Usage: %s -V\n", progname); fprintf(stderr, " %s [ -v | -d ] [ -t ] [ -q ] [ ] ...\n", progname); exit(EXIT_FAILURE); } main( int argc, char *argv[]) { int i; int *mp; int j; int parcnt; int msgid; unsigned long interval = 0; int toid; int rc; progname = mybasename(argv[0], ""); toid = MSGTO_PPPLCD; debug_level = DBG_WARNING|DBG_ERROR; 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], "-q") == 0) { (argc<3 || sscanf(argv[2], "%lu", &interval)!=1) && usage(); argc--; argv++; } else if (strcmp(argv[1], "-t") == 0) { (argc<3 || sscanf(argv[2], "%d", &toid)!=1) && usage(); argc--; argv++; } else if (strcmp(argv[1], "-d") == 0) { (argc<3 || sscanf(argv[2], "%lu", &debug_level)!=1) && usage(); argc--; argv++; } else if (strcmp(argv[1], "-v") == 0) { debug_level = 3; } else usage(); argv++; argc--; } if (argc == 1) usage(); /* making the lock should fail! */ if (my_lock("ppplcd", gen_lockfile_name) == 0) { my_unlock("ppplcd", gen_lockfile_name); error("server not running!"); } if (smf_init(SMS_MCMODE_CLIENT, NULL, NULL) != 0) error("initialisation of client-mode state machine failed"); for (i=1; i1) ? "s" : ""); *(mp+j) = atoi(argv[++i]); } } if ((rc=smf_submit(svrmsginfo_data, toid, time(NULL)+interval, msgid, mp, SMS_SUBMIT_QUEUE)) != 0) error("can't queue message (%d)", rc); if (mp != NULL) free(mp); debug(DBG_FUNCS, "main: eof"); } return(0); } int gen_lockfile_name( char *lockfile, char *lockwhat) { /* lockwhat is set to NULL */ sprintf(lockfile, "%s/%s.pid", LOCK_DIR, "ppplcd"); return(0); } @ 1.20 log @*** empty log message *** @ text @d3 1 a3 1 static char *sndmsg_c_rcs_id = "$Header: /diskb/home/alexis/dev/supported/ppplc/bin/RCS/sndmsg.c,v 1.19 1999/01/07 13:09:30 alexis Exp alexis $"; d143 1 a143 1 parcnt = svrmsginfo_data[lookup_msginfo(svrmsginfo_data, msgid)].argc; d153 1 a153 1 error("message %d (%s) requires %d parameter%s", msgid, svrmsginfo_data[lookup_msginfo(svrmsginfo_data, msgid)].cmt, parcnt, (parcnt>1) ? "s" : ""); @ 1.19 log @RCS Id is now Header lock functions generate names now @ text @d3 7 a9 1 static char *rcs_id = "$Header: sndmsg.c,v 1.18 1998/10/07 16:27:37 alexis Exp alexis $"; d16 6 a22 2 #include "ppplcd_msgids.h" #include "ppplcd_ipc.h" /* for forward refs */ d24 21 d46 2 d49 11 a59 1 static int gen_lockfile_name(char *, char *); /* write filename into buffer */ d62 15 a76 1 extern struct msginfrec svrmsginfo_data[]; d137 3 a139 2 if (ppplcd_ipc_client_init() != 0) error("no message queue!"); d159 1 a159 1 if ((rc=ipc_queue_submit(svrmsginfo_data, toid, time(NULL)+interval, msgid, mp)) != 0) @ 1.18 log @delinted switched to new simplified error() function @ text @d3 1 a3 1 static char *rcs_id = "$Id: sndmsg.c,v 1.17 1998/08/30 22:03:48 alexis Exp alexis $"; d16 2 d76 2 a77 2 if (my_lock("ppplcd", NULL) == 0) { my_unlock("ppplcd", NULL); d109 9 @ 1.17 log @added explicit return code in main that was causing usecnt to always return non-zero error mode to ppplcd @ text @d2 2 a3 1 static char *rcs_id = "$Id: sndmsg.c,v 1.16 1998/08/28 13:13:39 alexis Exp alexis $"; d8 1 a8 1 #include /* for strerror[] */ d19 1 a19 1 usage() d23 1 a23 1 exit(1); d35 1 a35 1 time_t interval = 0; d46 1 a46 1 exit(0); d49 1 a49 1 (argc<3 || sscanf(argv[2], "%ld", &interval)!=1) && usage(); d57 1 a57 1 (argc<3 || sscanf(argv[2], "%ld", &debug_level)!=1) && usage(); d76 1 a76 1 error(exit, 1, "server not running!"); d78 2 a79 2 if (ppplcd_ipc_client_init()) error(exit, 1, "no message queue!"); d83 1 a83 1 parcnt = (svrmsginfo_data+lookup_msginfo(svrmsginfo_data, msgid))->argc; d87 3 a89 3 if ((mp=(int *) calloc(sizeof(int), parcnt)) == NULL) { error(exit, 1, "calloc: %s", strerror[errno]); exit(1); d93 1 a93 1 error(exit, 1, "message %d (%s) requires %d parameter%s", msgid, (svrmsginfo_data+lookup_msginfo(svrmsginfo_data, msgid))->cmt, parcnt, (parcnt>1) ? "s" : ""); d99 2 a100 2 if (rc=ipc_queue_submit(svrmsginfo_data, toid, time(NULL)+interval, msgid, mp)) error(exit, 1, "can't queue message (%d)", rc); @ 1.16 log @milepost @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.15 1998/08/08 09:47:47 alexis Exp alexis $"; d105 2 @ 1.15 log @new system - heavily modified to use alarms @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.14 1998/08/07 11:28:42 alexis Exp $"; d16 1 a16 1 extern struct msginfrec svrmsginfdat[]; d21 1 a21 1 fprintf(stderr, " %s [ -v | -d level ] [ -q ] msgid [ ... ]\n", progname); d35 2 d39 1 a39 1 d51 4 d82 1 a82 1 parcnt = (svrmsginfdat+id2infidx(svrmsginfdat, msgid))->argc; d92 1 a92 1 error(exit, 1, "message %d (%s) requires %d parameter%s", msgid, (svrmsginfdat+id2infidx(svrmsginfdat, msgid))->cmt, parcnt, (parcnt>1) ? "s" : ""); d98 2 a99 2 if (ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, time(NULL)+interval, msgid, mp)) error(exit, 1, "message queue present, but can't queue"); @ 1.14 log @milepost - seems to work ok, though few messages seem wrong @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.13 1998/03/01 14:25:19 alexis Exp alexis $"; d21 1 a21 1 fprintf(stderr, " %s [ -v | -d level ] msgid [ ... ]\n", progname); d34 1 d37 1 d45 4 d90 3 a92 1 if (ppplcd_ipc_send_msg(svrmsginfdat, MSGTO_SVR, msgid, mp)) d96 2 @ 1.13 log @added '-v' option (which is pointless 'cos debug is done by binary bits) @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.12 1997/11/11 12:01:56 alexis Exp alexis $"; d6 2 d35 1 a35 1 progname = basename(argv[0], ""); a60 1 debug(DBG_SPECIAL1, "main: about to attempt locking"); a64 1 debug(DBG_SPECIAL1, "main: about to attempt client init"); a83 1 debug(DBG_SPECIAL1, "main: about to call ppplcd_ipc_send_msg"); @ 1.12 log @ppplcd_utils.h renamed lock functions renamed @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.11 1997/10/26 12:12:31 alexis Exp $"; d18 2 a19 1 fprintf(stderr, "Usage: %s [ -V | -d level ] msgid [ ... ]\n", progname); d44 3 @ 1.11 log @stamped for release 1.0.6 @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.10 1997/10/22 16:38:44 alexis Exp alexis $"; d7 1 a7 1 #include "ppplcd_utils.h" d56 2 a57 2 if (make_lock("ppplcd", NULL) == 0) { unmake_lock("ppplcd", NULL); @ 1.10 log @changed version info to use printf() not info() @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.9 1997/10/20 16:58:17 alexis Exp alexis $"; @ 1.9 log @modified basename function to take a second parameter to strip @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.8 1997/09/22 17:58:20 alexis Exp $"; d37 1 a37 2 debug_level |= DBG_INFO; info("version %s", patchlevel); @ 1.8 log @(un)make_lock() now invoked with extra parameter @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.7 1997/02/21 17:13:02 alexis Exp $"; d32 1 a32 1 progname = basename(argv[0]); @ 1.7 log @added debug support '-d' and corrected initialisation of debug level @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.6 1997/02/16 14:43:27 alexis Exp alexis $"; d57 2 a58 2 if (make_lock("ppplcd") == 0) { unmake_lock("ppplcd"); @ 1.6 log @added -V flag, now test if server is running, before initialising message queue. @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.5 1997/02/09 16:00:50 alexis Exp alexis $"; d18 1 a18 1 fprintf(stderr, "Usage: %s [ -V ] msgid [ ... ]\n", progname); d33 1 a33 1 debug_level = 1023; d40 5 d56 1 d61 1 d81 1 @ 1.5 log @More changes ... now works. @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.4 1997/02/01 21:52:17 alexis Exp alexis $"; d18 1 a18 1 fprintf(stderr, "Usage: %s msgid [ ... ]\n", progname); d35 12 a49 2 if (ppplcd_ipc_client_init()) error(exit, 1, "no message queue!"); d55 2 @ 1.4 log @MILEPOST - WORKS @ text @d2 1 a2 1 static char *rcs_id = "$Id: sndmsg.c,v 1.3 1997/01/31 14:43:34 alexis Exp alexis $"; d39 1 a39 1 error("no message queue!"); d43 1 a43 1 error("server not running!"); d53 1 a53 1 perror("calloc"); d58 1 a58 1 error("message %d (%s) requires %d parameter%s", msgid, (svrmsginfdat+id2infidx(svrmsginfdat, msgid))->cmt, parcnt, (parcnt>1) ? "s" : ""); d63 1 a63 1 error("message queue present, but can't queue"); @ 1.3 log @MILEPOST - MAY NOT WORK @ text @d2 1 a2 1 static char *rcs_id = "$Id$"; d7 4 a10 3 #include "pppld_utils.h" #include "pppld_msgids.h" #include "pppld_ipc.h" /* for forward refs */ d38 7 a44 1 pppld_ipc_client_init() && error("no message queue! is the server running?"); d62 1 a62 1 if (pppld_ipc_send_msg(svrmsginfdat, MSGTO_SVR, msgid, mp)) @ 1.2 log @WORKING MILESTONE @ text @d1 3 d38 1 a41 1 debug(DBG_MSGMAJ, "parameter count for message %s should be %d", argv[i], parcnt); d51 1 a51 1 error("not enough pars"); @ 1.1 log @Initial revision @ text @d1 2 a2 1 #include d10 7 d22 5 a26 1 char buf[MAX_MSG_SIZ]; d29 1 d31 2 a32 6 debug_level = 100; if (argc != 2) { perror("usage"); exit(1); } d34 22 a55 3 if (pppld_ipc_client_init()) { perror("msgget"); exit(1); a56 6 if (pppld_ipc_send_msg(MSGTO_SVR, msgid2txt(atoi(argv[1])))) { error("can't deliver message, server running?"); } exit(0); @