Files
m241Neelima/vxworks-6.9/target/src/posix/mqPxShow.c
T
2026-07-30 11:19:44 +05:30

154 lines
3.8 KiB
C

/* mqPxShow.c - POSIX message queue show */
/*
* Copyright (c) 1993-1996, 1999, 2003-2004, 2006, 2007, 2010
* Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement.
*/
/*
modification history
--------------------
01j,20apr10,jpb Updated classShowConnect typecast.
01i,06sep07,mfj documentation fix for apigen
01h,21apr06,kk publish mqPxShow() since show() no longer works on POSIX msgQs
01g,11feb04,m_s fixed man page warnings
01f,26jun03,ymz changed name obtain method (objCore moved to msq_que).
01e,17mar99,jdi doc: updated w/ info about proj facility (SPR 25727).
01d,19aug96,dbt modified test of name in mqPxShow (fixed SPR #4228).
01c,19jan95,jdi doc cleanup.
01c,03feb94,dvs changed show format; added include of private/mqPxLibP.h.
01b,01feb94,dvs documentation tweaks.
01a,16jun93,smb created.
*/
/*
DESCRIPTION
This library provides a show routine for display information on POSIX
message queue objects. The information displayed is for debugging purposes
and is intended to be a snapshot of the system at the time the call is made.
INCLUDE FILES: mqPxShow.h
*/
#include <vxWorks.h>
#include <stdio.h>
#include <sys/types.h>
#include <classLib.h>
#include <private/classLibP.h>
#include <private/objLibP.h>
#include <private/stdioP.h>
#include <private/mqPxLibP.h>
#include <mqueue.h>
#include <string.h>
/*******************************************************************************
*
* mqPxShow - display message queue internals
*
* This routine displays information on a POSIX message queue.
*
* RETURNS: OK or ERROR if the descriptor is invalid.
*
* ERRNO:
* \is
* \i S_objLib_OBJ_ID_ERROR
* message queue is invalid.
* \ie
*/
STATUS mqPxShow
(
mqd_t mqDesc,
int level
)
{
struct mq_attr attr;
char * name;
char pString[128];
int flags = 0;
pString[0] = EOS;
if (OBJ_VERIFY (mqDesc->f_data, mqClassId) != OK)
{
return (ERROR);
}
if (mq_getattr(mqDesc, &attr) != 0)
return (ERROR);
name = objNamePtrGet (mqDesc->f_data);
printf ("%-32s: %s\n", "Message queue name",
(name == NULL) ? "<NONE>" : name);
printf ("%-32s: %-10d\n", "No. of messages in queue", attr.mq_curmsgs);
printf ("%-32s: %-10d\n", "Maximum no. of messages", attr.mq_maxmsg);
printf ("%-32s: %-10d\n", "Maximum message size", attr.mq_msgsize);
/* now parse the flags for the msgQ */
if ((mqDesc->f_flag & (MQ_FLAG_READ | MQ_FLAG_WRITE))
== (MQ_FLAG_READ | MQ_FLAG_WRITE))
{
strcat (pString, "O_RDWR ");
flags = O_RDWR;
}
else if (mqDesc->f_flag & MQ_FLAG_READ)
{
strcat (pString, "O_RDONLY ");
flags = O_RDONLY;
}
else if (mqDesc->f_flag & MQ_FLAG_WRITE)
{
strcat (pString, "O_WRONLY ");
flags = O_WRONLY;
}
if (mqDesc->f_flag & MQ_FLAG_NONBLOCK)
{
strcat (pString, "O_NONBLOCK ");
flags |= O_NONBLOCK;
}
printf ("%-32s: %s (0x%-10x)\n", "Flags", pString, flags);
printf ("\n");
/* someday display the buffer contents with level >= 1 */
return (OK);
}
/******************************************************************************
*
* mqPxShowInit - initialize the POSIX message queue show facility
*
* This routine links the POSIX message queue show routine into the VxWorks
* system. It is called automatically when this show facility is configured
* into VxWorks using either of the following methods:
* \is
* \i If you use the configuration header files, define INCLUDE_SHOW_ROUTINES.
* \i If you use the project facility, select INCLUDE_POSIX_MQ_SHOW.
* \ie
*
* RETURNS: OK always
*
* ERRNO: N/A
*
*/
STATUS mqPxShowInit (void)
{
classShowConnect (mqClassId, (OBJ_SHOW_FUNC) mqPxShow);
return (OK);
}