diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-08-29 13:15:45 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-08-30 22:10:20 +0200 |
commit | 3a55b8e6fd51c3dda1ea71c6806f2ee2d71c1065 (patch) | |
tree | 93a83c576c8c4cad8164d6b7ef65dbb185aa8390 /lib/notmuch/properties.go | |
parent | ab7d32c1fe5182a7a7631bb4dc35bed49af752c0 (diff) | |
download | aerc-3a55b8e6fd51c3dda1ea71c6806f2ee2d71c1065.tar.gz |
notmuch: add notmuch bindings
aerc is using an unmaintained fork of a not-well-functioning notmuch
binding library. Add custom bindings directly into the aerc repo to make
them more maintainable and more customizable to our needs.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/notmuch/properties.go')
-rw-r--r-- | lib/notmuch/properties.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/notmuch/properties.go b/lib/notmuch/properties.go new file mode 100644 index 00000000..6c025d05 --- /dev/null +++ b/lib/notmuch/properties.go @@ -0,0 +1,39 @@ +//go:build notmuch +// +build notmuch + +package notmuch + +/* +#cgo LDFLAGS: -lnotmuch + +#include <notmuch.h> + +*/ +import "C" + +type Properties struct { + key *C.char + value *C.char + properties *C.notmuch_message_properties_t +} + +// Next advances the Properties iterator to the next property. Next returns false if +// no more properties are available +func (p *Properties) Next() bool { + if C.notmuch_message_properties_valid(p.properties) == 0 { + return false + } + p.key = C.notmuch_message_properties_key(p.properties) + p.value = C.notmuch_message_properties_value(p.properties) + C.notmuch_message_properties_move_to_next(p.properties) + return true +} + +// Returns the key of the current iterator location +func (p *Properties) Key() string { + return C.GoString(p.key) +} + +func (p *Properties) Value() string { + return C.GoString(p.value) +} |