ifeq ($(FCRONDYN), 1)
LIBOBJS := $(LIBOBJS)
endif
-OBJSD := fcron.o cl.o subs.o mem.o save.o temp_file.o log.o database.o job.o conf.o u_list.o exe_list.o lavg_list.o env_list.o fcronconf.o filesubs.o select.o fcrondyn_svr.o suspend.o $(LIBOBJS)
-OBJSTAB := fcrontab.o cl.o subs.o mem.o save.o temp_file.o log.o fileconf.o allow.o read_string.o u_list.o env_list.o fcronconf.o filesubs.o
-OBJSDYN := fcrondyn.o subs.o mem.o log.o allow.o read_string.o fcronconf.o filesubs.o
-OBJCONV := convert-fcrontab.o cl.o subs.o mem.o save.o log.o u_list.o env_list.o fcronconf.o filesubs.o
-OBJSIG := fcronsighup.o subs.o mem.o log.o allow.o fcronconf.o filesubs.o
+OBJSD := fcron.o cl.o subs.o mem.o save.o temp_file.o log.o database.o job.o conf.o u_list.o exe_list.o lavg_list.o env_list.o fcronconf.o mail.o filesubs.o select.o fcrondyn_svr.o suspend.o $(LIBOBJS)
+OBJSTAB := fcrontab.o cl.o subs.o mem.o save.o temp_file.o log.o fileconf.o allow.o read_string.o u_list.o env_list.o fcronconf.o mail.o filesubs.o
+OBJSDYN := fcrondyn.o subs.o mem.o log.o allow.o read_string.o fcronconf.o mail.o filesubs.o
+OBJCONV := convert-fcrontab.o cl.o subs.o mem.o save.o log.o u_list.o env_list.o fcronconf.o mail.o filesubs.o
+OBJSIG := fcronsighup.o subs.o mem.o log.o allow.o fcronconf.o mail.o filesubs.o
HEADERSALL := config.h $(SRCDIR)/global.h $(SRCDIR)/cl.h $(SRCDIR)/log.h $(SRCDIR)/subs.h $(SRCDIR)/mem.h $(SRCDIR)/save.h $(SRCDIR)/option.h $(SRCDIR)/dyncom.h $(SRCDIR)/mail.h
# this is a regular expression :
char *editor = NULL;
char *displayname = NULL;
-char
-*format_displayname(char *displayname_conf)
- /* Format the input string `conf_value` according to RFC5322 sec. 3.2.3.
- * <https://datatracker.ietf.org/doc/html/rfc5322#section-3.2.3>.
- * Returns: either the formatted displayname (possibly unchanged or empty)
- * as a new dynamically allocated string (must be properly freed by the
- * caller) or NULL on errors like buffer overflow. */
-{
- bool need_quotes = false;
- char c = '\0';
- char *ipos = NULL; /* Input position */
- char *output = NULL, *quoted_output = NULL;
-
- const uint buf_len = MAIL_FROM_VALUE_LEN_MAX;
- uint cwritten = 0; /* how many chars we have written */
-
- if (strlen(displayname_conf) == 0) return strdup2("");
-
- output = (char *)alloc_safe(buf_len * sizeof(char), "output buffer");
-
- /* walk the conf_value and rebuild it in buf1 */
- for (ipos = displayname_conf; *ipos; ipos++) {
- c = *ipos;
- if (strchr(SPECIAL_MBOX_CHARS, c)) {
- /* insert escape */
- if (c == DQUOTE) {
- output[cwritten] = BSLASH;
- cwritten++;
- }
- need_quotes = true;
- }
- if (cwritten >= buf_len) {
- error("Formatted 'displayname' exceeds %u chars", buf_len);
- Free_safe(output);
- return NULL;
- }
- output[cwritten] = c;
- cwritten++;
- }
-
- if (need_quotes) {
- quoted_output = (char *)alloc_safe(buf_len * sizeof(char), "quoted output buffer");
- int needed_len = snprintf(quoted_output, buf_len, "\"%s\"", output);
- if (needed_len >= buf_len){
- error("Formatted 'displayname' too long: length:%u > max:%u chars", needed_len, buf_len);
- Free_safe(output);
- Free_safe(quoted_output);
- return NULL;
- }
- Free_safe(output);
-
- return quoted_output;
- }
-
- return output;
-}
-
void
init_conf(void)
/* initialises config with compiled in constants */
signal(SIGPIPE, SIG_DFL);
}
-char *
-make_mailbox_addr(char *displayname_conf, char *mail_from, char *hostname)
- /* Produce a "mailbox" header as per RFC5322 sec. 3.2.3
- * <https://datatracker.ietf.org/doc/html/rfc5322#section-3.2.3>.
- * Returns: either the formatted mailbox header as a new dynamically
- * allocated string (must be properly freed by the caller) or NULL on
- * errors like buffer overflow. */
-{
- char *buf = NULL;
- uint written = 0;
- bool need_anglebrackets = false;
-
- const uint buf_len = MAIL_FROM_VALUE_LEN_MAX+1;
-
- buf = (char *)alloc_safe(buf_len * sizeof(char), "mailbox addr buffer");
-
- if (displayname_conf[0] != '\0') {
- /* displayname_conf isn't an empty string */
- need_anglebrackets = true;
- }
-
- /* no @ here, it's handled upstream */
- if (need_anglebrackets)
- written = snprintf(buf, buf_len, "%s %c%s%s%c",
- displayname_conf, '<', mail_from, hostname, '>');
- else
- written = snprintf(buf, buf_len, "%s%s", mail_from, hostname);
-
- if (written >= buf_len) {
- error("Mailbox addr exceeds %u chars", buf_len);
- Free_safe(buf);
- return NULL;
- }
-
- return buf;
-}
-
FILE *
create_mail(cl_t * line, char *subject, char *content_type, char *encoding,
char **env)
--- /dev/null
+/*
+ * FCRON - periodic command scheduler
+ *
+ * Copyright 2000-2021 Thibault Godouet <fcron@free.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * The GNU General Public License can also be found in the file
+ * `LICENSE' that comes with the fcron source distribution.
+ */
+
+
+#include "fcron.h"
+#include "mail.h"
+
+char
+*format_displayname(char *displayname_conf)
+ /* Format the input string `conf_value` according to RFC5322 sec. 3.2.3.
+ * <https://datatracker.ietf.org/doc/html/rfc5322#section-3.2.3>.
+ * Returns: either the formatted displayname (possibly unchanged or empty)
+ * as a new dynamically allocated string (must be properly freed by the
+ * caller) or NULL on errors like buffer overflow. */
+{
+ bool need_quotes = false;
+ char c = '\0';
+ char *ipos = NULL; /* Input position */
+ char *output = NULL, *quoted_output = NULL;
+
+ const uint buf_len = MAIL_FROM_VALUE_LEN_MAX;
+ uint cwritten = 0; /* how many chars we have written */
+
+ if (strlen(displayname_conf) == 0) return strdup2("");
+
+ output = (char *)alloc_safe(buf_len * sizeof(char), "output buffer");
+
+ /* walk the conf_value and rebuild it in buf1 */
+ for (ipos = displayname_conf; *ipos; ipos++) {
+ c = *ipos;
+ if (strchr(SPECIAL_MBOX_CHARS, c)) {
+ /* insert escape */
+ if (c == DQUOTE) {
+ output[cwritten] = BSLASH;
+ cwritten++;
+ }
+ need_quotes = true;
+ }
+ if (cwritten >= buf_len) {
+ error("Formatted 'displayname' exceeds %u chars", buf_len);
+ Free_safe(output);
+ return NULL;
+ }
+ output[cwritten] = c;
+ cwritten++;
+ }
+
+ if (need_quotes) {
+ quoted_output = (char *)alloc_safe(buf_len * sizeof(char), "quoted output buffer");
+ int needed_len = snprintf(quoted_output, buf_len, "\"%s\"", output);
+ if (needed_len >= buf_len){
+ error("Formatted 'displayname' too long: length:%u > max:%u chars", needed_len, buf_len);
+ Free_safe(output);
+ Free_safe(quoted_output);
+ return NULL;
+ }
+ Free_safe(output);
+
+ return quoted_output;
+ }
+
+ return output;
+}
+
+char *
+make_mailbox_addr(char *displayname_conf, char *mail_from, char *hostname)
+ /* Produce a "mailbox" header as per RFC5322 sec. 3.2.3
+ * <https://datatracker.ietf.org/doc/html/rfc5322#section-3.2.3>.
+ * Returns: either the formatted mailbox header as a new dynamically
+ * allocated string (must be properly freed by the caller) or NULL on
+ * errors like buffer overflow. */
+{
+ char *buf = NULL;
+ uint written = 0;
+ bool need_anglebrackets = false;
+
+ const uint buf_len = MAIL_FROM_VALUE_LEN_MAX+1;
+
+ buf = (char *)alloc_safe(buf_len * sizeof(char), "mailbox addr buffer");
+
+ if (displayname_conf[0] != '\0') {
+ /* displayname_conf isn't an empty string */
+ need_anglebrackets = true;
+ }
+
+ /* no @ here, it's handled upstream */
+ if (need_anglebrackets)
+ written = snprintf(buf, buf_len, "%s %c%s%s%c",
+ displayname_conf, '<', mail_from, hostname, '>');
+ else
+ written = snprintf(buf, buf_len, "%s%s", mail_from, hostname);
+
+ if (written >= buf_len) {
+ error("Mailbox addr exceeds %u chars", buf_len);
+ Free_safe(buf);
+ return NULL;
+ }
+
+ return buf;
+}
#define FROM_HEADER_KEY "From: "
#define MAIL_FROM_VALUE_LEN_MAX (MAIL_LINE_LEN_MAX - sizeof(FROM_HEADER_KEY))
+extern char *format_displayname(char *displayname_conf);
+extern char *make_mailbox_addr(char *displayname_conf, char *mail_from, char *hostname);
+
#endif /* __MAIL_H__ */
SRCST := mailbox_addr.c
OBJST := $(patsubst %.c,%.o,$(SRCST))
EXEST := $(patsubst %.c,%,$(SRCST))
-OBJSD := $(addprefix $(SRCDIR)/,log.o job.o mem.o filesubs.o subs.o fcronconf.o temp_file.o env_list.o u_list.o)
+OBJSD := $(addprefix $(SRCDIR)/,log.o job.o mem.o filesubs.o subs.o fcronconf.o mail.o temp_file.o env_list.o u_list.o)
CFLAGS += -I$(SRCDIR)
CFLAGS += @CFLAGS@