You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_dtcl-cvs@tcl.apache.org by da...@apache.org on 2001/06/23 17:30:58 UTC

cvs commit: tcl-moddtcl/docs commands.html

davidw      01/06/23 08:30:58

  Modified:    .        tcl_commands.c
               docs     commands.html
  Log:
  Updated docs with 'upload' command.
  Cleaned up 'upload' command some.
  
  Revision  Changes    Path
  1.10      +24 -14    tcl-moddtcl/tcl_commands.c
  
  Index: tcl_commands.c
  ===================================================================
  RCS file: /home/cvs/tcl-moddtcl/tcl_commands.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- tcl_commands.c	2001/06/21 17:47:12	1.9
  +++ tcl_commands.c	2001/06/23 15:30:56	1.10
  @@ -639,7 +639,8 @@
   	return TCL_ERROR;
       }
       command = Tcl_GetString(objv[1]);
  -
  +    
  +    result = Tcl_NewObj();
       if (!strcmp(command, "get"))
       {
   	char *varname = NULL;
  @@ -664,7 +665,7 @@
   			ApacheUpload_FILE(upload)), TCL_READABLE);
   		    Tcl_RegisterChannel(interp, chan);
   		    channelname = Tcl_GetChannelName(chan);
  -		    result = Tcl_NewStringObj(channelname, -1);
  +		    Tcl_SetStringObj(result, channelname, -1);
   		}
   	    } else if (!strcmp(method, "save")) {
   		/* save data to a specified filename  */
  @@ -702,7 +703,7 @@
   			break;
   		}
   		Tcl_Close(interp, savechan);
  -		result = Tcl_NewIntObj(1);
  +		Tcl_SetIntObj(result, 1);
   	    } else if (!strcmp(method, "data")) {
   		/* this sucks - we should use the hook, but I want to
                      get everything fixed and working first */
  @@ -717,17 +718,15 @@
   		    Tcl_SetChannelOption(interp, chan, "-translation", "binary");
   		    Tcl_SetChannelOption(interp, chan, "-encoding", "binary");
   		    /* put data in a variable  */
  -		    result = Tcl_NewObj();
   		    Tcl_ReadChars(chan, result, ApacheUpload_size(upload), 0);
   		} else {
   		    Tcl_AppendResult(interp, "Dtcl_UploadFilesToVar is not set", NULL);
   		    return TCL_ERROR;
   		}
   	    }
  -	    Tcl_SetObjResult(interp, result);
   	} else {
   	    /* no variable found  */
  -	    Tcl_SetObjResult(interp, Tcl_NewStringObj("", -1));
  +	    Tcl_SetStringObj(result, "", -1);
   	}
       } else if (!strcmp(command, "info")) {
   	char *varname = NULL;
  @@ -745,32 +744,43 @@
   	{
   	    if (!strcmp(infotype, "exists"))
   	    {
  -		result = Tcl_NewIntObj(1);
  +		Tcl_SetIntObj(result, 1);
   	    } else if (!strcmp(infotype, "size")) {
  -		result = Tcl_NewIntObj(ApacheUpload_size(upload));
  +		Tcl_SetIntObj(result, ApacheUpload_size(upload));
   	    } else if (!strcmp(infotype, "type")) {
   		char *type = NULL;
   		type = (char *)ApacheUpload_type(upload);
   		if (type)
  -		    result = Tcl_NewStringObj(type, -1);
  +		    Tcl_SetStringObj(result, type, -1);
   		else
  -		    result = Tcl_NewStringObj("", -1);
  +		    Tcl_SetStringObj(result, "", -1);
   	    } else if (!strcmp(infotype, "filename")) {
  -		result = Tcl_NewStringObj(upload->filename, -1);
  +		Tcl_SetStringObj(result, StringToUtf(upload->filename), -1);
   	    } else {
  -		Tcl_AddErrorInfo(interp, "unknown upload info command");
  +		Tcl_AddErrorInfo(interp, "unknown upload info command, should be exists|size|type|filename");
   		return TCL_ERROR;
   	    }
   	} else {
   	    if (!strcmp(infotype, "exists")) {
  -		result = Tcl_NewIntObj(0);
  +		Tcl_SetIntObj(result, 0);
   	    } else {
   		Tcl_AddErrorInfo(interp, "variable doesn't exist");
   		return TCL_ERROR;
   	    }
  +	}
  +    } else if (!strcmp(command, "names")) {
  +	upload = ApacheRequest_upload(global_req);
  +	while (upload)
  +	{
  +	    Tcl_ListObjAppendElement(interp, result, 
  +				     STRING_TO_UTF_TO_OBJ(upload->name));
  +	    upload = upload->next;
   	}
  -	Tcl_SetObjResult(interp, result);
  +    } else {
  +	Tcl_WrongNumArgs(interp, 1, objv, "upload get|info|names");
  +	return TCL_ERROR;
       }
  +    Tcl_SetObjResult(interp, result);
       return TCL_OK;
   }
   
  
  
  
  1.2       +43 -3     tcl-moddtcl/docs/commands.html
  
  Index: commands.html
  ===================================================================
  RCS file: /home/cvs/tcl-moddtcl/docs/commands.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- commands.html	2001/06/15 17:19:45	1.1
  +++ commands.html	2001/06/23 15:30:57	1.2
  @@ -1,5 +1,5 @@
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  -    <!-- $Id: commands.html,v 1.1 2001/06/15 17:19:45 davidw Exp $ -->
  +    <!-- $Id: commands.html,v 1.2 2001/06/23 15:30:57 davidw Exp $ -->
   <html>
     <head>
       <title>mod_dtcl tcl commands</title>
  @@ -49,7 +49,47 @@
   	<code><b>var all</b></code><br>
   	Return a list of variable names and values.
         </li>
  +
  +      <li><code><b>upload</b></code><br> These commands retrieve or
  +	retrieve information about files that have been uploaded to
  +	the server.  They replace the <code>UPLOAD</code> variable.
  +      </li>
  +      <li>
  +	<code><b>upload get <i>varname</i> channel</b></code><br>
  +	Returns a Tcl channel that can be used to access the uploaded file.
  +      </li>
  +      <li>
  +	<code><b>upload get <i>varname</i> save <i>name</i></b></code><br>
  +	Moves the uploaded file to the give name.
  +      </li>
  +      <li>
  +	<code><b>upload get <i>varname</i> data</b></code><br>
  +	Returns data uploaded to the server.  This is binary clean.
  +      </li>
  +
  +      <li>
  +	<code><b>upload info <i>varname</i> exists</b></code><br>
  +	Returns 1 if the variable exists, 0 if not.
  +      </li>
         <li>
  +	<code><b>upload info <i>varname</i> size</b></code><br>
  +	Returns the size of the file uploaded.
  +      </li>
  +      <li>
  +	<code><b>upload info <i>varname</i> type</b></code><br>If the
  +	Content-type is set, it is returned, otherwise, an empty
  +	string.
  +      </li>
  +      <li>
  +	<code><b>upload info <i>varname</i> filename</b></code><br>
  +	Returns the filename on the remote host that uploaded the file.
  +      </li>
  +      <li>
  +	<code><b>upload names</b></code><br> Returns the variable
  +	names, as a list, of all the files uploaded.
  +      </li>
  +
  +      <li>
   	<code><b>hgetvars</b></code><br> Get environmental, and Cookie
   	variables. This is in a seperate command so as not to make the
   	server do this every time you load a .ttml file. <code>ENVS</code> and
  @@ -113,7 +153,7 @@
   	HTML.  Currently, only the PID and size of the object
   	cache are reported.
         </li>
  -
  +<!--
         <li>
   	Note that these variables may be lists if more than one file
   	is uploaded at a time.<br>
  @@ -140,7 +180,7 @@
   	Contents of the uploaded file, if Dtcl_UploadFilesToVar is
   	set.<br>
         </li>
  -
  +-->
       </ul>
     </body>
   </html>