aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/homedir.c8
-rw-r--r--src/main.c36
2 files changed, 43 insertions, 1 deletions
diff --git a/src/homedir.c b/src/homedir.c
index 69fbc467c..694b9bc79 100644
--- a/src/homedir.c
+++ b/src/homedir.c
@@ -87,7 +87,13 @@ char *GetEnv(const char *variable, char do_expand)
/* return the home directory of the current user as an allocated string */
char *homedir(void)
{
- char *home = GetEnv("HOME", FALSE);
+ char *home;
+
+ home = GetEnv("CURL_HOME", FALSE);
+ if(home)
+ return home;
+
+ home = GetEnv("HOME", FALSE);
if(home)
return home;
diff --git a/src/main.c b/src/main.c
index f96dd8b57..3df33be5e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2233,7 +2233,43 @@ static void parseconfig(const char *filename,
snprintf(filebuffer, sizeof(filebuffer),
"%s%s%s", home, DIR_CHAR, CURLRC);
+#ifdef WIN32
+ /* Check if the file exists - if not, try CURLRC in the same
+ * directory as our executable
+ */
+ file = fopen(filebuffer, "r");
+ if (file != NULL) {
+ fclose(file);
+ filename = filebuffer;
+ }
+ else {
+ /* Get the filename of our executable. GetModuleFileName is
+ * defined in windows.h, which is #included into libcurl.
+ * We assume that we are using the ASCII version here.
+ */
+ int n = GetModuleFileName(0, filebuffer, sizeof(filebuffer));
+ if (n > 0 && n < sizeof(filebuffer)) {
+ /* We got a valid filename - get the directory part */
+ char *lastdirchar = strrchr(filebuffer, '\\');
+ if (lastdirchar) {
+ int remaining;
+ *lastdirchar = 0;
+ /* If we have enough space, build the RC filename */
+ remaining = sizeof(filebuffer) - strlen(filebuffer);
+ if (strlen(CURLRC) < remaining - 1) {
+ snprintf(lastdirchar, remaining,
+ "%s%s", DIR_CHAR, CURLRC);
+ /* Don't bother checking if it exists - we do
+ * that later
+ */
+ filename = filebuffer;
+ }
+ }
+ }
+ }
+#else /* WIN32 */
filename = filebuffer;
+#endif /* WIN32 */
}
free(home); /* we've used it, now free it */
}