summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-05-01 03:11:07 -0400
committerKyle Gunger <kgunger12@gmail.com>2024-05-01 03:11:07 -0400
commitfeccf0adf3e6861b11a7768669a63c327f77ec10 (patch)
tree3aab13f202d0963ce74900dba8a508e68fe93614 /include
parent21938c4ed611cd0945d62502abdb74527a533e78 (diff)
Vector code
Diffstat (limited to 'include')
-rw-r--r--include/osm/bind.h3
-rw-r--r--include/osm/device.h10
-rw-r--r--include/osm/discover.h9
-rw-r--r--include/osm/utils.h52
4 files changed, 74 insertions, 0 deletions
diff --git a/include/osm/bind.h b/include/osm/bind.h
index 5107c52..e1627c6 100644
--- a/include/osm/bind.h
+++ b/include/osm/bind.h
@@ -1,3 +1,5 @@
+#ifndef OSM_BIND_H
+#define OSM_BIND_H
/**
* Bind to the next available onboard socket in the given directory
@@ -12,3 +14,4 @@ int osm_bind_local(int sockfd, const char *sock_dir);
*/
int osm_open_onboard(char *sock_dir);
+#endif
diff --git a/include/osm/device.h b/include/osm/device.h
new file mode 100644
index 0000000..51a4ff2
--- /dev/null
+++ b/include/osm/device.h
@@ -0,0 +1,10 @@
+#ifndef OSM_DEVICE_H
+#define OSM_DEVICE_H
+
+#include <osm/utils.h>
+
+typedef struct {
+
+} OSMDevice;
+
+#endif
diff --git a/include/osm/discover.h b/include/osm/discover.h
new file mode 100644
index 0000000..68bda60
--- /dev/null
+++ b/include/osm/discover.h
@@ -0,0 +1,9 @@
+#ifndef OSM_DISCOVER_H
+#define OSM_DISCOVER_H
+
+#include <osm/utils.h>
+
+Vector osm_discover_onboard(char *sock_dir);
+
+#endif
+
diff --git a/include/osm/utils.h b/include/osm/utils.h
new file mode 100644
index 0000000..5a53f41
--- /dev/null
+++ b/include/osm/utils.h
@@ -0,0 +1,52 @@
+#ifndef OSM_UTILS_H
+#define OSM_UTILS_H
+
+// Vector utilities
+
+/**
+ * Vector represents a dynamic array
+ */
+typedef struct {
+ unsigned int count, size, elsz;
+ void *data;
+} Vector;
+
+Vector vect_init(unsigned int elsz);
+
+/**
+ * Add an element to an arbitrary index in the vector
+ */
+void vect_add(Vector *vec, unsigned int index);
+
+/**
+ * Remove an element from an arbitrary index in the vector
+ */
+void vect_remove(Vector *vec, unsigned int index);
+
+/**
+ * Push an element to the end of the vector
+ */
+void vect_push(Vector *vec, void *el);
+
+/**
+ * Pop an element from the end of the vector
+ */
+void vect_pop(Vector *vec);
+
+/**
+ * Get an element from the vector
+ */
+void *vect_get(Vector *vec, unsigned int index);
+
+/**
+ * Set an element inside the vector
+ */
+void *vect_set(Vector *vec, unsigned int index, void *el);
+
+/**
+ * Remove all associated data from the vector
+ */
+void vect_end(Vector *vect);
+
+
+#endif