Package opensmtpd implements OpenSMTPD-extras in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mproc.go 788B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package opensmtpd
  2. import (
  3. "fmt"
  4. )
  5. const (
  6. mINT = iota
  7. mUINT32
  8. mSIZET
  9. mTIME
  10. mSTRING
  11. mDATA
  12. mID
  13. mEVPID
  14. mMSGID
  15. mSOCKADDR
  16. mMAILADDR
  17. mENVELOPE
  18. )
  19. var mprocTypeName = map[uint8]string{
  20. mINT: "M_INT",
  21. mUINT32: "M_UINT32",
  22. mSIZET: "M_SIZET",
  23. mTIME: "M_TIME",
  24. mSTRING: "M_STRING",
  25. mDATA: "M_DATA",
  26. mID: "M_ID",
  27. mEVPID: "M_EVPID",
  28. mMSGID: "M_MSGID",
  29. mSOCKADDR: "M_SOCKADDR",
  30. mMAILADDR: "M_MAILADDR",
  31. mENVELOPE: "M_ENVELOPE",
  32. }
  33. func mprocType(t uint8) string {
  34. if s, ok := mprocTypeName[t]; ok {
  35. return s
  36. }
  37. return fmt.Sprintf("UNKNOWN %d", t)
  38. }
  39. type mprocTypeErr struct {
  40. want, got uint8
  41. }
  42. func (err mprocTypeErr) Error() string {
  43. return fmt.Sprintf("mproc: expected type %s, got %s",
  44. mprocType(err.want), mprocType(err.got))
  45. }