gpgme progress meter callback

Marcus Brinkmann Marcus.Brinkmann at
Sun Sep 8 02:05:02 CEST 2002

On Sat, Sep 07, 2002 at 02:46:23PM -0500, Jacob Perkins wrote:
> I'm confused about how to use the progess meter callback setup in gpgme.
> How do I construct a GpgmeProgessCb and a HookValue?

> Here's what I did, and it caused a segfault when I called
> gpgme_op_generate:
> GpgmeProgressCb *progfunc = "progress";	
> gpgme_set_progress_cb (ctx, *progfunc, key_status);

Do you need a PROGFUNC variable?  This could be as simple as:

gpgme_set_progress_cb (ctx, progfunc, key_status);

Of course passing a string to a pointer to a function pointer is completely
wrong.  I can not believe that you compiled this with -Wall and did not spot
the compiler warning "initialization of incompatible pointer type".
> and then I have:
> void
> progress (gpointer status, gchar *what, gint type, gint current, gint
> total){}

This is not too bad, but not strictly correct with the types.  The plethora
of g* types are GTK+ (or GLib) types, but that is not what a GpgmeProgressCb
is expected to take.  You should use this:

void progress (void *status, const char *what, int type, int current, int total);

and nothing else.  If you need a gpointer or gint, you can cast it to that

  gpointer gstatus = (gpointer) status;
  gchar *gwhat = (gchar *) what;

The gchar conversion might trigger a warning about dropping the const


`Rhubarb is no Egyptian god.' GNU    marcus at
Marcus Brinkmann              The Hurd
Marcus.Brinkmann at

More information about the Gnupg-devel mailing list