Commit 78882e46 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Paul Moore made curl check for the .curlrc file (_curlrc on windows) on two

more places. First, CURL_HOME is a new environment variable that is used
instead of HOME if it is set, to point out where the default config file
lives. If there's no config file in the dir pointed out by one of the
environment variables, the Windows version will instead check the same
directory the executable curl is located in.
parent 8465a367
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -7,6 +7,14 @@
                                  Changelog


Daniel (27 April 2005)
- Paul Moore made curl check for the .curlrc file (_curlrc on windows) on two
  more places. First, CURL_HOME is a new environment variable that is used
  instead of HOME if it is set, to point out where the default config file
  lives. If there's no config file in the dir pointed out by one of the
  environment variables, the Windows version will instead check the same
  directory the executable curl is located in.

Daniel (26 April 2005)
- Cory Nelson's work on nuking compiler warnings when building on x64 with
  VS2005.
+7 −1
Original line number Diff line number Diff line
@@ -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;

+36 −0
Original line number Diff line number Diff line
@@ -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 */
    }