summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-08-28 22:17:34 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-08-28 22:17:34 -0600
commit5fd4b54f3a833bdfabf067c4abafa56c11e02ab1 (patch)
treea0f2e720ef46709c6b59e4bcf8036f10831fe64c /src
parentb55355121e0ed259097254447f16739b0f3da61d (diff)
Clean up, based on making godoc slightly more readable
Diffstat (limited to 'src')
-rw-r--r--src/inotify/bits.go62
-rw-r--r--src/nshd/hackers_git/db_config.go9
-rw-r--r--src/nshd/hackers_git/hackers.go9
-rw-r--r--src/nslcd_proto/.gitignore2
-rw-r--r--src/nslcd_proto/Makefile10
-rw-r--r--src/nslcd_proto/enumerator@T.got36
-rwxr-xr-xsrc/nslcd_proto/struct_null_backend.go.sh12
-rw-r--r--src/nslcd_proto/util/enumerator@T.got40
-rwxr-xr-xsrc/nslcd_proto/util/struct_null_backend.go.sh14
9 files changed, 104 insertions, 90 deletions
diff --git a/src/inotify/bits.go b/src/inotify/bits.go
index f086b10..3606b52 100644
--- a/src/inotify/bits.go
+++ b/src/inotify/bits.go
@@ -1,8 +1,8 @@
package inotify
-/* Flags for the parameter of inotify_init1. */
const (
- /* These are, oddly, 24-bit numbers */
+ // Flags for the parameter of InotifyInit1().
+ // These, oddly, appear to be 24-bit numbers.
IN_CLOEXEC uint32 = 02000000
IN_NONBLOCK uint32 = 00004000
)
@@ -10,38 +10,38 @@ const (
type Mask uint32
const (
- /* Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH. */
- IN_ACCESS Mask = 0x00000001 /* File was accessed. */
- IN_MODIFY Mask = 0x00000002 /* File was modified. */
- IN_ATTRIB Mask = 0x00000004 /* Metadata changed. */
- IN_CLOSE_WRITE Mask = 0x00000008 /* Writtable file was closed. */
- IN_CLOSE_NOWRITE Mask = 0x00000010 /* Unwrittable file closed. */
- IN_OPEN Mask = 0x00000020 /* File was opened. */
- IN_MOVED_FROM Mask = 0x00000040 /* File was moved from X. */
- IN_MOVED_TO Mask = 0x00000080 /* File was moved to Y. */
- IN_CREATE Mask = 0x00000100 /* Subfile was created. */
- IN_DELETE Mask = 0x00000200 /* Subfile was deleted. */
- IN_DELETE_SELF Mask = 0x00000400 /* Self was deleted. */
- IN_MOVE_SELF Mask = 0x00000800 /* Self was moved. */
+ // Supported events suitable for the `mask` parameter of Inotify.AddWatch().
+ IN_ACCESS Mask = (1<< 0) // File was accessed.
+ IN_MODIFY Mask = (1<< 1) // File was modified.
+ IN_ATTRIB Mask = (1<< 2) // Metadata changed.
+ IN_CLOSE_WRITE Mask = (1<< 3) // Writtable file was closed.
+ IN_CLOSE_NOWRITE Mask = (1<< 4) // Unwrittable file closed.
+ IN_OPEN Mask = (1<< 5) // File was opened.
+ IN_MOVED_FROM Mask = (1<< 6) // File was moved from X.
+ IN_MOVED_TO Mask = (1<< 7) // File was moved to Y.
+ IN_CREATE Mask = (1<< 8) // Subfile was created.
+ IN_DELETE Mask = (1<< 9) // Subfile was deleted.
+ IN_DELETE_SELF Mask = (1<<10) // Self was deleted.
+ IN_MOVE_SELF Mask = (1<<11) // Self was moved.
- /* Events sent by the kernel. */
- IN_UNMOUNT Mask = 0x00002000 /* Backing fs was unmounted. */
- IN_Q_OVERFLOW Mask = 0x00004000 /* Event queued overflowed. */
- IN_IGNORED Mask = 0x00008000 /* File was ignored. */
+ // Events that appear in output without subscribing to them.
+ IN_UNMOUNT Mask = (1<<13) // Backing fs was unmounted.
+ IN_Q_OVERFLOW Mask = (1<<14) // Event queued overflowed.
+ IN_IGNORED Mask = (1<<15) // File was ignored (expect no more events).
- /* Special flags. */
- IN_ONLYDIR Mask = 0x01000000 /* Only watch the path if it is a directory. */
- IN_DONT_FOLLOW Mask = 0x02000000 /* Do not follow a sym link. */
- IN_EXCL_UNLINK Mask = 0x04000000 /* Exclude events on unlinked objects. */
- IN_MASK_ADD Mask = 0x20000000 /* Add to the mask of an already existing watch. */
- IN_ISDIR Mask = 0x40000000 /* Event occurred against dir. */
- IN_ONESHOT Mask = 0x80000000 /* Only send event once. */
-
- /* Convenience macros */
- IN_CLOSE Mask = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* Close. */
- IN_MOVE Mask = (IN_MOVED_FROM | IN_MOVED_TO) /* Moves. */
- IN_ALL_EVENTS Mask = 0x00000FFF /* All events which a program can wait on. */
+ // Special flags that you may pass to Inotify.AddWatch()...
+ // except for IN_ISDIR, which is a flag that is set on output events.
+ IN_ONLYDIR Mask = (1<<24) // Only watch the path if it is a directory.
+ IN_DONT_FOLLOW Mask = (1<<25) // Do not follow a sym link.
+ IN_EXCL_UNLINK Mask = (1<<26) // Exclude events on unlinked objects.
+ IN_MASK_ADD Mask = (1<<29) // Add to the mask of an already existing watch.
+ IN_ISDIR Mask = (1<<30) // Event occurred against dir.
+ IN_ONESHOT Mask = (1<<31) // Only send event once.
+ // Convenience macros */
+ IN_CLOSE Mask = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) // Close.
+ IN_MOVE Mask = (IN_MOVED_FROM | IN_MOVED_TO) // Moves.
+ IN_ALL_EVENTS Mask = 0x00000FFF // All events which a program can wait on.
)
var in_bits [32]string = [32]string{
diff --git a/src/nshd/hackers_git/db_config.go b/src/nshd/hackers_git/db_config.go
index 5ef4fe6..aa8bef8 100644
--- a/src/nshd/hackers_git/db_config.go
+++ b/src/nshd/hackers_git/db_config.go
@@ -1,6 +1,9 @@
package hackers_git
-import p "nslcd_proto"
+import (
+ p "nslcd_proto"
+ "nslcd_proto/util"
+)
func (o *Hackers) Config_Get(cred p.Ucred, req p.Request_Config_Get) p.Config_Enumerator {
o.lock.RLock()
@@ -16,8 +19,8 @@ func (o *Hackers) Config_Get(cred p.Ucred, req p.Request_Config_Get) p.Config_En
}
if val != nil {
- return p.New_Config_List([]p.Config{p.Config(*val)})
+ return util.New_Config_List([]p.Config{p.Config(*val)})
} else {
- return p.Config_Ø{}
+ return util.Config_Ø{}
}
}
diff --git a/src/nshd/hackers_git/hackers.go b/src/nshd/hackers_git/hackers.go
index f7c4573..230f08b 100644
--- a/src/nshd/hackers_git/hackers.go
+++ b/src/nshd/hackers_git/hackers.go
@@ -2,7 +2,8 @@ package hackers_git
import (
"inotify"
- p "nslcd_proto"
+ "nslcd_proto"
+ "nslcd_proto/util"
"nslcd_systemd"
"sd_daemon/logger"
"sync"
@@ -14,10 +15,10 @@ type Config struct {
}
type Hackers struct {
- p.NullBackend
+ util.NullBackend
cfg Config
lock sync.RWMutex
- users map[int32]p.Passwd
+ users map[int32]nslcd_proto.Passwd
passwords map[int32]string
in_fd *inotify.Inotify
@@ -28,7 +29,7 @@ type Hackers struct {
}
var _ nslcd_systemd.Backend = &Hackers{}
-var _ p.Backend = &Hackers{}
+var _ nslcd_proto.Backend = &Hackers{}
func (o *Hackers) Close() {
logger.Info("Closing hackers.git session")
diff --git a/src/nslcd_proto/.gitignore b/src/nslcd_proto/.gitignore
index c655813..86bd764 100644
--- a/src/nslcd_proto/.gitignore
+++ b/src/nslcd_proto/.gitignore
@@ -1,5 +1,5 @@
/interface_backend.go
-/struct_null_backend.go
+/util/struct_null_backend.go
/func_handlerequest.go
/requests.txt
/responses.txt
diff --git a/src/nslcd_proto/Makefile b/src/nslcd_proto/Makefile
index f45360b..52e58f5 100644
--- a/src/nslcd_proto/Makefile
+++ b/src/nslcd_proto/Makefile
@@ -1,8 +1,8 @@
_ := $(MAKEFILE_LIST)
d := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
-generate := $(generate) $d/interface_backend.go $d/func_handlerequest.go $d/struct_null_backend.go
-secondary := $(secondary) $d/enumerator-list.mk $d/requests.txt $d/responses.txt $d/enumerator@*.go
+generate := $(generate) $d/interface_backend.go $d/func_handlerequest.go $d/util/struct_null_backend.go
+secondary := $(secondary) $d/enumerator-list.mk $d/requests.txt $d/responses.txt $d/*@*.go $d/util/*@*.go
ifeq (,$(filter clean,$(MAKECMDGOALS)))
-include $d/enumerator-list.mk
@@ -27,9 +27,11 @@ endif
$d/enumerator@%.go: $d/enumerator@T.got
< $< sed 's/<T>/$*/g' > $@
+$d/util/enumerator@%.go: $d/util/enumerator@T.got
+ < $< sed 's/<T>/$*/g' > $@
$d/enumerator-list.mk: $d/responses.txt $d/Makefile
- < $< sed -rn 's|.*|generate += $$d/enumerator@&.go|p' > $@
+ < $< sed -rn 's|.*|generate += $$d/enumerator@&.go $$d/util/enumerator@&.go|p' > $@
$d/requests.txt: $d/nslcd_h.go $d/Makefile
< $< grep -Eo '\btype Request_([^_ ]+)(_\S+)?' | sed 's/^type Request_//' > $@
@@ -41,4 +43,4 @@ $d/responses.txt: $d/interface_backend.go $d/Makefile
$d/interface_backend.go: $d/requests.txt
$d/func_handlerequest.go: $d/requests.txt
-$d/struct_null_backend.go: $d/interface_backend.go
+$d/util/struct_null_backend.go: $d/interface_backend.go
diff --git a/src/nslcd_proto/enumerator@T.got b/src/nslcd_proto/enumerator@T.got
index 5a540ae..023c774 100644
--- a/src/nslcd_proto/enumerator@T.got
+++ b/src/nslcd_proto/enumerator@T.got
@@ -1,4 +1,3 @@
-// -*- Mode: Go -*-
package nslcd_proto
type <T>_Enumerator interface {
@@ -6,37 +5,4 @@ type <T>_Enumerator interface {
GenericGetNext() (n interface{}, err error)
}
-type <T>_List struct {
- dat []<T>
- i int
-}
-
-var _ <T>_Enumerator = &<T>_List{}
-
-func New_<T>_List(ary []<T>) *<T>_List {
- return &<T>_List{ary, 0}
-}
-
-func (o *<T>_List) GetNext() (n *<T>, err error) {
- if o.i < len(o.dat) {
- n = &o.dat[o.i]
- o.i++
- }
- err = nil
- return
-}
-
-func (o *<T>_List) GenericGetNext() (n interface{}, err error) {
- return o.GetNext()
-}
-
-type <T>_Ø struct{}
-
-var _ <T>_Enumerator = <T>_Ø{}
-
-func (o <T>_Ø) GetNext() (*<T>, error) {
- return nil, nil
-}
-func (o <T>_Ø) GenericGetNext() (interface{}, error) {
- return nil, nil
-}
+// -*- Mode: Go -*-
diff --git a/src/nslcd_proto/struct_null_backend.go.sh b/src/nslcd_proto/struct_null_backend.go.sh
deleted file mode 100755
index 99788aa..0000000
--- a/src/nslcd_proto/struct_null_backend.go.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env bash
-# -*- Mode: Go -*-
-interface=$1
-cat <<EOF | gofmt
-package nslcd_proto
-
-type NullBackend struct{}
-
-$(< "$interface" sed -rn 's/^\t(.*\) (\S+)_Enumerator)$/func (o NullBackend) \1 { return \2_Ø{} }/p')
-
-var _ Backend = NullBackend{}
-EOF
diff --git a/src/nslcd_proto/util/enumerator@T.got b/src/nslcd_proto/util/enumerator@T.got
new file mode 100644
index 0000000..e1dd2ae
--- /dev/null
+++ b/src/nslcd_proto/util/enumerator@T.got
@@ -0,0 +1,40 @@
+package util
+
+import "nslcd_proto"
+
+type <T>_List struct {
+ dat []nslcd_proto.<T>
+ i int
+}
+
+var _ nslcd_proto.<T>_Enumerator = &<T>_List{}
+
+func New_<T>_List(ary []nslcd_proto.<T>) *<T>_List {
+ return &<T>_List{ary, 0}
+}
+
+func (o *<T>_List) GetNext() (n *nslcd_proto.<T>, err error) {
+ if o.i < len(o.dat) {
+ n = &o.dat[o.i]
+ o.i++
+ }
+ err = nil
+ return
+}
+
+func (o *<T>_List) GenericGetNext() (n interface{}, err error) {
+ return o.GetNext()
+}
+
+type <T>_Ø struct{}
+
+var _ nslcd_proto.<T>_Enumerator = <T>_Ø{}
+
+func (o <T>_Ø) GetNext() (*nslcd_proto.<T>, error) {
+ return nil, nil
+}
+func (o <T>_Ø) GenericGetNext() (interface{}, error) {
+ return nil, nil
+}
+
+// -*- Mode: Go -*-
diff --git a/src/nslcd_proto/util/struct_null_backend.go.sh b/src/nslcd_proto/util/struct_null_backend.go.sh
new file mode 100755
index 0000000..7cbdbd0
--- /dev/null
+++ b/src/nslcd_proto/util/struct_null_backend.go.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+# -*- Mode: Go -*-
+interface=$1
+cat <<EOF
+package util
+
+import p "nslcd_proto"
+
+type NullBackend struct{}
+
+$(< "$interface" sed -rn 's/^\t([^(]+)\(Ucred, ([^)]+)\) (\S+)_Enumerator$/func (o NullBackend) \1(p.Ucred, p.\2) p.\3_Enumerator { return \3_Ø{} }/p')
+
+var _ p.Backend = NullBackend{}
+EOF