aboutsummaryrefslogtreecommitdiff
path: root/common_smtp.go
diff options
context:
space:
mode:
Diffstat (limited to 'common_smtp.go')
-rw-r--r--common_smtp.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/common_smtp.go b/common_smtp.go
new file mode 100644
index 0000000..5c458db
--- /dev/null
+++ b/common_smtp.go
@@ -0,0 +1,19 @@
+package main
+
+import "strings"
+
+func parse_smtp_line(line string) (cmd, param string) {
+ line = strings.TrimSuffix(line, "\n")
+ line = strings.TrimSuffix(line, "\r")
+ cmd_end := strings.IndexByte(line, ' ')
+ var param_start int
+ if cmd_end == -1 {
+ cmd_end = len(line)
+ param_start = len(line)
+ } else {
+ param_start = cmd_end + 1
+ }
+ cmd = strings.ToUpper(line[:cmd_end])
+ param = line[param_start:]
+ return
+}