Back to index

courier  0.68.2
Classes | Defines | Functions | Variables
moduledel.h File Reference
#include <sys/types.h>
#include <time.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  moduledel

Defines

#define MODULEDEL_MSGNUM(c)   ((c)[0])
#define MODULEDEL_MSGID(c)   ((c)[1])
#define MODULEDEL_SENDER(c)   ((c)[2])
#define MODULEDEL_DELID(c)   ((c)[3])
#define MODULEDEL_HOST(c)   ((c)[4])

Functions

struct moduledelmodule_getdel ()
char * module_getline (int(*)(void *), void *)
char ** module_parsecols (char *)
struct moduledelmodule_parsedel (char **)
void module_init (void(*)(unsigned, unsigned))
void module_completed (unsigned, unsigned)
void module_delivery_timeout (time_t n)
pid_t module_fork (unsigned, unsigned *)
pid_t module_fork_noblock (unsigned, unsigned *)
void module_blockset ()
void module_blockclr ()
void module_restore ()
void module_signal (int)

Variables

unsigned module_nchildren
unsigned * module_delids
pid_t * module_pids

Class Documentation

struct moduledel

Definition at line 31 of file moduledel.h.

Class Members
const char * delid
const char * host
ino_t inum
const char * msgid
unsigned nreceipients
char ** receipients
const char * sender

Define Documentation

#define MODULEDEL_DELID (   c)    ((c)[3])

Definition at line 82 of file moduledel.h.

#define MODULEDEL_HOST (   c)    ((c)[4])

Definition at line 83 of file moduledel.h.

#define MODULEDEL_MSGID (   c)    ((c)[1])

Definition at line 80 of file moduledel.h.

#define MODULEDEL_MSGNUM (   c)    ((c)[0])

Definition at line 79 of file moduledel.h.

#define MODULEDEL_SENDER (   c)    ((c)[2])

Definition at line 81 of file moduledel.h.


Function Documentation

void module_blockclr ( )

Definition at line 247 of file moduledel.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void module_blockset ( )

Definition at line 242 of file moduledel.c.

{
       wait_block();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void module_completed ( unsigned  ,
unsigned   
)

Definition at line 205 of file moduledel.c.

{
char   buf[MAXLONGSIZE+1];
char   *p;
unsigned c;

       i=i;
       p=buf+MAXLONGSIZE-1;
       *p='\n';
       p[1]=0;
       c=1;
       do
       {
              *--p= (n % 10) + '0';
              ++c;
       } while ((n=n / 10) != 0);
       if (write (1, p, c) != c)
              ;
}

Here is the caller graph for this function:

void module_delivery_timeout ( time_t  n)

Definition at line 348 of file moduledel.c.

Here is the caller graph for this function:

pid_t module_fork ( unsigned  ,
unsigned *   
)

Definition at line 358 of file moduledel.c.

{
pid_t  pid;

       module_blockset();

       pid=module_fork_common(delid, slotptr, 1);

       if (pid)
              module_blockclr();
       return (pid);
}

Here is the call graph for this function:

Here is the caller graph for this function:

pid_t module_fork_noblock ( unsigned  ,
unsigned *   
)

Definition at line 353 of file moduledel.c.

{
       return (module_fork_common(delid, slotptr, 0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct moduledel* module_getdel ( ) [read]

Definition at line 194 of file moduledel.c.

{
char   **cols;
char   *line=module_getline( &get_stdin, 0);

       if (!line)    return (0);

       if ((cols=module_parsecols(linebuf)) == 0)       return (0);
       return (module_parsedel(cols));
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* module_getline ( int(*)(void *)  ,
void *   
)

Definition at line 95 of file moduledel.c.

{
size_t n;
int    c;

       for (n=0; ; n++)
       {
              do
              {
                     errno=0;
                     c= (*get_func)(ptr);
              } while (c == EOF && errno == EINTR);

              if (n >= linebufsize)
              {
                     if ((linebuf=(char *)
                            (linebufsize ? realloc(linebuf,
                                   linebufsize += 256):
                                   malloc(linebufsize += 256))) == 0)
                            clog_msg_errno();
              }

              if (c == '\n' || c == EOF)  break;

              linebuf[n]=c;
       }
       linebuf[n]=0;
       if (c == EOF && n == 0)     return (0);
       return (linebuf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void module_init ( void(*)(unsigned, unsigned)  )

Definition at line 268 of file moduledel.c.

{
const  char *p=getenv("MAXDELS");
unsigned n;

       if (!p)       p="0";

       if (!func)
              func= &module_completed;

       module_nchildren=atol(p);
       if (module_nchildren <= 0)  module_nchildren=1;

       if ((module_pids=malloc(module_nchildren*sizeof(*module_pids))) == 0 ||
           (module_delids=malloc(module_nchildren*sizeof(*module_delids))) == 0 ||
           (module_timeout=malloc(module_nchildren*sizeof(*module_timeout)))
           == 0 ||
           (module_sig=malloc(module_nchildren*sizeof(*module_sig))) == 0)
              clog_msg_errno();

       for (n=0; n<module_nchildren; n++)
              module_pids[n]= -1;

       childfunc=func;
       signal(SIGCHLD, childsig);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char** module_parsecols ( char *  )

Definition at line 47 of file moduledel.c.

{
unsigned l;
size_t ncols=1;
size_t n;

       for (l=0; p[l]; l++)
              if (p[l] == '\t')    ++ncols;

       if (ncols >= colcnt)
       {
              colcnt=ncols+10;
              cols=(char **)(cols ? realloc(cols, colcnt*sizeof(char *))
                            : malloc(colcnt*sizeof(char *)));
       }
       ncols=1;
       cols[0]=linebuf;
       for (n=0; p[n]; n++)
              if (p[n] == '\t')
                     cols[ncols++]=p+n+1;
       cols[ncols]=0;
       if (ncols < 6)       return (0);
       return (cols);
}

Here is the caller graph for this function:

struct moduledel* module_parsedel ( char **  ) [read]

Definition at line 72 of file moduledel.c.

{
size_t n;
const char *cp;
static struct moduledel msginfo;

       for (n=1; cols[n]; n++)
              cols[n][-1]=0;

       cp=cols[0];
       msginfo.inum=0;
       while (*cp >= '0' && *cp <= '9')
              msginfo.inum = msginfo.inum*10 + (*cp++ - '0');
       msginfo.msgid=cols[1];

       msginfo.sender=cols[2];
       msginfo.delid=cols[3];
       msginfo.host=cols[4];
       msginfo.receipients=&cols[5];
       msginfo.nreceipients=(n - 5)/2;
       return (&msginfo);
}

Here is the caller graph for this function:

void module_restore ( )

Definition at line 252 of file moduledel.c.

{
       wait_restore();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void module_signal ( int  )

Definition at line 371 of file moduledel.c.

{
       unsigned n;

       module_blockset();

       for (n=0; n<module_nchildren; n++)
              if (module_pids[n] > 0)
              {
                     kill(module_pids[n], signum);
              }
       module_blockclr();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

unsigned* module_delids

Definition at line 41 of file moduledel.c.

unsigned module_nchildren

Definition at line 40 of file moduledel.c.

pid_t* module_pids

Definition at line 42 of file moduledel.c.