#include #include #include /* Descriptor structure definitions */ #include /* LIB RTL symbol definitions */ #include /* Standard C symbol definitions */ #include /* System Service status code def'ns */ #include /* CREMBX definitions */ #include /* ASSIGN definitions */ #include /* I/O definitions */ #define $ARRAY_DESCRIPTOR(name,size,array_name) \ char array_name[ size ]; \ struct dsc$descriptor_s name = \ { size, DSC$K_DTYPE_T, DSC$K_CLASS_S, array_name } main() { # define max_msg_len 256 $DESCRIPTOR(mailbox_name_desc,"MAILBOX_EXAMPLE"); $ARRAY_DESCRIPTOR(read_buffer_desc,max_msg_len,read_buffer); int status, mailbox_channel; int true=1, false = 0; struct io_status_block { /* I/O status block */ short int condition; short int count; int dev; } iosb; /* * Create a permanent mailbox with a READONLY channel. It's logical name * will be entered into the LNM$PERMANENT_MAILBOX logical name table. */ sys$crembx(1,&mailbox_channel,0,0,0,0,&mailbox_name_desc,CMB$M_READONLY); /* * Mark it for deletion */ sys$delmbx(mailbox_channel); /* * Loop forever, first waiting til a WRITE channel is assigned to the mailbox * and then reading data from it until the WRITER deassigns. */ while (TRUE) { /* First, check to see if there is a WRITER assigned to the mailbox */ status = sys$qiow ( 0, mailbox_channel, IO$_SENSEMODE|IO$M_WRITERCHECK, &iosb, 0,0, 0,0,0,0,0,0); /* If there was no WRITER, then wait for one.*/ if (iosb.condition == SS$_NOWRITER) status = sys$qiow ( 0, mailbox_channel, IO$_SETMODE|IO$M_WRITERWAIT, &iosb, 0,0, 0,0,0,0,0,0); /* * While the status is good, READ from the mailbox, and write it to */ while (status == SS$_NORMAL) { status = sys$qiow( 0, mailbox_channel, IO$_READVBLK|IO$M_WRITERCHECK, &iosb, 0,0, read_buffer_desc.dsc$a_pointer,max_msg_len, 0,0,0,0); status=iosb.condition; read_buffer_desc.dsc$w_length = iosb.count; lib$put_output(&read_buffer_desc); } } }