7 /* trigger a mail service
9 /* #include <mail_proto.h>
11 /* int mail_trigger(class, service, request, length)
13 /* const char *service;
14 /* const char *request;
17 /* mail_trigger() wakes up the specified mail subsystem, by
18 /* sending it the specified request.
22 /* Name of a class of local transport channel endpoints,
23 /* either \fIpublic\fR (accessible by any local user) or
24 /* \fIprivate\fR (administrative access only).
26 /* The name of a local transport endpoint within the named class.
28 /* A string. The list of valid requests is service specific.
30 /* The length of the request string.
32 /* The result is -1 in case of problems, 0 otherwise.
33 /* Warnings are logged.
35 /* Works with FIFO or UNIX-domain services only.
37 /* Should use master.cf to find out what transport to use.
39 /* fifo_trigger(3) trigger a FIFO-based service
40 /* unix_trigger(3) trigger a UNIX_domain service
44 /* The Secure Mailer license must be distributed with this software.
47 /* IBM T.J. Watson Research
49 /* Yorktown Heights, NY 10598, USA
57 /* Utility library. */
66 #include "mail_params.h"
67 #include "mail_proto.h"
69 /* mail_trigger - trigger a service */
71 int mail_trigger(const char *class, const char *service
,
72 const char *req_buf
, ssize_t req_len
)
79 * XXX Some systems cannot tell the difference between a named pipe
80 * (fifo) or a UNIX-domain socket. So we may have to try both.
82 path
= mail_pathname(class, service
);
83 if ((status
= stat(path
, &st
)) < 0) {
84 msg_warn("unable to look up %s: %m", path
);
85 } else if (S_ISFIFO(st
.st_mode
)) {
86 status
= fifo_trigger(path
, req_buf
, req_len
, var_trigger_timeout
);
87 if (status
< 0 && S_ISSOCK(st
.st_mode
))
88 status
= LOCAL_TRIGGER(path
, req_buf
, req_len
, var_trigger_timeout
);
89 } else if (S_ISSOCK(st
.st_mode
)) {
90 status
= LOCAL_TRIGGER(path
, req_buf
, req_len
, var_trigger_timeout
);
92 msg_warn("%s is not a socket or a fifo", path
);