lib: make capn_{de,in}flate + capn_stream private
There is no point in having these functions be part of the public API.
This commit is contained in:
parent
33ae16bba8
commit
f2058f60c0
5 changed files with 65 additions and 34 deletions
|
|
@ -39,6 +39,7 @@ include_HEADERS += \
|
|||
lib/capnp_c.h
|
||||
|
||||
noinst_HEADERS += \
|
||||
lib/capnp_int.h \
|
||||
compiler/str.h \
|
||||
compiler/schema.capnp.h \
|
||||
compiler/c++.capnp.h \
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
#include "capnp_c.h"
|
||||
#include "capnp_priv.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
#include "capnp_c.h"
|
||||
#include "capnp_priv.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef min
|
||||
|
|
|
|||
|
|
@ -273,40 +273,6 @@ int capn_write_mem(struct capn *c, uint8_t *p, size_t sz, int packed);
|
|||
void capn_free(struct capn *c);
|
||||
void capn_reset_copy(struct capn *c);
|
||||
|
||||
/* capn_stream encapsulates the needed fields for capn_(deflate|inflate) in a
|
||||
* similar manner to z_stream from zlib
|
||||
*
|
||||
* The user should set next_in, avail_in, next_out, avail_out to the
|
||||
* available in/out buffers before calling capn_(deflate|inflate).
|
||||
*
|
||||
* Other fields should be zero initialized.
|
||||
*/
|
||||
struct capn_stream {
|
||||
const uint8_t *next_in;
|
||||
size_t avail_in;
|
||||
uint8_t *next_out;
|
||||
size_t avail_out;
|
||||
unsigned zeros, raw;
|
||||
|
||||
uint8_t inflate_buf[8];
|
||||
size_t avail_buf;
|
||||
};
|
||||
|
||||
#define CAPN_MISALIGNED -1
|
||||
#define CAPN_NEED_MORE -2
|
||||
|
||||
/* capn_deflate deflates a stream to the packed format
|
||||
* capn_inflate inflates a stream from the packed format
|
||||
*
|
||||
* Returns:
|
||||
* CAPN_MISALIGNED - if the unpacked data is not 8 byte aligned
|
||||
* CAPN_NEED_MORE - more packed data/room is required (out for inflate, in for
|
||||
* deflate)
|
||||
* 0 - success, all output for inflate, all input for deflate processed
|
||||
*/
|
||||
int capn_deflate(struct capn_stream*);
|
||||
int capn_inflate(struct capn_stream*);
|
||||
|
||||
/* Inline functions */
|
||||
|
||||
|
||||
|
|
|
|||
62
lib/capnp_priv.h
Normal file
62
lib/capnp_priv.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/* vim: set sw=8 ts=8 sts=8 noet: */
|
||||
/* capnp_c.h
|
||||
*
|
||||
* Copyright (C) 2013 James McKaskill
|
||||
* Copyright (C) 2014 Steve Dee
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* functions / structures in this header are private to the capnproto-c
|
||||
* library; applications should not call or use them.
|
||||
*/
|
||||
|
||||
#ifndef CAPNP_PRIV_H
|
||||
#define CAPNP_PRIV_H
|
||||
|
||||
#include "capnp_c.h"
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define intern __attribute__((visibility ("internal")))
|
||||
#else
|
||||
# define intern /**/
|
||||
#endif
|
||||
|
||||
/* capn_stream encapsulates the needed fields for capn_(deflate|inflate) in a
|
||||
* similar manner to z_stream from zlib
|
||||
*
|
||||
* The user should set next_in, avail_in, next_out, avail_out to the
|
||||
* available in/out buffers before calling capn_(deflate|inflate).
|
||||
*
|
||||
* Other fields should be zero initialized.
|
||||
*/
|
||||
struct capn_stream {
|
||||
const uint8_t *next_in;
|
||||
size_t avail_in;
|
||||
uint8_t *next_out;
|
||||
size_t avail_out;
|
||||
unsigned zeros, raw;
|
||||
|
||||
uint8_t inflate_buf[8];
|
||||
size_t avail_buf;
|
||||
};
|
||||
|
||||
#define CAPN_MISALIGNED -1
|
||||
#define CAPN_NEED_MORE -2
|
||||
|
||||
/* capn_deflate deflates a stream to the packed format
|
||||
* capn_inflate inflates a stream from the packed format
|
||||
*
|
||||
* Returns:
|
||||
* CAPN_MISALIGNED - if the unpacked data is not 8 byte aligned
|
||||
* CAPN_NEED_MORE - more packed data/room is required (out for inflate, in for
|
||||
* deflate)
|
||||
* 0 - success, all output for inflate, all input for deflate processed
|
||||
*/
|
||||
intern int capn_deflate(struct capn_stream*);
|
||||
intern int capn_inflate(struct capn_stream*);
|
||||
|
||||
|
||||
#endif /* CAPNP_PRIV_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue