Back to index

courier  0.68.2
Defines | Functions | Variables
libgpg.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "gpg.h"
#include "gpglib.h"

Go to the source code of this file.

Defines

#define WEXITSTATUS(stat_val)   ((unsigned)(stat_val) >> 8)
#define WIFEXITED(stat_val)   (((stat_val) & 255) == 0)

Functions

int libmail_gpg_cleanup ()
static char * optionfile (const char *gpgdir)
int libmail_gpg_has_gpg (const char *gpgdir)

Variables

int libmail_gpg_stdin = -1
int libmail_gpg_stdout = -1
int libmail_gpg_stderr = -1
pid_t libmail_gpg_pid = -1

Define Documentation

#define WEXITSTATUS (   stat_val)    ((unsigned)(stat_val) >> 8)

Definition at line 23 of file libgpg.c.

#define WIFEXITED (   stat_val)    (((stat_val) & 255) == 0)

Definition at line 26 of file libgpg.c.


Function Documentation

Definition at line 36 of file libgpg.c.

{
       int rc=0;

       if (libmail_gpg_stdin >= 0)
       {
              close(libmail_gpg_stdin);
              libmail_gpg_stdin= -1;
       }

       if (libmail_gpg_stdout >= 0)
       {
              close(libmail_gpg_stdout);
              libmail_gpg_stdout= -1;
       }

       if (libmail_gpg_stderr >= 0)
       {
              close(libmail_gpg_stderr);
              libmail_gpg_stderr= -1;
       }

       if (libmail_gpg_pid >= 0 && kill(libmail_gpg_pid, 0) >= 0)
       {
              int waitstat;
              pid_t p;

              while ((p=wait(&waitstat)) != libmail_gpg_pid)
              {
                     if (p < 0 && errno == ECHILD)
                            return (-1);
              }

              rc= WIFEXITED(waitstat) ? WEXITSTATUS(waitstat): -1;
              libmail_gpg_pid= -1;
       }
       return (rc);
}

Here is the caller graph for this function:

int libmail_gpg_has_gpg ( const char *  gpgdir)

Definition at line 89 of file libgpg.c.

{
       char *p=optionfile(gpgdir);
       struct stat stat_buf;
       int rc;

       if (!p)
              return (-1);

       rc=stat(p, &stat_buf);
       free(p);
       if (rc == 0)
              rc=stat(GPG, &stat_buf);

       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static char* optionfile ( const char *  gpgdir) [static]

Definition at line 75 of file libgpg.c.

{
       char *p=malloc(strlen(gpgdir)+sizeof("/options"));

       if (p)
              strcat(strcpy(p, gpgdir), "/options");
       return (p);
}

Here is the caller graph for this function:


Variable Documentation

pid_t libmail_gpg_pid = -1

Definition at line 34 of file libgpg.c.

Definition at line 33 of file libgpg.c.

Definition at line 32 of file libgpg.c.

Definition at line 32 of file libgpg.c.