srv_createmsgq

Description

Create a message queue.

Syntax

CS_RETCODE srv_createmsgq(msgqnamep, msgq_namelen,
              msgqidp)
CS_CHAR        *msgqnamep;
CS_INT             msgqname_len;
SRV_OBJID     *msgqidp;

Parameters

msgqnamep

A pointer to the name of the queue to create. It is an error to attempt to create a queue that al&ready exists.

msgqname_len

The length of the name in *msgqnamep. If the name is null terminated, an application can set msgqname_len to CS_NULLTERM. A message queue can be up to SRV_MAXNAME characters long.

msgqidp

Open Server returns the ID of the newly created message queue in *msgqidp.

Returns

Table 3-24: Return values (srv_createmsgq)

Returns:

To indicate:

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

#include <ospublic.h>

/*
** Local Prototype
*/
CS_RETCODE      ex_srv_createmsgq PROTOTYPE((
     SRV_OBJID     *msgqp,
     CS_CHAR       *msgqnm
));

/*
** EX_SRV_CREATEMSGQ
**
**     Example routine to create an Open Server message queue
 **     using srv_createmsgq.
**
** Arguments:
**     msgqp   Return pointer to the created message queue
 **             identifier.
**     msgqn   Null terminated name for the created queue.
**
** Returns:
**  CS_SUCCEED  Message queue with given name successfully
                 created.
**  CS_FAIL     An error was detected.
*/
CS_RETCODE            ex_srv_createmsgq(msgqp, msgqnm)
SRV_OBJID             *msgqp;
CS_CHAR               *msgqnm;
{
     /* Check parameters. */
     if ((CS_INT)strlen(msgqnm) > SRV_MAXNAME)
     {
          return(CS_FAIL);
     }

     /* Create the message queue. */
     if (srv_createmsgq(msgqnm, (CS_INT)CS_NULLTERM, msgqp) !=
           CS_SUCCEED)
     {
          return(CS_FAIL);
     }
     return(CS_SUCCEED);
}

Usage

See also

srv_deletemsgq, srv_getmsgq, srv_getobjname, srv_putmsgq