Mail Archives: cygwin/1999/04/28/11:31:46
Mumit Khan <khan AT xraylith DOT wisc DOT EDU> writes:
>
> Please try the following untested code (note the explicit adding to win32
> env as well):
>
> int
> add_path (const char *newdir)
> {
> char newpath[1024];
> #if __CYGWIN__
> char scratch[1024];
> #endif /* __CYGWIN__ */
> const char *pathvar = getenv ("PATH");
> sprintf (newpath, "PATH=%s:%s", newdir, pathvar);
> putenv (newpath);
> printf ("New path: %s\n", newpath);
>
> #if __CYGWIN__
> /* now do the win32 path. */
> cygwin32_posix_to_win32_path_list (pathvar, scratch);
> sprintf (newpath, "%s;%s", newdir, scratch);
> SetEnvironmentVariable ("PATH", newpath);
> printf ("New path: %s\n", newpath);
> #endif /* __CYGWIN__ */
> return 0;
> }
>
Ooops. Try this instead:
#include <windows.h>
int add_path (const char *newdir)
{
char newpath[1024];
#ifdef __CYGWIN__
char scratch[1024];
#endif
const char *pathvar = getenv ("PATH");
sprintf (newpath, "PATH=%s:%s", newdir, pathvar);
putenv (newpath);
printf ("New path: %s\n", newpath);
#ifdef __CYGWIN__
/* now do the win32 path. */
sprintf (scratch, "%s:%s", newdir, pathvar);
cygwin32_posix_to_win32_path_list (scratch, newpath);
SetEnvironmentVariable ("PATH", newpath);
printf ("New path: %s\n", newpath);
#endif
return 0;
}
and you can now call add_path with Cygwin pathname that will get
translated to win32 pathname correctly:
add_path ("/usr/local/lib");
Now since dlopen essentially is the same as LoadLibrary (and returns
the same handle), you could just use dlopen and dlclose (which will
call the unload library routine). I don't know the details of who's
calling the unload routine, so I can't judge if that will work for
you.
Regards,
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -