#ifndef NULL #define NULL (void *)0 #endif int pwd() { char *getcwd(); register char *dir; char *dirfix; if (!(dir = getcwd(NULL,256))) { perror("pwd"); return -1; } /* change backslashes to forward slashes */ for (dirfix = dir; *dirfix; dirfix++) *dirfix = (*dirfix == '\\' ? '/' : tolower(*dirfix)); write(1,"/",1); write(1,dir,strlen(dir)); crlf(); if (dir) free(dir); return 0; }