src/
authorMarcus Brinkmann <mb@g10code.com>
Wed, 9 May 2007 22:20:26 +0000 (22:20 +0000)
committerMarcus Brinkmann <mb@g10code.com>
Wed, 9 May 2007 22:20:26 +0000 (22:20 +0000)
2007-05-09  Marcus Brinkmann  <marcus@g10code.de>

* gcrypt.h.in (gcry_ac_io_t): Add name for anonymous union, and mark
all members as internal (actually: deprecated).

cipher/
2007-05-09  Marcus Brinkmann  <marcus@g10code.de>

* ac.c (_gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read):
Adjust users of gcry_ac_io_t because union is not anonymous
anymore.

cipher/ChangeLog
cipher/ac.c
src/ChangeLog
src/gcrypt.h.in

index d4eb19b..8a5c5e9 100644 (file)
@@ -1,3 +1,9 @@
+2007-05-09  Marcus Brinkmann  <marcus@g10code.de>
+
+       * ac.c (_gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read):
+       Adjust users of gcry_ac_io_t because union is not anonymous
+       anymore.
+
 2007-05-02  Werner Koch  <wk@g10code.com>
 
        * camellia-glue.c (camellia_setkey, camellia_encrypt)
index bd8a9c1..8a2ae10 100644 (file)
@@ -946,13 +946,13 @@ _gcry_ac_io_init_va (gcry_ac_io_t *ac_io,
       switch (type)
        {
        case GCRY_AC_IO_STRING:
-         ac_io->readable.string.data = va_arg (ap, unsigned char *);
-         ac_io->readable.string.data_n = va_arg (ap, size_t);
+         ac_io->io.readable.string.data = va_arg (ap, unsigned char *);
+         ac_io->io.readable.string.data_n = va_arg (ap, size_t);
          break;
 
        case GCRY_AC_IO_CALLBACK:
-         ac_io->readable.callback.cb = va_arg (ap, gcry_ac_data_read_cb_t);
-         ac_io->readable.callback.opaque = va_arg (ap, void *);
+         ac_io->io.readable.callback.cb = va_arg (ap, gcry_ac_data_read_cb_t);
+         ac_io->io.readable.callback.opaque = va_arg (ap, void *);
          break;
        }
       break;
@@ -960,13 +960,13 @@ _gcry_ac_io_init_va (gcry_ac_io_t *ac_io,
       switch (type)
        {
        case GCRY_AC_IO_STRING:
-         ac_io->writable.string.data = va_arg (ap, unsigned char **);
-         ac_io->writable.string.data_n = va_arg (ap, size_t *);
+         ac_io->io.writable.string.data = va_arg (ap, unsigned char **);
+         ac_io->io.writable.string.data_n = va_arg (ap, size_t *);
          break;
 
        case GCRY_AC_IO_CALLBACK:
-         ac_io->writable.callback.cb = va_arg (ap, gcry_ac_data_write_cb_t);
-         ac_io->writable.callback.opaque = va_arg (ap, void *);
+         ac_io->io.writable.callback.cb = va_arg (ap, gcry_ac_data_write_cb_t);
+         ac_io->io.writable.callback.opaque = va_arg (ap, void *);
          break;
        }
       break;
@@ -1022,18 +1022,18 @@ _gcry_ac_io_write (gcry_ac_io_t *ac_io, unsigned char *buffer, size_t buffer_n)
       {
        unsigned char *p;
 
-       if (*ac_io->writable.string.data)
+       if (*ac_io->io.writable.string.data)
          {
-           p = gcry_realloc (*ac_io->writable.string.data,
-                             *ac_io->writable.string.data_n + buffer_n);
+           p = gcry_realloc (*ac_io->io.writable.string.data,
+                             *ac_io->io.writable.string.data_n + buffer_n);
            if (! p)
              err = gcry_error_from_errno (errno);
            else
              {
-               if (*ac_io->writable.string.data != p)
-                 *ac_io->writable.string.data = p;
-               memcpy (p + *ac_io->writable.string.data_n, buffer, buffer_n);
-               *ac_io->writable.string.data_n += buffer_n;
+               if (*ac_io->io.writable.string.data != p)
+                 *ac_io->io.writable.string.data = p;
+               memcpy (p + *ac_io->io.writable.string.data_n, buffer, buffer_n);
+               *ac_io->io.writable.string.data_n += buffer_n;
              }
          }
        else
@@ -1047,16 +1047,16 @@ _gcry_ac_io_write (gcry_ac_io_t *ac_io, unsigned char *buffer, size_t buffer_n)
            else
              {
                memcpy (p, buffer, buffer_n);
-               *ac_io->writable.string.data = p;
-               *ac_io->writable.string.data_n = buffer_n;
+               *ac_io->io.writable.string.data = p;
+               *ac_io->io.writable.string.data_n = buffer_n;
              }
          }
       }
       break;
 
     case GCRY_AC_IO_CALLBACK:
-      err = (*ac_io->writable.callback.cb) (ac_io->writable.callback.opaque,
-                                           buffer, buffer_n);
+      err = (*ac_io->io.writable.callback.cb) (ac_io->io.writable.callback.opaque,
+                                              buffer, buffer_n);
       break;
     }
 
@@ -1084,7 +1084,7 @@ _gcry_ac_io_read (gcry_ac_io_t *ac_io,
        size_t bytes_to_read;
        size_t bytes_wanted;
 
-       bytes_available = ac_io->readable.string.data_n - nread;
+       bytes_available = ac_io->io.readable.string.data_n - nread;
        bytes_wanted = *buffer_n;
 
        if (bytes_wanted > bytes_available)
@@ -1092,15 +1092,15 @@ _gcry_ac_io_read (gcry_ac_io_t *ac_io,
        else
          bytes_to_read = bytes_wanted;
 
-       memcpy (buffer, ac_io->readable.string.data + nread, bytes_to_read);
+       memcpy (buffer, ac_io->io.readable.string.data + nread, bytes_to_read);
        *buffer_n = bytes_to_read;
        err = 0;
        break;
       }
 
     case GCRY_AC_IO_CALLBACK:
-      err = (*ac_io->readable.callback.cb) (ac_io->readable.callback.opaque,
-                                           buffer, buffer_n);
+      err = (*ac_io->io.readable.callback.cb)
+       (ac_io->io.readable.callback.opaque, buffer, buffer_n);
       break;
     }
 
index dd76eb1..15d25dd 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-09  Marcus Brinkmann  <marcus@g10code.de>
+
+       * gcrypt.h.in (gcry_ac_io_t): Add name for anonymous union, and mark
+       all members as internal (actually: deprecated).
+
 2007-05-04  Werner Koch  <wk@g10code.com>
 
        * Makefile.am (.rc.lo): New to replace gmake specific suffix rule.
index 23cd36f..bb3bc9a 100644 (file)
@@ -101,6 +101,15 @@ extern "C" {
 #define _GCRY_GCC_ATTR_MALLOC
 #endif
 
+/* Some members in a public type should only be used internally.
+   There is no "internal" attribute, so we abuse the deprecated
+   attribute to discourage external use.  */
+#ifdef _GCRYPT_IN_LIBGCRYPT
+#define _GCRY_ATTR_INTERNAL
+#else
+#define _GCRY_ATTR_INTERNAL    _GCRY_GCC_ATTR_DEPRECATED
+#endif
+
 /* Wrappers for the libgpg-error library.  */
 
 typedef gpg_error_t gcry_error_t;
@@ -1253,8 +1262,8 @@ gcry_ac_io_type_t;
 typedef struct gcry_ac_io
 {
   /* This is an INTERNAL structure, do NOT use manually.  */
-  gcry_ac_io_mode_t mode;
-  gcry_ac_io_type_t type;
+  gcry_ac_io_mode_t mode _GCRY_ATTR_INTERNAL;
+  gcry_ac_io_type_t type _GCRY_ATTR_INTERNAL;
   union
   {
     union
@@ -1285,7 +1294,7 @@ typedef struct gcry_ac_io
       } string;
       void *opaque;
     } writable;
-  };
+  } io _GCRY_ATTR_INTERNAL;
 }
 gcry_ac_io_t;