cURL / Mailing Lists / curl-users / Single Mail

curl-users

RE: default location for ca-bundle.crt on windows

From: Roth, Kevin P. <KPRoth_at_MarathonOil.com>
Date: Wed, 23 Oct 2002 14:54:18 -0400

-----Original Message-----
From: Daniel Stenberg [mailto:daniel_at_haxx.se]
Sent: Wednesday, October 23, 2002 10:26 AM

> This is not at all a bad idea. But AFAIK, windows users are not known
> to use environment variables very widely either.

True. However, it's nice to provide that option, for those few windows
users who do like to use environment variables. There are more who like
environment variables than there are using a .curlrc file or $HOME...

> Is it possibly in windows to figure out where the curl binary is located
> when that is run? If so, we could check that directory first for the
> presence of a file using the standard ca cert bundle name.

I was kind of hoping that would be a "standard" thing in C, until I
realized that argv[0] is just what the user typed when he ran curl.exe;
not necessarily a full path.

So, here's a tiny program that will find a given filename by looking in
these folders, in order:
 1. directory the executable is in
 2. current working directory
 3. Windows System Directory (e.g. C:\windows\system32)
 4. Windows Directory (e.g. C:\windows)
 5. %PATH%

#include <windows.h>

int main(int argc, char *argv[])
{
 DWORD buflen;
 char *ptr = NULL; //pointer to the file-name part of the path
 char *retval = (char *) malloc(sizeof (TCHAR) * (MAX_PATH + 1));
 retval[0] = '\0';
 buflen = SearchPath(NULL, "curl-ca-bundle.crt", NULL, MAX_PATH+1, retval, &ptr);
 if (buflen > 0)
   printf("Path: %s\n", retval);

 free(retval);
 return 0;
}

Can this code be adjusted for proper use in curl and added, possibly along
with the code for looking up that environment variable?

--Kevin

-------------------------------------------------------
This sf.net email is sponsored by: Influence the future
of Java(TM) technology. Join the Java Community
Process(SM) (JCP(SM)) program now.
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0002en
Received on 2002-10-23