Adding upstream version 3.86+dfsg.
[syslinux-debian/hramrach.git] / com32 / lib / opendir.c
blob21fe91d4de458a1f7e7ed26480b5cb43379ee595
1 /*
2 * opendir.c
3 */
5 #include <dirent.h>
6 #include <stdio.h>
7 #include <errno.h>
9 #include <com32.h>
10 #include <string.h>
11 #include <unistd.h>
12 #include <fcntl.h>
13 #include <stdlib.h>
15 DIR *opendir(const char *pathname)
17 DIR *newdir;
18 com32sys_t regs;
20 newdir = NULL;
22 strlcpy(__com32.cs_bounce, pathname, __com32.cs_bounce_size);
24 regs.eax.w[0] = 0x0020;
25 regs.esi.w[0] = OFFS(__com32.cs_bounce);
26 regs.es = SEG(__com32.cs_bounce);
28 __com32.cs_intcall(0x22, &regs, &regs);
30 if (!(regs.eflags.l & EFLAGS_CF)) {
31 /* Initialization: malloc() then zero */
32 newdir = calloc(1, sizeof(DIR));
33 strcpy(newdir->dd_name, pathname);
34 newdir->dd_fd = regs.esi.w[0];
35 newdir->dd_sect = regs.eax.l;
36 newdir->dd_stat = 0;
39 /* We're done */
40 return newdir;