Texcaller
Functions
Internals of the Texcaller C interface
Texcaller C interface

Functions

static const char * escape_latex_char (char c)
 Escape a single character for LaTeX.
static char * sprintf_alloc (const char *format,...)
 Variant of sprintf() that allocates the needed memory automatically.
static int remove_directory_recursively (char **error, const char *dirname)
 Remove a directory recursively like rm -r.
static void read_file (char **result, size_t *result_size, char **error, const char *path)
 Read a file completely into a buffer that can be used as a string.
static int write_file (char **error, const char *path, const char *source, size_t source_size)
 Write a buffer completely into a file.

Function Documentation

static const char* escape_latex_char ( char  c) [static]

Escape a single character for LaTeX.

Parameters:
cthe character to escape
Returns:
a string constant (not to be freed) containing the character's replacement, or NULL if the character doesn't need to be replaced.
static char* sprintf_alloc ( const char *  format,
  ... 
) [static]

Variant of sprintf() that allocates the needed memory automatically.

Parameters:
formatformat string for sprintf()
...further arguments to sprintf()
Returns:
a newly allocated string containing the result of sprintf(), or NULL when out of memory or sprintf() failed.
static int remove_directory_recursively ( char **  error,
const char *  dirname 
) [static]

Remove a directory recursively like rm -r.

Returns:
0 on success, -1 on failure
Parameters:
errorOn failure, error will be set to a newly allocated string that contains the error message. On success, or when out of memory, error will be set to NULL.
dirnamethe directory to remove
static void read_file ( char **  result,
size_t *  result_size,
char **  error,
const char *  path 
) [static]

Read a file completely into a buffer that can be used as a string.

Parameters:
resultwill be set to a newly allocated buffer that contains the complete content of the file, with a '\0' added to the end. If an error occured, result will be set to NULL.
result_sizewill be set to the size of result, not counting the added '\0'. If an error occured, result_size will be set to 0.
errorOn failure, error will be set to a newly allocated string that contains the error message. On success, or when out of memory, error will be set to NULL.
pathpath of the file to read
static int write_file ( char **  error,
const char *  path,
const char *  source,
size_t  source_size 
) [static]

Write a buffer completely into a file.

If the file already exists, it will be overwritten.

Returns:
0 on success, -1 on failure
Parameters:
errorOn failure, error will be set to a newly allocated string that contains the error message. On success, or when out of memory, error will be set to NULL.
pathpath of the file to write to
sourcebuffer to write
source_sizesize of source