Back to index

courier  0.68.2
cancelmsg.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 #include      "courier.h"
00007 #include      "comqueuename.h"
00008 #include      "commsgcancel.h"
00009 #include      "comctlfile.h"
00010 #include      "comparseqid.h"
00011 #include      "comctlfile.h"
00012 #include      <sys/types.h>
00013 #include      <sys/uio.h>
00014 #include      <string.h>
00015 #include      <signal.h>
00016 #include      <stdlib.h>
00017 #if    HAVE_UNISTD_H
00018 #include      <unistd.h>
00019 #endif
00020 #if    HAVE_FCNTL_H
00021 #include      <fcntl.h>
00022 #endif
00023 #if    HAVE_SYS_IOCTL_H
00024 #include      <sys/ioctl.h>
00025 #endif
00026 #if    HAVE_SYS_STAT_H
00027 #include      <sys/stat.h>
00028 #endif
00029 
00030 /*
00031 **     NOTE - this program must be setuid and setgid to daemon.
00032 **     setuid is required - queue file is read-only by owner.
00033 */
00034 
00035 int main(int argc, char **argv)
00036 {
00037 const  char *qid;
00038 
00039        if (chdir(courierdir()))
00040        {
00041               perror("chdir");
00042               return (1);
00043        }
00044        if (argc < 2) return (0);
00045 
00046        qid=argv[1];
00047        if (msgcancel(qid, (const char **)argv+2, argc-2, 1))
00048        {
00049               fprintf(stderr, "Message not found.\n");
00050               exit(1);
00051        }
00052        printf("Message scheduled for cancellation.\n");
00053        return (0);
00054 }