77 lines
2.8 KiB
Diff
77 lines
2.8 KiB
Diff
src/tool_parsecfg.c | 42 ++++++++++++++++--------------------------
|
|
1 file changed, 16 insertions(+), 26 deletions(-)
|
|
|
|
diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c
|
|
index a166757..6a00b80 100644
|
|
--- a/src/tool_parsecfg.c
|
|
+++ b/src/tool_parsecfg.c
|
|
@@ -47,29 +47,20 @@ static const char *unslashquote(const char *line, char *param);
|
|
static bool my_get_line(FILE *fp, struct curlx_dynbuf *, bool *error);
|
|
|
|
#ifdef WIN32
|
|
-static FILE *execpath(const char *filename, char **pathp)
|
|
+static FILE *execpath(const TCHAR *filename)
|
|
{
|
|
- static char filebuffer[512];
|
|
- /* Get the filename of our executable. GetModuleFileName is already declared
|
|
- * via inclusions done in setup header file. We assume that we are using
|
|
- * the ASCII version here.
|
|
- */
|
|
- unsigned long len = GetModuleFileNameA(0, filebuffer, sizeof(filebuffer));
|
|
- if(len > 0 && len < sizeof(filebuffer)) {
|
|
- /* We got a valid filename - get the directory part */
|
|
- char *lastdirchar = strrchr(filebuffer, '\\');
|
|
+ static const size_t BUFFSIZE = 512;
|
|
+ TCHAR filebuffer[BUFFSIZE];
|
|
+ unsigned long len = GetModuleFileName(0, filebuffer, BUFFSIZE);
|
|
+ if((len > 0) && (len < BUFFSIZE)) {
|
|
+ TCHAR *lastdirchar = _tcsrchr(filebuffer, TEXT('\\'));
|
|
if(lastdirchar) {
|
|
- size_t remaining;
|
|
- *lastdirchar = 0;
|
|
- /* If we have enough space, build the RC filename */
|
|
- remaining = sizeof(filebuffer) - strlen(filebuffer);
|
|
- if(strlen(filename) < remaining - 1) {
|
|
- FILE *f;
|
|
- msnprintf(lastdirchar, remaining, "%s%s", DIR_CHAR, filename);
|
|
- *pathp = filebuffer;
|
|
- f = fopen(filebuffer, FOPEN_READTEXT);
|
|
- return f;
|
|
- }
|
|
+ *lastdirchar = TEXT('\0');
|
|
+ }
|
|
+ if (_tcslen(filebuffer) + _tcslen(filename) + 2U < BUFFSIZE) {
|
|
+ _tcscat(filebuffer, TEXT("\\"));
|
|
+ _tcscat(filebuffer, filename);
|
|
+ return _tfopen(filebuffer, TEXT(FOPEN_READTEXT));
|
|
}
|
|
}
|
|
|
|
@@ -89,7 +80,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
|
|
|
if(!filename) {
|
|
/* NULL means load .curlrc from homedir! */
|
|
- char *curlrc = findfile(".curlrc", CURLRC_DOTSCORE);
|
|
+ char *curlrc = NULL; /* findfile(".curlrc", CURLRC_DOTSCORE); */
|
|
if(curlrc) {
|
|
file = fopen(curlrc, FOPEN_READTEXT);
|
|
if(!file) {
|
|
@@ -100,14 +91,13 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
|
}
|
|
#ifdef WIN32 /* Windows */
|
|
else {
|
|
- char *fullp;
|
|
/* check for .curlrc then _curlrc in the dir of the executable */
|
|
- file = execpath(".curlrc", &fullp);
|
|
+ file = execpath(TEXT(".curlrc") /*,&fullp*/);
|
|
if(!file)
|
|
- file = execpath("_curlrc", &fullp);
|
|
+ file = execpath(TEXT("_curlrc") /*,&fullp*/);
|
|
if(file)
|
|
/* this is the filename we read from */
|
|
- filename = fullp;
|
|
+ filename = ".curlrc";
|
|
}
|
|
#endif
|
|
}
|