aboutsummaryrefslogtreecommitdiff
path: root/utils/clen.go
diff options
context:
space:
mode:
authorJulien Dessaux2020-02-22 11:57:50 +0100
committerJulien Dessaux2020-02-22 11:57:50 +0100
commitbcfaffac240d74cd79bec3c2a9d3c144d215b495 (patch)
treeedd2c5f1e011afee759970323042fcf35bf68962 /utils/clen.go
parentImproved tests for job package (diff)
downloadbareos-zabbix-check-bcfaffac240d74cd79bec3c2a9d3c144d215b495.tar.gz
bareos-zabbix-check-bcfaffac240d74cd79bec3c2a9d3c144d215b495.tar.bz2
bareos-zabbix-check-bcfaffac240d74cd79bec3c2a9d3c144d215b495.zip
Added tests to the state package, and reworked the code around that
Diffstat (limited to 'utils/clen.go')
-rw-r--r--utils/clen.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils/clen.go b/utils/clen.go
new file mode 100644
index 0000000..17d1c4b
--- /dev/null
+++ b/utils/clen.go
@@ -0,0 +1,11 @@
+package utils
+
+// Clen returns the length of a null terminated string like in C
+func Clen(n []byte) int {
+ for i := 0; i < len(n); i++ {
+ if n[i] == 0 {
+ return i
+ }
+ }
+ return len(n)
+}