queue_null.c revision 1.7
1/*	$OpenBSD: queue_null.c,v 1.7 2018/05/14 15:23:05 gilles 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#include <limits.h>
40
41#include "smtpd.h"
42#include "log.h"
43
44static int
45queue_null_message_create(uint32_t *msgid)
46{
47	*msgid = queue_generate_msgid();
48	return (1);
49}
50
51static int
52queue_null_message_commit(uint32_t msgid, const char *path)
53{
54	return (1);
55}
56
57static int
58queue_null_message_delete(uint32_t msgid)
59{
60	return (1);
61}
62
63static int
64queue_null_message_fd_r(uint32_t msgid)
65{
66	return (-1);
67}
68
69static int
70queue_null_envelope_create(uint32_t msgid, const char *buf, size_t len,
71    uint64_t *evpid)
72{
73	*evpid = queue_generate_evpid(msgid);
74	return (1);
75}
76
77static int
78queue_null_envelope_delete(uint64_t evpid)
79{
80	return (1);
81}
82
83static int
84queue_null_envelope_update(uint64_t evpid, const char *buf, size_t len)
85{
86	return (1);
87}
88
89static int
90queue_null_envelope_load(uint64_t evpid, char *buf, size_t len)
91{
92	return (0);
93}
94
95static int
96queue_null_envelope_walk(uint64_t *evpid, char *buf, size_t len)
97{
98	return (-1);
99}
100
101static int
102queue_null_init(struct passwd *pw, int server, const char *conf)
103{
104	queue_api_on_message_create(queue_null_message_create);
105	queue_api_on_message_commit(queue_null_message_commit);
106	queue_api_on_message_delete(queue_null_message_delete);
107	queue_api_on_message_fd_r(queue_null_message_fd_r);
108	queue_api_on_envelope_create(queue_null_envelope_create);
109	queue_api_on_envelope_delete(queue_null_envelope_delete);
110	queue_api_on_envelope_update(queue_null_envelope_update);
111	queue_api_on_envelope_load(queue_null_envelope_load);
112	queue_api_on_envelope_walk(queue_null_envelope_walk);
113
114	return (1);
115}
116
117struct queue_backend queue_backend_null = {
118	queue_null_init,
119};
120