From 5079850140ad53d2cdb2395c90cb65061249579c Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 16 Jan 2025 08:56:18 +0800 Subject: parse_{smtp,imap}_line --- common_smtp.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 common_smtp.go (limited to 'common_smtp.go') 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 +} -- cgit v1.2.3