bug-recutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-recutils] [PATCH] src: always provide encryption routines and t


From: Michał Masłowski
Subject: Re: [bug-recutils] [PATCH] src: always provide encryption routines and their prototypes.
Date: Tue, 27 Mar 2012 22:25:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> Please.  I find it preferable to have to update the dummy variant than
> to clobber rec-crypt.c with all those conditional compilation blocks.

Included the new patch.


2012-03-27  Michał Masłowski  <address@hidden>

        src: always provide encryption routines and their prototypes.
        * src/Makefile.am [!CRYPT]: Build rec-crypt-dummy.c instead of
        rec-crypt.c if encryption is disabled.
        * src/rec-crypt-dummy.c: New file.
        * src/rec.h: Unconditionalize encryption routine declarations.


From fcfa21c89259d45683b05db697326392d2181d87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Mas=C5=82owski?= <address@hidden>
Date: Thu, 22 Mar 2012 19:36:37 +0100
Subject: [PATCH] src: always provide encryption routines and their
 prototypes.

This makes the ABI of librec not depend on REC_CRYPT_SUPPORT, so
programs linking to librec don't need to be recompiled to use
encryption or the library without it enabled.  A side effect of this
change is rec.h declaring encryption routines when not including
config.h before, like it would be done in external programs using the
library.
---
 src/Makefile.am       |    2 ++
 src/rec-crypt-dummy.c |   80 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/rec.h             |    7 ++---
 3 files changed, 85 insertions(+), 4 deletions(-)
 create mode 100644 src/rec-crypt-dummy.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 6832092..7f87288 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,6 +46,8 @@ librec_la_SOURCES = rec.c \
 
 if CRYPT
    librec_la_SOURCES += rec-crypt.c
+else
+   librec_la_SOURCES += rec-crypt-dummy.c
 endif
 
 BUILT_SOURCES = rec-sex-tab.h
diff --git a/src/rec-crypt-dummy.c b/src/rec-crypt-dummy.c
new file mode 100644
index 0000000..30b6e0d
--- /dev/null
+++ b/src/rec-crypt-dummy.c
@@ -0,0 +1,80 @@
+/* -*- mode: C -*- Time-stamp: "2012-03-27 21:29:06 mtjm"
+ *
+ *       File:         rec-crypt-dummy.c
+ *       Date:         Tue Mar 27 21:29:06 2012
+ *
+ *       GNU recutils - Dummy replacements for encryption routines
+ *
+ */
+
+/* Copyright (C) 2011, 2012 Jose E. Marchesi */
+
+/* This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include <rec.h>
+
+bool
+rec_encrypt (char   *in,
+             size_t  in_size,
+             const char   *password,
+             char  **out,
+             size_t *out_size)
+{
+  return false;
+}
+
+bool
+rec_decrypt (char   *in,
+             size_t  in_size,
+             const char   *password,
+             char  **out,
+             size_t *out_size)
+{
+  return false;
+}
+
+bool
+rec_encrypt_record (rec_rset_t rset,
+                    rec_record_t record,
+                    const char *password)
+{
+  return false;
+}
+
+bool
+rec_encrypt_field (rec_field_t field,
+                   const char *password)
+{
+  return false;
+}
+
+bool
+rec_decrypt_field (rec_field_t field,
+                   const char *password)
+{
+  return false;
+}
+
+bool
+rec_decrypt_record (rec_rset_t rset,
+                    rec_record_t record,
+                    const char *password)
+{
+  return false;
+}
+
+/* End of rec-crypt-dummy.c */
diff --git a/src/rec.h b/src/rec.h
index cbcc62f..242368e 100644
--- a/src/rec.h
+++ b/src/rec.h
@@ -1998,12 +1998,13 @@ char *rec_sex_eval_str (rec_sex_t sex, rec_record_t 
record);
 void rec_sex_print_ast (rec_sex_t sex);
 
 
-#if defined REC_CRYPT_SUPPORT
-
 /*
  * ENCRYPTION
  *
  * The following routines encrypt and decrypt fields in rec data.
+ *
+ * If librec was built without encryption support, all of them will do
+ * nothing and return 'false' as if an error occurred.
  */
 
 /* Prefix used in the encrypted and ASCII encoded field values, which
@@ -2068,8 +2069,6 @@ bool rec_decrypt_field (rec_field_t field, const char 
*password);
 bool rec_decrypt_record (rec_rset_t rset, rec_record_t record,
                          const char *password);
 
-#endif /* REC_CRYPT_SUPPORT */
-
 #endif /* !GNU_REC_H */
 
 /* End of rec.h */
-- 
1.7.9.4

Attachment: pgpIBmCpRmdue.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]