summaryrefslogtreecommitdiff
path: root/src/os_windows/ce_freopen.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-02-17 17:25:57 +0000
committer <>2015-03-17 16:26:24 +0000
commit780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch)
tree598f8b9fa431b228d29897e798de4ac0c1d3d970 /src/os_windows/ce_freopen.c
parent7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff)
downloadberkeleydb-master.tar.gz
Imported from /home/lorry/working-area/delta_berkeleydb/db-6.1.23.tar.gz.HEADdb-6.1.23master
Diffstat (limited to 'src/os_windows/ce_freopen.c')
-rw-r--r--src/os_windows/ce_freopen.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/os_windows/ce_freopen.c b/src/os_windows/ce_freopen.c
new file mode 100644
index 00000000..331450d0
--- /dev/null
+++ b/src/os_windows/ce_freopen.c
@@ -0,0 +1,52 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 2001, 2015 Oracle and/or its affiliates. All rights reserved.
+ *
+ * $Id$
+ */
+
+#include "db_config.h"
+
+#include "db_int.h"
+
+/*
+ * __ce_freopen --
+ * Reopen a stream on WinCE.
+ *
+ * PUBLIC: #ifdef DB_WINCE
+ * PUBLIC: FILE * __ce_freopen
+ * PUBLIC: __P((const char *, const char *, FILE *));
+ * PUBLIC: #endif
+ */
+FILE *
+__ce_freopen(path, mode, stream)
+ const char *path, *mode;
+ FILE *stream;
+{
+ size_t lenm, lenp;
+ wchar_t *wpath, *wmode;
+ FILE *handle;
+
+ wpath = NULL;
+ wmode = NULL;
+ handle = NULL;
+ lenp = strlen(path) + 1;
+ lenm = strlen(mode) + 1;
+
+ if (__os_malloc(NULL, lenp * sizeof(wchar_t), &wpath) != 0 ||
+ __os_malloc(NULL, lenm * sizeof(wchar_t), &wmode) != 0)
+ goto err;
+
+ if (mbstowcs(wpath, path, lenp) != lenp ||
+ mbstowcs(wmode, mode, lenm) != lenm)
+ goto err;
+
+ handle = _wfreopen(wpath, wmode, stream);
+err:
+ if (wpath != NULL)
+ __os_free(NULL, wpath);
+ if (wmode != NULL)
+ __os_free(NULL, wmode);
+ return handle;
+}