Merge pull request #1596 from lovell/add-gio-to-dependencies

Increase minimum glib-2.0 dependency to v2.15 (released March 2012)
This commit is contained in:
John Cupitt 2020-03-26 20:35:30 +00:00 committed by GitHub
commit df72de89d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 10 additions and 401 deletions

View File

@ -450,41 +450,9 @@ AC_CHECK_LIB(m,cbrt,[AC_DEFINE(HAVE_CBRT,1,[have cbrt() in libm.])])
AC_CHECK_LIB(m,hypot,[AC_DEFINE(HAVE_HYPOT,1,[have hypot() in libm.])])
AC_CHECK_LIB(m,atan2,[AC_DEFINE(HAVE_ATAN2,1,[have atan2() in libm.])])
# have to have these parts of glib ... we need glib 2.6 for GOption
# gio is optional, see below
PKG_CHECK_MODULES(REQUIRED, glib-2.0 >= 2.6 gmodule-2.0 gobject-2.0)
PACKAGES_USED="$PACKAGES_USED glib-2.0 gmodule-2.0 gobject-2.0"
# from 2.12 we have g_base64_encode()
PKG_CHECK_MODULES(BASE64_ENCODE, glib-2.0 >= 2.12,
[AC_DEFINE(HAVE_BASE64_ENCODE,1,
[define if your glib has g_base64_encode().]
)
],
[:
]
)
# from 2.14 we have g_option_context_get_help()
PKG_CHECK_MODULES(CONTEXT_GET_HELP, glib-2.0 >= 2.14,
[AC_DEFINE(HAVE_CONTEXT_GET_HELP,1,
[define if your glib has g_option_context_get_help().]
)
],
[:
]
)
# from 2.15 we have GIO
PKG_CHECK_MODULES(GIO, glib-2.0 >= 2.15,
[AC_DEFINE(HAVE_GIO,1,
[define if your glib has GIO.]
)
PACKAGES_USED="$PACKAGES_USED gio-2.0"
],
[:
]
)
# have to have these parts of glib ... we need glib 2.15 for gio
PKG_CHECK_MODULES(REQUIRED, glib-2.0 >= 2.15 gmodule-2.0 gobject-2.0 gio-2.0)
PACKAGES_USED="$PACKAGES_USED glib-2.0 gmodule-2.0 gobject-2.0 gio-2.0"
# from 2.28 we have a monotonic timer
PKG_CHECK_MODULES(MONOTONIC_TIME, glib-2.0 >= 2.28,

View File

@ -2169,7 +2169,7 @@ vips_foreign_operation_init( void )
vips_foreign_save_rad_target_get_type();
#endif /*HAVE_RADIANCE*/
#if defined(HAVE_POPPLER) && defined(HAVE_GIO)
#if defined(HAVE_POPPLER)
vips_foreign_load_pdf_file_get_type();
vips_foreign_load_pdf_buffer_get_type();
vips_foreign_load_pdf_source_get_type();

View File

@ -68,7 +68,7 @@
/* TODO ... put minimise support back in.
*/
#if defined(HAVE_POPPLER) && defined(HAVE_GIO)
#if defined(HAVE_POPPLER)
#include <cairo.h>
#include <poppler.h>
@ -801,7 +801,7 @@ vips_foreign_load_pdf_source_init( VipsForeignLoadPdfSource *source )
{
}
#endif /*defined(HAVE_POPPLER) && defined(HAVE_GIO)*/
#endif /*defined(HAVE_POPPLER)*/
/* Also used by the pdfium loader.
*/

View File

@ -67,10 +67,7 @@
#include <vips/internal.h>
#include <vips/debug.h>
/* We need GIO for GInputStream.
*/
#if defined(HAVE_RSVG) && defined(HAVE_GIO)
#if defined(HAVE_RSVG)
#include <cairo.h>
#include <librsvg/rsvg.h>
@ -728,7 +725,7 @@ vips_foreign_load_svg_buffer_init( VipsForeignLoadSvgBuffer *buffer )
{
}
#endif /*HAVE_RSVG && HAVE_GIO*/
#endif /*HAVE_RSVG*/
/**
* vips_svgload:

View File

@ -269,8 +269,6 @@ VipsSourceCustom *vips_source_custom_new( void );
* hook librsvg up to libvips using the GInputStream interface.
*/
#ifdef HAVE_GIO
#define VIPS_TYPE_G_INPUT_STREAM (vips_g_input_stream_get_type())
#define VIPS_G_INPUT_STREAM( obj ) \
(G_TYPE_CHECK_INSTANCE_CAST( (obj), \
@ -306,8 +304,6 @@ typedef struct _VipsGInputStreamClass {
GInputStream *vips_g_input_stream_new_from_source( VipsSource *source );
#endif /*HAVE_GIO*/
#define VIPS_TYPE_TARGET (vips_target_get_type())
#define VIPS_TARGET( obj ) \
(G_TYPE_CHECK_INSTANCE_CAST( (obj), \

View File

@ -133,9 +133,6 @@ void vips__link_break_all( VipsImage *im );
void *vips__link_map( VipsImage *image, gboolean upstream,
VipsSListMap2Fn fn, void *a, void *b );
char *vips__b64_encode( const unsigned char *data, size_t data_length );
unsigned char *vips__b64_decode( const char *buffer, size_t *data_length );
gboolean vips__mmap_supported( int fd );
void *vips__mmap( int fd, int writeable, size_t length, gint64 offset );
int vips__munmap( const void *start, size_t length );

View File

@ -91,9 +91,7 @@ extern "C" {
/* Needed for VipsGInputStream.
*/
#ifdef HAVE_GIO
#include <gio/gio.h>
#endif /*HAVE_GIO*/
/* If we're being parsed by SWIG, remove gcc attributes.
*/

View File

@ -16,7 +16,6 @@ libiofuncs_la_SOURCES = \
gate.c \
enumtypes.c \
object.c \
base64.c \
error.c \
image.c \
vips.c \

View File

@ -1,317 +0,0 @@
/* base64.c -- Encode/decode integers in base64 format
* Created: Mon Sep 23 16:55:12 1996 by faith@dict.org
* Revised: Sat Mar 30 12:02:36 2002 by faith@dict.org
* Copyright 1996, 2002 Rickard E. Faith (faith@dict.org)
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* \section{Base-64 Routines}
*
* \intro These routines use the 64-character subset of International
* Alphabet IA5 discussed in RFC 1421 (printeable encoding) and RFC 1522
* (base64 MIME).
*
Value Encoding Value Encoding Value Encoding Value Encoding
0 A 17 R 34 i 51 z
1 B 18 S 35 j 52 0
2 C 19 T 36 k 53 1
3 D 20 U 37 l 54 2
4 E 21 V 38 m 55 3
5 F 22 W 39 n 56 4
6 G 23 X 40 o 57 5
7 H 24 Y 41 p 58 6
8 I 25 Z 42 q 59 7
9 J 26 a 43 r 60 8
10 K 27 b 44 s 61 9
11 L 28 c 45 t 62 +
12 M 29 d 46 u 63 /
13 N 30 e 47 v
14 O 31 f 48 w (pad) =
15 P 32 g 49 x
16 Q 33 h 50 y
*
*/
/*
Hacked for VIPS ... does any length object (not just ints), formats
base64 into 70 character lines, output to a malloc'd buffer.
VIPS uses this to write BLOBs (like ICC profiles, for example) to the
XML that follows an image.
Modified on:
23/7/07 JC
- oop, needed a slightly larger worst-case buffer in im__b64_encode()
12/5/09
- fix signed/unsigned warning
25/3/11
- move to vips_ namespace
31/5/15
- oops siged/unsigned mess-up meant we were not padding correctly
20/3/19
- larger output allocate
- better max size check
*/
/*
#define DEBUG
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <vips/vips.h>
#include <vips/internal.h>
#ifdef HAVE_BASE64_ENCODE
/* glib 2.12 adds these.
*/
char *
vips__b64_encode( const unsigned char *data, size_t data_length )
{
return( g_base64_encode( data, data_length ) );
}
unsigned char *
vips__b64_decode( const char *buffer, size_t *data_length )
{
return( g_base64_decode( buffer, data_length ) );
}
#else /*!HAVE_BASE64_ENCODE*/
static unsigned char b64_list[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
#define XX 100
static unsigned char b64_index[256] = {
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,62, XX,XX,XX,63,
52,53,54,55, 56,57,58,59, 60,61,XX,XX, XX,XX,XX,XX,
XX, 0, 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,XX, XX,XX,XX,XX,
XX,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
41,42,43,44, 45,46,47,48, 49,50,51,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
};
/* Read (up to) 3 bytes from in. Be careful about byte ordering :-/ we need to
* end up with in[2] in the bottom few bits.
*/
static int
read24( const unsigned char *in, int remaining )
{
int bits;
int i;
bits = 0;
for( i = 0; i < 3; i++ ) {
bits = VIPS_LSHIFT_INT( bits, 8 );
if( remaining > 0 ) {
bits |= in[i];
remaining -= 1;
}
}
return( bits );
}
/* Output (up to) 24 bits as four base64 chars. Pad with '=' characters.
*/
static void
encode24( char *p, int bits, int remaining )
{
int i;
for( i = 0; i < 4; i++ ) {
if( remaining <= 0 )
p[i] = '=';
else {
/* Take the top 6 bits of 24.
*/
p[i] = b64_list[(bits >> 18) & 63];
bits = VIPS_LSHIFT_INT( bits, 6 );
remaining -= 6;
}
}
}
/* Output to a malloc'd buffer, NULL on error. Try to be simple and reliable,
* rather than quick.
*/
char *
vips__b64_encode( const unsigned char *data, size_t data_length )
{
/* Worst case: 1.333 chars per byte, plus 10% for extra carriage
* returns and stuff, plus the final \n\0.
*/
const size_t output_data_length = data_length * 44 / 30 + 10;
char *buffer;
char *p;
int i;
int cursor;
if( data_length > 10 * 1024 * 1024 ) {
/* We shouldn't really be used for large amounts of data, plus
* we are using int offsets.
*
* A large ICC profile can be 1MB, so allow 10MB.
*/
vips_error( "vips__b64_encode", "%s", _( "too much data" ) );
return( NULL );
}
if( !(buffer = vips_malloc( NULL, output_data_length )) )
return( NULL );
p = buffer;
*p++ = '\n';
cursor = 0;
for( i = 0; i < data_length; i += 3 ) {
int remaining = data_length - i;
int bits;
bits = read24( data + i, remaining );
encode24( p, bits, remaining * 8 );
p += 4;
cursor += 4;
if( cursor >= 76 ) {
*p++ = '\n';
cursor = 0;
}
}
if( cursor > 0 )
*p++ = '\n';
*p++ = '\0';
g_assert( (size_t) (p - buffer) < output_data_length );
#ifdef DEBUG
{
unsigned int total;
/* Calculate a very simple checksum for debugging.
*/
for( total = 0, i = 0; i < data_length; i++ )
total += data[i];
printf( "vips__b64_encode: length = %zu, checksum 0x%x\n",
data_length, total & 0xffff );
}
#endif /*DEBUG*/
return( buffer );
}
/* Decode base64 back to binary in a malloc'd buffer. NULL on error.
*/
unsigned char *
vips__b64_decode( const char *buffer, size_t *data_length )
{
const size_t buffer_length = strlen( buffer );
/* Worst case. Add one, since we don't want to return NULL for an empty
* input string, it would look like an error return.
*/
const size_t output_data_length = 1 + buffer_length * 3 / 4;
unsigned char *data;
unsigned char *p;
unsigned int bits;
int nbits;
int i;
/* A large ICC profile can be a couple of MB, so 10 should be plenty.
*/
if( output_data_length > 10 * 1024 * 1024 ) {
/* We shouldn't really be used for large amounts of data, plus
* we are using an int for offset.
*/
vips_error( "vips__b64_decode", "%s", _( "too much data" ) );
return( NULL );
}
if( !(data = vips_malloc( NULL, output_data_length )) )
return( NULL );
p = data;
bits = 0;
nbits = 0;
for( i = 0; i < buffer_length; i++ ) {
unsigned int val;
if( (val = b64_index[(int) buffer[i]]) != XX ) {
bits = VIPS_LSHIFT_INT( bits, 6 );
bits |= val;
nbits += 6;
if( nbits >= 8 ) {
*p++ = (bits >> (nbits - 8)) & 0xff;
nbits -= 8;
}
}
}
g_assert( (size_t) (p - data) < output_data_length );
if( data_length )
*data_length = p - data;
#ifdef DEBUG
{
unsigned int total;
/* Calculate a very simple checksum for debugging.
*/
for( total = 0, i = 0; i < p - data; i++ )
total += data[i];
printf( "vips__b64_decode: length = %d, checksum 0x%x\n",
p - data, total & 0xffff );
}
#endif /*DEBUG*/
return( data );
}
#endif /*HAVE_BASE64_ENCODE*/

View File

@ -49,8 +49,6 @@
#include <vips/internal.h>
#include <vips/debug.h>
#ifdef HAVE_GIO
#include <gio/gio.h>
static void vips_g_input_stream_seekable_iface_init( GSeekableIface *iface );
@ -301,5 +299,3 @@ vips_g_input_stream_new_from_source( VipsSource *source )
"input", source,
NULL ) );
}
#endif /*HAVE_GIO*/

View File

@ -486,9 +486,7 @@ vips_init( const char *argv0 )
vips_morphology_operation_init();
vips_draw_operation_init();
vips_mosaicing_operation_init();
#ifdef HAVE_GIO
vips_g_input_stream_get_type();
#endif /*HAVE_GIO*/
/* Load any vips8 plugins from the vips libdir. Keep going, even if
* some plugins fail to load.

View File

@ -735,7 +735,7 @@ transform_blob_save_string( const GValue *src_value, GValue *dest_value )
char *b64;
blob = vips_value_get_blob( src_value, &length );
if( (b64 = vips__b64_encode( blob, length )) ) {
if( (b64 = g_base64_encode( blob, length )) ) {
vips_value_set_save_string( dest_value, b64 );
vips_free( b64 );
}
@ -754,7 +754,7 @@ transform_save_string_blob( const GValue *src_value, GValue *dest_value )
size_t length;
b64 = vips_value_get_save_string( src_value );
if( (blob = vips__b64_decode( b64, &length )) )
if( (blob = g_base64_decode( b64, &length )) )
vips_value_set_blob( dest_value,
(VipsCallbackFn) vips_free, blob, length );
else

View File

@ -256,7 +256,6 @@ libvips/iofuncs/sinkmemory.c
libvips/iofuncs/window.c
libvips/iofuncs/reorder.c
libvips/iofuncs/targetcustom.c
libvips/iofuncs/base64.c
libvips/iofuncs/source.c
libvips/iofuncs/memory.c
libvips/iofuncs/sinkdisc.c

View File

@ -2619,12 +2619,6 @@ msgstr "»mmap %s« zur gleichen Adresse nicht möglich"
msgid "too little data"
msgstr "zu wenige Daten"
#. We shouldn't really be used for large amounts of data.
#.
#: libvips/iofuncs/base64.c:176 libvips/iofuncs/base64.c:241
msgid "too much data"
msgstr "zu viele Daten"
#: libvips/iofuncs/object.c:148
#, c-format
msgid "parameter %s not set"

View File

@ -5318,18 +5318,6 @@ msgstr ""
msgid "TB"
msgstr ""
#. We shouldn't really be used for large amounts of data, plus
#. * we are using int offsets.
#. *
#. * A large ICC profile can be 1MB, so allow 10MB of b64.
#.
#. We shouldn't really be used for large amounts of data, plus
#. * we are using an int for offset.
#.
#: ../libvips/iofuncs/base64.c:177 ../libvips/iofuncs/base64.c:244
msgid "too much data"
msgstr ""
#: ../libvips/morphology/morph.c:139
msgid "morphology operation"
msgstr ""

View File

@ -1138,15 +1138,11 @@ main( int argc, char **argv )
/* "vips" with no arguments does "vips --help".
*/
if( argc == 1 ) {
#ifdef HAVE_CONTEXT_GET_HELP
char *help;
help = g_option_context_get_help( context, TRUE, NULL );
printf( "%s", help );
g_free( help );
#else /* !HAVE_CONTEXT_GET_HELP */
printf( "help not available, your glib is too old\n" );
#endif /* HAVE_CONTEXT_GET_HELP */
exit( 0 );
}