yumapro  20.10-14
YumaPro SDK
General NCX Utilities

General utlities to support the server implementation. More...

Collaboration diagram for General NCX Utilities:

Functions

xmlChar * ncx_get_source_ex (const xmlChar *fspec, boolean expand_cwd, status_t *res)
 Expand a filespec into an absolute path. More...
 
xmlChar * ncx_get_source (const xmlChar *fspec, status_t *res)
 Expand a filespec into an absolute path. More...
 
boolean ncx_prefix_different (const xmlChar *prefix1, const xmlChar *prefix2, const xmlChar *modprefix)
 Check if the specified prefix pair reference different modules. More...
 
status_t ncx_get_version (xmlChar *buffer, uint32 buffsize)
 Get the the Yuma version ID string. More...
 
status_t ncx_get_feature_code (xmlChar *buffer, uint32 buffsize)
 Get the the Feature Code String. More...
 
int32 ncx_compare_base_uris (const xmlChar *str1, const xmlChar *str2)
 Compare the base part of 2 URI strings. More...
 
boolean ncx_val_protocol_enabled (ncx_protocol_t proto, uint16 flags)
 Check if the specified protocol version is enabled. More...
 
void ncx_set_val_protocol_enabled (ncx_protocol_t proto, uint16 *flags)
 Set the specified protocol version to be enabled in a uint16 bits val. More...
 
void ncx_set_val_protocol_disabled (ncx_protocol_t proto, uint16 *flags)
 Set the specified protocol version to be disabled in a uint16 bits val. More...
 
boolean ncx_protocol_is_netconf (ncx_protocol_t proto)
 Check if the protocol is a NETCONF protocol. More...
 
void ncx_write_tracefile (const char *buff, uint32 count)
 Write a byte to the tracefile. More...
 
status_t ncx_decode_url_string (const xmlChar *urlstr, uint32 urlstrlen, xmlChar *buffer, uint32 *cnt)
 Fill buffer with a plain string from a URL string. More...
 
status_t ncx_create_pidfile (const xmlChar *progname, boolean fileloc_fhs)
 Create the pidfile for the specified program. More...
 
status_t ncx_add_ydtrace (const xmlChar *fspec)
 Add the filespec of a yangdump file being processed. More...
 
boolean ncx_find_ydtrace (const xmlChar *fspec)
 Find the filespec of a yangdump file being processed. More...
 
ncx_result_format_t ncx_get_file_result_format (const xmlChar *filespec)
 Check the filespec string for a file assignment statement to see if it is text, XML, or JSON. More...
 
boolean ncx_library_mode_ok (const xmlChar *modname, const xmlChar *rpcname)
 Check if RPC OK to use in library mode. More...
 
const char * ncx_get_progname (void)
 Get the progname buffer. More...
 
boolean ncx_ok_for_inline_data (obj_template_t *obj)
 Check if the object is OK for inline data. More...
 
boolean ncx_check_inline_data_state (const xmlChar *line, boolean curstate)
 Check the input line for Start or End of data tags. More...
 
void ncx_set_use_return_status (void)
 Enable the return_status parameter. More...
 
boolean ncx_use_return_status (void)
 Check if the return_status should be returned. More...
 
ncx_bad_reply_enum ncx_get_handle_badreply_enum (const xmlChar *valstr)
 Check if the specified string matches an ncx_bad_reply_enum enum. More...
 
const xmlChar * ncx_get_handle_badreply_string (ncx_bad_reply_enum badreply)
 Get the string for the specified enum value. More...
 
void ncx_set_handle_badreply (ncx_bad_reply_enum enumval)
 Set the enum value for the Bad Reply handling option. More...
 
ncx_bad_reply_enum ncx_get_handle_badreply (void)
 Get the enum for the Bad Reply Handling option. More...
 
boolean ncx_conf_env_vars_enabled (void)
 Get the Config Environment Variable Replacement flag. More...
 
ncx_etag_t ncx_txid2etag (ncx_transaction_id_t txid)
 Cast ncx_txid_t to ncx_etag_t. More...
 
const xmlChar * ncx_get_xpath_type_str (ncx_xpath_type_t xpath_typ)
 Get the string for the ncx_xpath_type_t enum. More...
 
status_t send_buff (int fd, const char *buffer, size_t cnt)
 Send the buffer to the network peer. More...
 

Detailed Description

General utlities to support the server implementation.

Convert the filespec to an absolute path.

Function Documentation

◆ ncx_add_ydtrace()

status_t ncx_add_ydtrace ( const xmlChar *  fspec)

Add the filespec of a yangdump file being processed.

Parameters
fspecfilespec to save
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_check_inline_data_state()

boolean ncx_check_inline_data_state ( const xmlChar *  line,
boolean  curstate 
)

Check the input line for Start or End of data tags.

Parameters
lineline buffer to check
curstateFALSE if not inline; TRUE if in inline
Returns
new inline state
Here is the caller graph for this function:

◆ ncx_compare_base_uris()

int32 ncx_compare_base_uris ( const xmlChar *  str1,
const xmlChar *  str2 
)

Compare the base part of 2 URI strings.

Parameters
str1URI string 1
str2URI string 2
Returns
compare of base parts (up to '?'); -1, 0 or 1
Here is the call graph for this function:

◆ ncx_conf_env_vars_enabled()

boolean ncx_conf_env_vars_enabled ( void  )

Get the Config Environment Variable Replacement flag.

Placeholder: no configuration option to turn this off

Returns
TRUE if .conf file env-var replacement enabled
FALSE if .conf file env-var replacement disabled

◆ ncx_create_pidfile()

status_t ncx_create_pidfile ( const xmlChar *  progname,
boolean  fileloc_fhs 
)

Create the pidfile for the specified program.

Check if the file already exists. If so, then print an error message and return an error

Parameters
prognameprogram name
fileloc_fhsTRUE if FHS locations; FALSE if yumadir location
Returns
status
Here is the call graph for this function:

◆ ncx_decode_url_string()

status_t ncx_decode_url_string ( const xmlChar *  urlstr,
uint32  urlstrlen,
xmlChar *  buffer,
uint32 *  cnt 
)

Fill buffer with a plain string from a URL string.

Parameters
urlstrstring to convert
urlstrlennumber of bytes to check
bufferbuffer to fill; may be NULL to get count
cntaddress of return cnt
Return values
OUTPUTS*cnt = number bytes required, if non-NULL inputs
Returns
status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_find_ydtrace()

boolean ncx_find_ydtrace ( const xmlChar *  fspec)

Find the filespec of a yangdump file being processed.

Parameters
fspecfilespec to find
Returns
TRUE if found, FALSE if not
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_get_feature_code()

status_t ncx_get_feature_code ( xmlChar *  buffer,
uint32  buffsize 
)

Get the the Feature Code String.

Parameters
bufferbuffer to hold the feature code string
buffsizenumber of bytes in buffer
Returns
status
Here is the call graph for this function:

◆ ncx_get_file_result_format()

ncx_result_format_t ncx_get_file_result_format ( const xmlChar *  filespec)

Check the filespec string for a file assignment statement to see if it is text, XML, or JSON.

Parameters
filespecstring to check
Returns
result format enumeration; RF_NONE if some error
Here is the call graph for this function:

◆ ncx_get_handle_badreply()

ncx_bad_reply_enum ncx_get_handle_badreply ( void  )

Get the enum for the Bad Reply Handling option.

Returns
Configured bad reply enum value

Get the enum for the Bad Reply Handling option.

Returns
Configured bad reply enum value

◆ ncx_get_handle_badreply_enum()

ncx_bad_reply_enum ncx_get_handle_badreply_enum ( const xmlChar *  valstr)

Check if the specified string matches an ncx_bad_reply_enum enum.

Parameters
valstrto use for convertion
Returns
enum value if OK
Here is the call graph for this function:

◆ ncx_get_handle_badreply_string()

const xmlChar* ncx_get_handle_badreply_string ( ncx_bad_reply_enum  badreply)

Get the string for the specified enum value.

Parameters
badreplyenum value to check
Returns
string pointer if OK

◆ ncx_get_progname()

const char* ncx_get_progname ( void  )

Get the progname buffer.

Returns
progname buffer
Here is the caller graph for this function:

◆ ncx_get_source()

xmlChar* ncx_get_source ( const xmlChar *  fspec,
status_t res 
)

Expand a filespec into an absolute path.

Get a malloced buffer containing the complete filespec for the given input string. If this is a complete dirspec, this this will just strdup the value.

This is just a best effort to get the full spec. If the full spec is greater than 1500 bytes, then a NULL value (error) will be returned

This will expand the cwd!

  • Change ./ –> cwd/
  • Remove ~/ –> $HOME
  • add trailing '/' if not present
Parameters
fspecinput filespec
resaddress of return status
Return values
*resreturn status, NO_ERR if return is non-NULL
Returns
malloced buffer containing possibly expanded full filespec
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncx_get_source_ex()

xmlChar* ncx_get_source_ex ( const xmlChar *  fspec,
boolean  expand_cwd,
status_t res 
)

Expand a filespec into an absolute path.

Get a malloced buffer containing the complete filespec for the given input string. If this is a complete dirspec, this this will just strdup the value.

This is just a best effort to get the full spec. If the full spec is greater than 1500 bytes, then a NULL value (error) will be returned

  • Change ./ –> cwd/
  • Remove ~/ –> $HOME
  • add trailing '/' if not present
Parameters
fspecinput filespec
expand_cwdTRUE if foo should be expanded to /cur/dir/foo; FALSE if not
resaddress of return status
Return values
*resreturn status, NO_ERR if return is non-NULL
Returns
malloced buffer containing possibly expanded full filespec
Here is the caller graph for this function:

◆ ncx_get_version()

status_t ncx_get_version ( xmlChar *  buffer,
uint32  buffsize 
)

Get the the Yuma version ID string.

Parameters
bufferbuffer to hold the version string
buffsizenumber of bytes in buffer
Returns
status

◆ ncx_get_xpath_type_str()

const xmlChar* ncx_get_xpath_type_str ( ncx_xpath_type_t  xpath_typ)

Get the string for the ncx_xpath_type_t enum.

Parameters
xpath_typxpath_typ enum to convert to str
Returns
string for the xpath_type

◆ ncx_library_mode_ok()

boolean ncx_library_mode_ok ( const xmlChar *  modname,
const xmlChar *  rpcname 
)

Check if RPC OK to use in library mode.

Hardwired list of RPCs OK for library mode Only used by the server if –library-mode=true

HACK: this should be in the server, not libncx

Parameters
modnamemodule name containing the RPC method
rpcnameRPC name to check
Returns
true if OK for library mode; false if OK for library mode
Here is the call graph for this function:

◆ ncx_ok_for_inline_data()

boolean ncx_ok_for_inline_data ( obj_template_t obj)

Check if the object is OK for inline data.

Parameters
objobject to check
Returns
TRUE if OK; FALSE if not
Here is the call graph for this function:

◆ ncx_prefix_different()

boolean ncx_prefix_different ( const xmlChar *  prefix1,
const xmlChar *  prefix2,
const xmlChar *  modprefix 
)

Check if the specified prefix pair reference different modules.

Parameters
prefix11st prefix to check (may be NULL)
prefix22nd prefix to check (may be NULL)
modprefixmodule prefix to check (may be NULL)
Returns
TRUE if prefix1 and prefix2 reference different modules' FALSE if prefix1 and prefix2 reference the same modules
Here is the call graph for this function:

◆ ncx_protocol_is_netconf()

boolean ncx_protocol_is_netconf ( ncx_protocol_t  proto)

Check if the protocol is a NETCONF protocol.

Parameters
protoprotocol version to check
Returns
true if a NETCONF protocol; false if not

◆ ncx_set_handle_badreply()

void ncx_set_handle_badreply ( ncx_bad_reply_enum  enumval)

Set the enum value for the Bad Reply handling option.

Parameters
enumvalenum value to use

◆ ncx_set_use_return_status()

void ncx_set_use_return_status ( void  )

Enable the return_status parameter.

◆ ncx_set_val_protocol_disabled()

void ncx_set_val_protocol_disabled ( ncx_protocol_t  proto,
uint16 *  flags 
)

Set the specified protocol version to be disabled in a uint16 bits val.

Parameters
protoprotocol version to enable
flagsaddress of bitmask to set
Return values
*flagsis set with the bit for the protocol

◆ ncx_set_val_protocol_enabled()

void ncx_set_val_protocol_enabled ( ncx_protocol_t  proto,
uint16 *  flags 
)

Set the specified protocol version to be enabled in a uint16 bits val.

Parameters
protoprotocol version to enable
flagsaddress of bitmask to set
Return values
*flagsis set with the bit for the protocol
See also
ncx_val_protocol_enabled

◆ ncx_txid2etag()

ncx_etag_t ncx_txid2etag ( ncx_transaction_id_t  txid)

Cast ncx_txid_t to ncx_etag_t.

This is a utility function to convert uint64 txid to uint32 etag so that it is more alignment-safe when cast

Parameters
txiduint64 ncx_transaction_id_t object
Returns
etag is returned with value txid & 0xffffffff
Here is the caller graph for this function:

◆ ncx_use_return_status()

boolean ncx_use_return_status ( void  )

Check if the return_status should be returned.

Returns
TRUE if shell wants return status; FALSE to return zero

◆ ncx_val_protocol_enabled()

boolean ncx_val_protocol_enabled ( ncx_protocol_t  proto,
uint16  flags 
)

Check if the specified protocol version is enabled.

Parameters
protoprotocol enum to check
flagsbitmask to check if proto is set
Returns
TRUE if protocol enabled; FALSE if protocol not enabled or error
See also
ncx_set_val_protocol_enabled

◆ ncx_write_tracefile()

void ncx_write_tracefile ( const char *  buff,
uint32  count 
)

Write a byte to the tracefile.

Internal function only

Parameters
buffbuffer to write
countnumber of chars to write
Here is the caller graph for this function:

◆ send_buff()

status_t send_buff ( int  fd,
const char *  buffer,
size_t  cnt 
)

Send the buffer to the network peer.

This function is used by applications which do not select for write_fds, and may not block (if fnctl used)

Parameters
fdthe socket to write to
bufferthe buffer to write
cntthe number of bytes to write
Returns
status