]> git.proxmox.com Git - rustc.git/blob - src/vendor/libssh2-sys/libssh2/src/misc.h
New upstream version 1.19.0+dfsg1
[rustc.git] / src / vendor / libssh2-sys / libssh2 / src / misc.h
1 #ifndef __LIBSSH2_MISC_H
2 #define __LIBSSH2_MISC_H
3 /* Copyright (c) 2009-2014 by Daniel Stenberg
4 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms,
8 * with or without modification, are permitted provided
9 * that the following conditions are met:
10 *
11 * Redistributions of source code must retain the above
12 * copyright notice, this list of conditions and the
13 * following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials
18 * provided with the distribution.
19 *
20 * Neither the name of the copyright holder nor the names
21 * of any other contributors may be used to endorse or
22 * promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
26 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
27 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
35 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
38 * OF SUCH DAMAGE.
39 */
40
41 struct list_head {
42 struct list_node *last;
43 struct list_node *first;
44 };
45
46 struct list_node {
47 struct list_node *next;
48 struct list_node *prev;
49 struct list_head *head;
50 };
51
52 int _libssh2_error_flags(LIBSSH2_SESSION* session, int errcode, const char* errmsg, int errflags);
53 int _libssh2_error(LIBSSH2_SESSION* session, int errcode, const char* errmsg);
54
55 void _libssh2_list_init(struct list_head *head);
56
57 /* add a node last in the list */
58 void _libssh2_list_add(struct list_head *head,
59 struct list_node *entry);
60
61 /* return the "first" node in the list this head points to */
62 void *_libssh2_list_first(struct list_head *head);
63
64 /* return the next node in the list */
65 void *_libssh2_list_next(struct list_node *node);
66
67 /* return the prev node in the list */
68 void *_libssh2_list_prev(struct list_node *node);
69
70 /* remove this node from the list */
71 void _libssh2_list_remove(struct list_node *entry);
72
73 size_t _libssh2_base64_encode(struct _LIBSSH2_SESSION *session,
74 const char *inp, size_t insize, char **outptr);
75
76 unsigned int _libssh2_ntohu32(const unsigned char *buf);
77 libssh2_uint64_t _libssh2_ntohu64(const unsigned char *buf);
78 void _libssh2_htonu32(unsigned char *buf, uint32_t val);
79 void _libssh2_store_u32(unsigned char **buf, uint32_t value);
80 void _libssh2_store_str(unsigned char **buf, const char *str, size_t len);
81 void *_libssh2_calloc(LIBSSH2_SESSION* session, size_t size);
82
83 #if defined(LIBSSH2_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
84 /* provide a private one */
85 #undef HAVE_GETTIMEOFDAY
86 int __cdecl _libssh2_gettimeofday(struct timeval *tp, void *tzp);
87 #define HAVE_LIBSSH2_GETTIMEOFDAY
88 #define LIBSSH2_GETTIMEOFDAY_WIN32 /* enable the win32 implementation */
89 #else
90 #ifdef HAVE_GETTIMEOFDAY
91 #define _libssh2_gettimeofday(x,y) gettimeofday(x,y)
92 #define HAVE_LIBSSH2_GETTIMEOFDAY
93 #endif
94 #endif
95
96 #endif /* _LIBSSH2_MISC_H */