aboutsummaryrefslogblamecommitdiff
path: root/common_smtp.go
blob: 5c458db4a54a1829bd5d59eb2e2295d0c18cdc65 (plain) (tree)


















                                                       
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
}