aboutsummaryrefslogtreecommitdiff
path: root/libssh/buffer.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2008-11-04 21:59:12 +0000
committerAris Adamantiadis <aris@0xbadc0de.be>2008-11-04 21:59:12 +0000
commit64e73b8d8ab216c5dd8812c8cdad39b7f1bfc4d2 (patch)
tree2c5f71d247607d17b55df210adc6b75d833b3572 /libssh/buffer.c
parent90bb81f7b0a729f0508c02586b3d609950d24f2c (diff)
downloadlibssh-64e73b8d8ab216c5dd8812c8cdad39b7f1bfc4d2.tar.gz
libssh-64e73b8d8ab216c5dd8812c8cdad39b7f1bfc4d2.tar.xz
libssh-64e73b8d8ab216c5dd8812c8cdad39b7f1bfc4d2.zip
doxygen fixes. Mostly typos and some comments.
sftp must be fully documented ! git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@187 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/buffer.c')
-rw-r--r--libssh/buffer.c71
1 files changed, 63 insertions, 8 deletions
diff --git a/libssh/buffer.c b/libssh/buffer.c
index d51a826..60eceef 100644
--- a/libssh/buffer.c
+++ b/libssh/buffer.c
@@ -39,7 +39,7 @@ BUFFER *buffer_new(){
return buffer;
}
-/** \brief desallocate a buffer
+/** \brief deallocate a buffer
* \param buffer buffer to free
*/
void buffer_free(BUFFER *buffer){
@@ -90,19 +90,36 @@ void buffer_add_data(BUFFER *buffer,const void *data,int len){
buffer->used+=len;
}
+/** \internal
+ * \brief add a SSH string to the tail of buffer
+ * \param buffer buffer
+ * \param string SSH String to add
+ */
void buffer_add_ssh_string(BUFFER *buffer,STRING *string){
u32 len=ntohl(string->size);
buffer_add_data(buffer,string,len+sizeof(u32));
}
-
+/** \internal
+ * \brief add a 32 bits unsigned integer to the tail of buffer
+ * \param buffer buffer
+ * \param data 32 bits integer
+ */
void buffer_add_u32(BUFFER *buffer,u32 data){
buffer_add_data(buffer,&data,sizeof(data));
}
-
+/** \internal
+ * \brief add a 64 bits unsigned integer to the tail of buffer
+ * \param buffer buffer
+ * \param data 64 bits integer
+ */
void buffer_add_u64(BUFFER *buffer,u64 data){
buffer_add_data(buffer,&data,sizeof(data));
}
-
+/** \internal
+ * \brief add a 8 bits unsigned integer to the tail of buffer
+ * \param buffer buffer
+ * \param data 8 bits integer
+ */
void buffer_add_u8(BUFFER *buffer,u8 data){
buffer_add_data(buffer,&data,sizeof(u8));
}
@@ -203,6 +220,14 @@ int buffer_pass_bytes_end(BUFFER *buffer,int len){
return len;
}
+/** \internal
+ * \brief gets remaining data out of the buffer. Adjust the read pointer.
+ * \param buffer Buffer to read
+ * \param data data buffer where to store the data
+ * \param len length to read from the buffer
+ * \returns 0 if there is not enough data in buffer
+ * \returns len otherwise.
+ */
int buffer_get_data(BUFFER *buffer, void *data, int len){
if(buffer->pos+len>buffer->used)
return 0; /*no enough data in buffer */
@@ -210,19 +235,43 @@ int buffer_get_data(BUFFER *buffer, void *data, int len){
buffer->pos+=len;
return len; /* no yet support for partial reads (is it really needed ?? ) */
}
-
+/** \internal
+ * \brief gets a 8 bits unsigned int out of the buffer. Adjusts the read pointer.
+ * \param buffer Buffer to read
+ * \param data pointer to a u8 where to store the data
+ * \returns 0 if there is not enough data in buffer
+ * \returns 1 otherwise.
+ */
int buffer_get_u8(BUFFER *buffer, u8 *data){
return buffer_get_data(buffer,data,sizeof(u8));
}
+/** \internal
+ * \brief gets a 32 bits unsigned int out of the buffer. Adjusts the read pointer.
+ * \param buffer Buffer to read
+ * \param data pointer to a u32 where to store the data
+ * \returns 0 if there is not enough data in buffer
+ * \returns 4 otherwise.
+ */
int buffer_get_u32(BUFFER *buffer, u32 *data){
return buffer_get_data(buffer,data,sizeof(u32));
}
-
+/** \internal
+ * \brief gets a 64 bits unsigned int out of the buffer. Adjusts the read pointer.
+ * \param buffer Buffer to read
+ * \param data pointer to a u64 where to store the data
+ * \returns 0 if there is not enough data in buffer
+ * \returns 8 otherwise.
+ */
int buffer_get_u64(BUFFER *buffer, u64 *data){
return buffer_get_data(buffer,data,sizeof(u64));
}
-
+/** \internal
+ * \brief gets a SSH String out of the buffer. Adjusts the read pointer.
+ * \param buffer Buffer to read
+ * \returns The SSH String read
+ * \returns NULL otherwise.
+ */
STRING *buffer_get_ssh_string(BUFFER *buffer){
u32 stringlen;
u32 hostlen;
@@ -241,8 +290,14 @@ STRING *buffer_get_ssh_string(BUFFER *buffer){
}
return str;
}
+/** \internal
+ * \brief gets a mpint out of the buffer. Adjusts the read pointer.
+ * SSH-1 only
+ * \param buffer Buffer to read
+ * \returns the SSH String containing the mpint
+ * \returns NULL otherwise
+ */
-/* this one is SSH-1 only */
STRING *buffer_get_mpint(BUFFER *buffer){
u16 bits;
u32 len;