aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/opendir.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/lib/opendir.c')
-rw-r--r--com32/lib/opendir.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/com32/lib/opendir.c b/com32/lib/opendir.c
new file mode 100644
index 00000000..aa2ba5b9
--- /dev/null
+++ b/com32/lib/opendir.c
@@ -0,0 +1,41 @@
+/*
+ * opendir.c
+ */
+
+#include <dirent.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <com32.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+
+DIR *opendir(const char *pathname)
+{
+ DIR *newdir;
+ com32sys_t regs;
+
+ newdir = NULL;
+
+ strlcpy(__com32.cs_bounce, pathname, __com32.cs_bounce_size);
+
+ regs.eax.w[0] = 0x0020;
+ regs.esi.w[0] = OFFS(__com32.cs_bounce);
+ regs.es = SEG(__com32.cs_bounce);
+
+ __com32.cs_intcall(0x22, &regs, &regs);
+
+ if (!(regs.eflags.l & EFLAGS_CF)) {
+ /* Initialization: malloc() then zero */
+ newdir = calloc(1, sizeof(DIR));
+ strcpy(newdir->dd_name, pathname);
+ newdir->dd_fd = regs.esi.w[0];
+ newdir->dd_sect = regs.eax.l;
+ newdir->dd_stat = 0;
+ }
+
+ /* We're done */
+ return newdir;
+}