]> oss.titaniummirror.com Git - repo_shell.git/blobdiff - stra.h
Code for supporting git ACLs. acl_test is useful.
[repo_shell.git] / stra.h
diff --git a/stra.h b/stra.h
new file mode 100644 (file)
index 0000000..a2f43d6
--- /dev/null
+++ b/stra.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2012, Titanium Mirror, Inc.
+ * All Rights Reserved.
+ *
+ * This document is the proprietary and confidential property of
+ * Titanium Mirror, Inc.  All use, distribution, reproduction or re-distribution
+ * is disallowed without the prior express written consent of
+ * Titanium Mirror, Inc.
+ */
+
+/*
+ * A dynamic string array implementation.
+ *
+ * @author R. Steve McKown <rsmckown@gmail.com>
+ */
+
+
+#ifndef STRA_H
+#define STRA_H
+
+#include <stddef.h>
+
+typedef int (*stra_fneq_t)(void *item1, void *item2);
+
+typedef struct {
+  size_t count;
+  size_t size;
+  char **items;
+} stra_t;
+
+/* Initialize an stra structure, to hold up to size strings */
+void stra_init(stra_t *stra, size_t size);
+
+/* Destroy all dynamic memory associated with the stra.  Use init to reuse */
+void stra_destroy(stra_t *stra);
+
+/* Add an item to the end of the string array, returning its ele# */
+int stra_add(stra_t *stra, const char *item);
+
+/* Return the ele# of the first string matching item */
+int stra_find(stra_t *stra, const char *item);
+
+/* Return the count of items in the stra */
+size_t stra_count(stra_t *stra);
+
+/* Return the current size of the stra */
+size_t stra_size(stra_t *stra);
+
+/* Return a pointer to the item at ele# ele */
+char *stra_item(stra_t *stra, size_t ele);
+
+#endif /* end of include guard: STRA_H */