Adding upstream version 4.00~pre54+dfsg.
[syslinux-debian/hramrach.git] / com32 / lib / getcwd.c
blob38fae52ab7db23551c4d00319da3facde21482b4
1 /*
2 * getcwd.c
3 */
5 #include <syslinux/config.h>
6 #include <klibc/compiler.h>
7 #include <com32.h>
9 #include <dirent.h>
10 #include <stdio.h>
11 #include <errno.h>
12 #include <string.h>
14 char *getcwd(char *buf, size_t size)
16 static com32sys_t reg;
17 char *pwdstr, *ret;
19 reg.eax.w[0] = 0x001f;
20 __intcall(0x22, &reg, &reg);
21 pwdstr = MK_PTR(reg.es, reg.ebx.w[0]);
22 if ((strlen(pwdstr) < size) && (buf != NULL)) {
23 strcpy(buf, pwdstr);
24 ret = buf;
25 } else {
26 ret = NULL;
27 errno = ERANGE;
29 return ret;