1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
'\"
'\" The contents of this file are subject to the AOLserver Public License
'\" Version 1.1 (the "License"); you may not use this file except in
'\" compliance with the License. You may obtain a copy of the License at
'\" http://aolserver.com/.
'\"
'\" Software distributed under the License is distributed on an "AS IS"
'\" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
'\" the License for the specific language governing rights and limitations
'\" under the License.
'\"
'\" The Original Code is AOLserver Code and related documentation
'\" distributed by AOL.
'\"
'\" The Initial Developer of the Original Code is America Online,
'\" Inc. Portions created by AOL are Copyright (C) 1999 America Online,
'\" Inc. All Rights Reserved.
'\"
'\" Alternatively, the contents of this file may be used under the terms
'\" of the GNU General Public License (the "GPL"), in which case the
'\" provisions of GPL are applicable instead of those above. If you wish
'\" to allow use of your version of this file only under the terms of the
'\" GPL and not to allow others to use your version of this file under the
'\" License, indicate your decision by deleting the provisions above and
'\" replace them with the notice and other provisions required by the GPL.
'\" If you do not delete the provisions above, a recipient may use your
'\" version of this file under either the License or the GPL.
'\"
'\"
'\" $Header: /cvsroot/aolserver/aolserver/doc/Ns_ConnCopy.3,v 1.6 2006/04/19 17:37:30 jgdavidson Exp $
'\"
'\"
.so man.macros
.TH Ns_ConnCopy 3 4.0 AOLserver "AOLserver Library Procedures"
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
Ns_ConnCopyToChannel, Ns_ConnCopyToDString, Ns_ConnCopyToFd, Ns_ConnCopyToFile \- Copy request content to open file or dstring
.SH SYNOPSIS
.nf
\fB#include "ns.h"\fR
.sp
int
\fBNs_ConnCopyToChannel\fR(\fIconn, ncopy, chan\fR)
.sp
int
\fBNs_ConnCopyToDString\fR(\fIconn, ncopy, dsPtr\fR)
.sp
int
\fBNs_ConnCopyToFd\fR(\fIconn, ncopy, fd\fR)
.sp
int
\fBNs_ConnCopyToFile\fR(\fIconn, ncopy, fp\fR)
.SH ARGUMENTS
.AS Ns_Channel chan in
.AP Ns_Channel chan in
Pointer to Tcl channel open for write.
.AP Ns_Conn conn in
Pointer to open connection.
.AP Ns_DString dsPtr in
Initialized dstring.
.AP int fd in
File descriptor open for write.
.AP FILE fp in
Stdio FILE pointer open for write.
.AP int ncopy in
Number of bytes to copy.
.BE
.SH DESCRIPTION
.PP
These functions copy content from an open connection request to the
given open file descriptor, FILE, dstring, or Tcl_Channel. The
routines work by copying from the content buffer; see the man page
on \fBNs_ConnContent\fR for how this buffer is managed for both
small and large requests.
.PP
The functions all return the number of bytes copied which will match
the requested \fIncopy\fR argument unless there is an error writing
the content or the requested bytes is greater than the number of
bytes still available to be read. An internal offset into the
connection is maintained and is shared with routines such as
\fBNs_ConnRead\fR which also consume content from the same buffer.
Note that routines which access the entire content, e.g.,
\fBNs_ConnContent\fR, \fBNs_ConnContentFd\fR, or \fBNs_ConnGetQuery\fR
will continue to provide access to the entire request regardless
if one of the \fBNs_ConnCopy\fR or \fBNs_ConnRead\fR functions have
been used.
.SH EXAMPLES
The following example demonstrates copying user data to a
temp file:
.CS
fd = open("myfile.out", O_WRONLY|O_BINARY);
len = Ns_ConnContentLength(conn);
if (Ns_ConnCopyToFd(conn, len, fd) != len) {
... error writing content or content already consumed ...
}
.CE
.SH "SEE ALSO"
Ns_ConnRead(3), Ns_ConnReadLine(3), Ns_ConnContent(3), Ns_ConnContentFd(3)
.SH KEYWORDS
connection, content, read
|