/mnt/hgfs/jamie_On_My_Mac/store/version_control/svn/integralive/library/trunk/src/helper.h File Reference

Go to the source code of this file.

Defines

#define PACKAGE_NAME   "libIntegra"
#define ARRAY_ELEMENTS(_array)   (sizeof(_array)/sizeof(_array[0]))
#define NTG_PATH   1
#define NTG_HOME   2
#define NTG_PWD   4
#define NTG_CWD   8
#define NTG_LD_LIBRARY_PATH   16
#define NTG_XDG_DATA_DIRS   32
#define NTG_NTG_BRIDGE_PATH   64
#define NTG_NTG_MAP_PATH   128
#define NTG_NTG_USER_DIR   256
#define NTG_EXTRA_LIB
#define NTG_EXTRA_BRIDGE
#define NTG_EXTRA_MAP
#define NTG_DEFAULT_LD_LIBRARY_PATH   NTG_EXTRA_LIB "/usr/lib"
#define NTG_DEFAULT_BRIDGE_PATH   NTG_EXTRA_BRIDGE "/usr/lib/integra"
#define NTG_DEFAULT_SHARE_PATH_PREFIX1   NTG_EXTRA_MAP
#define NTG_DEFAULT_SHARE_PATH_PREFIX2   "/usr/share/"
#define NTG_COLON   ":"
#define NTG_MODULES_SUBDIR   "/modules"
#define NTG_DEFAULT_DATA_PATH   NTG_DEFAULT_SHARE_PATH_PREFIX1 PACKAGE_NAME NTG_COLON NTG_DEFAULT_SHARE_PATH_PREFIX2 PACKAGE_NAME
#define NTG_DEFAULT_MAP_PATH   NTG_DEFAULT_DATA_PATH
#define NTG_DEFAULT_XDG_DATA_DIRS_PATH   NTG_DEFAULT_DATA_PATH NTG_COLON NTG_DEFAULT_SHARE_PATH_PREFIX1 PACKAGE_NAME NTG_MODULES_SUBDIR NTG_COLON NTG_DEFAULT_SHARE_PATH_PREFIX2 PACKAGE_NAME NTG_MODULES_SUBDIR
#define NTG_DEFAULT_USER_DIR   "/.integra"
#define NTG_FILE_SUFFIXES   "ixd,xsd"
#define NTG_NULL_BYTES   1

Functions

int ntg_count_digits (int num)
 Count the number of digits in an int.
int ntg_post (char *format,...)
 Convenience function to print a message to stderr.
int ntg_lower (char *str)
 Convenience function to convert a string to lowercase.
int ntg_upper (char *str)
 Convenience function to convert a string to uppercase.
char * ntg_append_string (char *dest, const char *source)
char * ntg_append_path (char *dest, const char *source)
char * ntg_build_path_list (int envvars)
char * ntg_file_find (const char *filename, int envvars)
 Find a file and return its path.
char * ntg_search_for_file (const char *token, char *file_suffix, int envvars)
 Search for files matching the token and suffix and return the path of the first match.
unsigned int array_elements (void **array)
void ntg_bashfilename (const char *from, char *to)
void ntg_unbashfilename (const char *from, char *to)
int ntg_is_absolute_path (const char *dir)
char * ntg_replace_substring (const char *string, const char *original, const char *replacement)

Define Documentation

#define ARRAY_ELEMENTS ( _array   )     (sizeof(_array)/sizeof(_array[0]))

Macro to get the number of elements in an the array

Referenced by ntg_value_append().

#define NTG_COLON   ":"
#define NTG_CWD   8
#define NTG_DEFAULT_BRIDGE_PATH   NTG_EXTRA_BRIDGE "/usr/lib/integra"

Referenced by ntg_build_path_list().

#define NTG_DEFAULT_DATA_PATH   NTG_DEFAULT_SHARE_PATH_PREFIX1 PACKAGE_NAME NTG_COLON NTG_DEFAULT_SHARE_PATH_PREFIX2 PACKAGE_NAME
#define NTG_DEFAULT_LD_LIBRARY_PATH   NTG_EXTRA_LIB "/usr/lib"

Referenced by ntg_build_path_list().

#define NTG_DEFAULT_MAP_PATH   NTG_DEFAULT_DATA_PATH

Referenced by ntg_build_path_list().

#define NTG_DEFAULT_SHARE_PATH_PREFIX1   NTG_EXTRA_MAP
#define NTG_DEFAULT_SHARE_PATH_PREFIX2   "/usr/share/"
#define NTG_DEFAULT_USER_DIR   "/.integra"

Referenced by ntg_build_path_list().

#define NTG_DEFAULT_XDG_DATA_DIRS_PATH   NTG_DEFAULT_DATA_PATH NTG_COLON NTG_DEFAULT_SHARE_PATH_PREFIX1 PACKAGE_NAME NTG_MODULES_SUBDIR NTG_COLON NTG_DEFAULT_SHARE_PATH_PREFIX2 PACKAGE_NAME NTG_MODULES_SUBDIR

Referenced by ntg_build_path_list().

#define NTG_EXTRA_BRIDGE
#define NTG_EXTRA_LIB

These are the defaults for the above

#define NTG_EXTRA_MAP
#define NTG_FILE_SUFFIXES   "ixd,xsd"
#define NTG_HOME   2

Referenced by ntg_build_path_list().

#define NTG_LD_LIBRARY_PATH   16

Referenced by ntg_build_path_list().

#define NTG_MODULES_SUBDIR   "/modules"
#define NTG_NTG_BRIDGE_PATH   64
#define NTG_NTG_MAP_PATH   128

Referenced by ntg_build_path_list().

#define NTG_NTG_USER_DIR   256

Referenced by ntg_build_path_list().

#define NTG_NULL_BYTES   1
#define NTG_PATH   1

These constants are used to determine which environment variables are used in file searches

Referenced by ntg_build_path_list().

#define NTG_PWD   4

Referenced by ntg_build_path_list().

#define NTG_XDG_DATA_DIRS   32

Referenced by ntg_build_path_list().

#define PACKAGE_NAME   "libIntegra"

Function Documentation

unsigned int array_elements ( void **  array  ) 

Return the number of elements in an array pointers

char* ntg_append_path ( char *  dest,
const char *  source 
)

Appends one path to another (not including null character), and returns a pointer to the resulting path

References ntg_append_string(), and ntg_realloc().

Referenced by ntg_build_path_list().

char* ntg_append_string ( char *  dest,
const char *  source 
)

Appends one string to another (not including null character), and returns a pointer to the resulting string

References ntg_realloc().

Referenced by ntg_append_path(), ntg_build_path_list(), and ntg_instance_name_from_path().

void ntg_bashfilename ( const char *  from,
char *  to 
)

thanks to Miller Puckette these helpers

from Miller Puckette

Referenced by ntg_file_find().

char* ntg_build_path_list ( int  envvars  ) 

Returns a null-terminated colon delimited string representing the list of paths based on an environment variable code.

See envars description in ntg_file_find.

This function will only guarantee that the file exists. It is up to the caller to check other things about the file, e.g. test if it is read/writable.

This function allocates memory for the returned path. It is up to the caller to free this.

References DB_HELPER, DEBUG_POST(), ntg_append_path(), ntg_append_string(), NTG_CWD, NTG_DEFAULT_BRIDGE_PATH, NTG_DEFAULT_LD_LIBRARY_PATH, NTG_DEFAULT_MAP_PATH, NTG_DEFAULT_USER_DIR, NTG_DEFAULT_XDG_DATA_DIRS_PATH, ntg_free(), NTG_HOME, NTG_LD_LIBRARY_PATH, ntg_malloc(), NTG_NTG_BRIDGE_PATH, NTG_NTG_MAP_PATH, NTG_NTG_USER_DIR, NTG_PATH, NTG_PWD, ntg_realloc(), and NTG_XDG_DATA_DIRS.

Referenced by ntg_file_find(), and ntg_search_for_file().

int ntg_count_digits ( int  num  ) 

Count the number of digits in an int.

Note:
{I'm sure there must be a library function for this, so if there is could someone please email me}

Referenced by ntg_instance_register_namespace(), ntg_instance_set_name(), and send_loaded().

char* ntg_file_find ( const char *  filename,
int  envvars 
)

Find a file and return its path.

Parameters:
char *filename The full name of the file to search for
int envvars The sum of the environment variable codes for inclusion in the search e.g. NTG_BRIDGE_PATH+PATH.

A binary and is performed on the envvars variable to determine which paths to search.

References DB_HELPER, DEBUG_POST(), ntg_bashfilename(), ntg_build_path_list(), ntg_free(), ntg_malloc(), NTG_NULL_BYTES, and ntg_realloc().

Referenced by ntg_server_run().

int ntg_is_absolute_path ( const char *  dir  ) 

from Miller Puckette

int ntg_lower ( char *  str  ) 

Convenience function to convert a string to lowercase.

Note:
{The string is modified *in place*}

Referenced by handler_module_load(), and handler_module_nodelist().

int ntg_post ( char *  format,
  ... 
)

Convenience function to print a message to stderr.

Referenced by set_value_from_osc().

char* ntg_replace_substring ( const char *  string,
const char *  original,
const char *  replacement 
)

References ntg_malloc().

Referenced by ntg_server_fix_connections().

char* ntg_search_for_file ( const char *  token,
char *  file_suffix,
int  envvars 
)

Search for files matching the token and suffix and return the path of the first match.

Parameters:
char *token The file name pattern to search for.
char *suffix The file name suffix to match or NULL.
int envvars The sum of the environment variable codes for inclusion in the search e.g. NTG_BRIDGE_PATH+PATH.

Note that this method returns the first match which may or may not be what one wants. The main purpose of for this function is to find the local XSD Schema file regardless of its version number.

A binary and is performed on the envvars variable to determine which paths to search.

References DB_HELPER, DEBUG_POST(), ntg_build_path_list(), ntg_free(), and ntg_malloc().

void ntg_unbashfilename ( const char *  from,
char *  to 
)

from Miller Puckette

int ntg_upper ( char *  str  ) 

Convenience function to convert a string to uppercase.

Note:
{The string is modified *in place*}

Generated on Tue Jan 5 14:02:29 2010 for LibIntegra by  doxygen 1.6.1