xref: /openbsd-src/usr.sbin/smtpd/queue_null.c (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1 /*	$OpenBSD: queue_null.c,v 1.5 2014/07/08 15:45:32 eric Exp $	*/
2 
3 /*
4  * Copyright (c) 2012 Eric Faurot <eric@openbsd.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 #include <sys/stat.h>
24 
25 #include <ctype.h>
26 #include <err.h>
27 #include <errno.h>
28 #include <event.h>
29 #include <fcntl.h>
30 #include <imsg.h>
31 #include <inttypes.h>
32 #include <libgen.h>
33 #include <pwd.h>
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include <time.h>
38 #include <unistd.h>
39 
40 #include "smtpd.h"
41 #include "log.h"
42 
43 static int
44 queue_null_message_create(uint32_t *msgid)
45 {
46 	*msgid = queue_generate_msgid();
47 	return (1);
48 }
49 
50 static int
51 queue_null_message_commit(uint32_t msgid, const char *path)
52 {
53 	return (1);
54 }
55 
56 static int
57 queue_null_message_delete(uint32_t msgid)
58 {
59 	return (1);
60 }
61 
62 static int
63 queue_null_message_fd_r(uint32_t msgid)
64 {
65 	return (-1);
66 }
67 
68 static int
69 queue_null_message_corrupt(uint32_t msgid)
70 {
71 	return (0);
72 }
73 
74 static int
75 queue_null_envelope_create(uint32_t msgid, const char *buf, size_t len,
76     uint64_t *evpid)
77 {
78 	*evpid = queue_generate_evpid(msgid);
79 	return (1);
80 }
81 
82 static int
83 queue_null_envelope_delete(uint64_t evpid)
84 {
85 	return (1);
86 }
87 
88 static int
89 queue_null_envelope_update(uint64_t evpid, const char *buf, size_t len)
90 {
91 	return (1);
92 }
93 
94 static int
95 queue_null_envelope_load(uint64_t evpid, char *buf, size_t len)
96 {
97 	return (0);
98 }
99 
100 static int
101 queue_null_envelope_walk(uint64_t *evpid, char *buf, size_t len)
102 {
103 	return (-1);
104 }
105 
106 static int
107 queue_null_init(struct passwd *pw, int server, const char *conf)
108 {
109 	queue_api_on_message_create(queue_null_message_create);
110 	queue_api_on_message_commit(queue_null_message_commit);
111 	queue_api_on_message_delete(queue_null_message_delete);
112 	queue_api_on_message_fd_r(queue_null_message_fd_r);
113 	queue_api_on_message_corrupt(queue_null_message_corrupt);
114 	queue_api_on_envelope_create(queue_null_envelope_create);
115 	queue_api_on_envelope_delete(queue_null_envelope_delete);
116 	queue_api_on_envelope_update(queue_null_envelope_update);
117 	queue_api_on_envelope_load(queue_null_envelope_load);
118 	queue_api_on_envelope_walk(queue_null_envelope_walk);
119 
120 	return (1);
121 }
122 
123 struct queue_backend queue_backend_null = {
124 	queue_null_init,
125 };
126