| 1 |  |  | /*	$OpenBSD: delivery.c,v 1.6 2015/01/20 17:37:54 deraadt Exp $	*/ | 
    
    | 2 |  |  |  | 
    
    | 3 |  |  | /* | 
    
    | 4 |  |  |  * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> | 
    
    | 5 |  |  |  * | 
    
    | 6 |  |  |  * Permission to use, copy, modify, and distribute this software for any | 
    
    | 7 |  |  |  * purpose with or without fee is hereby granted, provided that the above | 
    
    | 8 |  |  |  * copyright notice and this permission notice appear in all copies. | 
    
    | 9 |  |  |  * | 
    
    | 10 |  |  |  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 
    
    | 11 |  |  |  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 
    
    | 12 |  |  |  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 
    
    | 13 |  |  |  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 
    
    | 14 |  |  |  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 
    
    | 15 |  |  |  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 
    
    | 16 |  |  |  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 
    
    | 17 |  |  |  */ | 
    
    | 18 |  |  |  | 
    
    | 19 |  |  | #include <sys/types.h> | 
    
    | 20 |  |  | #include <sys/queue.h> | 
    
    | 21 |  |  | #include <sys/tree.h> | 
    
    | 22 |  |  | #include <sys/socket.h> | 
    
    | 23 |  |  |  | 
    
    | 24 |  |  | #include <ctype.h> | 
    
    | 25 |  |  | #include <err.h> | 
    
    | 26 |  |  | #include <event.h> | 
    
    | 27 |  |  | #include <fcntl.h> | 
    
    | 28 |  |  | #include <imsg.h> | 
    
    | 29 |  |  | #include <stdio.h> | 
    
    | 30 |  |  | #include <stdlib.h> | 
    
    | 31 |  |  | #include <string.h> | 
    
    | 32 |  |  | #include <limits.h> | 
    
    | 33 |  |  |  | 
    
    | 34 |  |  | #include "smtpd.h" | 
    
    | 35 |  |  | #include "log.h" | 
    
    | 36 |  |  |  | 
    
    | 37 |  |  | extern struct delivery_backend delivery_backend_mbox; | 
    
    | 38 |  |  | extern struct delivery_backend delivery_backend_mda; | 
    
    | 39 |  |  | extern struct delivery_backend delivery_backend_maildir; | 
    
    | 40 |  |  | extern struct delivery_backend delivery_backend_filename; | 
    
    | 41 |  |  | extern struct delivery_backend delivery_backend_lmtp; | 
    
    | 42 |  |  |  | 
    
    | 43 |  |  | struct delivery_backend * | 
    
    | 44 |  |  | delivery_backend_lookup(enum action_type type) | 
    
    | 45 |  |  | { | 
    
    | 46 |  |  | 	switch (type) { | 
    
    | 47 |  |  | 	case A_MBOX: | 
    
    | 48 |  |  | 		return &delivery_backend_mbox; | 
    
    | 49 |  |  | 	case A_MDA: | 
    
    | 50 |  |  | 		return &delivery_backend_mda; | 
    
    | 51 |  |  | 	case A_MAILDIR: | 
    
    | 52 |  |  | 		return &delivery_backend_maildir; | 
    
    | 53 |  |  | 	case A_FILENAME: | 
    
    | 54 |  |  | 		return &delivery_backend_filename; | 
    
    | 55 |  |  | 	case A_LMTP: | 
    
    | 56 |  |  | 		return &delivery_backend_lmtp; | 
    
    | 57 |  |  | 	default: | 
    
    | 58 |  |  | 		break; | 
    
    | 59 |  |  | 	} | 
    
    | 60 |  |  | 	return NULL; | 
    
    | 61 |  |  | } |