gpgme 0.3.8

Stéphane Corthésy stephane at sente.ch
Sun Jul 14 12:40:01 CEST 2002


Hi,

I tried to compile gpgme 0.3.8 on MacOS X, but I failed to compile it 
out-of-the-box :-(

Anyway, I could patch it :-)

Basically, there are no vasprintf() and asprintf() functions on MacOS X; 
I tried using the replacement you provide (it was not part of 0.3.8 
distro, but I found it in the repository), but it doesn't work: even the 
test suite on vasprintf() fails:

PASS: 33 305419896
PASS: 
236                                                                                                                                                                                                        5
PASS: 337 
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006
PASS: 290 
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007
PASS: 161 jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa
777777777777777777333333333333366666666666622222222222777777777777733333
Bus error


I found another unoptimized implementation of vasprintf(), and this time 
all tests passed. Could you please correct your implementation? Thanks.
(Note that the prototype of vasprintf() in gpgme/util.h is wrong; third 
arg is not of correct type. Note also that he version found in gpgme is 
not the same as to the one in libgcrypt, which doesn't work either).


There are also #include problems in gpgme/ath-pth.c and ath-pthread.c: 
instead of #including <malloc.h> (which doesn't exist on MacOS X; we 
have <sys/malloc.h>), I need to #include <stdlib.h>.

During compilation there were also some #warnings which should be 
corrected:

debug.h:54: undefined or invalid # directive
	#elsif is not recognized; doesn't matter here
	
encrypt-sign.c: In function `encrypt_sign_status_handler':
encrypt-sign.c:44: warning: passing arg 2 of 
`gpgme_data_release_and_get_mem' from incompatible pointer type
	argument is of type int instead of size_t

key.c: In function `gpgme_key_get_string_attr':
key.c:996: warning: enumeration value `GPGME_ATTR_SIG_SUMMARY' not 
handled in switch


Cheers,

Stéphane

P.-S.
Why are gpgme releases not announced on this mailing-list?

=======================
diff -ur gpgme-0.3.8/gpgme/Makefile.in /tmp/gpgme-0.3.8/gpgme/Makefile.in
--- gpgme-0.3.8/gpgme/Makefile.in	Tue Jun 25 20:37:02 2002
+++ /tmp/gpgme-0.3.8/gpgme/Makefile.in	Sat Jul 13 17:18:58 2002
@@ -168,6 +168,7 @@
  	sema.h io.h \
  	${system_components} \
  	debug.c debug.h \
+	vasprintf.c \
  	gpgme.c version.c errors.c

  subdir = gpgme
@@ -193,7 +194,7 @@
  	decrypt-verify.lo verify.lo sign.lo passphrase.lo progress.lo \
  	key.lo keylist.lo trustlist.lo import.lo export.lo genkey.lo \
  	delete.lo rungpg.lo engine-gpgsm.lo engine.lo $(am__objects_1) \
-	debug.lo gpgme.lo version.lo errors.lo
+	debug.lo gpgme.lo version.lo errors.lo vasprintf.lo
  libgpgme_la_OBJECTS = $(am_libgpgme_la_OBJECTS)
  SCRIPTS = $(bin_SCRIPTS)

@@ -223,6 +224,7 @@
  @AMDEP_TRUE@	./$(DEPDIR)/recipient.Plo ./$(DEPDIR)/rungpg.Plo \
  @AMDEP_TRUE@	./$(DEPDIR)/sign.Plo ./$(DEPDIR)/signers.Plo \
  @AMDEP_TRUE@	./$(DEPDIR)/trustlist.Plo ./$(DEPDIR)/util.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/vasprintf.Plo \
  @AMDEP_TRUE@	./$(DEPDIR)/verify.Plo ./$(DEPDIR)/version.Plo \
  @AMDEP_TRUE@	./$(DEPDIR)/w32-io.Plo ./$(DEPDIR)/w32-sema.Plo \
  @AMDEP_TRUE@	./$(DEPDIR)/w32-util.Plo ./$(DEPDIR)/wait.Plo
@@ -338,6 +340,7 @@
  @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/signers.Plo at am__quote@
  @AMDEP_TRUE@@am__include@ 
@am__quote at ./$(DEPDIR)/trustlist.Plo at am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/util.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ 
@am__quote at ./$(DEPDIR)/vasprintf.Plo at am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/verify.Plo at am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/version.Plo at am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/w32-io.Plo at am__quote@
diff -ur gpgme-0.3.8/gpgme/ath-pth.c /tmp/gpgme-0.3.8/gpgme/ath-pth.c
--- gpgme-0.3.8/gpgme/ath-pth.c	Sun Jun  2 21:19:25 2002
+++ /tmp/gpgme-0.3.8/gpgme/ath-pth.c	Sat Jul 13 17:19:59 2002
@@ -18,7 +18,7 @@
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 
02111-1307, USA
   */

-#include <malloc.h>
+#include <stdlib.h>
  #include <errno.h>
  #include <pth.h>

diff -ur gpgme-0.3.8/gpgme/ath-pthread.c 
/tmp/gpgme-0.3.8/gpgme/ath-pthread.c
--- gpgme-0.3.8/gpgme/ath-pthread.c	Sun Jun  2 21:19:25 2002
+++ /tmp/gpgme-0.3.8/gpgme/ath-pthread.c	Sat Jul 13 17:23:45 2002
@@ -18,7 +18,7 @@
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 
02111-1307, USA
   */

-#include <malloc.h>
+#include <stdlib.h>
  #include <errno.h>
  #include <pthread.h>

diff -ur gpgme-0.3.8/gpgme/util.h /tmp/gpgme-0.3.8/gpgme/util.h
--- gpgme-0.3.8/gpgme/util.h	Wed May  8 13:01:36 2002
+++ /tmp/gpgme-0.3.8/gpgme/util.h	Sat Jul 13 17:45:33 2002
@@ -77,7 +77,7 @@
  #ifdef HAVE_CONFIG_H
  #if !HAVE_VASPRINTF
  #include <stdarg.h>
-int vasprintf (char **result, const char *format, va_list *args);
+int vasprintf (char **result, const char *format, va_list args);
  int asprintf (char **result, const char *format, ...);
  #endif

=======================
// From http://www.unixpapa.com/incnote/stdio.html
int vasprintf(char **ret, const char *format, va_list ap)
   {
       int len= 100;        /* First guess at the size */
       if ((*ret= (char *)malloc(len)) == NULL) return -1;
#ifdef TEST
   global_total_width = len;
#endif
       while (1)
       {
           int nchar= vsnprintf(*ret, len, format, ap);
           if (nchar > -1 && nchar < len) return nchar;
           if (nchar > -1)
               len= nchar+1;
           else
               len*= 2;
           if ((*ret= (char *)realloc(*ret, len)) == NULL)  return -1;
#ifdef TEST
   global_total_width = len;
#endif
       }
   }





More information about the Gnupg-devel mailing list