From: erickson Date: Mon, 6 Jun 2005 17:36:04 +0000 (+0000) Subject: added X-Git-Tag: osrf_rel_2_0_1~1552 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7ab2420d74af45fc207d4bf94d83dd02460c594d;p=OpenSRF.git added git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@320 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/include/utils.h b/include/utils.h new file mode 100644 index 0000000..1fac59d --- /dev/null +++ b/include/utils.h @@ -0,0 +1,33 @@ +#ifndef UTILS_H +#define UTILS_H + +#include + +#define BUFFER_MAX_SIZE 10485760 + +void* safe_malloc(int size); + +// --------------------------------------------------------------------------------- +// Generic growing buffer. Add data all you want +// --------------------------------------------------------------------------------- +struct growing_buffer_struct { + char *buf; + int n_used; + int size; +}; +typedef struct growing_buffer_struct growing_buffer; + +growing_buffer* buffer_init( int initial_num_bytes); +int buffer_addchar(growing_buffer* gb, char c); +int buffer_add(growing_buffer* gb, char* c); +int buffer_fadd(growing_buffer* gb, const char* format, ... ); +int buffer_reset( growing_buffer* gb); +char* buffer_data( growing_buffer* gb); +int buffer_free( growing_buffer* gb ); +int buffer_add_char(growing_buffer* gb, char c); + + +char* uescape( const char* string, int size, int full_escape ); +double get_timestamp_millis(); + +#endif