Back to index

courier  0.68.2
Functions
testgpg.c File Reference
#include "config.h"
#include "gpglib.h"
#include "unicode/unicode.h"
#include "numlib/numlib.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

static int dump_stdout (const char *p, size_t l, void *dummy)
static int poll_wait (void *dummy)
static void genkey (const char *d)
static int show_key (const char *fingerprint, const char *shortname, const char *key, int invalid, struct gpg_list_info *dummy)
static void genlist (const char *d, int flag)
static int expkey (const char *d, const char *f, int flag)
static int delkey (const char *d, const char *f, int flag)
static int signkey (const char *d, const char *signthis, const char *signwith)
static int checksign (const char *d, const char *stuff, const char *sig)
static int import (const char *filename)
int main (int argc, char **argv)

Function Documentation

static int checksign ( const char *  d,
const char *  stuff,
const char *  sig 
) [static]

Definition at line 88 of file testgpg.c.

{
       return (libmail_gpg_checksign(d, stuff, sig, dump_stdout, NULL));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int delkey ( const char *  d,
const char *  f,
int  flag 
) [static]

Definition at line 78 of file testgpg.c.

{
       return (libmail_gpg_deletekey(d, flag, f, dump_stdout, NULL));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int dump_stdout ( const char *  p,
size_t  l,
void *  dummy 
) [static]

Definition at line 18 of file testgpg.c.

{
       if (l == 0)
              return 0;

       if (fwrite(p, l, 1, stdout) != 1)
              exit(1);
       fflush(stdout);
       return (0);
}

Here is the caller graph for this function:

static int expkey ( const char *  d,
const char *  f,
int  flag 
) [static]

Definition at line 73 of file testgpg.c.

{
       return (libmail_gpg_exportkey(d, flag, f, dump_stdout, dump_stdout, NULL));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void genkey ( const char *  d) [static]

Definition at line 36 of file testgpg.c.

{
       libmail_gpg_genkey(d, "iso-8859-1",
                 "John Smith",
                 "john@example.com",
                 "Dummy ISO-8859 Tst key",
                 1024,
                 2048,
                 12,
                 'm',
                 "",
                 dump_stdout,
                 poll_wait,
                 NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void genlist ( const char *  d,
int  flag 
) [static]

Definition at line 64 of file testgpg.c.

{
       struct gpg_list_info gli;

       memset(&gli, 0, sizeof(gli));

       libmail_gpg_listkeys(d, flag, show_key, dump_stdout, &gli);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int import ( const char *  filename) [static]

Definition at line 93 of file testgpg.c.

{
       FILE *f=fopen(filename, "r");
       int rc;

       if (!f)
       {
              perror(filename);
              return (1);
       }

       if ((rc=libmail_gpg_import_start(NULL, 1)) == 0)
       {
              char buf[BUFSIZ];
              int n;

              while ((n=fread(buf, 1, sizeof(buf), f)) > 0)
              {
                     if ((rc=libmail_gpg_import_do(buf, n,
                                                dump_stdout, NULL)) != 0)
                            return (rc);
              }

              rc=libmail_gpg_import_finish(dump_stdout, NULL);
       }
       return (rc);
}

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 121 of file testgpg.c.

{
       if (argc < 3)
              return (0);

       if (strcmp(argv[2], "gen") == 0)
       {
              genkey(argv[1]);
              return (0);
       }

       if (strcmp(argv[2], "listpub") == 0)
       {
              genlist(argv[1], 0);
              return (0);
       }

       if (strcmp(argv[2], "listsec") == 0)
       {
              genlist(argv[1], 1);
              return (0);
       }

       if (strcmp(argv[2], "exppub") == 0 && argc >= 4)
       {
              exit(expkey(argv[1], argv[3], 0));
              return (0);
       }

       if (strcmp(argv[2], "expsec") == 0 && argc >= 4)
       {
              exit(expkey(argv[1], argv[3], 1));
              return (0);
       }

       if (strcmp(argv[2], "delpub") == 0 && argc >= 4)
       {
              exit (delkey(argv[1], argv[3], 0));
              return (0);
       }

       if (strcmp(argv[2], "delsec") == 0 && argc >= 4)
       {
              exit (delkey(argv[1], argv[3], 1));
              return (0);
       }

       if (strcmp(argv[2], "sign") == 0 && argc >= 5)
       {
              exit(signkey(argv[1], argv[3], argv[4]));
              return (0);
       }

       if (strcmp(argv[2], "checksign") == 0 && argc >= 5)
       {
              exit(checksign(argv[1], argv[3], argv[4]));
              return (0);
       }

       if (strcmp(argv[2], "import") == 0)
              exit(import(argv[1]));

       return (0);
}

Here is the call graph for this function:

static int poll_wait ( void *  dummy) [static]

Definition at line 29 of file testgpg.c.

{
       putchar('*');
       fflush(stdout);
       return (0);
}

Here is the caller graph for this function:

static int show_key ( const char *  fingerprint,
const char *  shortname,
const char *  key,
int  invalid,
struct gpg_list_info dummy 
) [static]

Definition at line 52 of file testgpg.c.

{
       printf("Fingerprint: %s\nShort: %s\n%s\n\n",
              fingerprint,
              shortname,
              key);
       fflush(stdout);
       return (0);
}

Here is the caller graph for this function:

static int signkey ( const char *  d,
const char *  signthis,
const char *  signwith 
) [static]

Definition at line 83 of file testgpg.c.

{
       return (libmail_gpg_signkey(d, signthis, signwith, -1, dump_stdout, 0, NULL));
}

Here is the call graph for this function:

Here is the caller graph for this function: