2017-02-26 18:37:46 +01:00
|
|
|
/* A dynamic memory buffer that expands as you write.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This file is part of VIPS.
|
|
|
|
|
|
|
|
VIPS is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
02110-1301 USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VIPS_DBUF_H
|
|
|
|
#define VIPS_DBUF_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /*__cplusplus*/
|
|
|
|
|
|
|
|
#include <vips/vips.h>
|
|
|
|
|
2017-02-28 17:44:12 +01:00
|
|
|
/* A buffer in the process of being written to.
|
2017-02-26 18:37:46 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _VipsDbuf {
|
|
|
|
/* All fields are private.
|
|
|
|
*/
|
|
|
|
/*< private >*/
|
|
|
|
|
|
|
|
/* The current base, and the size of the allocated memory area.
|
|
|
|
*/
|
2017-02-27 23:06:22 +01:00
|
|
|
unsigned char *data;
|
2017-02-28 14:40:34 +01:00
|
|
|
size_t allocated_size;
|
2017-02-26 18:37:46 +01:00
|
|
|
|
2017-02-28 14:40:34 +01:00
|
|
|
/* The size of the actual data that's been written. This will usually
|
|
|
|
* be <= allocated_size, but always >= write_point.
|
|
|
|
*/
|
|
|
|
size_t data_size;
|
|
|
|
|
|
|
|
/* The write point.
|
2017-02-26 18:37:46 +01:00
|
|
|
*/
|
|
|
|
size_t write_point;
|
2017-02-28 14:40:34 +01:00
|
|
|
|
2017-02-26 18:37:46 +01:00
|
|
|
} VipsDbuf;
|
|
|
|
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-12-04 14:42:31 +01:00
|
|
|
void vips_dbuf_destroy( VipsDbuf *dbuf );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-12-04 14:42:31 +01:00
|
|
|
void vips_dbuf_init( VipsDbuf *dbuf );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2022-02-27 14:42:17 +01:00
|
|
|
gboolean vips_dbuf_minimum_size( VipsDbuf *dbuf, size_t size );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-27 23:06:22 +01:00
|
|
|
gboolean vips_dbuf_allocate( VipsDbuf *dbuf, size_t size );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-08-27 12:03:34 +02:00
|
|
|
size_t vips_dbuf_read( VipsDbuf *dbuf, unsigned char *data, size_t size );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-27 23:06:22 +01:00
|
|
|
unsigned char *vips_dbuf_get_write( VipsDbuf *dbuf, size_t *size );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-28 17:44:12 +01:00
|
|
|
gboolean vips_dbuf_write( VipsDbuf *dbuf,
|
2017-02-27 23:06:22 +01:00
|
|
|
const unsigned char *data, size_t size );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2019-10-29 18:43:51 +01:00
|
|
|
gboolean vips_dbuf_writef( VipsDbuf *dbuf, const char *fmt, ... )
|
2022-09-23 15:37:35 +02:00
|
|
|
G_GNUC_PRINTF( 2, 3 );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2018-01-26 18:20:58 +01:00
|
|
|
gboolean vips_dbuf_write_amp( VipsDbuf *dbuf, const char *str );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-28 14:40:34 +01:00
|
|
|
void vips_dbuf_reset( VipsDbuf *dbuf );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-26 18:37:46 +01:00
|
|
|
void vips_dbuf_destroy( VipsDbuf *dbuf );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-28 14:40:34 +01:00
|
|
|
gboolean vips_dbuf_seek( VipsDbuf *dbuf, off_t offset, int whence );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-28 14:40:34 +01:00
|
|
|
void vips_dbuf_truncate( VipsDbuf *dbuf );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-28 17:44:12 +01:00
|
|
|
off_t vips_dbuf_tell( VipsDbuf *dbuf );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-27 23:06:22 +01:00
|
|
|
unsigned char *vips_dbuf_string( VipsDbuf *dbuf, size_t *size );
|
2022-04-16 11:58:55 +02:00
|
|
|
VIPS_API
|
2017-02-27 23:06:22 +01:00
|
|
|
unsigned char *vips_dbuf_steal( VipsDbuf *dbuf, size_t *size );
|
2017-02-26 18:37:46 +01:00
|
|
|
|
|
|
|
#endif /*VIPS_DBUF_H*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /*__cplusplus*/
|