sample.html revision 120256
190792Sgshapiro<html> 290792Sgshapiro<head><title>A Sample Filter</title></head> 390792Sgshapiro<body> 490792Sgshapiro<h1>A Sample Filter</h1> 590792Sgshapiro 690792SgshapiroThe following sample logs each message to a separate temporary file, 790792Sgshapiroadds a recipient given with the -a flag, and rejects a disallowed 890792Sgshapirorecipient address given with the -r flag. It recognizes the following 990792Sgshapirooptions: 1090792Sgshapiro<p> 1190792Sgshapiro<center> 1290792Sgshapiro<table border="1" cellpadding=2 cellspacing=1> 1390792Sgshapiro<tr><td><code>-p port</code></td><td>The port through which the MTA will connect to the filter.</td></tr> 1490792Sgshapiro<tr><td><code>-t sec</code></td><td>The timeout value.</td></tr> 1590792Sgshapiro<tr><td><code>-r addr</code></td><td>A recipient to reject.</td></tr> 1690792Sgshapiro<tr><td><code>-a addr</code></td><td>A recipient to add.</td></tr> 1790792Sgshapiro</table> 1890792Sgshapiro</center> 1990792Sgshapiro<hr> 2090792Sgshapiro<pre> 2198121Sgshapiro#include <sys/types.h> 2298121Sgshapiro#include <sys/stat.h> 2398121Sgshapiro#include <errno.h> 2490792Sgshapiro#include <stdio.h> 2590792Sgshapiro#include <stdlib.h> 2690792Sgshapiro#include <string.h> 2790792Sgshapiro#include <sysexits.h> 2890792Sgshapiro#include <unistd.h> 2998121Sgshapiro 3098121Sgshapiro#include "libmilter/mfapi.h" 3198121Sgshapiro 3290792Sgshapiro#ifndef bool 3398121Sgshapiro# define bool int 3498121Sgshapiro# define TRUE 1 3598121Sgshapiro# define FALSE 0 3698121Sgshapiro#endif /* ! bool */ 3790792Sgshapiro 3890792Sgshapiro 3990792Sgshapirostruct mlfiPriv 4090792Sgshapiro{ 4198121Sgshapiro char *mlfi_fname; 4298121Sgshapiro char *mlfi_connectfrom; 4398121Sgshapiro char *mlfi_helofrom; 4498121Sgshapiro FILE *mlfi_fp; 4590792Sgshapiro}; 4690792Sgshapiro 4798121Sgshapiro#define MLFIPRIV ((struct mlfiPriv *) <a href="smfi_getpriv.html">smfi_getpriv</a>(ctx)) 4890792Sgshapiro 4998121Sgshapiroextern sfsistat mlfi_cleanup(SMFICTX *, bool); 5098121Sgshapiro 5190792Sgshapiro/* recipients to add and reject (set with -a and -r options) */ 5298121Sgshapirochar *add = NULL; 5398121Sgshapirochar *reject = NULL; 5490792Sgshapiro 5590792Sgshapirosfsistat 5690792Sgshapiro<a href="xxfi_connect.html">mlfi_connect</a>(ctx, hostname, hostaddr) 5798121Sgshapiro SMFICTX *ctx; 5898121Sgshapiro char *hostname; 5998121Sgshapiro _SOCK_ADDR *hostaddr; 6090792Sgshapiro{ 6198121Sgshapiro struct mlfiPriv *priv; 6298121Sgshapiro char *ident; 6390792Sgshapiro 6498121Sgshapiro /* allocate some private memory */ 6598121Sgshapiro priv = malloc(sizeof *priv); 6698121Sgshapiro if (priv == NULL) 6798121Sgshapiro { 6898121Sgshapiro /* can't accept this message right now */ 6998121Sgshapiro return SMFIS_TEMPFAIL; 7098121Sgshapiro } 7198121Sgshapiro memset(priv, '\0', sizeof *priv); 7290792Sgshapiro 7398121Sgshapiro /* save the private data */ 7498121Sgshapiro <a href="smfi_setpriv.html">smfi_setpriv</a>(ctx, priv); 7598121Sgshapiro 7698121Sgshapiro ident = <a href="smfi_getsymval.html">smfi_getsymval</a>(ctx, "_"); 7798121Sgshapiro if (ident == NULL) 7898121Sgshapiro ident = "???"; 7998121Sgshapiro if ((priv->mlfi_connectfrom = strdup(ident)) == NULL) 8098121Sgshapiro { 8198121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 8298121Sgshapiro return SMFIS_TEMPFAIL; 8398121Sgshapiro } 8498121Sgshapiro 8598121Sgshapiro /* continue processing */ 8698121Sgshapiro return SMFIS_CONTINUE; 8790792Sgshapiro} 8890792Sgshapiro 8990792Sgshapirosfsistat 9090792Sgshapiro<a href="xxfi_helo.html">mlfi_helo</a>(ctx, helohost) 9198121Sgshapiro SMFICTX *ctx; 9298121Sgshapiro char *helohost; 9390792Sgshapiro{ 9498121Sgshapiro size_t len; 9598121Sgshapiro char *tls; 9698121Sgshapiro char *buf; 9798121Sgshapiro struct mlfiPriv *priv = MLFIPRIV; 9898121Sgshapiro 9998121Sgshapiro tls = <a href="smfi_getsymval.html">smfi_getsymval</a>(ctx, "{tls_version}"); 10098121Sgshapiro if (tls == NULL) 10198121Sgshapiro tls = "No TLS"; 10298121Sgshapiro if (helohost == NULL) 10398121Sgshapiro helohost = "???"; 10498121Sgshapiro len = strlen(tls) + strlen(helohost) + 3; 10598121Sgshapiro if ((buf = (char*) malloc(len)) == NULL) 10698121Sgshapiro { 10798121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 10898121Sgshapiro return SMFIS_TEMPFAIL; 10998121Sgshapiro } 11098121Sgshapiro snprintf(buf, len, "%s, %s", helohost, tls); 11198121Sgshapiro if (priv->mlfi_helofrom != NULL) 11298121Sgshapiro free(priv->mlfi_helofrom); 11398121Sgshapiro priv->mlfi_helofrom = buf; 11498121Sgshapiro 11598121Sgshapiro /* continue processing */ 11698121Sgshapiro return SMFIS_CONTINUE; 11790792Sgshapiro} 11890792Sgshapiro 11990792Sgshapirosfsistat 12090792Sgshapiro<a href="xxfi_envfrom.html">mlfi_envfrom</a>(ctx, argv) 12198121Sgshapiro SMFICTX *ctx; 12298121Sgshapiro char **argv; 12390792Sgshapiro{ 12498121Sgshapiro struct mlfiPriv *priv = MLFIPRIV; 12598121Sgshapiro char *mailaddr = <a href="smfi_getsymval.html">smfi_getsymval</a>(ctx, "{mail_addr}"); 12698121Sgshapiro int argc = 0; 12790792Sgshapiro 12898121Sgshapiro /* open a file to store this message */ 12998121Sgshapiro if ((priv->mlfi_fname = strdup("/tmp/msg.XXXXXX")) == NULL) 13098121Sgshapiro { 13198121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 13298121Sgshapiro return SMFIS_TEMPFAIL; 13398121Sgshapiro } 13490792Sgshapiro 13598121Sgshapiro if (mkstemp(priv->mlfi_fname) == -1) 13698121Sgshapiro { 13798121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 13898121Sgshapiro return SMFIS_TEMPFAIL; 13998121Sgshapiro } 14098121Sgshapiro 14198121Sgshapiro if ((priv->mlfi_fp = fopen(priv->mlfi_fname, "w+")) == NULL) 14298121Sgshapiro { 14398121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 14498121Sgshapiro return SMFIS_TEMPFAIL; 14598121Sgshapiro } 14698121Sgshapiro 14798121Sgshapiro /* count the arguments */ 14898121Sgshapiro while (*argv++ != NULL) 14998121Sgshapiro ++argc; 15098121Sgshapiro 15198121Sgshapiro /* log the connection information we stored earlier: */ 15298121Sgshapiro if (fprintf(priv->mlfi_fp, "Connect from %s (%s)\n\n", 15398121Sgshapiro priv->mlfi_helofrom, priv->mlfi_connectfrom) == EOF) 15498121Sgshapiro { 15598121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 15698121Sgshapiro return SMFIS_TEMPFAIL; 15798121Sgshapiro } 15898121Sgshapiro /* log the sender */ 15998121Sgshapiro if (fprintf(priv->mlfi_fp, "FROM %s (%d argument%s)\n", 16098121Sgshapiro mailaddr ? mailaddr : "???", argc, 16198121Sgshapiro (argc == 1) ? "" : "s") == EOF) 16298121Sgshapiro { 16398121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 16498121Sgshapiro return SMFIS_TEMPFAIL; 16598121Sgshapiro } 16698121Sgshapiro 16798121Sgshapiro /* continue processing */ 16898121Sgshapiro return SMFIS_CONTINUE; 16990792Sgshapiro} 17090792Sgshapiro 17190792Sgshapirosfsistat 17290792Sgshapiro<a href="xxfi_envrcpt.html">mlfi_envrcpt</a>(ctx, argv) 17398121Sgshapiro SMFICTX *ctx; 17498121Sgshapiro char **argv; 17590792Sgshapiro{ 17698121Sgshapiro struct mlfiPriv *priv = MLFIPRIV; 17798121Sgshapiro char *rcptaddr = <a href="smfi_getsymval.html">smfi_getsymval</a>(ctx, "{rcpt_addr}"); 17898121Sgshapiro int argc = 0; 17998121Sgshapiro 18098121Sgshapiro /* count the arguments */ 18198121Sgshapiro while (*argv++ != NULL) 18298121Sgshapiro ++argc; 18398121Sgshapiro 18498121Sgshapiro /* log this recipient */ 18598121Sgshapiro if (reject != NULL && rcptaddr != NULL && 18698121Sgshapiro (strcasecmp(rcptaddr, reject) == 0)) 18798121Sgshapiro { 18898121Sgshapiro if (fprintf(priv->mlfi_fp, "RCPT %s -- REJECTED\n", 18998121Sgshapiro rcptaddr) == EOF) 19098121Sgshapiro { 19198121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 19298121Sgshapiro return SMFIS_TEMPFAIL; 19398121Sgshapiro } 19498121Sgshapiro return SMFIS_REJECT; 19590792Sgshapiro } 19698121Sgshapiro if (fprintf(priv->mlfi_fp, "RCPT %s (%d argument%s)\n", 19798121Sgshapiro rcptaddr ? rcptaddr : "???", argc, 19898121Sgshapiro (argc == 1) ? "" : "s") == EOF) 19998121Sgshapiro { 20098121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 20198121Sgshapiro return SMFIS_TEMPFAIL; 20298121Sgshapiro } 20398121Sgshapiro 20498121Sgshapiro /* continue processing */ 20598121Sgshapiro return SMFIS_CONTINUE; 20690792Sgshapiro} 20790792Sgshapiro 20890792Sgshapirosfsistat 20990792Sgshapiro<a href="xxfi_header.html">mlfi_header</a>(ctx, headerf, headerv) 21098121Sgshapiro SMFICTX *ctx; 21198121Sgshapiro char *headerf; 21298121Sgshapiro unsigned char *headerv; 21390792Sgshapiro{ 21498121Sgshapiro /* write the header to the log file */ 21598121Sgshapiro if (fprintf(MLFIPRIV->mlfi_fp, "%s: %s\n", headerf, headerv) == EOF) 21698121Sgshapiro { 21798121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 21898121Sgshapiro return SMFIS_TEMPFAIL; 21998121Sgshapiro } 22090792Sgshapiro 22198121Sgshapiro /* continue processing */ 22298121Sgshapiro return SMFIS_CONTINUE; 22390792Sgshapiro} 22490792Sgshapiro 22590792Sgshapirosfsistat 22690792Sgshapiro<a href="xxfi_eoh.html">mlfi_eoh</a>(ctx) 22798121Sgshapiro SMFICTX *ctx; 22890792Sgshapiro{ 22998121Sgshapiro /* output the blank line between the header and the body */ 23098121Sgshapiro if (fprintf(MLFIPRIV->mlfi_fp, "\n") == EOF) 23198121Sgshapiro { 23298121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 23398121Sgshapiro return SMFIS_TEMPFAIL; 23498121Sgshapiro } 23590792Sgshapiro 23698121Sgshapiro /* continue processing */ 23798121Sgshapiro return SMFIS_CONTINUE; 23890792Sgshapiro} 23990792Sgshapiro 24090792Sgshapirosfsistat 24190792Sgshapiro<a href="xxfi_body.html">mlfi_body</a>(ctx, bodyp, bodylen) 24298121Sgshapiro SMFICTX *ctx; 24398121Sgshapiro unsigned char *bodyp; 24498121Sgshapiro size_t bodylen; 24590792Sgshapiro{ 24698121Sgshapiro struct mlfiPriv *priv = MLFIPRIV; 24790792Sgshapiro 24898121Sgshapiro /* output body block to log file */ 24998121Sgshapiro if (fwrite(bodyp, bodylen, 1, priv->mlfi_fp) != 1) 25098121Sgshapiro { 25198121Sgshapiro /* write failed */ 25298121Sgshapiro fprintf(stderr, "Couldn't write file %s: %s\n", 25398121Sgshapiro priv->mlfi_fname, strerror(errno)); 25498121Sgshapiro (void) mlfi_cleanup(ctx, FALSE); 25598121Sgshapiro return SMFIS_TEMPFAIL; 25698121Sgshapiro } 25798121Sgshapiro 25898121Sgshapiro /* continue processing */ 25998121Sgshapiro return SMFIS_CONTINUE; 26090792Sgshapiro} 26190792Sgshapiro 26290792Sgshapirosfsistat 26390792Sgshapiro<a href="xxfi_eom.html">mlfi_eom</a>(ctx) 26498121Sgshapiro SMFICTX *ctx; 26590792Sgshapiro{ 26698121Sgshapiro bool ok = TRUE; 26798121Sgshapiro 26898121Sgshapiro /* change recipients, if requested */ 26998121Sgshapiro if (add != NULL) 27098121Sgshapiro ok = (<a href="smfi_addrcpt.html">smfi_addrcpt</a>(ctx, add) == MI_SUCCESS); 27198121Sgshapiro return mlfi_cleanup(ctx, ok); 27290792Sgshapiro} 27390792Sgshapiro 27490792Sgshapirosfsistat 27590792Sgshapiro<a href="xxfi_abort.html">mlfi_abort</a>(ctx) 27698121Sgshapiro SMFICTX *ctx; 27790792Sgshapiro{ 27898121Sgshapiro return mlfi_cleanup(ctx, FALSE); 27990792Sgshapiro} 28090792Sgshapiro 28190792Sgshapirosfsistat 28290792Sgshapiromlfi_cleanup(ctx, ok) 28398121Sgshapiro SMFICTX *ctx; 28498121Sgshapiro bool ok; 28590792Sgshapiro{ 28698121Sgshapiro sfsistat rstat = SMFIS_CONTINUE; 28798121Sgshapiro struct mlfiPriv *priv = MLFIPRIV; 28898121Sgshapiro char *p; 28998121Sgshapiro char host[512]; 29098121Sgshapiro char hbuf[1024]; 29190792Sgshapiro 29298121Sgshapiro if (priv == NULL) 29398121Sgshapiro return rstat; 29490792Sgshapiro 29598121Sgshapiro /* close the archive file */ 29698121Sgshapiro if (priv->mlfi_fp != NULL && fclose(priv->mlfi_fp) == EOF) 29798121Sgshapiro { 29898121Sgshapiro /* failed; we have to wait until later */ 29998121Sgshapiro fprintf(stderr, "Couldn't close archive file %s: %s\n", 30098121Sgshapiro priv->mlfi_fname, strerror(errno)); 30198121Sgshapiro rstat = SMFIS_TEMPFAIL; 30298121Sgshapiro (void) unlink(priv->mlfi_fname); 30398121Sgshapiro } 30498121Sgshapiro else if (ok) 30598121Sgshapiro { 30698121Sgshapiro /* add a header to the message announcing our presence */ 30798121Sgshapiro if (gethostname(host, sizeof host) < 0) 30898121Sgshapiro snprintf(host, sizeof host, "localhost"); 30998121Sgshapiro p = strrchr(priv->mlfi_fname, '/'); 31098121Sgshapiro if (p == NULL) 31198121Sgshapiro p = priv->mlfi_fname; 31298121Sgshapiro else 31398121Sgshapiro p++; 31498121Sgshapiro snprintf(hbuf, sizeof hbuf, "%s@%s", p, host); 31598121Sgshapiro if (<a href="smfi_addheader.html">smfi_addheader</a>(ctx, "X-Archived", hbuf) != MI_SUCCESS) 31698121Sgshapiro { 31798121Sgshapiro /* failed; we have to wait until later */ 31898121Sgshapiro fprintf(stderr, 31998121Sgshapiro "Couldn't add header: X-Archived: %s\n", 32098121Sgshapiro hbuf); 32198121Sgshapiro ok = FALSE; 32298121Sgshapiro rstat = SMFIS_TEMPFAIL; 32398121Sgshapiro (void) unlink(priv->mlfi_fname); 32498121Sgshapiro } 32598121Sgshapiro } 32690792Sgshapiro else 32798121Sgshapiro { 32898121Sgshapiro /* message was aborted -- delete the archive file */ 32998121Sgshapiro fprintf(stderr, "Message aborted. Removing %s\n", 33098121Sgshapiro priv->mlfi_fname); 33198121Sgshapiro rstat = SMFIS_TEMPFAIL; 33298121Sgshapiro (void) unlink(priv->mlfi_fname); 33398121Sgshapiro } 33490792Sgshapiro 33598121Sgshapiro /* release private memory */ 33698121Sgshapiro if (priv->mlfi_fname != NULL) 33798121Sgshapiro free(priv->mlfi_fname); 33890792Sgshapiro 33998121Sgshapiro /* return status */ 34098121Sgshapiro return rstat; 34190792Sgshapiro} 34290792Sgshapiro 34390792Sgshapirosfsistat 34490792Sgshapiro<a href="xxfi_close.html">mlfi_close</a>(ctx) 34598121Sgshapiro SMFICTX *ctx; 34690792Sgshapiro{ 34798121Sgshapiro struct mlfiPriv *priv = MLFIPRIV; 34898121Sgshapiro 34998121Sgshapiro if (priv == NULL) 35098121Sgshapiro return SMFIS_CONTINUE; 35198121Sgshapiro if (priv->mlfi_connectfrom != NULL) 35298121Sgshapiro free(priv->mlfi_connectfrom); 35398121Sgshapiro if (priv->mlfi_helofrom != NULL) 35498121Sgshapiro free(priv->mlfi_helofrom); 35598121Sgshapiro free(priv); 35698121Sgshapiro <a href="smfi_setpriv.html">smfi_setpriv</a>(ctx, NULL); 35798121Sgshapiro return SMFIS_CONTINUE; 35890792Sgshapiro} 35990792Sgshapiro 36090792Sgshapirostruct smfiDesc smfilter = 36190792Sgshapiro{ 36298121Sgshapiro "SampleFilter", /* filter name */ 36398121Sgshapiro SMFI_VERSION, /* version code -- do not change */ 36498121Sgshapiro SMFIF_ADDHDRS, /* flags */ 36598121Sgshapiro <a href="xxfi_connect.html">mlfi_connect</a>, /* connection info filter */ 36698121Sgshapiro <a href="xxfi_helo.html">mlfi_helo</a>, /* SMTP HELO command filter */ 36798121Sgshapiro <a href="xxfi_envfrom.html">mlfi_envfrom</a>, /* envelope sender filter */ 36898121Sgshapiro <a href="xxfi_envrcpt.html">mlfi_envrcpt</a>, /* envelope recipient filter */ 36998121Sgshapiro <a href="xxfi_header.html">mlfi_header</a>, /* header filter */ 37098121Sgshapiro <a href="xxfi_eoh.html">mlfi_eoh</a>, /* end of header */ 37198121Sgshapiro <a href="xxfi_body.html">mlfi_body</a>, /* body block filter */ 37298121Sgshapiro <a href="xxfi_eom.html">mlfi_eom</a>, /* end of message */ 37398121Sgshapiro <a href="xxfi_abort.html">mlfi_abort</a>, /* message aborted */ 37498121Sgshapiro <a href="xxfi_close.html">mlfi_close</a>, /* connection cleanup */ 37590792Sgshapiro}; 37690792Sgshapiro 37798121Sgshapirostatic void 37898121Sgshapirousage(prog) 37998121Sgshapiro char *prog; 38090792Sgshapiro{ 38198121Sgshapiro fprintf(stderr, 382120256Sgshapiro "Usage: %s -p socket-addr [-t timeout] [-r reject-addr] [-a add-addr]\n", 38398121Sgshapiro prog); 38490792Sgshapiro} 38590792Sgshapiro 38690792Sgshapiroint 38790792Sgshapiromain(argc, argv) 38898121Sgshapiro int argc; 38998121Sgshapiro char **argv; 39090792Sgshapiro{ 391120256Sgshapiro bool setconn = FALSE; 39298121Sgshapiro int c; 39398121Sgshapiro const char *args = "p:t:r:a:h"; 39498121Sgshapiro extern char *optarg; 39590792Sgshapiro 39698121Sgshapiro /* Process command line options */ 39798121Sgshapiro while ((c = getopt(argc, argv, args)) != -1) 39890792Sgshapiro { 39998121Sgshapiro switch (c) 40098121Sgshapiro { 40198121Sgshapiro case 'p': 40298121Sgshapiro if (optarg == NULL || *optarg == '\0') 40398121Sgshapiro { 40498121Sgshapiro (void) fprintf(stderr, "Illegal conn: %s\n", 40598121Sgshapiro optarg); 40698121Sgshapiro exit(EX_USAGE); 40798121Sgshapiro } 40898121Sgshapiro if (<a href="smfi_setconn.html">smfi_setconn</a>(optarg) == MI_FAILURE) 40998121Sgshapiro { 41098121Sgshapiro (void) fprintf(stderr, 41198121Sgshapiro "smfi_setconn failed\n"); 41298121Sgshapiro exit(EX_SOFTWARE); 41398121Sgshapiro } 41490792Sgshapiro 41598121Sgshapiro /* 41698121Sgshapiro ** If we're using a local socket, make sure it 41798121Sgshapiro ** doesn't already exist. Don't ever run this 41898121Sgshapiro ** code as root!! 41998121Sgshapiro */ 42090792Sgshapiro 42198121Sgshapiro if (strncasecmp(optarg, "unix:", 5) == 0) 42298121Sgshapiro unlink(optarg + 5); 42398121Sgshapiro else if (strncasecmp(optarg, "local:", 6) == 0) 42498121Sgshapiro unlink(optarg + 6); 425120256Sgshapiro setconn = TRUE; 42698121Sgshapiro break; 42790792Sgshapiro 42898121Sgshapiro case 't': 42998121Sgshapiro if (optarg == NULL || *optarg == '\0') 43098121Sgshapiro { 43198121Sgshapiro (void) fprintf(stderr, "Illegal timeout: %s\n", 43298121Sgshapiro optarg); 43398121Sgshapiro exit(EX_USAGE); 43498121Sgshapiro } 43598121Sgshapiro if (<a href="smfi_settimeout.html">smfi_settimeout</a>(atoi(optarg)) == MI_FAILURE) 43698121Sgshapiro { 43798121Sgshapiro (void) fprintf(stderr, 43898121Sgshapiro "smfi_settimeout failed\n"); 43998121Sgshapiro exit(EX_SOFTWARE); 44098121Sgshapiro } 44198121Sgshapiro break; 44298121Sgshapiro 44398121Sgshapiro case 'r': 44498121Sgshapiro if (optarg == NULL) 44598121Sgshapiro { 44698121Sgshapiro (void) fprintf(stderr, 44798121Sgshapiro "Illegal reject rcpt: %s\n", 44898121Sgshapiro optarg); 44998121Sgshapiro exit(EX_USAGE); 45098121Sgshapiro } 45198121Sgshapiro reject = optarg; 45298121Sgshapiro break; 45398121Sgshapiro 45498121Sgshapiro case 'a': 45598121Sgshapiro if (optarg == NULL) 45698121Sgshapiro { 45798121Sgshapiro (void) fprintf(stderr, 45898121Sgshapiro "Illegal add rcpt: %s\n", 45998121Sgshapiro optarg); 46098121Sgshapiro exit(EX_USAGE); 46198121Sgshapiro } 46298121Sgshapiro add = optarg; 46398121Sgshapiro smfilter.xxfi_flags |= SMFIF_ADDRCPT; 46498121Sgshapiro break; 46598121Sgshapiro 46698121Sgshapiro case 'h': 46798121Sgshapiro default: 46898121Sgshapiro usage(argv[0]); 46998121Sgshapiro exit(EX_USAGE); 47098121Sgshapiro } 47190792Sgshapiro } 472120256Sgshapiro if (!setconn) 473120256Sgshapiro { 474120256Sgshapiro fprintf(stderr, "%s: Missing required -p argument\n", argv[0]); 475120256Sgshapiro usage(argv[0]); 476120256Sgshapiro exit(EX_USAGE); 477120256Sgshapiro } 47898121Sgshapiro if (<a href="smfi_register.html">smfi_register</a>(smfilter) == MI_FAILURE) 47998121Sgshapiro { 48098121Sgshapiro fprintf(stderr, "smfi_register failed\n"); 48198121Sgshapiro exit(EX_UNAVAILABLE); 48298121Sgshapiro } 48398121Sgshapiro return <a href="smfi_main.html">smfi_main</a>(); 48490792Sgshapiro} 48590792Sgshapiro 48690792Sgshapiro/* eof */ 48790792Sgshapiro 48890792Sgshapiro</pre> 48990792Sgshapiro<hr size="1"> 49090792Sgshapiro<font size="-1"> 491112810SgshapiroCopyright (c) 2000-2003 Sendmail, Inc. and its suppliers. 49290792SgshapiroAll rights reserved. 49390792Sgshapiro<br> 49490792SgshapiroBy using this file, you agree to the terms and conditions set 495112810Sgshapiroforth in the LICENSE. 49690792Sgshapiro</font> 49790792Sgshapiro</body> 49890792Sgshapiro</html> 499