added
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 6 Jun 2005 17:36:04 +0000 (17:36 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 6 Jun 2005 17:36:04 +0000 (17:36 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@320 9efc2488-bf62-4759-914b-345cdb29e865

include/utils.h [new file with mode: 0644]

diff --git a/include/utils.h b/include/utils.h
new file mode 100644 (file)
index 0000000..1fac59d
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <stdarg.h>
+
+#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