Ziti C SDK
Loading...
Searching...
No Matches
ziti_buffer.h
Go to the documentation of this file.
1/*
2Copyright (c) 2021 NetFoundry Inc.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8https://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef ZITI_SDK_ZITI_BUFFER_H
18#define ZITI_SDK_ZITI_BUFFER_H
19
20#include <stdint.h>
21#include "externs.h"
22#include "ziti_log.h"
23
24#if !defined(__DEFINED_ssize_t) && !defined(__ssize_t_defined)
25#if _WIN32
26typedef intptr_t ssize_t;
27#define __DEFINED_ssize_t
28#define __ssize_t_defined
29#else
30#include <unistd.h>
31#endif
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
43typedef struct string_buf_s string_buf_t;
44
50
57ZITI_FUNC string_buf_t *new_fixed_string_buf(char *outbuf, size_t max);
58
66
73ZITI_FUNC int string_buf_append(string_buf_t *wb, const char *str);
74
79
87ZITI_FUNC int string_buf_appendn(string_buf_t *wb, const char *str, size_t len);
88
96
105
112
121ZITI_FUNC char *string_buf_to_string(string_buf_t *wb, size_t *outlen);
122
123
124#ifdef __cplusplus
125}
126#endif
127#endif //ZITI_SDK_ZITI_BUFFER_H
#define ZITI_FUNC
Definition externs.h:38
int string_buf_fmt(string_buf_t *wb, const char *fmt,...)
printf style append operation.
int string_buf_appendn(string_buf_t *wb, const char *str, size_t len)
Append len bytes from str to the string buffer.
string_buf_t * new_fixed_string_buf(char *outbuf, size_t max)
Create buffer using passed in memory for output.
string_buf_t * new_string_buf()
Create new string buffer.
int string_buf_append_byte(string_buf_t *wb, char c)
Append one byte to the string buffer.
int string_buf_append_urlsafe(string_buf_t *wb, const char *str)
Appends [str] to [wb] converting to urlsafe encoding.
void delete_string_buf(string_buf_t *wb)
Deallocate all memory associated with the given string buffer.
char * string_buf_to_string(string_buf_t *wb, size_t *outlen)
Allocate string big enough to hold the contents of the buffer with '\0at the end and copy contents in...
size_t string_buf_size(string_buf_t *wb)
number of bytes written to the string buffer so far
struct string_buf_s string_buf_t
Growing string buffer.
Definition ziti_buffer.h:43
int string_buf_append(string_buf_t *wb, const char *str)
Append \0 terminated string to the buffer.
#define FORMAT_STRING(p)
Definition ziti_log.h:76
#define ziti_printf_args(a, b)
Definition ziti_log.h:82