[Previous] [Contents] [Next]

netmgr_ndtostr()

Convert a node descriptor to a string

Synopsis:

#include <sys/netmgr.h>

int netmgr_ndtostr( unsigned flags,
                    int nd, 
                    char * buf,
                    size_t maxbuf );

Library:

libc

Description:

The netmgr_ndtostr() function converts a node descriptor, nd, to a string and stores the string in the buffer pointed to by buf. The size of the buffer is given by maxbuf.

The flags argument indicates which part(s) of the Fully Qualified PathName (FQPN) to adjust. The following diagram shows the components for the FQPN, /net/qnet.qnx.com~redundant:


Components of a fully qualified pathname


Components of a fully qualified pathname.


The Fully Qualified Node Name (FQNN) is qnet.qnx.com.

The default string returned by netmgr_ndtostr() is the FQNN and the quality of service (QoS) if it's not the default (~loadbalance). This string may be passed to any other node that can call netmgr_strtond() and has a nd that refers to the same node with the same QoS.

A bitwise OR of flags modify the default string in the following way:

ND2S_DIR_HIDE
Never return the directory.
ND2S_DIR_SHOW
Always return a pathname to the root directory (i.e. /) of the node indicated by nd. For example, calling:
netmgr_ndtostr(ND2S_DIR_SHOW, nd, buf, sizeofbuf)
      

on a node with a default domain of qnx.com using a nd that refers to a FQNN of peterv.qnx.com returns:

/net/peterv.qnx.com/
      

If Qnet isn't active on the node, and netmgr_ndtostr(ND2S_DIR_SHOW, nd, buf, sizeofbuf) has a nd of ND_LOCAL_NODE, then / is returned.

ND2S_DOMAIN_HIDE
Never return the domain.
ND2S_DOMAIN_SHOW
Always return the domain.
ND2S_LOCAL_STR
Display shorter node names on your local node. For example, calling:
netmgr_ndtostr(ND2S_LOCAL_STR, nd, buf, sizeofbuf)
      

on a node with a default domain of qnx.com using a nd that refers to an FQPN of /net/peterv.qnx.com returns:

peterv
      

Whereas, a nd that refers to /net/peterv.anotherhost.com returns:

peterv.anotherhost.com
      
ND2S_NAME_HIDE
Never return the name.
ND2S_NAME_SHOW
Always return the name.
ND2S_QOS_HIDE
Never return the QoS.
ND2S_QOS_SHOW
Always return the quality of service (QoS).
ND2S_SEP_FORCE
Always return a leading separator. For example, calling:
netmgr_ndtostr(ND2S_SEP_FORCE|ND2S_DIR_HIDE|ND2S_NAME_HIDE|ND2S_DOMAIN_HIDE|ND2S_QOS_SHOW, nd, buf, sizeofbuf)
      

with a nd of ND_LOCAL_NODE returns:

~loadbalance
      

This is useful if you want to concatenate each component of the FQPN individually.


Note: Don't use a ND2S_*_HIDE and a corresponding ND2S_*_SHOW together.

Returns:

The length of the string or -1 if an error occurs ((errno is set).

Classification:

QNX 6

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

netmgr_strtond()


[Previous] [Contents] [Next]