Back to index

courier  0.68.2
Functions
comqueuename2.c File Reference
#include "courier.h"
#include "numlib/numlib.h"
#include "comqueuename.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>

Go to the source code of this file.

Functions

static int bigbrother_create_rename (const char *, char *)
void qmsgunlink (ino_t n, time_t rightnow)

Function Documentation

static int bigbrother_create_rename ( const char *  from,
char *  to 
) [static]

Definition at line 76 of file comqueuename2.c.

{
       char *p;

       if (rename(from, to) == 0)
              return (0);

       /* Perhaps the directory has to be created? */

       p=strrchr(to, '/');

       *p=0;
       mkdir(to, 0700);
       *p='/';
       return (rename(from, to));
}

Here is the caller graph for this function:

void qmsgunlink ( ino_t  n,
time_t  rightnow 
)

Definition at line 24 of file comqueuename2.c.

{
       const char *bigbrother=getenv("ARCHIVEDIR");

       if (bigbrother && *bigbrother)
       {
              struct tm *tmptr=localtime(&rightnow);

              /* Archive this message */

              if (tmptr)
              {
                     const char *dname=qmsgsdatname(n);
                     const char *tname=strrchr(dname, '/');

                     char *p=courier_malloc(strlen(bigbrother)+
                                          strlen(tname)+40);

                     sprintf(p, "%s/%04d.%02d.%02d%s",
                            bigbrother, tmptr->tm_year + 1900,
                            tmptr->tm_mon+1,
                            tmptr->tm_mday, tname);

                     if (bigbrother_create_rename(dname, p) == 0)
                     {
                            dname=qmsgsctlname(n);

                            strcpy(strrchr(p, '/'), strrchr(dname, '/'));

                            if (rename(dname, p) == 0)
                            {
                                   free(p);
                                   return;
                            }
                     }

                     clog_msg_start_err();
                     clog_msg_str("Unable to move ");
                     clog_msg_str(dname);
                     clog_msg_str(" to ");
                     clog_msg_str(p);
                     clog_msg_send();
                     clog_msg_prerrno();

                     free(p);
              }
       }

       unlink(qmsgsdatname(n));
       unlink(qmsgsctlname(n));
}

Here is the call graph for this function:

Here is the caller graph for this function: