Adding upstream version 4.02+dfsg.
[syslinux-debian/hramrach.git] / com32 / modules / pwd.c
blob880327d6029e90b44165303dcdc714504aab9858
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 openconsole(&dev_rawcon_r, &dev_stdcon_w);
40 pwdptr = getcwd(pwd, PATH_MAX);
41 if (pwdptr) {
42 if (pwd[0] != 0)
43 puts(pwd);
44 else
45 puts(".");
46 } else {
47 rv = errno;
48 puts("ERROR: getcwd() returned NULL");
50 return rv;