From owner-freebsd-multimedia Thu Aug 21 18:23:25 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id SAA06251 for multimedia-outgoing; Thu, 21 Aug 1997 18:23:25 -0700 (PDT) Received: from rah.star-gate.com (rah.star-gate.com [204.188.121.18]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id SAA06242 for ; Thu, 21 Aug 1997 18:23:12 -0700 (PDT) Received: from rah.star-gate.com (localhost.star-gate.com [127.0.0.1]) by rah.star-gate.com (8.8.7/8.8.5) with ESMTP id SAA00408; Thu, 21 Aug 1997 18:23:10 -0700 (PDT) Message-Id: <199708220123.SAA00408@rah.star-gate.com> X-Mailer: exmh version 2.0gamma 1/27/96 To: multimedia@freebsd.org cc: luigi@labinfo.iet.unipi.it Subject: new isa.c Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="==_Exmh_262108880" Date: Thu, 21 Aug 1997 18:23:09 -0700 From: Amancio Hasty Sender: owner-freebsd-multimedia@freebsd.org X-Loop: FreeBSD.org Precedence: bulk This is a multipart MIME message. --==_Exmh_262108880 Content-Type: text/plain; charset=us-ascii --==_Exmh_262108880 Content-Type: application/octet-stream ; name="isa.c" Content-Description: isa.c Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="isa.c" LyotCiAqIENvcHlyaWdodCAoYykgMTk5MSBUaGUgUmVnZW50cyBvZiB0aGUgVW5pdmVyc2l0 eSBvZiBDYWxpZm9ybmlhLgogKiBBbGwgcmlnaHRzIHJlc2VydmVkLgogKgogKiBUaGlzIGNv ZGUgaXMgZGVyaXZlZCBmcm9tIHNvZnR3YXJlIGNvbnRyaWJ1dGVkIHRvIEJlcmtlbGV5IGJ5 CiAqIFdpbGxpYW0gSm9saXR6LgogKgogKiBSZWRpc3RyaWJ1dGlvbiBhbmQgdXNlIGluIHNv dXJjZSBhbmQgYmluYXJ5IGZvcm1zLCB3aXRoIG9yIHdpdGhvdXQKICogbW9kaWZpY2F0aW9u LCBhcmUgcGVybWl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