--- /dev/null
+/* queryparam.h - query program parameters Author: Kees J. Bot
+ * 22 Apr 1994
+ */
+#ifndef _MINIX__QUERYPARAM_H
+#define _MINIX__QUERYPARAM_H
+
+#include <ansi.h>
+
+typedef size_t _mnx_size_t;
+
+struct export_param_list {
+ char *name; /* "variable", "[", ".field", or NULL. */
+ void *offset; /* Address of a variable or field offset. */
+ size_t size; /* Size of the resulting object. */
+};
+
+struct export_params {
+ struct export_param_list *list; /* List of exported parameters. */
+ struct export_params *next; /* Link several sets of parameters. */
+};
+
+#ifdef __STDC__
+#define qp_stringize(var) #var
+#define qp_dotstringize(var) "." #var
+#else
+#define qp_stringize(var) "var"
+#define qp_dotstringize(var) ".var"
+#endif
+#define QP_VARIABLE(var) { qp_stringize(var), &(var), sizeof(var) }
+#define QP_ARRAY(var) { "[", 0, sizeof((var)[0]) }
+#define QP_VECTOR(var,ptr,len) { qp_stringize(var), &(ptr), -1 },\
+ { "[", &(len), sizeof(*(ptr)) }
+#define QP_FIELD(field, type) { qp_dotstringize(field), \
+ (void *)offsetof(type, field), \
+ sizeof(((type *)0)->field) }
+#define QP_END() { 0, 0, 0 }
+
+void qp_export _ARGS((struct export_params *_ex_params));
+int queryparam _ARGS((int (*_qgetc) _ARGS((void)), void **_paddress,
+ _mnx_size_t *_psize));
+_mnx_size_t paramvalue _ARGS((char **_value, void *_address,
+ _mnx_size_t _size));
+#endif /* _MINIX__QUERYPARAM_H */
+
+/* $PchId: queryparam.h,v 1.1 2005/06/28 14:31:26 philip Exp $ */
--- /dev/null
+/* 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 $
+ */