Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/src/cmd/refer/util.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#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;
	}
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].