/* CMS REPLACEMENT HISTORY, Element PRINTMSG.C */ /* 1I1 25-APR-2006 16:28:04 MYTH "V56 baselevel code freeze" */ /* 1H1 13-JUN-2004 15:45:33 MILLIGAN "V55 baselevel code freeze" */ /* 1G1 11-MAY-2003 23:09:01 TIBBERT "V54 baselevel code freeze" */ /* 1F1 22-JAN-2002 20:01:56 SYSTEM "V53 baselevel code freeze" */ /* 1E1 2-MAY-2001 04:46:43 MILLIGAN "V52 baselevel code freeze" */ /* 1D1 11-DEC-2000 23:06:10 MYTH "V51 baselevel code freeze" */ /* 1C1 12-MAY-2000 05:53:57 MUGGERIDGE "V51IFT baselevel code freeze" */ /* 1B1 28-OCT-1998 21:13:57 MUGGERIDGE "V50SSB baselevel code freeze" */ /* 1A1 18-JUN-1998 08:00:27 MUGGERIDGE "V50IFT baselevel code freeze" */ /* *1 9-OCT-1997 19:19:11 GEMIGNANI "Initial population of IPv6 source" */ /* CMS REPLACEMENT HISTORY, Element PRINTMSG.C */ /* ** printmsg.c: OpenVMS print a message on the console */ #include #include #include #include #include extern int SYS$SNDOPR(struct dsc$descriptor_s *, unsigned short); static int printmessage(char *); main(argc, argv) int argc; char *argv[]; { char *message; if (argc != 2) { fprintf(stderr, "usage: %s \n", argv[0]); exit (1); } message = argv[1]; if (!printmessage(message)) { fprintf(stderr,"%s: couldn't print your message\n", argv[0]); exit (1); } printf("Message Delivered!\n"); exit (0); } /* ** Print a message to the console. Return a Boolean indicating ** whether the message was actually printed. */ static int printmessage(msg) char *msg; { struct dsc$descriptor_s desc; union { char buffer[256]; /* Preallocate space for text */ struct opcdef opc; } message; int status; /* ** Build the message request block. */ message.opc.opc$b_ms_type = OPC$_RQ_RQST; message.opc.opc$b_ms_target = OPC$M_NM_CENTRL; message.opc.opc$w_ms_status = 0; message.opc.opc$l_ms_rqstid = 0; strcpy((char *) &message.opc.opc$l_ms_text, msg); desc.dsc$a_pointer = (char *) &message.opc; desc.dsc$w_length = (char *) &message.opc.opc$l_ms_text - (char *) &message + strlen((char *) &message.opc.opc$l_ms_text); /* ** Send the message to the console. */ status = SYS$SNDOPR(&desc, /* MSGBUF */ 0); /* CHAN */ if (status & 1) return 1; return 0; }