--- tcl_commands.c	Wed Jun 26 09:12:43 2002
+++ tcl_commands.c	Mon Mar 26 02:01:19 2007
@@ -359,3 +359,3 @@
     char *t;
-    char *authorization = NULL;
+    const char *authorization;
 
@@ -397,4 +397,4 @@
     /* Get the user/pass info for Basic authentication */
-    (const char*)authorization = ap_table_get(globals->r->headers_in, "Authorization");
-    if (authorization && !strcasecmp(ap_getword_nc(POOL, &authorization, ' '), "Basic"))
+    authorization = ap_table_get(globals->r->headers_in, "Authorization");
+    if (authorization && !strcasecmp(ap_getword(POOL, &authorization, ' '), "Basic"))
     {
@@ -739,15 +739,19 @@
 	{
+	    union {
+		ClientData handle;
+		int fd;
+	    } handle;
+	    FILE *f;
 	    Tcl_Channel chan;
 	    char *method = Tcl_GetString(objv[3]);
+	    f = ApacheUpload_FILE(upload);
+	    handle.fd = f ? fileno(f) : -1;
 	    if (!strcmp(method, "channel"))
 	    {
-		if (ApacheUpload_FILE(upload) != NULL)
+		if (handle.fd != -1)
 		{
 		    /* create and return a file channel */
-		    char *channelname = NULL;
-		    chan = Tcl_MakeFileChannel((ClientData)fileno(
-			ApacheUpload_FILE(upload)), TCL_READABLE);
+		    chan = Tcl_MakeFileChannel(handle.handle, TCL_READABLE);
 		    Tcl_RegisterChannel(interp, chan);
-		    channelname = Tcl_GetChannelName(chan);
-		    Tcl_SetStringObj(result, channelname, -1);
+		    Tcl_SetStringObj(result, Tcl_GetChannelName(chan), -1);
 		}
@@ -772,4 +776,3 @@
 
-		chan = Tcl_MakeFileChannel((ClientData)fileno(
-		    ApacheUpload_FILE(upload)), TCL_READABLE);
+		chan = Tcl_MakeFileChannel(handle.handle, TCL_READABLE);
 		Tcl_SetChannelOption(interp, chan, "-translation", "binary");
@@ -799,4 +802,3 @@
 		    bytes = Tcl_Alloc(ApacheUpload_size(upload));
-		    chan = Tcl_MakeFileChannel((ClientData)fileno(
-			ApacheUpload_FILE(upload)), TCL_READABLE);
+		    chan = Tcl_MakeFileChannel(handle.handle, TCL_READABLE);
 		    Tcl_SetChannelOption(interp, chan, "-translation", "binary");
