From owner-freebsd-arch Thu Apr 27 10:56:45 2000 Delivered-To: freebsd-arch@freebsd.org Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (Postfix) with ESMTP id 0E27637B53C for ; Thu, 27 Apr 2000 10:56:35 -0700 (PDT) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.3/8.9.3) with ESMTP id TAA01953 for ; Thu, 27 Apr 2000 19:56:29 +0200 (CEST) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id TAA01263 for freebsd-arch@freebsd.org; Thu, 27 Apr 2000 19:56:29 +0200 (CEST) Received: from bubba.whistle.com (bubba.whistle.com [207.76.205.7]) by hub.freebsd.org (Postfix) with ESMTP id D8E5137B798 for ; Thu, 27 Apr 2000 10:54:04 -0700 (PDT) (envelope-from archie@whistle.com) Received: (from archie@localhost) by bubba.whistle.com (8.9.3/8.9.2) id KAA66171 for freebsd-arch@freebsd.org; Thu, 27 Apr 2000 10:54:04 -0700 (PDT) From: Archie Cobbs Message-Id: <200004271754.KAA66171@bubba.whistle.com> Subject: ASCII <--> binary conversion in the kernel To: freebsd-arch@freebsd.org Date: Thu, 27 Apr 2000 10:54:04 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, In developing netgraph we came up with a way to easily convert an arbitrary C structure, even one with variable length array fields, into a human readable ASCII string and back, all farily efficiently from within the kernel. The code that does this is completely indepedent from the rest of netgraph and lives in these files: /usr/src/sys/netgraph/ng_parse.h /usr/src/sys/netgraph/ng_parse.c It occurred to me that this capability might be useful in other parts of the kernel, e.g., "device hints" structures, KLD module initialization files, sysctl, etc. It's not even limited to C structures; it can convert any structured binary data to ASCII and back. Just wanted to give people a heads-up in case anyone is looking for such a thing. We've found it pretty handy. For details, see: http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netgraph/ng_parse.h?rev=1.3 -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message