![]() |
![]() |
![]() |
Convert a node descriptor to a string
#include <sys/netmgr.h> int netmgr_ndtostr( unsigned flags, int nd, char * buf, size_t maxbuf );
libc
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.
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:
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.
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
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.
![]() |
Don't use a ND2S_*_HIDE and a corresponding ND2S_*_SHOW together. |
The length of the string or -1 if an error occurs ((errno is set).
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
![]() |
![]() |
![]() |