1 /* path.c - return a pathname */
3 static char ident[] = "@(#)$Id: path.c,v 1.6 1992/12/15 00:20:22 jromine Exp $";
10 #define NCWD (sizeof CWD - 1)
14 #define NPWD (sizeof PWD - 1)
19 static char *expath ();
23 char *path (name, flag)
30 if ((cp = expath (name, flag))
31 && (ep = cp + strlen (cp) - 1) > cp
40 static char *expath (name, flag)
48 if (flag == TSUBCWF) {
49 (void) sprintf (buffer, "%s/%s", m_getfolder (), name);
50 name = m_mailpath (buffer);
52 (void) sprintf (buffer, "%s/", m_maildir (""));
53 if (ssequal (buffer, name)) {
55 name = getcpy (name + strlen (buffer));
63 && (strncmp (name, CWD, NCWD)
65 && strcmp (name, DOTDOT)
66 && strncmp (name, PWD, NPWD))))
72 if (strcmp (name, DOT) == 0 || strcmp (name, CWD) == 0)
75 ep = pwds + strlen (pwds);
76 if ((cp = rindex (pwds, '/')) == NULL)
82 if (strncmp (name, CWD, NCWD) == 0)
85 if (strcmp (name, DOTDOT) == 0 || strcmp (name, PWD) == 0) {
86 (void) sprintf (buffer, "%.*s", cp - pwds, pwds);
87 return getcpy (buffer);
90 if (strncmp (name, PWD, NPWD) == 0)
95 (void) sprintf (buffer, "%.*s/%s", cp - pwds, pwds, name);
96 return getcpy (buffer);
119 for (dp = cp; *dp == '/'; dp++)
121 (void) strcpy (cp--, dp);
125 if (strcmp (cp, DOT) == 0) {
131 if (strcmp (cp, DOTDOT) == 0) {
132 for (cp -= 2; cp > f; cp--)
140 if (strncmp (cp, PWD, NPWD) == 0) {
141 for (dp = cp - 2; dp > f; dp--)
146 (void) strcpy (dp, cp + NPWD - 1);
150 if (strncmp (cp, CWD, NCWD) == 0) {
151 (void) strcpy (cp - 1, cp + NCWD - 1);