xref: /openbsd-src/usr.sbin/smtpd/scheduler_backend.c (revision 897fc685943471cf985a0fe38ba076ea6fe74fa5)
1 /*	$OpenBSD: scheduler_backend.c,v 1.15 2015/01/20 17:37:54 deraadt Exp $	*/
2 
3 /*
4  * Copyright (c) 2012 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 scheduler_backend scheduler_backend_null;
38 extern struct scheduler_backend scheduler_backend_proc;
39 extern struct scheduler_backend scheduler_backend_ramqueue;
40 
41 struct scheduler_backend *
42 scheduler_backend_lookup(const char *name)
43 {
44 	if (!strcmp(name, "null"))
45 		return &scheduler_backend_null;
46 	if (!strcmp(name, "ramqueue"))
47 		return &scheduler_backend_ramqueue;
48 
49 	return &scheduler_backend_proc;
50 }
51 
52 void
53 scheduler_info(struct scheduler_info *sched, struct envelope *evp)
54 {
55 	sched->evpid = evp->id;
56 	sched->type = evp->type;
57 	sched->creation = evp->creation;
58 	sched->retry = evp->retry;
59 	sched->expire = evp->expire;
60 	sched->lasttry = evp->lasttry;
61 	sched->lastbounce = evp->lastbounce;
62 	sched->nexttry	= 0;
63 }
64