Dash:
[t2-trunk.git] / package / base / dietlibc / ether_aton.patch
blobc1c5e1804d4b03cc4a316a378623c7ace291e016
2 Copy from glibc, needed for udhcpd.
4 - Rene Rebe <rene@exactcode.de>
6 --- /dev/null 2006-01-02 14:13:10.967999000 +0100
7 +++ diet/libugly/ether_aton.c 2006-01-02 21:37:51.000000000 +0100
8 @@ -0,0 +1,69 @@
9 +/* Copyright (C) 1996,97,98,99,2002 Free Software Foundation, Inc.
10 + This file is part of the GNU C Library.
11 + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
13 + The GNU C Library is free software; you can redistribute it and/or
14 + modify it under the terms of the GNU Lesser General Public
15 + License as published by the Free Software Foundation; either
16 + version 2.1 of the License, or (at your option) any later version.
18 + The GNU C Library is distributed in the hope that it will be useful,
19 + but WITHOUT ANY WARRANTY; without even the implied warranty of
20 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 + Lesser General Public License for more details.
23 + You should have received a copy of the GNU Lesser General Public
24 + License along with the GNU C Library; if not, write to the Free
25 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 + 02111-1307 USA. */
28 +#include <ctype.h>
29 +#include <stdlib.h>
30 +#include <net/ethernet.h>
32 +struct ether_addr *
33 +ether_aton_r (const char *asc, struct ether_addr *addr)
35 + size_t cnt;
37 + for (cnt = 0; cnt < 6; ++cnt)
38 + {
39 + unsigned int number;
40 + char ch;
42 + ch = tolower (*asc++);
43 + if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
44 + return NULL;
45 + number = isdigit (ch) ? (ch - '0') : (ch - 'a' + 10);
47 + ch = tolower (*asc);
48 + if ((cnt < 5 && ch != ':') || (cnt == 5 && ch != '\0' && !isspace (ch)))
49 + {
50 + ++asc;
51 + if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
52 + return NULL;
53 + number <<= 4;
54 + number += isdigit (ch) ? (ch - '0') : (ch - 'a' + 10);
56 + ch = *asc;
57 + if (cnt < 5 && ch != ':')
58 + return NULL;
59 + }
61 + /* Store result. */
62 + addr->ether_addr_octet[cnt] = (unsigned char) number;
64 + /* Skip ':'. */
65 + ++asc;
66 + }
68 + return addr;
71 +struct ether_addr *
72 +ether_aton (const char *asc)
74 + static struct ether_addr result;
76 + return ether_aton_r (asc, &result);