From 1b733d1196a7cf67d17461d9808d77ec59383114 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Fri, 2 Feb 2007 16:09:12 +0000
Subject: [PATCH] more docs, including a template.3 for new man pages

---
 docs/libssh2_channel_read_ex.3   |  5 ++--
 docs/libssh2_channel_readnb_ex.3 | 37 +++++++++++++++++++++++++
 docs/libssh2_sftp_init.3         | 20 ++++++++++++++
 docs/libssh2_sftp_open_ex.3      | 47 ++++++++++++++++++++++++++++++++
 docs/template.3                  | 15 ++++++++++
 5 files changed, 122 insertions(+), 2 deletions(-)
 create mode 100644 docs/libssh2_channel_readnb_ex.3
 create mode 100644 docs/libssh2_sftp_init.3
 create mode 100644 docs/libssh2_sftp_open_ex.3
 create mode 100644 docs/template.3

diff --git a/docs/libssh2_channel_read_ex.3 b/docs/libssh2_channel_read_ex.3
index 57f732f..c0ff7b0 100644
--- a/docs/libssh2_channel_read_ex.3
+++ b/docs/libssh2_channel_read_ex.3
@@ -1,4 +1,4 @@
-.\" $Id: libssh2_channel_read_ex.3,v 1.2 2007/01/02 05:47:00 gusarov Exp $
+.\" $Id: libssh2_channel_read_ex.3,v 1.3 2007/02/02 16:09:12 bagder Exp $
 .\"
 .TH libssh2_channel_read_ex 3 "14 Dec 2006" "libssh2 0.15" "libssh2 manual"
 .SH NAME
@@ -31,6 +31,7 @@ currently defines a stream ID of 1 to be the stderr substream.
 \fIlibssh2_channel_read(3)\fP and \fIlibssh2_channel_read_stderr(3)\fP are
 macros.
 .SH RETURN VALUE
-Actual number of bytes read or \-1 on failure.
+Actual number of bytes read or negative on failure. Since version 0.15 it
+returns LIBSSH2CHANNEL_EAGAIN when it would otherwise block.
 .SH "SEE ALSO"
 
diff --git a/docs/libssh2_channel_readnb_ex.3 b/docs/libssh2_channel_readnb_ex.3
new file mode 100644
index 0000000..f06ea28
--- /dev/null
+++ b/docs/libssh2_channel_readnb_ex.3
@@ -0,0 +1,37 @@
+.\" $Id: libssh2_channel_readnb_ex.3,v 1.1 2007/02/02 16:09:12 bagder Exp $
+.\"
+.TH libssh2_channel_read_ex 3 "14 Dec 2006" "libssh2 0.15" "libssh2 manual"
+.SH NAME
+libssh2_channel_read_ex - read data from a channel stream
+.SH SYNOPSIS
+#include <libssh2.h>
+
+int libssh2_channel_readnb_ex(LIBSSH2_CHANNEL *channel, int stream_id,
+                            char *buf, size_t buflen);
+
+int libssh2_channel_readnb(LIBSSH2_CHANNEL *channel, char *buf,
+                         size_t buflen);
+
+int libssh2_channel_readnb_stderr(LIBSSH2_CHANNEL *channel, char *buf,
+                                size_t buflen);
+.SH DESCRIPTION
+Attempt to read data from an active channel stream. All channel streams have
+one standard I/O substream (stream_id == 0), and may have up to 2^32 extended
+data streams as identified by the selected \fIstream_id\fP. The SSH2 protocol
+currently defines a stream ID of 1 to be the stderr substream.
+
+\fIchannel\fP - active channel stream to read from. 
+
+\fIstream_id\fP - substream ID number (e.g. 0 or SSH_EXTENDED_DATA_STDERR) 
+
+\fIbuf\fP - pointer to storage buffer to read data into
+
+\fIbuflen\fP - size of the buf storage
+
+\fIlibssh2_channel_read(3)\fP and \fIlibssh2_channel_read_stderr(3)\fP are
+macros.
+.SH RETURN VALUE
+Actual number of bytes read or negative on failure. It returns
+LIBSSH2CHANNEL_EAGAIN when it would otherwise block. While
+LIBSSH2CHANNEL_EAGAIN is a negative number, it isn't really a failure per se.
+.SH "SEE ALSO"
diff --git a/docs/libssh2_sftp_init.3 b/docs/libssh2_sftp_init.3
new file mode 100644
index 0000000..db0f572
--- /dev/null
+++ b/docs/libssh2_sftp_init.3
@@ -0,0 +1,20 @@
+.\" $Id: libssh2_sftp_init.3,v 1.1 2007/02/02 16:09:12 bagder Exp $
+.\"
+.TH libssh2_sftp_init 3 "23 Jan 2007" "libssh2 0.15" "libssh2 manual"
+.SH NAME
+libssh2_sftp_init - 
+.SH SYNOPSIS
+#include <libssh2.h>
+
+LIBSSH2_SFTP *libssh2_sftp_init(LIBSSH2_SESSION *session);
+.SH DESCRIPTION
+Open a channel and initialize the SFTP subsystem. Although the SFTP subsystem
+operates over the same type of channel as those exported by the Channel API,
+the protocol itself implements its own unique binary packet protocol which
+must be managed with the libssh2_sftp_*() family of functions. When an SFTP
+session is complete, it must be destroyed using the
+\fIlibssh2_sftp_shutdown(3)\fP function.
+.SH RETURN VALUE
+A pointer to the newly allocated SFTP instance or NULL on failure.
+.SH "SEE ALSO"
+.BI libssh2_sftp_shutdown(3), libssh2_sftp_open_ex(3)
diff --git a/docs/libssh2_sftp_open_ex.3 b/docs/libssh2_sftp_open_ex.3
new file mode 100644
index 0000000..574dcd0
--- /dev/null
+++ b/docs/libssh2_sftp_open_ex.3
@@ -0,0 +1,47 @@
+.\" $Id: libssh2_sftp_open_ex.3,v 1.1 2007/02/02 16:09:12 bagder Exp $
+.\"
+.TH libssh2_sftp_open_ex 3 "23 Jan 2007" "libssh2 0.15" "libssh2 manual"
+.SH NAME
+libssh2_sftp_open - 
+.SH SYNOPSIS
+#include <libssh2.h>
+
+LIBSSH2_SFTP_HANDLE *libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp,
+                     char *filename, int filename_len,
+                     unsigned long flags, long mode, int open_type);
+
+LIBSSH2_SFTP_HANDLE *libssh2_sftp_open(LIBSSH2_SFTP *sftp,
+                     char *filename, unsigned long flags, long mode);
+
+LIBSSH2_SFTP_HANDLE *libssh2_sftp_opendir(LIBSSH2_SFTP *sftp,
+                     char *path);
+.SH DESCRIPTION
+    *  sftp
+
+          SFTP instance as returned by libssh2_sftp_init(). 
+
+    * filename
+
+          Remote file/directory resource to open 
+
+    * filename_len
+
+          Length of filename 
+
+    * flags
+
+          Any (reasonable) combination of the LIBSSH2_FXF_* constants corresponding fopen modes. 
+
+    * mode
+
+          POSIX file permissions to assign if the file is being newly created. 
+
+    * open_type
+
+          Either of LIBSSH2_SFTP_OPENFILE (to open a file) or LIBSSH2_SFTP_OPENDIR (to open a directory). 
+.SH RETURN VALUE
+A pointer to the newly created LIBSSH2_SFTP_HANDLE instance or NULL on
+failure.
+.SH "SEE ALSO"
+.BI libssh_sftp_close(3)
+
diff --git a/docs/template.3 b/docs/template.3
new file mode 100644
index 0000000..812460c
--- /dev/null
+++ b/docs/template.3
@@ -0,0 +1,15 @@
+.\" $Id: template.3,v 1.1 2007/02/02 16:09:12 bagder Exp $
+.\"
+.TH libssh2_template 3 "14 Dec 2006" "libssh2 0.15" "libssh2 manual"
+.SH NAME
+libssh2_template - short function description
+.SH SYNOPSIS
+#include <libssh2.h>
+
+void libssh2_template(void);
+.SH DESCRIPTION
+Long text describing the function and its input arguments.
+.SH RETURN VALUE
+Describe what the funtion returns.
+.SH "SEE ALSO"
+Add related functions