Plan 9 from Bell Labs’s /usr/web/sources/patch/sorry/upcase_etheraddr/parseether.c

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


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

int
parseether(uchar *to, char *from)
{
	char nip[3];
	char *p;
	int i;

	p = from;
	for(i = 0; i < 6; i++){
		if(*p == 0)
			return -1;
		nip[0] = *p++;
		if (nip[0] >= 'A' && nip[0] <= 'F')
			nip[0] |= ' ';
		if(*p == 0)
			return -1;
		nip[1] = *p++;
		if (nip[1] >= 'A' && nip[1] <= 'F')
			nip[1] |= ' ';
		nip[2] = 0;
		to[i] = strtoul(nip, 0, 16);
		if(*p == ':')
			p++;
	}
	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 webmaster@9p.io.