Call your local customer support centre and have them activate your
DIA account. This is dial in access to the DSNlink system - a service
to which you are entitled as long as you have a support contract.
The service is also available on the internet (telnet to
dia.service.digital.com) and on the web at http://www.service.digital.com
(note, the web site may not be available in all areas). Using the
query "example c mailbox" I found 157 articles, most of which are
example programs using mailboxes (though not all are in C). I've
appended one.
Example-C How To Create, Write To, And Read A Mailbox
COPYRIGHT (c) 1988, 1993 by Digital Equipment Corporation.
ALL RIGHTS RESERVED. No distribution except as provided under contract.
Copyright (c) Digital Equipment Corporation 1994. All rights reserved.
PRODUCT: VAX C/DEC C
DEC C for OpenVMS AXP
OP/SYS: OpenVMS VAX
OpenVMS AXP
SOURCE: Digital Equipment Corporation
OVERVIEW:
This example shows how to create a temporary mailbox, read from a mailbox,
and write to a mailbox.
*** CAUTION ***
This sample program has been tested using VAX C V3.2 on OpenVMS VAX V6.1,
DEC C V4.0 on OpenVMS VAX V6.1, and DEC C V4.0 on OpenVMS AXP V6.1.
However, we cannot guarantee its effectiveness because of the possibility
of error in transmitting or implementing it. It is meant to be used as a
template for writing your own program, and it may require modification for
use on your system.
SOURCE:
This programming example was taken from the VAX/VMS Education Series,
UTILIZING VMS FEATURES FROM VAX C, C Language Workbook, (Aug 86).
PROGRAM NOTES:
The programs MAILS and MAILR must be run from two processes in the same
group. To run the programs, log in at one terminal, execute the DEFINE
command as explained below, and run one program. Then log onto another
terminal, execute the DEFINE command for that process and run the other
terminal.
Because both MAILS and MAILR use $CREMBX to create a temporary mailbox
with the logical name FOZZIE_BEAR (if no such mailbox exists) and assign
a channel to it, the programs can be run in any order. If MAILS had used
$CREMBX and MAILR had used $ASSIGN, for example, it would be necessary to
run MAILS first.
When you specify a logical name for a temporary mailbox, the $CREMBX
service enters the name into the LNM$TEMPORARY_MAILBOX logical name table.
Normally, LNM$TEMPORARY_MAILBOX specifies LNM$JOB, the job-wide logical
name table; thus, only processes in the same job as the process that first
creates the mailbox can use the logical name to access the temporary
mailbox. If you want to use the temporary mailbox to enable communication
between processes in different jobs, you must redefine LNM$TEMPORARY_
MAILBOX in the process logical name directory table (LNM$PROCESS_
DIRECTORY), to specify a logical name table that those processes can
access.
For instance, if you want to use the mailbox as a communication device for
processes in the same group, you must redefine LNM$TEMPORARY_MAILBOX to
specify LNM$GROUP, the group logical name table. The following DCL command
assigns temporary mailbox logical names to the group logical name table:
$DEFINE/TABLE=LNM$PROCESS_DIRECTORY LNM$TEMPORARY_MAILBOX LNM$GROUP
Because $QIOW is used for input and output rather than $QIO, both MAILS
and MAILR wait for I/O to complete before advancing to the next program
statement.
The P1 argument of $QIOW is the address of a buffer of ASCII text, not the
address of an ASCII string descriptor.
PROGRAMS:
/* MAILS.C
This program writes to a mailbox with the
logical name FOZZIE_BEAR. Since this is a
synchronous operation, the write does not
complete until the process MAILR reads the message. */
#include
#include
#include
#include
#include
main()
{
typedef struct
{
short cond_value;
short count;
int info;
} io_statblk;
io_statblk iosb;
short channel;
$DESCRIPTOR(mailbox_name, "FOZZIE_BEAR");
char message[]="This is a message.";
register status;
/* create mailbox and/or assign channel to it */
if (((status = sys$crembx(0,&channel,0,0,0,0,&mailbox_name)) &1) !=1)
lib$stop(status);
/* write a message to the mailbox */
if (((status = sys$qiow(1, channel, IO$_WRITEVBLK, &iosb, 0, 0,
message, sizeof(message), 0,0,0,0)) &1) != 1)
lib$stop(status);
if ((iosb.cond_value &1) != 1)
lib$stop(iosb.cond_value);
/* notify user */
printf("\nMAILS has completed mailbox write.\n");
}
/* MAILR.C
This program reads from the mailbox created by
MAILS. As soon as it reads the mailbox, MAILS
can continue. */
#include
#include
#include
#include
#include
main()
{
typedef struct
{
short cond_value;
short count;
int info;
} io_statblk;
io_statblk iosb;
short channel;
$DESCRIPTOR(mailbox_name, "FOZZIE_BEAR");
char input[30];
register status;
/* create mailbox and/or assign channel to it */
if (((status = sys$crembx(0,&channel,0,0,0,0,&mailbox_name)) &1) !=1)
lib$stop(status);
/* read the mailbox */
if (((status = sys$qiow(2, channel, IO$_READVBLK, &iosb, 0, 0,
input, sizeof(input)-1, 0,0,0,0)) &1) != 1)
lib$stop(status);
if ((iosb.cond_value &1) != 1)
lib$stop(iosb.cond_value);
/* output the mailbox message */
input[iosb.count] = '\0';
printf("\n%s\n", input);
}
RUNNING THE PROGRAM:
$ ! RUN FROM ONE TERMINAL
$
$ SET PROCESS/PRIV=GRPNAM
$ DEFINE/TABLE=LNM$PROCESS_DIRECTORY LNM$TEMPORARY_MAILBOX LNM$GROUP
$
$ CC MAILS
$!
$! If this program is compiled with Dec C (VAX or AXP), use the following
$! command to link it.
$ LINK MAILS
$!
$! If this program is compiled with VAX C, use this command to link it.
$! Be sure to comment out the link command used for DEC C and uncomment
$! this.
$! LINK MAILS,SYS$INPUT/OPTIONS
!sys$share:vaxcrtl.exe/share
$ RUN MAILS
MAILS has completed mailbox write.
$ ! RUN FROM ANOTHER TERMINAL
$
$ SET PROCESS/PRIV=GRPNAM
$ DEFINE/TABLE=LNM$PROCESS_DIRECTORY LNM$TEMPORARY_MAILBOX LNM$GROUP
$
$ CC MAILR
$!
$! If this program is compiled with Dec C (VAX or AXP), use the following
$! command to link it.
$ LINK MAILR
$!
$! If this program is compiled with VAX C, use this command to link it.
$! Be sure to comment out the link command used for DEC C and uncomment
$! this.
$! LINK MAILR,SYS$INPUT/OPTIONS
!sys$share:vaxcrtl.exe/share
$ RUN MAILR
This is a message.
REFERENCE(S):
"OpenVMS System Services Reference Manual: A-GETMSG", May 1993, (AA-PV6FA-TK)
"OpenVMS System Services Reference Manual: GETQUI-Z", May 1993 (AA-PV6GA-TK)
"OpenVMS System I/O User's Reference Manual", May 1993 (AA-PV6SA-TK), Chapter 4