mailstats.c (182352) | mailstats.c (249729) |
---|---|
1/* | 1/* |
2 * Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers. | 2 * Copyright (c) 1998-2002, 2013 Sendmail, Inc. and its suppliers. |
3 * All rights reserved. 4 * Copyright (c) 1983 Eric P. Allman. All rights reserved. 5 * Copyright (c) 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * By using this file, you agree to the terms and conditions set 9 * forth in the LICENSE file which can be found at the top level of 10 * the sendmail distribution. --- 4 unchanged lines hidden (view full) --- 15#include <sm/gen.h> 16 17SM_IDSTR(copyright, 18"@(#) Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.\n\ 19 All rights reserved.\n\ 20 Copyright (c) 1988, 1993\n\ 21 The Regents of the University of California. All rights reserved.\n") 22 | 3 * All rights reserved. 4 * Copyright (c) 1983 Eric P. Allman. All rights reserved. 5 * Copyright (c) 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * By using this file, you agree to the terms and conditions set 9 * forth in the LICENSE file which can be found at the top level of 10 * the sendmail distribution. --- 4 unchanged lines hidden (view full) --- 15#include <sm/gen.h> 16 17SM_IDSTR(copyright, 18"@(#) Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.\n\ 19 All rights reserved.\n\ 20 Copyright (c) 1988, 1993\n\ 21 The Regents of the University of California. All rights reserved.\n") 22 |
23SM_IDSTR(id, "@(#)$Id: mailstats.c,v 8.100 2002/06/27 23:24:06 gshapiro Exp $") | 23SM_IDSTR(id, "@(#)$Id: mailstats.c,v 8.102 2013/03/12 15:24:50 ca Exp $") |
24 25#include <unistd.h> 26#include <stddef.h> 27#include <stdlib.h> 28#include <ctype.h> 29#include <string.h> 30#include <time.h> 31#ifdef EX_OK --- 31 unchanged lines hidden (view full) --- 63 time_t now; 64 char mtable[MAXMAILERS][MNAMELEN + 1]; 65 char sfilebuf[MAXPATHLEN]; 66 char buf[MAXLINE]; 67 struct statistics stats; 68 extern char *ctime(); 69 extern char *optarg; 70 extern int optind; | 24 25#include <unistd.h> 26#include <stddef.h> 27#include <stdlib.h> 28#include <ctype.h> 29#include <string.h> 30#include <time.h> 31#ifdef EX_OK --- 31 unchanged lines hidden (view full) --- 63 time_t now; 64 char mtable[MAXMAILERS][MNAMELEN + 1]; 65 char sfilebuf[MAXPATHLEN]; 66 char buf[MAXLINE]; 67 struct statistics stats; 68 extern char *ctime(); 69 extern char *optarg; 70 extern int optind; |
71# define MSOPTS "cC:f:opP" |
|
71 72 cfile = getcfname(0, 0, SM_GET_SENDMAIL_CF, NULL); 73 sfile = NULL; 74 mnames = true; 75 progmode = false; 76 trunc = false; | 72 73 cfile = getcfname(0, 0, SM_GET_SENDMAIL_CF, NULL); 74 sfile = NULL; 75 mnames = true; 76 progmode = false; 77 trunc = false; |
77 while ((ch = getopt(argc, argv, "cC:f:opP")) != -1) | 78 while ((ch = getopt(argc, argv, MSOPTS)) != -1) |
78 { 79 switch (ch) 80 { 81 case 'c': 82 cfile = getcfname(0, 0, SM_GET_SUBMIT_CF, NULL); 83 break; 84 85 case 'C': 86 cfile = optarg; 87 break; 88 89 case 'f': 90 sfile = optarg; 91 break; 92 | 79 { 80 switch (ch) 81 { 82 case 'c': 83 cfile = getcfname(0, 0, SM_GET_SUBMIT_CF, NULL); 84 break; 85 86 case 'C': 87 cfile = optarg; 88 break; 89 90 case 'f': 91 sfile = optarg; 92 break; 93 |
94 |
|
93 case 'o': 94 mnames = false; 95 break; 96 97 case 'p': 98 trunc = true; 99 /* FALLTHROUGH */ 100 101 case 'P': 102 progmode = true; 103 break; 104 | 95 case 'o': 96 mnames = false; 97 break; 98 99 case 'p': 100 trunc = true; 101 /* FALLTHROUGH */ 102 103 case 'P': 104 progmode = true; 105 break; 106 |
107 |
|
105 case '?': 106 default: 107 usage: 108 (void) sm_io_fputs(smioerr, SM_TIME_DEFAULT, 109 "usage: mailstats [-C cffile] [-c] [-P] [-f stfile] [-o] [-p]\n"); 110 exit(EX_USAGE); 111 } 112 } --- 13 unchanged lines hidden (view full) --- 126 exit(EX_NOINPUT); 127 } 128 129 mno = 0; 130 (void) sm_strlcpy(mtable[mno++], "prog", MNAMELEN + 1); 131 (void) sm_strlcpy(mtable[mno++], "*file*", MNAMELEN + 1); 132 (void) sm_strlcpy(mtable[mno++], "*include*", MNAMELEN + 1); 133 | 108 case '?': 109 default: 110 usage: 111 (void) sm_io_fputs(smioerr, SM_TIME_DEFAULT, 112 "usage: mailstats [-C cffile] [-c] [-P] [-f stfile] [-o] [-p]\n"); 113 exit(EX_USAGE); 114 } 115 } --- 13 unchanged lines hidden (view full) --- 129 exit(EX_NOINPUT); 130 } 131 132 mno = 0; 133 (void) sm_strlcpy(mtable[mno++], "prog", MNAMELEN + 1); 134 (void) sm_strlcpy(mtable[mno++], "*file*", MNAMELEN + 1); 135 (void) sm_strlcpy(mtable[mno++], "*include*", MNAMELEN + 1); 136 |
134 while (sm_io_fgets(cfp, SM_TIME_DEFAULT, buf, sizeof(buf)) != NULL) | 137 while (sm_io_fgets(cfp, SM_TIME_DEFAULT, buf, sizeof(buf)) >= 0) |
135 { 136 register char *b; 137 char *s; 138 register char *m; 139 140 b = strchr(buf, '#'); 141 if (b == NULL) 142 b = strchr(buf, '\n'); --- 122 unchanged lines hidden (view full) --- 265 else if (i != sizeof stats || stats.stat_size != sizeof(stats)) 266 { 267 (void) sm_io_fputs(smioerr, SM_TIME_DEFAULT, 268 "mailstats: file size changed.\n"); 269 exit(EX_OSERR); 270 } 271 } 272 | 138 { 139 register char *b; 140 char *s; 141 register char *m; 142 143 b = strchr(buf, '#'); 144 if (b == NULL) 145 b = strchr(buf, '\n'); --- 122 unchanged lines hidden (view full) --- 268 else if (i != sizeof stats || stats.stat_size != sizeof(stats)) 269 { 270 (void) sm_io_fputs(smioerr, SM_TIME_DEFAULT, 271 "mailstats: file size changed.\n"); 272 exit(EX_OSERR); 273 } 274 } 275 |
276 |
|
273 if (progmode) 274 { 275 (void) time(&now); 276 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%ld %ld\n", 277 (long) stats.stat_itime, (long) now); 278 } 279 else 280 { --- 88 unchanged lines hidden --- | 277 if (progmode) 278 { 279 (void) time(&now); 280 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%ld %ld\n", 281 (long) stats.stat_itime, (long) now); 282 } 283 else 284 { --- 88 unchanged lines hidden --- |