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

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


#include <u.h>
#include <libc.h>
#include <ctype.h>

char*
mailnamenb(char *name)
{
	Rune	dummy;

	if(isdigit(name[0]) == 0){
		name += chartorune(&dummy, name);
		if(name[0] == '.')
			name++;
	}
	return name;
}

char*
cleanpath(char* file, char* dir)
{
	char*	s;
	char*	t;
	char	cwd[512];

	assert(file && file[0]);
	if(file[1])
		file = strdup(file);
	else {
		s = file;
		file = malloc(3);
		file[0] = s[0];
		file[1] = 0;
	}
	s = cleanname(file);
	if(s[0] != '/' && access(s, AEXIST) == 0){
		getwd(cwd, sizeof(cwd));
		t = smprint("%s/%s", cwd, s);
		free(s);
		return t;
	}
	if(s[0] != '/' && dir != nil && dir[0] != 0){
		t = smprint("%s/%s", dir, s);
		free(s);
		s = cleanname(t);
	}
	return s;
}


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].