Back to index

courier  0.68.2
comqueuename.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 1999 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #if    HAVE_CONFIG_H
00007 #include      "courier_lib_config.h"
00008 #endif
00009 #include      "courier.h"
00010 #include      "localstatedir.h"
00011 #include      "comqueuename.h"
00012 #include      "maxlongsize.h"
00013 #include      "comstrinode.h"
00014 #include      "comstrtimestamp.h"
00015 #include      <stdlib.h>
00016 #include      <string.h>
00017 
00018 const char *qmsgsdir(ino_t inum)
00019 {
00020 static char buf[MAXLONGSIZE + 10 + sizeof(MSGSDIR "/") ];
00021 
00022        return (strcat(strcpy(buf, MSGSDIR "/"),
00023               strinode(inum % QDIRCOUNT)));
00024 }
00025 
00026 static const char * qmsgsname(ino_t inum, const char *type)
00027 {
00028 static char buf[MAXLONGSIZE*2+20 ];
00029 
00030        strcpy(buf, qmsgsdir(inum));
00031        return (strcat(strcat(strcat(buf, "/"), type), strinode(inum)));
00032 }
00033 
00034 const char *qmsgsctlname(ino_t inum)
00035 {
00036        return (qmsgsname(inum, "C"));
00037 }
00038 
00039 const char *qmsgsdatname(ino_t inum)
00040 {
00041        return (qmsgsname(inum, "D"));
00042 }
00043 
00044 const char *qmsgqdir(time_t t)
00045 {
00046 static char buf[MAXLONGSIZE + 10 + sizeof(MSGQDIR "/") ];
00047 
00048        strcat(strcpy(buf, MSGQDIR "/"), strtimestamp(t));
00049        buf[strlen(buf)-4]=0;       /* I'm pretty sure it's at least 1971 */
00050        return (buf);
00051 }
00052 
00053 const char *qmsgqname(ino_t i, time_t t)
00054 {
00055 static char buf[MAXLONGSIZE*3 + 25 + sizeof(MSGQDIR "/") ];
00056 
00057        strcat(strcpy(buf, qmsgqdir(t)), "/C");
00058        strcat(buf, strinode(i));
00059        strcat(buf, ".");
00060        strcat(buf, strtimestamp(t));
00061        return (buf);
00062 }