#include "def.h"
char *todir(char *t)
{
char *s;
if (t==0)
err("missing directory or file name argument");
s = t+strlen(t);
while (s >= t && *s != '/')
s--;
if (s < t)
return t;
*s++ = 0;
t = (*t ? t : "/");
if (chdir(t) < 0)
err("can't chdir to %s", t);
strcpy(usedir, t);
return s;
}
int setfrom(int c)
{
switch (c) {
case 'y':
case '\0':
default:
return 1000;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
return c - '0';
case 'n':
case '0':
return 0;
}
}
|