Back to index

courier  0.68.2
Classes | Defines | Functions
mimegpgfork.h File Reference
#include "config.h"
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  gpgmime_forkinfo

Defines

#define GPG_SE_SIGN   1
#define GPG_SE_ENCRYPT   2

Functions

int libmail_gpgmime_forksignencrypt (const char *, const char *, int,#define GPG_SE_SIGN#define GPG_SE_ENCRYPT int, char **, int(*)(const char *, size_t, void *), void *, struct gpgmime_forkinfo *)
int libmail_gpgmime_forkchecksign (const char *, const char *, const char *, const char *, int, char **, struct gpgmime_forkinfo *)
int libmail_gpgmime_forkdecrypt (const char *, const char *, int, char **, int(*)(const char *, size_t, void *), void *, struct gpgmime_forkinfo *)
void libmail_gpgmime_write (struct gpgmime_forkinfo *, const char *, size_t)
int libmail_gpgmime_finish (struct gpgmime_forkinfo *)
const char * libmail_gpgmime_getoutput (struct gpgmime_forkinfo *)
const char * libmail_gpgmime_getcharset (struct gpgmime_forkinfo *)

Define Documentation

#define GPG_SE_ENCRYPT   2
#define GPG_SE_SIGN   1

Function Documentation

Definition at line 301 of file mimegpgfork.c.

{
       pid_t p2;
       int waitstat;

       gpgmime_writeflush(fi);
       close(fi->togpg_fd);
       sigaction(SIGPIPE, &fi->old_pipe_sig, NULL);

       while (!fi->gpg_errflag &&
              (fi->fromgpg_fd >= 0 || fi->fromgpg_errfd >= 0))
       {
              fd_set fdr;
              int maxfd=0;

              FD_ZERO(&fdr);

              if (fi->fromgpg_fd >= 0)
              {
                     FD_SET(fi->fromgpg_fd, &fdr);
                     if (fi->fromgpg_fd > maxfd)
                            maxfd=fi->fromgpg_fd;
              }

              if (fi->fromgpg_errfd >= 0)
              {
                     FD_SET(fi->fromgpg_errfd, &fdr);
                     if (fi->fromgpg_errfd > maxfd)
                            maxfd=fi->fromgpg_errfd;
              }

              if (select(maxfd+1, &fdr, NULL, NULL, NULL) <= 0)
                     continue;

              libmail_gpgmime_read(fi, &fdr);
       }

       while ((p2=wait(&waitstat)) != fi->gpg_pid)
       {
              if (p2 < 0 && errno == ECHILD)
                     break;
       }

       if (fi->gpg_errflag == 0)
       {
              if (!WIFEXITED(waitstat))
                     fi->gpg_errflag=1;
              else
                     fi->gpg_errflag=WEXITSTATUS(waitstat);
       }
       return (fi->gpg_errflag);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpgmime_forkchecksign ( const char *  ,
const char *  ,
const char *  ,
const char *  ,
int  ,
char **  ,
struct gpgmime_forkinfo  
)

Definition at line 387 of file mimegpgfork.c.

{
       char *xargvec[3];
       char **newargv;
       int i;
       int rc;

       xargvec[0]="--verify";
       xargvec[1]="--charset";
       xargvec[2]=GPG_CHARSET;

       newargv=(char **)malloc((argc+2)*sizeof(char *));
       if (!newargv)
       {
              perror("malloc");
              exit(1);
       }

       for (i=0; i<argc; i++)
              newargv[i]=argv[i];
       newargv[i++]=(char *)signature_filename;
       newargv[i++]=(char *)content_filename;

       rc=libmail_gpgmime_fork(gpgdir, passphrase_fd, 3, xargvec, i, newargv, gpgfi);
       free(newargv);
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpgmime_forkdecrypt ( const char *  ,
const char *  ,
int  ,
char **  ,
int(*)(const char *, size_t, void *)  ,
void *  ,
struct gpgmime_forkinfo  
)

Definition at line 420 of file mimegpgfork.c.

{
       char *xargv[3];
       int rc;

       xargv[0]="--decrypt";
       xargv[1]="--charset";
       xargv[2]=GPG_CHARSET;

       rc=libmail_gpgmime_fork(gpgdir, passphrase_fd, 3, xargv, argc, argv, gpgfi);

       gpgfi->gpg_readhandler= output_func;
       gpgfi->gpg_voidarg= output_voidarg;
       return (rc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int libmail_gpgmime_forksignencrypt ( const char *  ,
const char *  ,
int  ,
#define GPG_SE_SIGN#define GPG_SE_ENCRYPT  int,
char **  ,
int(*)(const char *, size_t, void *)  ,
void *  ,
struct gpgmime_forkinfo  
)
const char* libmail_gpgmime_getcharset ( struct gpgmime_forkinfo )

Definition at line 446 of file mimegpgfork.c.

{
       return (GPG_CHARSET);
}

Here is the caller graph for this function:

const char* libmail_gpgmime_getoutput ( struct gpgmime_forkinfo )

Definition at line 441 of file mimegpgfork.c.

{
       return (gpgfi->gpg_errbuf);
}

Here is the caller graph for this function:

void libmail_gpgmime_write ( struct gpgmime_forkinfo ,
const char *  ,
size_t   
)

Definition at line 181 of file mimegpgfork.c.

{
       while (n)
       {
              size_t i;

              if (fi->gpg_writecnt == sizeof(fi->gpg_writebuf))
                     gpgmime_writeflush(fi);

              i=sizeof(fi->gpg_writebuf) - fi->gpg_writecnt;

              if ((size_t)i > n)
                     i=n;

              memcpy(fi->gpg_writebuf + fi->gpg_writecnt, p, i);

              fi->gpg_writecnt += i;

              p += i;
              n -= i;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function: