aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/email_addr.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-23 11:33:48 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-23 14:45:27 +0100
commit6d57fbfa112799366447775d5a52974e29bf887d (patch)
treeb022cdecf9cb27a39508cb9d6db43a016e8912ac /src/libmime/email_addr.h
parent6832271dbc2771c7e3b2512fef2dcc054ab55c49 (diff)
downloadrspamd-6d57fbfa112799366447775d5a52974e29bf887d.tar.gz
rspamd-6d57fbfa112799366447775d5a52974e29bf887d.zip
[Feature] Add new representation of email address
Diffstat (limited to 'src/libmime/email_addr.h')
-rw-r--r--src/libmime/email_addr.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/libmime/email_addr.h b/src/libmime/email_addr.h
new file mode 100644
index 000000000..353692ff5
--- /dev/null
+++ b/src/libmime/email_addr.h
@@ -0,0 +1,64 @@
+/*-
+ * Copyright 2016 Vsevolod Stakhov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef SRC_LIBMIME_EMAIL_ADDR_H_
+#define SRC_LIBMIME_EMAIL_ADDR_H_
+
+#include "config.h"
+#include "ref.h"
+
+struct raw_header;
+
+enum rspamd_email_address_flags {
+ RSPAMD_EMAIL_ADDR_VALID = (1 << 0),
+ RSPAMD_EMAIL_ADDR_IP = (1 << 1),
+ RSPAMD_EMAIL_ADDR_BRACED = (1 << 2),
+ RSPAMD_EMAIL_ADDR_QUOTED = (1 << 3),
+ RSPAMD_EMAIL_ADDR_EMPTY = (1 << 4),
+};
+
+/*
+ * Structure that represents email address in a convenient way
+ */
+struct rspamd_email_address {
+ const gchar *raw;
+ const gchar *addr;
+ const gchar *user;
+ const gchar *domain;
+
+ guint raw_len;
+ guint addr_len;
+ guint user_len;
+ guint domain_len;
+ enum rspamd_email_address_flags flags;
+
+ ref_entry_t ref;
+};
+
+/**
+ * Create email address from a single rfc822 address (e.g. from mail from:)
+ * @param str string to use
+ * @param len length of string
+ * @return
+ */
+struct rspamd_email_address * rspamd_email_address_from_smtp (
+ const gchar *str, guint len);
+
+struct rspamd_email_address * rspamd_email_address_ref (
+ struct rspamd_email_address *addr);
+
+void rspamd_email_address_unref (struct rspamd_email_address *addr);
+
+#endif /* SRC_LIBMIME_EMAIL_ADDR_H_ */