minix/lib/libminlib/paramvalue.c
Ben Gras 2fe8fb192f Full switch to clang/ELF. Drop ack. Simplify.
There is important information about booting non-ack images in
docs/UPDATING. ack/aout-format images can't be built any more, and
booting clang/ELF-format ones is a little different. Updating to the
new boot monitor is recommended.

Changes in this commit:

	. drop boot monitor -> allowing dropping ack support
	. facility to copy ELF boot files to /boot so that old boot monitor
	  can still boot fairly easily, see UPDATING
	. no more ack-format libraries -> single-case libraries
	. some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases
	. drop several ack toolchain commands, but not all support
	  commands (e.g. aal is gone but acksize is not yet).
	. a few libc files moved to netbsd libc dir
	. new /bin/date as minix date used code in libc/
	. test compile fix
	. harmonize includes
	. /usr/lib is no longer special: without ack, /usr/lib plays no
	  kind of special bootstrapping role any more and bootstrapping
	  is done exclusively through packages, so releases depend even
	  less on the state of the machine making them now.
	. rename nbsd_lib* to lib*
	. reduce mtree
2012-02-14 14:52:02 +01:00

51 lines
1.3 KiB
C

/* paramvalue() - decode kernel parameter values Author: Kees J. Bot
* 7 May 1994
* The kernel returns the results of parameter queries
* by the XXQUERYPARAM svrctl calls as an array of hex digits, like this:
* "75020000,080C0000". These are the values of two four-byte variables.
* Paramvalue() decodes such a string.
*/
#define nil 0
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <minix/queryparam.h>
size_t paramvalue(char **value, void *address, size_t size)
/* Decode the string *value storing the result in the object at address with
* the given size. *value is left at the next parameter, *address is padded
* with zeros if needed, and the actual size of the value is returned.
*/
{
unsigned char *addr= address;
char *v= *value;
int nibble;
size_t n;
n= 0;
while (*v != 0 && *v != ',') {
nibble= *v++ - '0';
if (nibble > 0x9) nibble= nibble + '0' - 'A' + 0xA;
if (nibble > 0xF) nibble= nibble + 'A' - 'a';
if (size > 0) {
if (n % 2 == 0) {
*addr= nibble << 4;
} else {
*addr++|= nibble;
size--;
}
n++;
}
}
while (size > 0) { *addr++= 0; size--; }
while (*v != 0 && *v++ != ',') {}
*value= v;
return n / 2;
}
/*
* $PchId: paramvalue.c,v 1.3 1996/02/22 09:15:56 philip Exp $
*/