summaryrefslogtreecommitdiffstats
path: root/apps/apps.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2004-03-25 20:09:00 +0000
committerRichard Levitte <levitte@openssl.org>2004-03-25 20:09:00 +0000
commitd530017c003890695977e3a9bfd62e420f943b83 (patch)
tree8903cd703f90a746ed19ae8005b145c1c3cffc85 /apps/apps.c
parentfd9fa844e21b08b6038e7175f05fbd9be815d3df (diff)
Move the definition of Win32_rename(), since the macro rename gets undefined
in the middle of the code on Windows, and that disrupts operations in functions later that use rename()... PR: 853
Diffstat (limited to 'apps/apps.c')
-rw-r--r--apps/apps.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/apps/apps.c b/apps/apps.c
index eae1fedcd3..fa2f8a2b85 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -341,44 +341,6 @@ void program_name(char *in, char *out, int size)
#endif
#endif
-#ifdef OPENSSL_SYS_WIN32
-int WIN32_rename(char *from, char *to)
- {
-#ifndef OPENSSL_SYS_WINCE
- /* Windows rename gives an error if 'to' exists, so delete it
- * first and ignore file not found errror
- */
- if((remove(to) != 0) && (errno != ENOENT))
- return -1;
-#undef rename
- return rename(from, to);
-#else
- /* convert strings to UNICODE */
- {
- BOOL result = FALSE;
- WCHAR* wfrom;
- WCHAR* wto;
- int i;
- wfrom = malloc((strlen(from)+1)*2);
- wto = malloc((strlen(to)+1)*2);
- if (wfrom != NULL && wto != NULL)
- {
- for (i=0; i<(int)strlen(from)+1; i++)
- wfrom[i] = (short)from[i];
- for (i=0; i<(int)strlen(to)+1; i++)
- wto[i] = (short)to[i];
- result = MoveFile(wfrom, wto);
- }
- if (wfrom != NULL)
- free(wfrom);
- if (wto != NULL)
- free(wto);
- return result;
- }
-#endif
- }
-#endif
-
int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[])
{
int num,len,i;
@@ -2114,3 +2076,41 @@ error:
return NULL;
}
+/* This code MUST COME AFTER anything that uses rename() */
+#ifdef OPENSSL_SYS_WIN32
+int WIN32_rename(char *from, char *to)
+ {
+#ifndef OPENSSL_SYS_WINCE
+ /* Windows rename gives an error if 'to' exists, so delete it
+ * first and ignore file not found errror
+ */
+ if((remove(to) != 0) && (errno != ENOENT))
+ return -1;
+#undef rename
+ return rename(from, to);
+#else
+ /* convert strings to UNICODE */
+ {
+ BOOL result = FALSE;
+ WCHAR* wfrom;
+ WCHAR* wto;
+ int i;
+ wfrom = malloc((strlen(from)+1)*2);
+ wto = malloc((strlen(to)+1)*2);
+ if (wfrom != NULL && wto != NULL)
+ {
+ for (i=0; i<(int)strlen(from)+1; i++)
+ wfrom[i] = (short)from[i];
+ for (i=0; i<(int)strlen(to)+1; i++)
+ wto[i] = (short)to[i];
+ result = MoveFile(wfrom, wto);
+ }
+ if (wfrom != NULL)
+ free(wfrom);
+ if (wto != NULL)
+ free(wto);
+ return result;
+ }
+#endif
+ }
+#endif