Look up the object ID for a message queue or mutex with a specified name.
CS_RETCODE srv_getobjid(obj_type, obj_namep,
obj_namelen, obj_idp, infop)
CS_INT obj_type; CS_CHAR *obj_namep; CS_INT obj_namelen; SRV_OBJID *obj_idp; CS_INT *infop;
Indicates whether the object is a mutex (SRV_C_MUTEX) or a message queue SRV_C_MQUEUE).
A pointer to a CS_CHAR buffer that contains the name of the object.
The length of the string in *obj_namep. If the string is null terminated, obj_namelen can be CS_NULLTERM.
A pointer to a SRV_OBJID structure that will receive the identifier for the object, if found.
A pointer to a CS_INT. The following table describes the possible values returned in *infop if srv_getobjid returns CS_FAIL:
Value |
Meaning |
---|---|
SRV_I_NOEXIST |
The object does not exist. |
SRV_I_UNKNOWN |
Some other error occurred, for example, a null object name. |
Returns |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ospublic.h>
/*
** Local Prototype
*/
CS_INT ex_srv_getobjid PROTOTYPE((
CS_INT obj_type,
CS_CHAR *obj_name,
SRV_OBJID *obj_idp
));
/*
** EX_SRV_GETOBJID
** An example routine to retrieve the object id for a specified
** message queue or mutex name.
** Arguments:
** obj_type SRV_C_MUTEX if requesting a mutex object id, and
** SRV_C_MQUEUE if requesting a message queue object
id.
** obj_name A null terminated string which specifies the name
** of the message queue or the mutex.
** obj_idp A pointer to a SRV_OBJID structure that will store
** the identifier for the object.
** Returns:
** CS_SUCCEED If the object id was retrieved
successfully.
** SRV_I_NOEXIST If the object does not exist.
** CS_FAIL If the object was not retrieved due to an error
*/
CS_INT ex_srv_getobjid(obj_type, obj_name, obj_idp)
CS_INT obj_type;
CS_CHAR *obj_name;
SRV_OBJID *obj_idp;
{
CS_INT info; /* The reason for failure. */
CS_INT status; /* The return status. */
/* Validate the obj_type. */ if ( (obj_type != SRV_C_MUTEX) && (obj_type !=
SRV_C_MQUEUE) )
{
return(CS_FAIL);
}
/* Make sure that the object name is not null. */
if ( obj_name == (CS_CHAR *)NULL )
{
return(CS_FAIL);
}
/* Ensure that the pointer to the SRV_OBJID is not null */
if ( obj_idp == (SRV_OBJID *)NULL )
{
return(CS_FAIL);
}
/* Get the object id. */
status = (CS_INT)srv_getobjid( obj_type, obj_name,
CS_NULLTERM, obj_idp, &info);
/* Check the status. */
if ( (status == CS_FAIL) && (info == SRV_I_NOEXIST) )
{
status = SRV_I_NOEXIST;
}
return(status);
}
Open Server maintains a table that maps the unique object identifiers of message queues and mutexes to their names. Given the name, srv_getobjid finds the identifier.
srv_createmsgq, srv_createmutex, srv_deletemsgq, srv_deletemutex, srv_getmsgq, srv_getobjname, srv_lockmutex,srv_putmsgq, srv_unlockmutex