LAL  7.5.0.1-b72065a
whereami.h File Reference

Prototypes

WAI_FUNCSPEC int WAI_PREFIX() getExecutablePath (char *out, int capacity, int *dirname_length)
 Returns the path to the current executable. More...
 
WAI_FUNCSPEC int WAI_PREFIX() getModulePath (char *out, int capacity, int *dirname_length)
 Returns the path to the current module. More...
 

Go to the source code of this file.

Macros

#define WAI_FUNCSPEC
 
#define WAI_PREFIX(function)   wai_##function
 

Macro Definition Documentation

◆ WAI_FUNCSPEC

#define WAI_FUNCSPEC

Definition at line 14 of file whereami.h.

◆ WAI_PREFIX

#define WAI_PREFIX (   function)    wai_##function

Definition at line 17 of file whereami.h.

Function Documentation

◆ getExecutablePath()

WAI_FUNCSPEC int WAI_PREFIX() getExecutablePath ( char *  out,
int  capacity,
int *  dirname_length 
)

Returns the path to the current executable.

Usage:

  • first call int length = wai_getExecutablePath(NULL, 0, NULL); to retrieve the length of the path
  • allocate the destination buffer with path = (char*)malloc(length + 1);
  • call wai_getExecutablePath(path, length, NULL) again to retrieve the path
  • add a terminal NUL character with ‘path[length] = ’\0';`
Parameters
outdestination buffer, optional
capacitydestination buffer capacity
dirname_lengthoptional recipient for the length of the dirname part of the path.
Returns
the length of the executable path on success (without a terminal NUL character), otherwise -1

◆ getModulePath()

WAI_FUNCSPEC int WAI_PREFIX() getModulePath ( char *  out,
int  capacity,
int *  dirname_length 
)

Returns the path to the current module.

Usage:

  • first call int length = wai_getModulePath(NULL, 0, NULL); to retrieve the length of the path
  • allocate the destination buffer with path = (char*)malloc(length + 1);
  • call wai_getModulePath(path, length, NULL) again to retrieve the path
  • add a terminal NUL character with ‘path[length] = ’\0';`
Parameters
outdestination buffer, optional
capacitydestination buffer capacity
dirname_lengthoptional recipient for the length of the dirname part of the path.
Returns
the length of the module path on success (without a terminal NUL character), otherwise -1