Adding upstream version 6.02~pre8+dfsg.
[syslinux-debian/hramrach.git] / com32 / modules / pwd.c
blob2794e3dd8e804ba26e6cbc45370678e94711c3ce
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2010 Gene Cumm - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
14 * Display present (current) working directory
17 #include <errno.h>
18 #include <stdio.h>
19 #include <console.h>
20 #include <unistd.h>
21 #include <dirent.h>
23 /* Size of path buffer string */
24 #ifndef PATH_MAX
25 # ifdef NAME_MAX
26 # define PATH_MAX NAME_MAX
27 # elif FILENAME_MAX
28 # define PATH_MAX FILENAME_MAX
29 # else
30 # define PATH_MAX 256
31 # endif /* NAME_MAX */
32 #endif /* PATH_MAX */
34 int main(void)
36 int rv = 0;
37 char pwd[PATH_MAX], *pwdptr;
39 pwdptr = getcwd(pwd, PATH_MAX);
40 if (pwdptr) {
41 if (pwd[0] != 0)
42 puts(pwd);
43 else
44 puts(".");
45 } else {
46 rv = errno;
47 puts("ERROR: getcwd() returned NULL");
49 return rv;