Classes | Macros | Typedefs | Functions
rhino/demo/c/dr_libs/old/dr.h File Reference
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <stdint.h>
#include <stddef.h>
Include dependency graph for rhino/demo/c/dr_libs/old/dr.h:

Go to the source code of this file.

Classes

struct  dr_cmdline
 
struct  dr_timer
 
struct  drpath_iterator
 
struct  drpath_segment
 

Macros

#define _TRUNCATE   ((size_t)-1)
 
#define dr_abs(x)   (((x) < 0) ? (-(x)) : (x))
 
#define dr_clamp(x, low, high)   (dr_max(low, dr_min(x, high)))
 
#define DR_FALSE   0
 
#define DR_INLINE   static inline
 
#define dr_max(x, y)   (((x) > (y)) ? (x) : (y))
 
#define dr_min(x, y)   (((x) < (y)) ? (x) : (y))
 
#define dr_path_h
 
#define dr_round_up(x, multiple)   ((((x) + ((multiple) - 1)) / (multiple)) * (multiple))
 
#define dr_round_up_signed(x, multiple)   ((((x) + (((x) >= 0)*((multiple) - 1))) / (multiple)) * (multiple))
 
#define DR_SIZED_TYPES_DEFINED
 
#define DR_TRUE   1
 
#define dr_zero_object(pObject)   memset(pObject, 0, sizeof(*pObject));
 
#define IN
 
#define OUT
 
#define STRINGIFY(x)   #x
 
#define TOSTRING(x)   STRINGIFY(x)
 
#define UNUSED(x)   ((void)(x))
 

Typedefs

typedef dr_uint32 dr_bool32
 
typedef dr_uint8 dr_bool8
 
typedef struct dr_cmdline dr_cmdline
 
typedef dr_bool32 dr_cmdline_parse_proc(const char *key, const char *value, void *pUserData)
 
typedef int16_t dr_int16
 
typedef int32_t dr_int32
 
typedef int64_t dr_int64
 
typedef int8_t dr_int8
 
typedef dr_bool32(* dr_iterate_files_proc) (const char *filePath, void *pUserData)
 
typedef void(* dr_key_value_error_proc) (void *pUserData, const char *message, unsigned int line)
 
typedef void(* dr_key_value_pair_proc) (void *pUserData, const char *key, const char *value)
 
typedef size_t(* dr_key_value_read_proc) (void *pUserData, void *pDataOut, size_t bytesToRead)
 
typedef void * dr_mutex
 Mutex. More...
 
typedef void * dr_semaphore
 Semaphore. More...
 
typedef void * dr_thread
 Thread. More...
 
typedef int(* dr_thread_entry_proc) (void *pData)
 
typedef uint16_t dr_uint16
 
typedef uint32_t dr_uint32
 
typedef uint64_t dr_uint64
 
typedef uint8_t dr_uint8
 
typedef struct drpath_iterator drpath_iterator
 

Functions

DR_INLINE int _itoa_s (int value, char *dst, size_t dstSizeInBytes, int radix)
 
DR_INLINE int _stricmp (const char *string1, const char *string2)
 
DR_INLINE void dr_aligned_free (void *ptr)
 
DR_INLINE void * dr_aligned_malloc (size_t alignment, size_t size)
 
dr_bool32 dr_cmdline_key_exists (dr_cmdline *pCmdLine, const char *key)
 Helper for determining whether or not the given key exists. More...
 
int dr_cmdline_to_argv (dr_cmdline *pCmdLine, char ***argvOut)
 
dr_bool32 dr_copy_file (const char *srcPath, const char *dstPath, dr_bool32 failIfExists)
 
size_t dr_copy_line (const char *str, char *lineOut, size_t lineOutSize)
 Makes a copy of the first line of the given string. More...
 
dr_bool32 dr_create_empty_file (const char *fileName, dr_bool32 failIfExists)
 
dr_mutex dr_create_mutex ()
 
dr_semaphore dr_create_semaphore (int initialValue)
 
dr_thread dr_create_thread (dr_thread_entry_proc entryProc, void *pData)
 
void dr_date_YYYYMMDD (time_t t, char *strOut, unsigned int strOutSize)
 
void dr_datetime_short (time_t t, char *strOut, unsigned int strOutSize)
 Formats a data/time string. More...
 
dr_bool32 dr_delete_file (const char *filePath)
 
void dr_delete_mutex (dr_mutex mutex)
 Deletes a mutex object. More...
 
void dr_delete_semaphore (dr_semaphore semaphore)
 Deletes the given semaphore. More...
 
void dr_delete_thread (dr_thread thread)
 
dr_bool32 dr_directory_exists (const char *directoryPath)
 
dr_bool32 dr_file_exists (const char *filePath)
 
const char * dr_first_non_whitespace (const char *str)
 Finds the first non-whitespace character in the given string. More...
 
const char * dr_first_whitespace (const char *str)
 Finds the first occurance of a whitespace character in the given string. More...
 
FILE * dr_fopen (const char *fileName, const char *openMode)
 
void dr_free_argv (char **argv)
 
void dr_free_file_data (void *valueReturnedByOpenAndReadFile)
 
dr_bool32 dr_get_config_folder_path (char *pathOut, size_t pathOutSize)
 
const char * dr_get_current_directory (char *pathOut, size_t pathOutSize)
 Retrieves the current directory. More...
 
dr_bool32 dr_get_executable_directory_path (char *pathOut, size_t pathOutSize)
 
dr_bool32 dr_get_executable_path (char *pathOut, size_t pathOutSize)
 
dr_uint64 dr_get_file_modified_time (const char *filePath)
 
dr_bool32 dr_get_log_folder_path (char *pathOut, size_t pathOutSize)
 
unsigned int dr_get_logical_processor_count ()
 Retrieves the number of logical cores on system. More...
 
unsigned int dr_get_process_id ()
 
size_t dr_get_username (char *usernameOut, size_t usernameOutSize)
 
dr_bool32 dr_hex_char_to_uint (char ascii, unsigned int *out)
 
dr_bool32 dr_init_cmdline (dr_cmdline *pCmdLine, int argc, char **argv)
 Initializes a command line object. More...
 
dr_bool32 dr_init_cmdline_win32 (dr_cmdline *pCmdLine, const char *args)
 Initializes a command line object using a Win32 style command line. More...
 
static dr_bool32 dr_is_directory (const char *directoryPath)
 
dr_bool32 dr_is_file_read_only (const char *filePath)
 
dr_bool32 dr_is_whitespace (dr_uint32 utf32)
 
dr_bool32 dr_iterate_files (const char *directory, dr_bool32 recursive, dr_iterate_files_proc proc, void *pUserData)
 
int dr_itoa_s (int value, char *dst, size_t dstSizeInBytes, int radix)
 
void dr_lock_mutex (dr_mutex mutex)
 Locks the given mutex. More...
 
static const char * dr_ltrim (const char *str)
 
dr_bool32 dr_mkdir (const char *directoryPath)
 
dr_bool32 dr_mkdir_recursive (const char *directoryPath)
 
dr_bool32 dr_move_file (const char *oldPath, const char *newPath)
 
const char * dr_next_line (const char *str)
 Finds the beginning of the next line. More...
 
DR_INLINE dr_uint32 dr_next_power_of_2 (dr_uint32 value)
 
const char * dr_next_token (const char *tokens, char *tokenOut, size_t tokenOutSize)
 
time_t dr_now ()
 Retrieves a time_t as of the time the function was called. More...
 
void * dr_open_and_read_file (const char *filePath, size_t *pFileSizeOut)
 
char * dr_open_and_read_text_file (const char *filePath, size_t *pFileSizeOut)
 
dr_bool32 dr_open_and_write_file (const char *filePath, const void *pData, size_t dataSize)
 
dr_bool32 dr_open_and_write_text_file (const char *filePath, const char *text)
 
void dr_parse_cmdline (dr_cmdline *pCmdLine, dr_cmdline_parse_proc callback, void *pUserData)
 Parses the given command line. More...
 
void dr_parse_key_value_pairs (dr_key_value_read_proc onRead, dr_key_value_pair_proc onPair, dr_key_value_error_proc onError, void *pUserData)
 
dr_bool32 dr_parse_key_value_pairs_from_file (const char *filePath, dr_key_value_pair_proc onPair, dr_key_value_error_proc onError, void *pUserData)
 
double dr_randd ()
 
float dr_randf ()
 
dr_bool32 dr_release_semaphore (dr_semaphore semaphore)
 Releases the given semaphore and increments it's counter by one upon returning. More...
 
static const char * dr_rtrim (const char *str)
 
dr_bool32 dr_set_current_directory (const char *path)
 Sets the current directory. More...
 
void dr_sleep (unsigned int milliseconds)
 
int dr_strcat_s (char *dst, size_t dstSizeInBytes, const char *src)
 
int dr_strcpy_s (char *dst, size_t dstSizeInBytes, const char *src)
 
char * dr_string_replace (const char *src, const char *query, const char *replacement)
 
void dr_string_replace_ascii (char *src, char c, char replacement)
 
int dr_strncat_s (char *dst, size_t dstSizeInBytes, const char *src, size_t count)
 
int dr_strncpy_s (char *dst, size_t dstSizeInBytes, const char *src, size_t count)
 
void dr_strrmchar (char *str, char c)
 Removes every occurance of the given character from the given string. More...
 
void dr_timer_init (dr_timer *pTimer)
 
double dr_timer_tick (dr_timer *pTimer)
 
void dr_trim (char *str)
 Trims both the leading and trailing whitespace from the given string. More...
 
void dr_unlock_mutex (dr_mutex mutex)
 Unlocks the given mutex. More...
 
DR_INLINE unsigned int dr_utf16_to_utf32_ch (unsigned short utf16[2])
 Converts a UTF-16 character to UTF-32. More...
 
DR_INLINE unsigned int dr_utf16pair_to_utf32_ch (unsigned short utf160, unsigned short utf161)
 Converts a UTF-16 surrogate pair to UTF-32. More...
 
DR_INLINE int dr_utf32_to_utf16_ch (unsigned int utf32, unsigned short utf16[2])
 
void dr_wait_and_delete_thread (dr_thread thread)
 Helper function for waiting for a thread and then deleting the handle after it has terminated. More...
 
dr_bool32 dr_wait_semaphore (dr_semaphore semaphore)
 Waits on the given semaphore object and decrements it's counter by one upon returning. More...
 
void dr_wait_thread (dr_thread thread)
 Waits for the given thread to terminate. More...
 
int dr_winmain_to_argv (const char *cmdlineWinMain, char ***argvOut)
 
void dr_yield ()
 
dr_bool32 drpath_append (char *base, size_t baseBufferSizeInBytes, const char *other)
 
size_t drpath_append_and_clean (char *dst, size_t dstSizeInBytes, const char *base, const char *other)
 Appends one path to the other and then cleans it. More...
 
dr_bool32 drpath_append_extension (char *base, size_t baseBufferSizeInBytes, const char *extension)
 Appends an extension to the given path. More...
 
dr_bool32 drpath_append_iterator (char *base, size_t baseBufferSizeInBytes, drpath_iterator i)
 Appends an iterator object to the given base path. More...
 
dr_bool32 drpath_at_end (drpath_iterator i)
 
dr_bool32 drpath_at_start (drpath_iterator i)
 
char * drpath_base_path (char *path)
 
size_t drpath_clean (const char *path, char *pathOut, size_t pathOutSizeInBytes)
 
dr_bool32 drpath_copy_and_append (char *dst, size_t dstSizeInBytes, const char *base, const char *other)
 
dr_bool32 drpath_copy_and_append_extension (char *dst, size_t dstSizeInBytes, const char *base, const char *extension)
 
dr_bool32 drpath_copy_and_append_iterator (char *dst, size_t dstSizeInBytes, const char *base, drpath_iterator i)
 
dr_bool32 drpath_copy_and_remove_extension (char *dst, size_t dstSizeInBytes, const char *path)
 Creates a copy of the given string and removes the extension. More...
 
dr_bool32 drpath_copy_and_remove_file_name (char *dst, size_t dstSizeInBytes, const char *path)
 Creates a copy of the given string and removes the extension. More...
 
void drpath_copy_base_path (const char *path, char *baseOut, size_t baseSizeInBytes)
 
const char * drpath_copy_file_name (const char *path, char *fileNameOut, size_t fileNameSizeInBytes)
 Copies the file name into the given buffer. More...
 
dr_bool32 drpath_equal (const char *path1, const char *path2)
 
const char * drpath_extension (const char *path)
 
dr_bool32 drpath_extension_equal (const char *path, const char *extension)
 
const char * drpath_file_name (const char *path)
 
dr_bool32 drpath_first (const char *path, drpath_iterator *i)
 
dr_bool32 drpath_is_absolute (const char *path)
 
dr_bool32 drpath_is_child (const char *childAbsolutePath, const char *parentAbsolutePath)
 
dr_bool32 drpath_is_descendant (const char *descendantAbsolutePath, const char *parentAbsolutePath)
 
dr_bool32 drpath_is_linux_style_root_segment (const drpath_iterator i)
 Determines whether or not the given iterator refers to a Linux style root directory ("/") More...
 
dr_bool32 drpath_is_relative (const char *path)
 
dr_bool32 drpath_is_root_segment (const drpath_iterator i)
 Determines whether or not the given iterator refers to the root segment of a path. More...
 
dr_bool32 drpath_is_win32_style_root_segment (const drpath_iterator i)
 Determines whether or not the given iterator refers to a Windows style root directory. More...
 
dr_bool32 drpath_iterators_equal (const drpath_iterator i0, const drpath_iterator i1)
 
dr_bool32 drpath_last (const char *path, drpath_iterator *i)
 Creates an iterator beginning at the last segment. More...
 
dr_bool32 drpath_next (drpath_iterator *i)
 
dr_bool32 drpath_prev (drpath_iterator *i)
 
dr_bool32 drpath_remove_extension (char *path)
 
dr_bool32 drpath_remove_file_name (char *path)
 Removes the last segment from the given path. More...
 
dr_bool32 drpath_segments_equal (const char *s0Path, const drpath_segment s0, const char *s1Path, const drpath_segment s1)
 
dr_bool32 drpath_to_absolute (const char *relativePathToMakeAbsolute, const char *basePath, char *absolutePathOut, size_t absolutePathOutSizeInBytes)
 
void drpath_to_backslashes (char *path)
 
void drpath_to_forward_slashes (char *path)
 
dr_bool32 drpath_to_relative (const char *absolutePathToMakeRelative, const char *absolutePathToMakeRelativeTo, char *relativePathOut, size_t relativePathOutSizeInBytes)
 
DR_INLINE int strcat_s (char *dst, size_t dstSizeInBytes, const char *src)
 
DR_INLINE int strcpy_s (char *dst, size_t dstSizeInBytes, const char *src)
 
DR_INLINE int strncat_s (char *dst, size_t dstSizeInBytes, const char *src, size_t count)
 
DR_INLINE int strncpy_s (char *dst, size_t dstSizeInBytes, const char *src, size_t count)
 

Macro Definition Documentation

◆ _TRUNCATE

#define _TRUNCATE   ((size_t)-1)

Definition at line 154 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_abs

#define dr_abs (   x)    (((x) < 0) ? (-(x)) : (x))

Definition at line 131 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_clamp

#define dr_clamp (   x,
  low,
  high 
)    (dr_max(low, dr_min(x, high)))

Definition at line 108 of file rhino/demo/c/dr_libs/old/dr.h.

◆ DR_FALSE

#define DR_FALSE   0

Definition at line 72 of file rhino/demo/c/dr_libs/old/dr.h.

◆ DR_INLINE

#define DR_INLINE   static inline

Definition at line 34 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_max

#define dr_max (   x,
 
)    (((x) > (y)) ? (x) : (y))

Definition at line 104 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_min

#define dr_min (   x,
 
)    (((x) < (y)) ? (x) : (y))

Definition at line 100 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_path_h

#define dr_path_h

Definition at line 3412 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_round_up

#define dr_round_up (   x,
  multiple 
)    ((((x) + ((multiple) - 1)) / (multiple)) * (multiple))

Definition at line 112 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_round_up_signed

#define dr_round_up_signed (   x,
  multiple 
)    ((((x) + (((x) >= 0)*((multiple) - 1))) / (multiple)) * (multiple))

Definition at line 116 of file rhino/demo/c/dr_libs/old/dr.h.

◆ DR_SIZED_TYPES_DEFINED

#define DR_SIZED_TYPES_DEFINED

Definition at line 48 of file rhino/demo/c/dr_libs/old/dr.h.

◆ DR_TRUE

#define DR_TRUE   1

Definition at line 71 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_zero_object

#define dr_zero_object (   pObject)    memset(pObject, 0, sizeof(*pObject));

Definition at line 750 of file rhino/demo/c/dr_libs/old/dr.h.

◆ IN

#define IN

Definition at line 84 of file rhino/demo/c/dr_libs/old/dr.h.

◆ OUT

#define OUT

Definition at line 88 of file rhino/demo/c/dr_libs/old/dr.h.

◆ STRINGIFY

#define STRINGIFY (   x)    #x

Definition at line 76 of file rhino/demo/c/dr_libs/old/dr.h.

◆ TOSTRING

#define TOSTRING (   x)    STRINGIFY(x)

Definition at line 77 of file rhino/demo/c/dr_libs/old/dr.h.

◆ UNUSED

#define UNUSED (   x)    ((void)(x))

Definition at line 92 of file rhino/demo/c/dr_libs/old/dr.h.

Typedef Documentation

◆ dr_bool32

Definition at line 70 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_bool8

typedef dr_uint8 dr_bool8

Definition at line 69 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_cmdline

typedef struct dr_cmdline dr_cmdline

Definition at line 574 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_cmdline_parse_proc

typedef dr_bool32 dr_cmdline_parse_proc(const char *key, const char *value, void *pUserData)

Definition at line 585 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_int16

typedef int16_t dr_int16

Definition at line 62 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_int32

typedef int32_t dr_int32

Definition at line 64 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_int64

typedef int64_t dr_int64

Definition at line 66 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_int8

typedef int8_t dr_int8

Definition at line 60 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_iterate_files_proc

typedef dr_bool32(* dr_iterate_files_proc) (const char *filePath, void *pUserData)

Definition at line 422 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_key_value_error_proc

typedef void(* dr_key_value_error_proc) (void *pUserData, const char *message, unsigned int line)

Definition at line 337 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_key_value_pair_proc

typedef void(* dr_key_value_pair_proc) (void *pUserData, const char *key, const char *value)

Definition at line 336 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_key_value_read_proc

typedef size_t(* dr_key_value_read_proc) (void *pUserData, void *pDataOut, size_t bytesToRead)

Definition at line 335 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_mutex

typedef void* dr_mutex

Mutex.

Definition at line 665 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_semaphore

typedef void* dr_semaphore

Semaphore.

Definition at line 685 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_thread

typedef void* dr_thread

Thread.

Definition at line 631 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_thread_entry_proc

typedef int(* dr_thread_entry_proc) (void *pData)

Definition at line 632 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_uint16

typedef uint16_t dr_uint16

Definition at line 63 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_uint32

typedef uint32_t dr_uint32

Definition at line 65 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_uint64

typedef uint64_t dr_uint64

Definition at line 67 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_uint8

typedef uint8_t dr_uint8

Definition at line 61 of file rhino/demo/c/dr_libs/old/dr.h.

◆ drpath_iterator

Function Documentation

◆ _itoa_s()

DR_INLINE int _itoa_s ( int  value,
char *  dst,
size_t  dstSizeInBytes,
int  radix 
)

Definition at line 184 of file rhino/demo/c/dr_libs/old/dr.h.

◆ _stricmp()

DR_INLINE int _stricmp ( const char *  string1,
const char *  string2 
)

Definition at line 178 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_aligned_free()

DR_INLINE void dr_aligned_free ( void *  ptr)

Definition at line 320 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_aligned_malloc()

DR_INLINE void* dr_aligned_malloc ( size_t  alignment,
size_t  size 
)

Definition at line 306 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_cmdline_key_exists()

dr_bool32 dr_cmdline_key_exists ( dr_cmdline pCmdLine,
const char *  key 
)

Helper for determining whether or not the given key exists.

◆ dr_cmdline_to_argv()

int dr_cmdline_to_argv ( dr_cmdline pCmdLine,
char ***  argvOut 
)

◆ dr_copy_file()

dr_bool32 dr_copy_file ( const char *  srcPath,
const char *  dstPath,
dr_bool32  failIfExists 
)

◆ dr_copy_line()

size_t dr_copy_line ( const char *  str,
char *  lineOut,
size_t  lineOutSize 
)

Makes a copy of the first line of the given string.

◆ dr_create_empty_file()

dr_bool32 dr_create_empty_file ( const char *  fileName,
dr_bool32  failIfExists 
)

◆ dr_create_mutex()

dr_mutex dr_create_mutex ( )

Creates a mutex object.

Remarks
If an error occurs, 0 is returned. Otherwise a handle the size of a pointer is returned.

◆ dr_create_semaphore()

dr_semaphore dr_create_semaphore ( int  initialValue)

Creates a semaphore object.

Remarks
If an error occurs, 0 is returned. Otherwise a handle the size of a pointer is returned.

◆ dr_create_thread()

dr_thread dr_create_thread ( dr_thread_entry_proc  entryProc,
void *  pData 
)

Creates and begins executing a new thread.

Remarks
This will not return until the thread has entered into it's entry point.
Creating a thread should be considered an expensive operation. For high performance, you should create threads at load time and cache them.

◆ dr_date_YYYYMMDD()

void dr_date_YYYYMMDD ( time_t  t,
char *  strOut,
unsigned int  strOutSize 
)

◆ dr_datetime_short()

void dr_datetime_short ( time_t  t,
char *  strOut,
unsigned int  strOutSize 
)

Formats a data/time string.

◆ dr_delete_file()

dr_bool32 dr_delete_file ( const char *  filePath)

◆ dr_delete_mutex()

void dr_delete_mutex ( dr_mutex  mutex)

Deletes a mutex object.

◆ dr_delete_semaphore()

void dr_delete_semaphore ( dr_semaphore  semaphore)

Deletes the given semaphore.

◆ dr_delete_thread()

void dr_delete_thread ( dr_thread  thread)

Deletes the given thread.

Remarks
This does not actually exit the thread, but rather deletes the memory that was allocated for the thread object returned by dr_create_thread().
It is usually best to wait for the thread to terminate naturally with dr_wait_thread() before calling this function, however it is still safe to do something like the following.
dr_delete_thread(dr_create_thread(my_thread_proc, pData))

◆ dr_directory_exists()

dr_bool32 dr_directory_exists ( const char *  directoryPath)

◆ dr_file_exists()

dr_bool32 dr_file_exists ( const char *  filePath)

◆ dr_first_non_whitespace()

const char* dr_first_non_whitespace ( const char *  str)

Finds the first non-whitespace character in the given string.

◆ dr_first_whitespace()

const char* dr_first_whitespace ( const char *  str)

Finds the first occurance of a whitespace character in the given string.

◆ dr_fopen()

FILE* dr_fopen ( const char *  fileName,
const char *  openMode 
)

◆ dr_free_argv()

void dr_free_argv ( char **  argv)

◆ dr_free_file_data()

void dr_free_file_data ( void *  valueReturnedByOpenAndReadFile)

◆ dr_get_config_folder_path()

dr_bool32 dr_get_config_folder_path ( char *  pathOut,
size_t  pathOutSize 
)

Retrieves the path of the user's config directory.

Remarks
On Windows this will typically be APPDATA% and on Linux it will usually be ~/.config

◆ dr_get_current_directory()

const char* dr_get_current_directory ( char *  pathOut,
size_t  pathOutSize 
)

Retrieves the current directory.

◆ dr_get_executable_directory_path()

dr_bool32 dr_get_executable_directory_path ( char *  pathOut,
size_t  pathOutSize 
)

Retrieves the path of the directory containing the executable.

Remarks
Currently only works on Windows and Linux. Other platforms will be added as they're needed.

◆ dr_get_executable_path()

dr_bool32 dr_get_executable_path ( char *  pathOut,
size_t  pathOutSize 
)

Retrieves the path of the executable.

Remarks
Currently only works on Windows and Linux. Other platforms will be added as they're needed.

◆ dr_get_file_modified_time()

dr_uint64 dr_get_file_modified_time ( const char *  filePath)

◆ dr_get_log_folder_path()

dr_bool32 dr_get_log_folder_path ( char *  pathOut,
size_t  pathOutSize 
)

Retrieves the path of the user's log directory.

Remarks
On Windows this will typically be APPDATA% and on Linux it will usually be var/log

◆ dr_get_logical_processor_count()

unsigned int dr_get_logical_processor_count ( )

Retrieves the number of logical cores on system.

◆ dr_get_process_id()

unsigned int dr_get_process_id ( )

◆ dr_get_username()

size_t dr_get_username ( char *  usernameOut,
size_t  usernameOutSize 
)

◆ dr_hex_char_to_uint()

dr_bool32 dr_hex_char_to_uint ( char  ascii,
unsigned int *  out 
)

◆ dr_init_cmdline()

dr_bool32 dr_init_cmdline ( dr_cmdline pCmdLine,
int  argc,
char **  argv 
)

Initializes a command line object.

◆ dr_init_cmdline_win32()

dr_bool32 dr_init_cmdline_win32 ( dr_cmdline pCmdLine,
const char *  args 
)

Initializes a command line object using a Win32 style command line.

◆ dr_is_directory()

static dr_bool32 dr_is_directory ( const char *  directoryPath)
inlinestatic

Definition at line 456 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_is_file_read_only()

dr_bool32 dr_is_file_read_only ( const char *  filePath)

◆ dr_is_whitespace()

dr_bool32 dr_is_whitespace ( dr_uint32  utf32)

◆ dr_iterate_files()

dr_bool32 dr_iterate_files ( const char *  directory,
dr_bool32  recursive,
dr_iterate_files_proc  proc,
void *  pUserData 
)

◆ dr_itoa_s()

int dr_itoa_s ( int  value,
char *  dst,
size_t  dstSizeInBytes,
int  radix 
)

◆ dr_lock_mutex()

void dr_lock_mutex ( dr_mutex  mutex)

Locks the given mutex.

◆ dr_ltrim()

static const char* dr_ltrim ( const char *  str)
inlinestatic

Definition at line 203 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_mkdir()

dr_bool32 dr_mkdir ( const char *  directoryPath)

◆ dr_mkdir_recursive()

dr_bool32 dr_mkdir_recursive ( const char *  directoryPath)

◆ dr_move_file()

dr_bool32 dr_move_file ( const char *  oldPath,
const char *  newPath 
)

◆ dr_next_line()

const char* dr_next_line ( const char *  str)

Finds the beginning of the next line.

◆ dr_next_power_of_2()

DR_INLINE dr_uint32 dr_next_power_of_2 ( dr_uint32  value)

Definition at line 119 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_next_token()

const char* dr_next_token ( const char *  tokens,
char *  tokenOut,
size_t  tokenOutSize 
)

Retrieves the first token in the given string.

Remarks
This function is suitable for doing a simple whitespace tokenization of a null-terminated string.
The return value is a pointer to one character past the last character of the next token. You can use the return value to execute this function in a loop to parse an entire string.
<tokenOut> can be null. If the buffer is too small to contain the entire token it will be set to an empty string. The original input string combined with the return value can be used to reliably find the token.
This will handle double-quoted strings, so a string such as "My \"Complex String"" contains two tokens: "My" and ""Complex String"".
This function has no dependencies.

◆ dr_now()

time_t dr_now ( )

Retrieves a time_t as of the time the function was called.

◆ dr_open_and_read_file()

void* dr_open_and_read_file ( const char *  filePath,
size_t *  pFileSizeOut 
)

◆ dr_open_and_read_text_file()

char* dr_open_and_read_text_file ( const char *  filePath,
size_t *  pFileSizeOut 
)

◆ dr_open_and_write_file()

dr_bool32 dr_open_and_write_file ( const char *  filePath,
const void *  pData,
size_t  dataSize 
)

◆ dr_open_and_write_text_file()

dr_bool32 dr_open_and_write_text_file ( const char *  filePath,
const char *  text 
)

◆ dr_parse_cmdline()

void dr_parse_cmdline ( dr_cmdline pCmdLine,
dr_cmdline_parse_proc  callback,
void *  pUserData 
)

Parses the given command line.

◆ dr_parse_key_value_pairs()

void dr_parse_key_value_pairs ( dr_key_value_read_proc  onRead,
dr_key_value_pair_proc  onPair,
dr_key_value_error_proc  onError,
void *  pUserData 
)

Parses a series of simple Key/Value pairs.

Remarks
This function is suitable for parsing simple key/value config files.
This function will never allocate memory on the heap. Because of this there is a minor restriction in the length of an individual key/value pair which is 4KB.
Formatting rules are as follows:
  • The basic syntax for a key/value pair is [key][whitespace][value]. Example: MyProperty 1234
  • All key/value pairs must be declared on a single line, and a single line cannot contain more than a single key/value pair.
  • Comments begin with the '#' character and continue until the end of the line.
  • A key cannot contain spaces but are permitted in values.
  • The value will have any leading and trailing whitespace trimmed.
If an error occurs, that line will be skipped and processing will continue.

◆ dr_parse_key_value_pairs_from_file()

dr_bool32 dr_parse_key_value_pairs_from_file ( const char *  filePath,
dr_key_value_pair_proc  onPair,
dr_key_value_error_proc  onError,
void *  pUserData 
)

◆ dr_randd()

double dr_randd ( )

◆ dr_randf()

float dr_randf ( )

◆ dr_release_semaphore()

dr_bool32 dr_release_semaphore ( dr_semaphore  semaphore)

Releases the given semaphore and increments it's counter by one upon returning.

◆ dr_rtrim()

static const char* dr_rtrim ( const char *  str)
static

◆ dr_set_current_directory()

dr_bool32 dr_set_current_directory ( const char *  path)

Sets the current directory.

◆ dr_sleep()

void dr_sleep ( unsigned int  milliseconds)

Puts the calling thread to sleep for approximately the given number of milliseconds.

Remarks
This is not 100% accurate and should be considered an approximation.

◆ dr_strcat_s()

int dr_strcat_s ( char *  dst,
size_t  dstSizeInBytes,
const char *  src 
)

◆ dr_strcpy_s()

int dr_strcpy_s ( char *  dst,
size_t  dstSizeInBytes,
const char *  src 
)

◆ dr_string_replace()

char* dr_string_replace ( const char *  src,
const char *  query,
const char *  replacement 
)

◆ dr_string_replace_ascii()

void dr_string_replace_ascii ( char *  src,
char  c,
char  replacement 
)

◆ dr_strncat_s()

int dr_strncat_s ( char *  dst,
size_t  dstSizeInBytes,
const char *  src,
size_t  count 
)

◆ dr_strncpy_s()

int dr_strncpy_s ( char *  dst,
size_t  dstSizeInBytes,
const char *  src,
size_t  count 
)

◆ dr_strrmchar()

void dr_strrmchar ( char *  str,
char  c 
)

Removes every occurance of the given character from the given string.

◆ dr_timer_init()

void dr_timer_init ( dr_timer pTimer)

◆ dr_timer_tick()

double dr_timer_tick ( dr_timer pTimer)

◆ dr_trim()

void dr_trim ( char *  str)

Trims both the leading and trailing whitespace from the given string.

◆ dr_unlock_mutex()

void dr_unlock_mutex ( dr_mutex  mutex)

Unlocks the given mutex.

◆ dr_utf16_to_utf32_ch()

DR_INLINE unsigned int dr_utf16_to_utf32_ch ( unsigned short  utf16[2])

Converts a UTF-16 character to UTF-32.

Definition at line 268 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_utf16pair_to_utf32_ch()

DR_INLINE unsigned int dr_utf16pair_to_utf32_ch ( unsigned short  utf160,
unsigned short  utf161 
)

Converts a UTF-16 surrogate pair to UTF-32.

Definition at line 293 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_utf32_to_utf16_ch()

DR_INLINE int dr_utf32_to_utf16_ch ( unsigned int  utf32,
unsigned short  utf16[2] 
)

Converts a UTF-32 character to UTF-16.

Parameters
utf16[in] A pointer to an array of at least two 16-bit values that will receive the UTF-16 character.
Returns
2 if the returned character is a surrogate pair, 1 if it's a simple UTF-16 code point, or 0 if it's an invalid character.
Remarks
It is assumed the <utf16> is large enough to hold at least 2 unsigned shorts. <utf16> will be padded with 0 for unused components.

Definition at line 237 of file rhino/demo/c/dr_libs/old/dr.h.

◆ dr_wait_and_delete_thread()

void dr_wait_and_delete_thread ( dr_thread  thread)

Helper function for waiting for a thread and then deleting the handle after it has terminated.

◆ dr_wait_semaphore()

dr_bool32 dr_wait_semaphore ( dr_semaphore  semaphore)

Waits on the given semaphore object and decrements it's counter by one upon returning.

◆ dr_wait_thread()

void dr_wait_thread ( dr_thread  thread)

Waits for the given thread to terminate.

◆ dr_winmain_to_argv()

int dr_winmain_to_argv ( const char *  cmdlineWinMain,
char ***  argvOut 
)

◆ dr_yield()

void dr_yield ( )

◆ drpath_append()

dr_bool32 drpath_append ( char *  base,
size_t  baseBufferSizeInBytes,
const char *  other 
)

Appends two paths together, ensuring there is not double up on the last slash.

Parameters
base[in, out] The base path that is being appended to.
baseBufferSizeInBytes[in] The size of the buffer pointed to by "base", in bytes.
other[in] The other path segment.
Remarks
This assumes both paths are well formed and "other" is a relative path.

◆ drpath_append_and_clean()

size_t drpath_append_and_clean ( char *  dst,
size_t  dstSizeInBytes,
const char *  base,
const char *  other 
)

Appends one path to the other and then cleans it.

◆ drpath_append_extension()

dr_bool32 drpath_append_extension ( char *  base,
size_t  baseBufferSizeInBytes,
const char *  extension 
)

Appends an extension to the given path.

◆ drpath_append_iterator()

dr_bool32 drpath_append_iterator ( char *  base,
size_t  baseBufferSizeInBytes,
drpath_iterator  i 
)

Appends an iterator object to the given base path.

◆ drpath_at_end()

dr_bool32 drpath_at_end ( drpath_iterator  i)

Determines if the given iterator is at the end.

Parameters
i[in] The iterator to check.

◆ drpath_at_start()

dr_bool32 drpath_at_start ( drpath_iterator  i)

Determines if the given iterator is at the start.

Parameters
i[in] The iterator to check.

◆ drpath_base_path()

char* drpath_base_path ( char *  path)

Modifies the given path by transforming it into it's base path.

Returns <path>, for convenience.

◆ drpath_clean()

size_t drpath_clean ( const char *  path,
char *  pathOut,
size_t  pathOutSizeInBytes 
)

Cleans the path and resolves the ".." and "." segments.

Parameters
path[in] The path to clean.
pathOut[out] A pointer to the buffer that will receive the path.
pathOutSizeInBytes[in] The size of the buffer pointed to by pathOut, in bytes.
Returns
The number of bytes written to the output buffer, including the null terminator.
Remarks
The output path will never be longer than the input path.
The output buffer should never overlap with the input path.
As an example, the path "my/messy/../path" will result in "my/path"
The path "my/messy/../../../path" (note how there are too many ".." segments) will return "path" (the extra ".." segments will be dropped.)
If an error occurs, such as an invalid input path, 0 will be returned.

◆ drpath_copy_and_append()

dr_bool32 drpath_copy_and_append ( char *  dst,
size_t  dstSizeInBytes,
const char *  base,
const char *  other 
)

Appends two paths together, and copyies them to a separate buffer.

Parameters
dst[out] The destination buffer.
dstSizeInBytes[in] The size of the buffer pointed to by "dst", in bytes.
base[in] The base directory.
other[in] The relative path to append to "base".
Returns
DR_TRUE if the paths were appended successfully; DR_FALSE otherwise.
Remarks
This assumes both paths are well formed and "other" is a relative path.

◆ drpath_copy_and_append_extension()

dr_bool32 drpath_copy_and_append_extension ( char *  dst,
size_t  dstSizeInBytes,
const char *  base,
const char *  extension 
)

Appends an extension to the given base path and copies them to a separate buffer.

Parameters
dst[out] The destination buffer.
dstSizeInBytes[in] The size of the buffer pointed to by "dst", in bytes.
base[in] The base directory.
extension[in] The relative path to append to "base".
Returns
DR_TRUE if the paths were appended successfully; DR_FALSE otherwise.

◆ drpath_copy_and_append_iterator()

dr_bool32 drpath_copy_and_append_iterator ( char *  dst,
size_t  dstSizeInBytes,
const char *  base,
drpath_iterator  i 
)

Appends a base path and an iterator together, and copyies them to a separate buffer.

Parameters
dst[out] The destination buffer.
dstSizeInBytes[in] The size of the buffer pointed to by "dst", in bytes.
base[in] The base directory.
i[in] The iterator to append.
Returns
DR_TRUE if the paths were appended successfully; DR_FALSE otherwise.
Remarks
This assumes both paths are well formed and "i" is a valid iterator.

◆ drpath_copy_and_remove_extension()

dr_bool32 drpath_copy_and_remove_extension ( char *  dst,
size_t  dstSizeInBytes,
const char *  path 
)

Creates a copy of the given string and removes the extension.

◆ drpath_copy_and_remove_file_name()

dr_bool32 drpath_copy_and_remove_file_name ( char *  dst,
size_t  dstSizeInBytes,
const char *  path 
)

Creates a copy of the given string and removes the extension.

◆ drpath_copy_base_path()

void drpath_copy_base_path ( const char *  path,
char *  baseOut,
size_t  baseSizeInBytes 
)

Retrieves the base path from the given path, not including the trailing slash.

Parameters
path[in] The full path.
baseOut[out] A pointer to the buffer that will receive the base path.
baseSizeInBytes[in] The size in bytes of the buffer that will receive the base directory.
Remarks
As an example, when "path" is "C:/MyFolder/MyFile", the output will be "C:/MyFolder". Note that there is no trailing slash.
If "path" is something like "/MyFolder", the return value will be an empty string.

◆ drpath_copy_file_name()

const char* drpath_copy_file_name ( const char *  path,
char *  fileNameOut,
size_t  fileNameSizeInBytes 
)

Copies the file name into the given buffer.

◆ drpath_equal()

dr_bool32 drpath_equal ( const char *  path1,
const char *  path2 
)

Checks whether or not the two paths are equal.

Parameters
path1[in] The first path.
path2[in] The second path.
Returns
DR_TRUE if the paths are equal, DR_FALSE otherwise.
Remarks
This is case-sensitive.
This is more than just a string comparison. Rather, this splits the path and compares each segment. The path "C:/My/Folder" is considered equal to to "C:\\My\\Folder".

◆ drpath_extension()

const char* drpath_extension ( const char *  path)

Finds the file extension of the given file path.

Parameters
path[in] The path to search.
Returns
A pointer to the beginning of the string containing the file's extension.
Remarks
A path with a trailing slash will return an empty string.
The return value is just an offset of "path".
On a path such as "filename.ext1.ext2" the returned string will be "ext2".

◆ drpath_extension_equal()

dr_bool32 drpath_extension_equal ( const char *  path,
const char *  extension 
)

Checks if the extension of the given path is equal to the given extension.

Remarks
By default this is NOT case-sensitive, however if the standard library is disable, it is case-sensitive.

◆ drpath_file_name()

const char* drpath_file_name ( const char *  path)

Finds the file name portion of the path.

Parameters
path[in] The path to search.
Returns
A pointer to the beginning of the string containing the file name. If this is non-null, it will be an offset of "path".
Remarks
A path with a trailing slash will return an empty string.
The return value is just an offset of "path".

◆ drpath_first()

dr_bool32 drpath_first ( const char *  path,
drpath_iterator i 
)

Creates an iterator for iterating over each segment in a path.

Parameters
path[in] The path whose segments are being iterated.
Returns
True if at least one segment is found; DR_FALSE if it's an empty path.

◆ drpath_is_absolute()

dr_bool32 drpath_is_absolute ( const char *  path)

Determines whether or not the given path is absolute.

Parameters
path[in] The path to check.

◆ drpath_is_child()

dr_bool32 drpath_is_child ( const char *  childAbsolutePath,
const char *  parentAbsolutePath 
)

Determines whether or not the given path is a direct child of another.

Parameters
childAbsolutePath[in] The absolute of the child.
parentAbsolutePath[in] The absolute path of the parent.
Remarks
As an example, "C:/My/Folder" is NOT a child of "C:/" - it is a descendant. Alternatively, "C:/My" IS a child of "C:/".
If either path contains "." or "..", clean it with drpath_clean() before calling this.

◆ drpath_is_descendant()

dr_bool32 drpath_is_descendant ( const char *  descendantAbsolutePath,
const char *  parentAbsolutePath 
)

Determines whether or not the given path is a decendant of another.

Parameters
descendantAbsolutePath[in] The absolute path of the descendant.
parentAbsolutePath[in] The absolute path of the parent.
Remarks
As an example, "C:/My/Folder" is a descendant of "C:/".
If either path contains "." or "..", clean it with drpath_clean() before calling this.

◆ drpath_is_linux_style_root_segment()

dr_bool32 drpath_is_linux_style_root_segment ( const drpath_iterator  i)

Determines whether or not the given iterator refers to a Linux style root directory ("/")

◆ drpath_is_relative()

dr_bool32 drpath_is_relative ( const char *  path)

Determines whether or not the given path is relative.

Parameters
path[in] The path to check.

◆ drpath_is_root_segment()

dr_bool32 drpath_is_root_segment ( const drpath_iterator  i)

Determines whether or not the given iterator refers to the root segment of a path.

◆ drpath_is_win32_style_root_segment()

dr_bool32 drpath_is_win32_style_root_segment ( const drpath_iterator  i)

Determines whether or not the given iterator refers to a Windows style root directory.

◆ drpath_iterators_equal()

dr_bool32 drpath_iterators_equal ( const drpath_iterator  i0,
const drpath_iterator  i1 
)

Compares the string values of two iterators for equality.

Parameters
i0[in] The first iterator to compare.
i1[in] The second iterator to compare.
Returns
DR_TRUE if the strings are equal; DR_FALSE otherwise.

◆ drpath_last()

dr_bool32 drpath_last ( const char *  path,
drpath_iterator i 
)

Creates an iterator beginning at the last segment.

◆ drpath_next()

dr_bool32 drpath_next ( drpath_iterator i)

Goes to the next segment in the path as per the given iterator.

Parameters
i[in] A pointer to the iterator to increment.
Returns
True if the iterator contains a valid value. Use this to determine when to terminate iteration.

◆ drpath_prev()

dr_bool32 drpath_prev ( drpath_iterator i)

Goes to the previous segment in the path.

Parameters
i[in] A pointer to the iterator to decrement.
Returns
DR_TRUE if the iterator contains a valid value. Use this to determine when to terminate iteration.

◆ drpath_remove_extension()

dr_bool32 drpath_remove_extension ( char *  path)

Removes the extension from the given path.

Remarks
If the given path does not have an extension, 1 will be returned, but the string will be left unmodified.

◆ drpath_remove_file_name()

dr_bool32 drpath_remove_file_name ( char *  path)

Removes the last segment from the given path.

◆ drpath_segments_equal()

dr_bool32 drpath_segments_equal ( const char *  s0Path,
const drpath_segment  s0,
const char *  s1Path,
const drpath_segment  s1 
)

Compares a section of two strings for equality.

Parameters
s0Path[in] The first path.
s0[in] The segment of the first path to compare.
s1Path[in] The second path.
s1[in] The segment of the second path to compare.
Returns
DR_TRUE if the strings are equal; DR_FALSE otherwise.

◆ drpath_to_absolute()

dr_bool32 drpath_to_absolute ( const char *  relativePathToMakeAbsolute,
const char *  basePath,
char *  absolutePathOut,
size_t  absolutePathOutSizeInBytes 
)

Converts a relative path to an absolute path based on a base path.

Returns
DR_TRUE if the conversion was successful; DR_FALSE if there was an error.
Remarks
This is equivalent to an append followed by a clean. Slashes will be normalized to forward slashes.

◆ drpath_to_backslashes()

void drpath_to_backslashes ( char *  path)

Converts the slashes in the given path to back slashes.

Parameters
path[in] The path whose slashes are being converted.

◆ drpath_to_forward_slashes()

void drpath_to_forward_slashes ( char *  path)

Converts the slashes in the given path to forward slashes.

Parameters
path[in] The path whose slashes are being converted.

◆ drpath_to_relative()

dr_bool32 drpath_to_relative ( const char *  absolutePathToMakeRelative,
const char *  absolutePathToMakeRelativeTo,
char *  relativePathOut,
size_t  relativePathOutSizeInBytes 
)

Converts an absolute path to a relative path.

Returns
DR_TRUE if the conversion was successful; DR_FALSE if there was an error.
Remarks
This will normalize every slash to forward slashes.

◆ strcat_s()

DR_INLINE int strcat_s ( char *  dst,
size_t  dstSizeInBytes,
const char *  src 
)

Definition at line 167 of file rhino/demo/c/dr_libs/old/dr.h.

◆ strcpy_s()

DR_INLINE int strcpy_s ( char *  dst,
size_t  dstSizeInBytes,
const char *  src 
)

Definition at line 157 of file rhino/demo/c/dr_libs/old/dr.h.

◆ strncat_s()

DR_INLINE int strncat_s ( char *  dst,
size_t  dstSizeInBytes,
const char *  src,
size_t  count 
)

Definition at line 172 of file rhino/demo/c/dr_libs/old/dr.h.

◆ strncpy_s()

DR_INLINE int strncpy_s ( char *  dst,
size_t  dstSizeInBytes,
const char *  src,
size_t  count 
)

Definition at line 162 of file rhino/demo/c/dr_libs/old/dr.h.

dr_create_thread
dr_thread dr_create_thread(dr_thread_entry_proc entryProc, void *pData)
dr_delete_thread
void dr_delete_thread(dr_thread thread)


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:57