File: netstring.h

package info (click to toggle)
baresip 1.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 3,920 kB
  • sloc: ansic: 48,247; cpp: 2,273; objc: 961; makefile: 294; python: 259; sh: 31
file content (35 lines) | stat: -rw-r--r-- 858 bytes parent folder | download | duplicates (3)
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
/**
 * @file netstring.h  Streaming API for netstrings.
 *
 * This file is public domain,
 * adapted from https://github.com/PeterScott/netstring-c/"
 */

#ifndef __NETSTRING_STREAM_H
#define __NETSTRING_STREAM_H

#include <string.h>

const char* netstring_error_str(int err);

int netstring_read(char *buffer, size_t buffer_length,
		   char **netstring_start, size_t *netstring_length);

size_t netstring_num_len(size_t num);
size_t netstring_buffer_size(size_t data_length);

size_t netstring_encode_new(char **netstring, char *data, size_t len);

#define NETSTRING_MAX_SIZE 999999999

/* Errors that can occur during netstring parsing */
typedef enum {
	NETSTRING_ERROR_TOO_LONG = -100,
	NETSTRING_ERROR_NO_COLON,
	NETSTRING_ERROR_TOO_SHORT,
	NETSTRING_ERROR_NO_COMMA,
	NETSTRING_ERROR_LEADING_ZERO,
	NETSTRING_ERROR_NO_LENGTH
} netstring_error;

#endif