summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-08-29 19:02:43 +0000
committerNick Mathewson <nickm@torproject.org>2007-08-29 19:02:43 +0000
commitf189ecbf202b8cb96ff3ecea775c259083a3b8e3 (patch)
tree5ef5ad3894ab9d5eabc685c38dab5e075427073e /src/common/util.h
parent8408122222bda77347e46dedafc12abcd2b45e1e (diff)
downloadtor-f189ecbf202b8cb96ff3ecea775c259083a3b8e3.tar.gz
tor-f189ecbf202b8cb96ff3ecea775c259083a3b8e3.zip
r14832@catbus: nickm | 2007-08-29 15:00:27 -0400
Use (and debug) new file-writing functions in order to simplify code that formerly built big strings in RAM. svn:r11301
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h
index 0b7dfc6cb1..d973948c50 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -18,6 +18,13 @@
#include <stdio.h>
#include <stdlib.h>
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+#ifndef O_TEXT
+#define O_TEXT 0
+#endif
+
/* Replace assert() with a variant that sends failures to the log before
* calling assert() normally.
*/
@@ -213,9 +220,14 @@ file_status_t file_status(const char *filename);
* directory; see that function's documentation for details. */
typedef enum { CPD_NONE, CPD_CREATE, CPD_CHECK } cpd_check_t;
int check_private_dir(const char *dirname, cpd_check_t check);
+#define OPEN_FLAGS_REPLACE (O_WRONLY|O_CREAT|O_TRUNC)
+#define OPEN_FLAGS_APPEND (O_WRONLY|O_CREAT|O_APPEND)
typedef struct open_file_t open_file_t;
int start_writing_to_file(const char *fname, int open_flags, int mode,
open_file_t **data_out);
+FILE *start_writing_to_stdio_file(const char *fname, int open_flags, int mode,
+ open_file_t **data_out);
+FILE *fdopen_file(open_file_t *file_data);
int finish_writing_to_file(open_file_t *file_data);
int abort_writing_to_file(open_file_t *file_data);
int write_str_to_file(const char *fname, const char *str, int bin);