~ubuntu-branches/ubuntu/trusty/libssh/trusty-security

« back to all changes in this revision

Viewing changes to include/libssh/buffer.h

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2009-12-12 14:29:12 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20091212142912-ha5g2iibt6nfnjq8
Tags: 0.4.0-1
* New upstream release.
  - Bump soname
  - Adjust .symbols file
* Readd static library in -dev package
* Let dh_lintian install override file
* debian/README.Debian: Update file
* debian/rules: Add list-missing rule

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the SSH Library
 
3
 *
 
4
 * Copyright (c) 2009 by Aris Adamantiadis
 
5
 *
 
6
 * The SSH Library is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU Lesser General Public License as published by
 
8
 * the Free Software Foundation; either version 2.1 of the License, or (at your
 
9
 * option) any later version.
 
10
 *
 
11
 * The SSH Library is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
13
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 
14
 * License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public License
 
17
 * along with the SSH Library; see the file COPYING.  If not, write to
 
18
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 
19
 * MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#ifndef BUFFER_H_
 
23
#define BUFFER_H_
 
24
 
 
25
/** Describes a buffer state at a moment
 
26
 */
 
27
struct ssh_buffer_struct {
 
28
    char *data;
 
29
    uint32_t used;
 
30
    uint32_t allocated;
 
31
    uint32_t pos;
 
32
};
 
33
 
 
34
int buffer_add_ssh_string(ssh_buffer buffer, ssh_string string);
 
35
int buffer_add_u8(ssh_buffer buffer, uint8_t data);
 
36
int buffer_add_u16(ssh_buffer buffer, uint16_t data);
 
37
int buffer_add_u32(ssh_buffer buffer, uint32_t data);
 
38
int buffer_add_u64(ssh_buffer buffer, uint64_t data);
 
39
int buffer_add_data(ssh_buffer buffer, const void *data, uint32_t len);
 
40
int buffer_prepend_data(ssh_buffer buffer, const void *data, uint32_t len);
 
41
int buffer_add_buffer(ssh_buffer buffer, ssh_buffer source);
 
42
int buffer_reinit(ssh_buffer buffer);
 
43
 
 
44
/* buffer_get_rest returns a pointer to the current position into the buffer */
 
45
void *buffer_get_rest(ssh_buffer buffer);
 
46
/* buffer_get_rest_len returns the number of bytes which can be read */
 
47
uint32_t buffer_get_rest_len(ssh_buffer buffer);
 
48
 
 
49
/* buffer_read_*() returns the number of bytes read, except for ssh strings */
 
50
int buffer_get_u8(ssh_buffer buffer, uint8_t *data);
 
51
int buffer_get_u32(ssh_buffer buffer, uint32_t *data);
 
52
int buffer_get_u64(ssh_buffer buffer, uint64_t *data);
 
53
 
 
54
uint32_t buffer_get_data(ssh_buffer buffer, void *data, uint32_t requestedlen);
 
55
/* buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */
 
56
ssh_string buffer_get_ssh_string(ssh_buffer buffer);
 
57
/* gets a string out of a SSH-1 mpint */
 
58
ssh_string buffer_get_mpint(ssh_buffer buffer);
 
59
/* buffer_pass_bytes acts as if len bytes have been read (used for padding) */
 
60
uint32_t buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
 
61
uint32_t buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
 
62
 
 
63
#endif /* BUFFER_H_ */