From 41cd0e302d6554facd6b9f7daaa78304361efaef Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 25 Jul 2011 10:56:52 +0100 Subject: [PATCH] Require PCRE library. This library is widely available in distros. --- README | 4 ++-- configure.ac | 11 +++-------- src/dbdump.c | 6 ++---- src/filearch.c | 11 +++++------ src/guestfs-internal.h | 8 +------- src/inspect.c | 10 ++++------ src/inspect_apps.c | 10 ++++------ src/inspect_fs.c | 6 ++---- src/inspect_fs_cd.c | 6 ++---- src/inspect_fs_unix.c | 6 ++---- src/inspect_fs_windows.c | 6 ++---- src/match.c | 6 ------ 12 files changed, 29 insertions(+), 61 deletions(-) diff --git a/README b/README index 787ec32..6b2078e 100644 --- a/README +++ b/README @@ -58,12 +58,12 @@ For basic functionality and the C tools: - gperf +- pcre (Perl Compatible Regular Expressions C library) + - genisoimage (NOT mkisofs any more) - hivex >= 1.2.7 (http://libguestfs.org/download) (optional) -- pcre (Perl Compatible Regular Expressions C library) (optional) - - libmagic (the library that corresponds to the 'file' command) (optional) - libvirt (optional) diff --git a/configure.ac b/configure.ac index 4964b54..18c090f 100644 --- a/configure.ac +++ b/configure.ac @@ -411,6 +411,9 @@ AS_IF([test "x$with_readline" != xno], dnl For i18n. AM_GNU_GETTEXT([external]) +dnl Check for PCRE (required) +PKG_CHECK_MODULES([PCRE], [libpcre]) + dnl libmagic (highly recommended) AC_CHECK_LIB([magic],[magic_file], [AC_CHECK_HEADER([magic.h], @@ -420,14 +423,6 @@ AC_CHECK_LIB([magic],[magic_file], ], [AC_MSG_WARN([libmagic not found, some core features will be disabled])]) -dnl Check for PCRE (highly recommended) -PKG_CHECK_MODULES([PCRE], [libpcre], - [AC_SUBST([PCRE_CFLAGS]) - AC_SUBST([PCRE_LIBS]) - AC_DEFINE([HAVE_PCRE],[1],[PCRE found at compile time.]) - ], - [AC_MSG_WARN([PCRE not found, some core features will be disabled])]) - dnl libvirt (highly recommended) PKG_CHECK_MODULES([LIBVIRT], [libvirt], [AC_SUBST([LIBVIRT_CFLAGS]) diff --git a/src/dbdump.c b/src/dbdump.c index f9d06aa..caf6376 100644 --- a/src/dbdump.c +++ b/src/dbdump.c @@ -29,9 +29,7 @@ #include #include -#ifdef HAVE_PCRE #include -#endif #ifdef HAVE_HIVEX #include @@ -43,7 +41,7 @@ #include "guestfs.h" #include "guestfs-internal.h" -#if defined(HAVE_PCRE) && defined(HAVE_HIVEX) && defined(DB_DUMP) +#if defined(HAVE_HIVEX) && defined(DB_DUMP) static unsigned char *convert_hex_to_binary (guestfs_h *g, const char *hex, size_t hexlen, size_t *binlen_rtn); @@ -217,4 +215,4 @@ convert_hex_to_binary (guestfs_h *g, const char *hex, size_t hexlen, return bin; } -#endif /* defined(HAVE_PCRE) && defined(HAVE_HIVEX) && defined(DB_DUMP) */ +#endif /* defined(HAVE_HIVEX) && defined(DB_DUMP) */ diff --git a/src/filearch.c b/src/filearch.c index 14c7c02..0ed6425 100644 --- a/src/filearch.c +++ b/src/filearch.c @@ -26,9 +26,8 @@ #include #include -#ifdef HAVE_PCRE #include -#endif + #ifdef HAVE_LIBMAGIC #include #endif @@ -40,7 +39,7 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" -#if defined(HAVE_PCRE) && defined(HAVE_LIBMAGIC) +#if defined(HAVE_LIBMAGIC) static pcre *re_file_elf; static pcre *re_elf_ppc64; @@ -258,12 +257,12 @@ guestfs__file_architecture (guestfs_h *g, const char *path) return ret; /* caller frees */ } -#else /* no PCRE or libmagic at compile time */ +#else /* no libmagic at compile time */ /* XXX Should be an optgroup. */ #define NOT_IMPL(r) \ - error (g, _("file-architecture API not available since this version of libguestfs was compiled without PCRE or libmagic libraries")); \ + error (g, _("file-architecture API not available since this version of libguestfs was compiled without the libmagic library")); \ return r char * @@ -272,4 +271,4 @@ guestfs__file_architecture (guestfs_h *g, const char *path) NOT_IMPL(NULL); } -#endif /* no PCRE or libmagic at compile time */ +#endif /* no libmagic at compile time */ diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 99a0404..de073d2 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -22,9 +22,7 @@ #include #include -#ifdef HAVE_PCRE #include -#endif #define STREQ(a,b) (strcmp((a),(b)) == 0) #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0) @@ -348,12 +346,10 @@ extern int guestfs___build_appliance (guestfs_h *g, char **kernel, char **initrd extern void guestfs___launch_send_progress (guestfs_h *g, int perdozen); extern void guestfs___print_BufferIn (FILE *out, const char *buf, size_t buf_size); extern void guestfs___print_BufferOut (FILE *out, const char *buf, size_t buf_size); -#ifdef HAVE_PCRE extern int guestfs___match (guestfs_h *g, const char *str, const pcre *re); extern char *guestfs___match1 (guestfs_h *g, const char *str, const pcre *re); extern int guestfs___match2 (guestfs_h *g, const char *str, const pcre *re, char **ret1, char **ret2); extern int guestfs___match3 (guestfs_h *g, const char *str, const pcre *re, char **ret1, char **ret2, char **ret3); -#endif extern int guestfs___feature_available (guestfs_h *g, const char *feature); extern void guestfs___free_string_list (char **); extern size_t guestfs___checkpoint_cmdline (guestfs_h *g); @@ -361,7 +357,7 @@ extern void guestfs___rollback_cmdline (guestfs_h *g, size_t pos); extern void guestfs___call_callbacks_void (guestfs_h *g, uint64_t event); extern void guestfs___call_callbacks_message (guestfs_h *g, uint64_t event, const char *buf, size_t buf_len); extern void guestfs___call_callbacks_array (guestfs_h *g, uint64_t event, const uint64_t *array, size_t array_len); -#if defined(HAVE_PCRE) && defined(HAVE_HIVEX) +#if defined(HAVE_HIVEX) extern int guestfs___check_for_filesystem_on (guestfs_h *g, const char *device, int is_block, int is_partnum); extern char *guestfs___download_to_tmp (guestfs_h *g, struct inspect_fs *fs, const char *filename, const char *basename, int64_t max_size); extern char *guestfs___case_sensitive_path_silently (guestfs_h *g, const char *); @@ -391,11 +387,9 @@ extern int guestfs___check_windows_root (guestfs_h *g, struct inspect_fs *fs); #define safe_strndup guestfs_safe_strndup #define safe_memdup guestfs_safe_memdup #define safe_asprintf guestfs_safe_asprintf -#ifdef HAVE_PCRE #define match guestfs___match #define match1 guestfs___match1 #define match2 guestfs___match2 #define match3 guestfs___match3 -#endif #endif /* GUESTFS_INTERNAL_H_ */ diff --git a/src/inspect.c b/src/inspect.c index f04668d..c51804d 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -29,9 +29,7 @@ #include #include -#ifdef HAVE_PCRE #include -#endif #ifdef HAVE_HIVEX #include @@ -46,7 +44,7 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" -#if defined(HAVE_PCRE) && defined(HAVE_HIVEX) +#if defined(HAVE_HIVEX) /* The main inspection code. */ char ** @@ -591,12 +589,12 @@ guestfs___search_for_root (guestfs_h *g, const char *root) return NULL; } -#else /* no PCRE or hivex at compile time */ +#else /* no hivex at compile time */ /* XXX These functions should be in an optgroup. */ #define NOT_IMPL(r) \ - error (g, _("inspection API not available since this version of libguestfs was compiled without PCRE or hivex libraries")); \ + error (g, _("inspection API not available since this version of libguestfs was compiled without the hivex library")); \ return r char ** @@ -726,7 +724,7 @@ guestfs__inspect_is_multipart (guestfs_h *g, const char *root) NOT_IMPL(-1); } -#endif /* no PCRE or hivex at compile time */ +#endif /* no hivex at compile time */ void guestfs___free_inspect_info (guestfs_h *g) diff --git a/src/inspect_apps.c b/src/inspect_apps.c index 83c5e5e..ba27247 100644 --- a/src/inspect_apps.c +++ b/src/inspect_apps.c @@ -29,9 +29,7 @@ #include #include -#ifdef HAVE_PCRE #include -#endif #ifdef HAVE_HIVEX #include @@ -46,7 +44,7 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" -#if defined(HAVE_PCRE) && defined(HAVE_HIVEX) +#if defined(HAVE_HIVEX) #ifdef DB_DUMP static struct guestfs_application_list *list_applications_rpm (guestfs_h *g, struct inspect_fs *fs); @@ -601,12 +599,12 @@ sort_applications (struct guestfs_application_list *apps) compare_applications); } -#else /* no PCRE or hivex at compile time */ +#else /* no hivex at compile time */ /* XXX These functions should be in an optgroup. */ #define NOT_IMPL(r) \ - error (g, _("inspection API not available since this version of libguestfs was compiled without PCRE or hivex libraries")); \ + error (g, _("inspection API not available since this version of libguestfs was compiled without the hivex library")); \ return r struct guestfs_application_list * @@ -615,4 +613,4 @@ guestfs__inspect_list_applications (guestfs_h *g, const char *root) NOT_IMPL(NULL); } -#endif /* no PCRE or hivex at compile time */ +#endif /* no hivex at compile time */ diff --git a/src/inspect_fs.c b/src/inspect_fs.c index ff54634..3fa5c98 100644 --- a/src/inspect_fs.c +++ b/src/inspect_fs.c @@ -29,9 +29,7 @@ #include #include -#ifdef HAVE_PCRE #include -#endif #ifdef HAVE_HIVEX #include @@ -46,7 +44,7 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" -#if defined(HAVE_PCRE) && defined(HAVE_HIVEX) +#if defined(HAVE_HIVEX) /* Compile all the regular expressions once when the shared library is * loaded. PCRE is thread safe so we're supposedly OK here if @@ -538,4 +536,4 @@ guestfs___first_egrep_of_file (guestfs_h *g, const char *filename, return 1; } -#endif /* defined(HAVE_PCRE) && defined(HAVE_HIVEX) */ +#endif /* defined(HAVE_HIVEX) */ diff --git a/src/inspect_fs_cd.c b/src/inspect_fs_cd.c index 6ae08c3..96add97 100644 --- a/src/inspect_fs_cd.c +++ b/src/inspect_fs_cd.c @@ -29,9 +29,7 @@ #include #include -#ifdef HAVE_PCRE #include -#endif #ifdef HAVE_HIVEX #include @@ -46,7 +44,7 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" -#if defined(HAVE_PCRE) && defined(HAVE_HIVEX) +#if defined(HAVE_HIVEX) /* Debian/Ubuntu install disks are easy ... * @@ -401,4 +399,4 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs) return 0; } -#endif /* defined(HAVE_PCRE) && defined(HAVE_HIVEX) */ +#endif /* defined(HAVE_HIVEX) */ diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c index a34d691..2ea29ad 100644 --- a/src/inspect_fs_unix.c +++ b/src/inspect_fs_unix.c @@ -29,9 +29,7 @@ #include #include -#ifdef HAVE_PCRE #include -#endif #ifdef HAVE_HIVEX #include @@ -46,7 +44,7 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" -#if defined(HAVE_PCRE) && defined(HAVE_HIVEX) +#if defined(HAVE_HIVEX) /* Compile all the regular expressions once when the shared library is * loaded. PCRE is thread safe so we're supposedly OK here if @@ -850,4 +848,4 @@ inspect_with_augeas (guestfs_h *g, struct inspect_fs *fs, const char *filename, return r; } -#endif /* defined(HAVE_PCRE) && defined(HAVE_HIVEX) */ +#endif /* defined(HAVE_HIVEX) */ diff --git a/src/inspect_fs_windows.c b/src/inspect_fs_windows.c index da7540f..60d9c0f 100644 --- a/src/inspect_fs_windows.c +++ b/src/inspect_fs_windows.c @@ -29,9 +29,7 @@ #include #include -#ifdef HAVE_PCRE #include -#endif #ifdef HAVE_HIVEX #include @@ -46,7 +44,7 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" -#if defined(HAVE_PCRE) && defined(HAVE_HIVEX) +#if defined(HAVE_HIVEX) /* Compile all the regular expressions once when the shared library is * loaded. PCRE is thread safe so we're supposedly OK here if @@ -529,4 +527,4 @@ guestfs___case_sensitive_path_silently (guestfs_h *g, const char *path) return ret; } -#endif /* defined(HAVE_PCRE) && defined(HAVE_HIVEX) */ +#endif /* defined(HAVE_HIVEX) */ diff --git a/src/match.c b/src/match.c index 869850c..68b2d4b 100644 --- a/src/match.c +++ b/src/match.c @@ -22,15 +22,11 @@ #include #include -#ifdef HAVE_PCRE #include -#endif #include "guestfs.h" #include "guestfs-internal.h" -#ifdef HAVE_PCRE - /* Match a regular expression which contains no captures. Returns * true if it matches or false if it doesn't. */ @@ -124,5 +120,3 @@ guestfs___match3 (guestfs_h *g, const char *str, const pcre *re, return 1; } - -#endif /* HAVE_PCRE */ -- 1.8.3.1