summaryrefslogtreecommitdiffstats
path: root/3rd_party/libsrp6a-sha512/cstr.h
diff options
context:
space:
mode:
Diffstat (limited to '3rd_party/libsrp6a-sha512/cstr.h')
-rw-r--r--3rd_party/libsrp6a-sha512/cstr.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/3rd_party/libsrp6a-sha512/cstr.h b/3rd_party/libsrp6a-sha512/cstr.h
new file mode 100644
index 0000000..7cc019a
--- /dev/null
+++ b/3rd_party/libsrp6a-sha512/cstr.h
@@ -0,0 +1,94 @@
1#ifndef _CSTR_H_
2#define _CSTR_H_
3
4/* A general-purpose string "class" for C */
5
6#if !defined(P)
7#ifdef __STDC__
8#define P(x) x
9#else
10#define P(x) ()
11#endif
12#endif
13
14/* For building dynamic link libraries under windows, windows NT
15 * using MSVC1.5 or MSVC2.0
16 */
17
18#ifndef _DLLDECL
19#define _DLLDECL
20
21#ifdef MSVC15 /* MSVC1.5 support for 16 bit apps */
22#define _MSVC15EXPORT _export
23#define _MSVC20EXPORT
24#define _DLLAPI _export _pascal
25#define _CDECL
26#define _TYPE(a) a _MSVC15EXPORT
27#define DLLEXPORT 1
28
29#elif defined(MSVC20) || (defined(_USRDLL) && defined(SRP_EXPORTS))
30#define _MSVC15EXPORT
31#define _MSVC20EXPORT _declspec(dllexport)
32#define _DLLAPI
33#define _CDECL
34#define _TYPE(a) _MSVC20EXPORT a
35#define DLLEXPORT 1
36
37#else /* Default, non-dll. Use this for Unix or DOS */
38#define _MSVC15DEXPORT
39#define _MSVC20EXPORT
40#define _DLLAPI
41#if defined(WINDOWS) || defined(WIN32)
42#define _CDECL _cdecl
43#else
44#define _CDECL
45#endif
46#define _TYPE(a) a _CDECL
47#endif
48#endif /* _DLLDECL */
49
50#ifdef __cplusplus
51extern "C" {
52#endif /* __cplusplus */
53
54/* Arguments to allocator methods ordered this way for compatibility */
55typedef struct cstr_alloc_st {
56 void * (_CDECL * alloc)(size_t n, void * heap);
57 void (_CDECL * free)(void * p, void * heap);
58 void * heap;
59} cstr_allocator;
60
61typedef struct cstr_st {
62 char * data; /* Okay to access data and length fields directly */
63 int length;
64 int cap;
65 int ref; /* Simple reference counter */
66 cstr_allocator * allocator;
67} cstr;
68
69_TYPE( void ) cstr_set_allocator P((cstr_allocator * alloc));
70
71_TYPE( cstr * ) cstr_new P((void));
72_TYPE( cstr * ) cstr_new_alloc P((cstr_allocator * alloc));
73_TYPE( cstr * ) cstr_dup P((const cstr * str));
74_TYPE( cstr * ) cstr_dup_alloc P((const cstr * str, cstr_allocator * alloc));
75_TYPE( cstr * ) cstr_create P((const char * s));
76_TYPE( cstr * ) cstr_createn P((const char * s, int len));
77
78_TYPE( void ) cstr_free P((cstr * str));
79_TYPE( void ) cstr_clear_free P((cstr * str));
80_TYPE( void ) cstr_use P((cstr * str));
81_TYPE( void ) cstr_empty P((cstr * str));
82_TYPE( int ) cstr_copy P((cstr * dst, const cstr * src));
83_TYPE( int ) cstr_set P((cstr * str, const char * s));
84_TYPE( int ) cstr_setn P((cstr * str, const char * s, int len));
85_TYPE( int ) cstr_set_length P((cstr * str, int len));
86_TYPE( int ) cstr_append P((cstr * str, const char * s));
87_TYPE( int ) cstr_appendn P((cstr * str, const char * s, int len));
88_TYPE( int ) cstr_append_str P((cstr * dst, const cstr * src));
89
90#ifdef __cplusplus
91}
92#endif /* __cplusplus */
93
94#endif /* _CSTR_H_ */