Files
bzzz/vendor/github.com/mikioh/tcpopt/parse.go
anthonyrawlins 5978a0b8f5 WIP: Save agent roles integration work before CHORUS rebrand
- Agent roles and coordination features
- Chat API integration testing
- New configuration and workspace management

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 02:21:11 +10:00

38 lines
884 B
Go

// Copyright 2016 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcpopt
import (
"fmt"
"sync"
)
var parserMu sync.RWMutex
// Register registers a socket option parser.
func Register(level, name int, fn func([]byte) (Option, error)) {
parserMu.Lock()
parsers[int64(level)<<32|int64(name)] = fn
parserMu.Unlock()
}
// Unregister unregisters a socket option parser.
func Unregister(level, name int) {
parserMu.Lock()
delete(parsers, int64(level)<<32|int64(name))
parserMu.Unlock()
}
// Parse parses a socket option.
func Parse(level, name int, b []byte) (Option, error) {
parserMu.RLock()
defer parserMu.RUnlock()
fn, ok := parsers[int64(level)<<32|int64(name)]
if !ok {
return nil, fmt.Errorf("parser for level=%#x name=%#x not found", level, name)
}
return fn(b)
}