Forum OpenACS Development: Re: Win32-OpenACS Version 1.8

Collapse
Posted by Enrique Catalan on
Hi,

This could work for you as a workaround. We've fixed that overloading that function adding this code to one of our *-init.tcl procs:

if { [ns_info platform] == "win32"} {
rename ns_tmpnam aol_tmpnam
proc ns_tmpnam {} {
set tmp [aol_tmpnam]
set dir [parameter::get_from_package_key -package_key acs-subsite -parameter TmpDir]
return "${dir}${tmp}"
}
}

You just need to make sure that the MainSite parameter TmpDir in the site-map has the right path (i.e. C:\temp ).

In Windows, according to their documentation, the C function tmpnam() is deprecated and is not safe. They recommend to use tempnam(dir,filename) instead where you can specify the path and the filename.

Hope that helps!

Collapse
Posted by Gustaf Neumann on
Yes, this will work, but is awful, since it means that every aolserver application under windows using ns_tmpnam will have to do this. i was not daring to suggest this. it is better to fix aolserver.
Collapse
Posted by Maurizio Martignano on
Dear Gustaf, I absolutely agree with you.

The changes you proposed in your last post are allmost perfect. I had to change them as follows:

int i;
char *buf = _tempnam("/tmp", "nsd");

if (buf == NULL) {
Tcl_SetResult(interp, "could not generate temporary filename.", TCL_STATIC);
return TCL_ERROR;
}
/*
Change back slash characters into slash characters
*/
for (i = 0; i < strlen(buf); i++) {
if (buf[i] == '\\') buf[i] = '/';
}
/*
The documentation says that _tempnam() allocates memory via
malloc(); to be sure, that the "right" free() is used, we do
not use TCL_DYNAMIC but the TCL_VOLATILE followed by the manual
free().
*/
Tcl_SetResult(interp, buf, TCL_VOLATILE);
free(buf);

The problem is that _tempname generates file names in the Windows style (i.e. with back slash characters) and SqlLdr doesn't like that style for the "control" parameter (it requires normal slash characters).

Once again many thanks,
Maurizio

Collapse
Posted by Gustaf Neumann on
Dear Maurizio, great news, many thanks. let me know when other problems pop up. i'll try to channel the change into the aolserver sources. It's a pleasure to work with you

-gustaf