xref: /openbsd-src/usr.sbin/smtpd/scheduler_backend.c (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1 /*	$OpenBSD: scheduler_backend.c,v 1.14 2014/07/10 14:45:02 eric 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 
33 #include "smtpd.h"
34 #include "log.h"
35 
36 extern struct scheduler_backend scheduler_backend_null;
37 extern struct scheduler_backend scheduler_backend_proc;
38 extern struct scheduler_backend scheduler_backend_ramqueue;
39 
40 struct scheduler_backend *
41 scheduler_backend_lookup(const char *name)
42 {
43 	if (!strcmp(name, "null"))
44 		return &scheduler_backend_null;
45 	if (!strcmp(name, "ramqueue"))
46 		return &scheduler_backend_ramqueue;
47 
48 	return &scheduler_backend_proc;
49 }
50 
51 void
52 scheduler_info(struct scheduler_info *sched, struct envelope *evp)
53 {
54 	sched->evpid = evp->id;
55 	sched->type = evp->type;
56 	sched->creation = evp->creation;
57 	sched->retry = evp->retry;
58 	sched->expire = evp->expire;
59 	sched->lasttry = evp->lasttry;
60 	sched->lastbounce = evp->lastbounce;
61 	sched->nexttry	= 0;
62 }
63