aboutsummaryrefslogtreecommitdiff
path: root/user/lib/ld-weenix/ldnames.c
diff options
context:
space:
mode:
Diffstat (limited to 'user/lib/ld-weenix/ldnames.c')
-rw-r--r--user/lib/ld-weenix/ldnames.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/user/lib/ld-weenix/ldnames.c b/user/lib/ld-weenix/ldnames.c
new file mode 100644
index 0000000..b94486b
--- /dev/null
+++ b/user/lib/ld-weenix/ldnames.c
@@ -0,0 +1,63 @@
+/*
+ * File: ldnames.c
+ * Date: 30 March 1998
+ * Acct: David Powell (dep)
+ * Desc:
+ */
+
+#include "sys/types.h"
+
+#include "stdlib.h"
+#include "string.h"
+
+#include "ldalloc.h"
+#include "ldnames.h"
+
+typedef struct modent modent_t;
+struct modent
+{
+ const char *name;
+ modent_t *next;
+};
+
+static modent_t *names = NULL;
+
+/* This function adds a name to the global name list. This is intended
+ * for keeping track of what libraries have already been loaded so that
+ * circular/multiple dependencies don't result in a collosal mess.
+ *
+ * _ldaddname has the caveat that names passed must stick around; this
+ * works fine for names located in the dynstr section and are
+ * referenced in the dynamic section */
+
+void _ldaddname(const char *name)
+{
+ modent_t *newent;
+
+ newent = (modent_t *)_ldalloc(sizeof(*newent));
+ newent->name = name;
+ newent->next = names;
+ names = newent;
+}
+
+/* This function checks to see if the specified name has already been
+ * added to the name list (via _ldaddname). If so, 1 is returned.
+ * Otherwise, 0 is returned. */
+
+int _ldchkname(const char *name)
+{
+ /* Just does a linear search - nothing fancy here */
+
+ modent_t *curent;
+
+ curent = names;
+ while (curent)
+ {
+ if (strcmp(curent->name, name))
+ curent = curent->next;
+ else
+ return 1;
+ }
+
+ return 0;
+}