1;;; gEDA - GPL Electronic Design Automation
2;;; gnetlist - gEDA Netlist
3;;; Copyright (C) 1998-2010 Ales Hvezda
4;;; Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
5;;;
6;;; This program is free software; you can redistribute it and/or modify
7;;; it under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 2 of the License, or
9;;; (at your option) any later version.
10;;;
11;;; This program is distributed in the hope that it will be useful,
12;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with this program; if not, write to the Free Software
18;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19;;; MA 02111-1301 USA.
20
21;; RACAL-REDAC / Cadstar netlist format by Wojciech Kazubski 2003
22
23;;
24;; Display the individual net connections
25;;
26(define redac:display-connections
27   (lambda (nets port k)
28      (if (not (null? nets))
29	 (let ((item (string-append (car (car nets)) " " (car (cdr (car nets))))))
30	    (display item port)
31	    (if (not (null? (cdr nets)))
32	       (begin
33	       (if (> k 0)
34	          (begin
35	    	    (display " " port)
36		    (redac:display-connections (cdr nets) port (- k 1)))
37	          (begin
38	            (display (string-append "\r\n"  item " ") port)
39		    (redac:display-connections (cdr nets) port (+ k 6))))))))))
40
41
42(define redac:write-net
43   (lambda (port netnames)
44      (if (not (null? netnames))
45         (let ((netname (car netnames)))
46	    (display ".REM " port)
47	    (display netname port)
48	    (display "\r\n" port)
49            (redac:display-connections
50		       (gnetlist:get-all-connections netname) port 7)
51	    (display "\r\n" port)
52	    (redac:write-net port (cdr netnames))
53	    ))))
54
55(define redac
56   (lambda (filename)
57      (let ((port (if (string=? "-" filename)
58		      (current-output-port)
59		      (open-output-file filename))))
60         (display ".PCB\r\n" port)
61         (display ".REM CREATED BY gEDA GNETLIST\r\n" port)
62         (display ".CON\r\n" port)
63         (display ".COD 2\r\n\r\n" port)
64         (redac:write-net port (gnetlist:get-all-unique-nets "dummy"))
65         (display ".EOD\r\n" port)
66         (close-output-port port))))
67
68
69