atob8.c revision 22347
122347Spst/* atob8.c: The opieatob8() library function. 222347Spst 322347Spst%%% portions-copyright-cmetz 422347SpstPortions of this software are Copyright 1996 by Craig Metz, All Rights 522347SpstReserved. The Inner Net License Version 2 applies to these portions of 622347Spstthe software. 722347SpstYou should have received a copy of the license with this software. If 822347Spstyou didn't get a copy, you may request one from <license@inner.net>. 922347Spst 1022347SpstPortions of this software are Copyright 1995 by Randall Atkinson and Dan 1122347SpstMcDonald, All Rights Reserved. All Rights under this copyright are assigned 1222347Spstto the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and 1322347SpstLicense Agreement applies to this software. 1422347Spst 1522347Spst History: 1622347Spst 1722347Spst Modified by cmetz for OPIE 2.3. Return the output variable. 1822347Spst Don't check parameters. 1922347Spst Modified by cmetz for OPIE 2.2. Use FUNCTION declaration et al. 2022347Spst Inlined and obseleted opieskipspace(). Inlined and obseleted 2122347Spst opiehtoi(). 2222347Spst Created at NRL for OPIE 2.2 from opiesubr2.c 2322347Spst*/ 2422347Spst#include "opie_cfg.h" 2522347Spst#include <stdio.h> 2622347Spst#include "opie.h" 2722347Spst 2822347Spst/* Convert 8-byte hex-ascii string to binary array 2922347Spst */ 3022347Spstchar *opieatob8 FUNCTION((out, in), char *out AND char *in) 3122347Spst{ 3222347Spst register int i; 3322347Spst register int val; 3422347Spst 3522347Spst for (i = 0; i < 8; i++) { 3622347Spst while (*in == ' ' || *in == '\t') 3722347Spst in++; 3822347Spst if (!*in) 3922347Spst return NULL; 4022347Spst 4122347Spst if ((*in >= '0') && (*in <= '9')) 4222347Spst val = *(in++) - '0'; 4322347Spst else 4422347Spst if ((*in >= 'a') && (*in <= 'f')) 4522347Spst val = *(in++) - 'a' + 10; 4622347Spst else 4722347Spst if ((*in >= 'A') && (*in <= 'F')) 4822347Spst val = *(in++) - 'A' + 10; 4922347Spst else 5022347Spst return NULL; 5122347Spst 5222347Spst *out = val << 4; 5322347Spst 5422347Spst while (*in == ' ' || *in == '\t') 5522347Spst in++; 5622347Spst if (!*in) 5722347Spst return NULL; 5822347Spst 5922347Spst if ((*in >= '0') && (*in <= '9')) 6022347Spst val = *(in++) - '0'; 6122347Spst else 6222347Spst if ((*in >= 'a') && (*in <= 'f')) 6322347Spst val = *(in++) - 'a' + 10; 6422347Spst else 6522347Spst if ((*in >= 'A') && (*in <= 'F')) 6622347Spst val = *(in++) - 'A' + 10; 6722347Spst else 6822347Spst return NULL; 6922347Spst 7022347Spst *out++ |= val; 7122347Spst } 7222347Spst 7322347Spst return out; 7422347Spst} 75