File: buf.h

package info (click to toggle)
tinyssh 20250501-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,388 kB
  • sloc: ansic: 20,245; sh: 1,582; python: 1,449; makefile: 913
file content (69 lines) | stat: -rw-r--r-- 3,156 bytes parent folder | download | duplicates (2)
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
/*
20140108
20241208 - reformated using clang-format
Jan Mojzis
Public domain.
*/

#ifndef BUF_H____
#define BUF_H____

#include "crypto_uint8.h"
#include "crypto_uint32.h"

struct buf {
    unsigned char *buf;
    long long len;
    long long alloc;
};

extern void buf_init_(const char *, unsigned long long, struct buf *,
                      unsigned char *, long long);
extern void buf_purge_(const char *, unsigned long long, struct buf *);
extern int buf_ready_(const char *, unsigned long long, struct buf *,
                      long long);

extern int buf_put_(const char *, unsigned long long, struct buf *,
                    const unsigned char *, long long);
extern int buf_puts_(const char *, unsigned long long, struct buf *,
                     const char *);
extern int buf_putzerobytes_(const char *, unsigned long long, struct buf *,
                             long long);
extern int buf_putrandombytes_(const char *, unsigned long long, struct buf *,
                               long long);
extern int buf_putpadding_(const char *, unsigned long long, struct buf *,
                           long long);
extern int buf_putnum32_(const char *, unsigned long long, struct buf *,
                         crypto_uint32);
extern int buf_putnum8_(const char *, unsigned long long, struct buf *,
                        crypto_uint8);
extern int buf_putstringlen_(const char *, unsigned long long, struct buf *,
                             const unsigned char *, long long);
extern int buf_putstring_(const char *, unsigned long long, struct buf *,
                          const char *);
extern int buf_putsharedsecret_(const char *, unsigned long long, struct buf *,
                                const unsigned char *, long long);
extern int buf_putbase64_(const char *, unsigned long long, struct buf *,
                          const unsigned char *, long long);

#define buf_init(a, b, cc) buf_init_(__FILE__, __LINE__, (a), (b), (cc))
#define buf_purge(a) buf_purge_(__FILE__, __LINE__, (a))
#define buf_ready(a, b) buf_ready_(__FILE__, __LINE__, (a), (b))

#define buf_put(a, b, cc) buf_put_(__FILE__, __LINE__, (a), (b), (cc))
#define buf_puts(a, b) buf_puts_(__FILE__, __LINE__, (a), (b))
#define buf_putzerobytes(a, b) buf_putzerobytes_(__FILE__, __LINE__, (a), (b))
#define buf_putrandombytes(a, b)                                               \
    buf_putrandombytes_(__FILE__, __LINE__, (a), (b))
#define buf_putpadding(a, b) buf_putpadding_(__FILE__, __LINE__, (a), (b))
#define buf_putnum32(a, b) buf_putnum32_(__FILE__, __LINE__, (a), (b))
#define buf_putnum8(a, b) buf_putnum8_(__FILE__, __LINE__, (a), (b))
#define buf_putstringlen(a, b, cc)                                             \
    buf_putstringlen_(__FILE__, __LINE__, (a), (b), (cc))
#define buf_putstring(a, b) buf_putstring_(__FILE__, __LINE__, (a), (b))
#define buf_putsharedsecret(a, b, cc)                                          \
    buf_putsharedsecret_(__FILE__, __LINE__, (a), (b), (cc))
#define buf_putbase64(a, b, cc)                                                \
    buf_putbase64_(__FILE__, __LINE__, (a), (b), (cc))

#endif