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)
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111 USA
29 #include <libgeda/libgeda.h>
31 #include "../include/globals.h"
32 #include "../include/prototype.h"
34 #ifdef HAVE_LIBDMALLOC
40 static TOPLEVEL
*project_current
;
42 void g_set_project_current(TOPLEVEL
* pr_current
)
44 project_current
= pr_current
;
48 SCM
g_scm_c_get_uref (TOPLEVEL
*toplevel
, OBJECT
*object
)
50 SCM func
= scm_variable_ref (scm_c_lookup ("get-uref"));
51 SCM object_smob
= g_make_object_smob (toplevel
, object
);
52 SCM exp
= scm_list_2 (func
, object_smob
);
54 return g_scm_eval_protected (exp
, SCM_UNDEFINED
);
58 /* this function will only return a unique list of packages */
59 SCM
g_get_packages(SCM level
)
64 NETLIST
*nl_current
= NULL
;
66 SCM_ASSERT(scm_is_string (level
), level
, SCM_ARG1
, "gnetlist:get-pins");
68 /* build a hash table */
69 ht
= g_hash_table_new (g_str_hash
, g_str_equal
);
70 for (nl_current
= netlist_head
; nl_current
!= NULL
;
71 nl_current
= nl_current
->next
) {
72 if (nl_current
->component_uref
!= NULL
) {
73 /* add component_uref in the hash table */
74 /* uniqueness of component_uref is guaranteed by the hashtable */
76 if (g_hash_table_lookup (ht
, nl_current
->component_uref
) == NULL
) {
77 g_hash_table_insert (ht
, nl_current
->component_uref
,
78 nl_current
->component_uref
);
79 list
= scm_cons (scm_makfrom0str (nl_current
->component_uref
), list
);
83 g_hash_table_destroy (ht
);
88 /* this function will only return a non unique list of packages */
89 SCM
g_get_non_unique_packages(SCM level
)
93 NETLIST
*nl_current
= NULL
;
95 SCM_ASSERT(scm_is_string (level
), level
, SCM_ARG1
, "gnetlist:get-pins");
97 for (nl_current
= netlist_head
; nl_current
!= NULL
;
98 nl_current
= nl_current
->next
) {
99 if (nl_current
->component_uref
!= NULL
) {
100 list
= scm_cons (scm_makfrom0str (nl_current
->component_uref
),
109 SCM
g_get_pins(SCM uref
)
113 CPINLIST
*pl_current
;
115 SCM_ASSERT(scm_is_string (uref
), uref
, SCM_ARG1
, "gnetlist:get-pins");
117 /* here is where you make it multi page aware */
118 nl_current
= netlist_head
;
120 /* search for the first instance */
121 /* through the entire list */
122 while (nl_current
!= NULL
) {
124 if (nl_current
->component_uref
) {
125 if (strcmp(nl_current
->component_uref
, SCM_STRING_CHARS (uref
)) == 0) {
127 pl_current
= nl_current
->cpins
;
128 while (pl_current
!= NULL
) {
129 if (pl_current
->pin_number
) {
130 list
= scm_cons (scm_makfrom0str (pl_current
->pin_number
),
133 pl_current
= pl_current
->next
;
137 nl_current
= nl_current
->next
;
143 SCM
g_get_all_nets(SCM scm_level
)
148 CPINLIST
*pl_current
;
151 SCM_ASSERT(scm_is_string (scm_level
), scm_level
, SCM_ARG1
,
152 "gnetlist:get-all-nets");
154 nl_current
= netlist_head
;
156 /* walk through the list of components, and through the list
157 * of individual pins on each, adding net names to the list
158 * being careful to ignore duplicates, and unconnected pins
160 while (nl_current
!= NULL
) {
161 pl_current
= nl_current
->cpins
;
162 while (pl_current
!= NULL
) {
163 if (pl_current
->net_name
) {
165 net_name
= pl_current
->net_name
;
166 /* filter off unconnected pins */
167 if (strncmp(net_name
, "unconnected_pin", 15) != 0) {
168 /*printf("Got net: `%s'\n",net_name); */
169 /* add the net name to the list */
171 printf("Got net: `%s'\n", net_name
);
172 printf("pin %s\n", pl_current
->pin_number
);
174 list
= scm_cons (scm_makfrom0str (net_name
),
178 pl_current
= pl_current
->next
;
180 nl_current
= nl_current
->next
;
186 SCM
g_get_all_unique_nets(SCM scm_level
)
192 CPINLIST
*pl_current
;
195 SCM_ASSERT(scm_is_string (scm_level
), scm_level
, SCM_ARG1
,
196 "gnetlist:get-all-unique-nets");
198 nl_current
= netlist_head
;
200 /* walk through the list of components, and through the list
201 * of individual pins on each, adding net names to the list
202 * being careful to ignore duplicates, and unconnected pins
204 while (nl_current
!= NULL
) {
205 pl_current
= nl_current
->cpins
;
206 while (pl_current
!= NULL
) {
207 if (pl_current
->net_name
) {
209 net_name
= pl_current
->net_name
;
210 /* filter off unconnected pins */
211 if (strncmp(net_name
, "unconnected_pin", 15) != 0) {
212 /* add the net name to the list */
213 /*printf("Got net: `%s'\n",net_name); */
215 x
= scm_makfrom0str (net_name
);
216 if (scm_member(x
, list
) == SCM_BOOL_F
) {
217 list
= scm_cons (x
, list
);
221 pl_current
= pl_current
->next
;
223 nl_current
= nl_current
->next
;
229 /* given a net name, return all connections */
230 SCM
g_get_all_connections(SCM scm_netname
)
235 SCM is_member
= SCM_EOL
;
236 SCM connlist
= SCM_EOL
;
237 SCM pairlist
= SCM_EOL
;
239 CPINLIST
*pl_current
;
241 char *wanted_net_name
;
246 SCM_ASSERT(scm_is_string(scm_netname
), scm_netname
, SCM_ARG1
,
247 "gnetlist:get-all-connections");
249 wanted_net_name
= SCM_STRING_CHARS (scm_netname
);
251 if (wanted_net_name
== NULL
) {
256 nl_current
= netlist_head
;
258 /* walk through the list of components, and through the list
259 * of individual pins on each, adding net names to the list
260 * being careful to ignore duplicates, and unconnected pins
262 while (nl_current
!= NULL
) {
263 pl_current
= nl_current
->cpins
;
264 while (pl_current
!= NULL
) {
265 if (pl_current
->net_name
) {
267 net_name
= pl_current
->net_name
;
268 /* filter off unconnected pins */
269 if (strcmp(net_name
, wanted_net_name
) == 0) {
270 /* add the net name to the list */
273 printf("found net: `%s'\n", net_name
);
276 n_current
= pl_current
->nets
;
277 while (n_current
!= NULL
) {
279 if (n_current
->connected_to
) {
282 pin
= (char *) g_malloc(sizeof(char) *
286 (char *) g_malloc(sizeof(char) *
290 sscanf(n_current
->connected_to
,
293 pairlist
= scm_list_n (scm_makfrom0str (uref
),
294 scm_makfrom0str (pin
),
298 is_member
= scm_member(x
, connlist
);
300 if (is_member
== SCM_BOOL_F
) {
301 connlist
= scm_cons (pairlist
, connlist
);
307 n_current
= n_current
->next
;
311 pl_current
= pl_current
->next
;
313 nl_current
= nl_current
->next
;
319 /* Given a uref and a pin number return a list of: */
320 /* (netname (uref pin) (uref pin) ... ) */
321 SCM
g_get_nets(SCM scm_uref
, SCM scm_pin
)
323 SCM outerlist
= SCM_EOL
;
324 SCM pinslist
= SCM_EOL
;
325 SCM pairlist
= SCM_EOL
;
326 NETLIST
*nl_current
= NULL
;
327 CPINLIST
*pl_current
= NULL
;
329 char *wanted_uref
= NULL
;
330 char *wanted_pin
= NULL
;
331 char *net_name
= NULL
;
336 SCM_ASSERT(scm_is_string (scm_uref
), scm_uref
, SCM_ARG1
,
337 "gnetlist:get-nets");
339 SCM_ASSERT(scm_is_string (scm_pin
), scm_pin
, SCM_ARG2
,
340 "gnetlist:get-nets");
343 wanted_uref
= SCM_STRING_CHARS (scm_uref
);
344 wanted_pin
= SCM_STRING_CHARS (scm_pin
);
346 nl_current
= netlist_head
;
348 /* search for the first instance */
349 /* through the entire list */
350 while (nl_current
!= NULL
) {
352 if (nl_current
->component_uref
) {
354 if (strcmp(nl_current
->component_uref
, wanted_uref
) == 0) {
356 pl_current
= nl_current
->cpins
;
357 while (pl_current
!= NULL
) {
359 if (pl_current
->pin_number
) {
360 if (strcmp(pl_current
->pin_number
, wanted_pin
) ==
363 n_current
= pl_current
->nets
;
365 if (pl_current
->net_name
) {
366 net_name
= pl_current
->net_name
;
369 while (n_current
!= NULL
) {
371 if (n_current
->connected_to
) {
374 pin
= (char *) g_malloc(sizeof(char) *
379 (char *) g_malloc(sizeof(char) *
383 sscanf(n_current
->connected_to
,
386 pairlist
= scm_list_n (scm_makfrom0str (uref
),
387 scm_makfrom0str (pin
),
390 pinslist
= scm_cons (pairlist
, pinslist
);
395 n_current
= n_current
->next
;
399 pl_current
= pl_current
->next
;
403 nl_current
= nl_current
->next
;
406 if (net_name
!= NULL
) {
407 outerlist
= scm_cons (scm_makfrom0str (net_name
), pinslist
);
409 outerlist
= scm_cons (scm_makfrom0str ("ERROR_INVALID_PIN"),
411 fprintf(stderr
, "Invalid wanted_pin passed to get-nets [%s]\n",
419 /* Given a uref, Return a list of pairs, each pair contains the name
420 * of the pin, and the name of the net connected to that pin.
422 SCM
g_get_pins_nets(SCM scm_uref
)
424 SCM pinslist
= SCM_EOL
;
425 SCM pairlist
= SCM_EOL
;
426 NETLIST
*nl_current
= NULL
;
427 CPINLIST
*pl_current
= NULL
;
429 char *wanted_uref
= NULL
;
430 char *net_name
= NULL
;
433 SCM_ASSERT(scm_is_string (scm_uref
),
434 scm_uref
, SCM_ARG1
, "gnetlist:get-pins-nets");
436 wanted_uref
= SCM_STRING_CHARS (scm_uref
);
438 /* search for the any instances */
439 /* through the entire list */
440 for (nl_current
= netlist_head
; nl_current
!= NULL
;
441 nl_current
= nl_current
->next
) {
443 /* is there a uref? */
444 if (nl_current
->component_uref
) {
445 /* is it the one we want ? */
446 if (strcmp(nl_current
->component_uref
, wanted_uref
) == 0) {
448 for (pl_current
= nl_current
->cpins
; pl_current
!= NULL
;
449 pl_current
= pl_current
->next
) {
450 /* is there a valid pin number and a valid name ? */
451 if (pl_current
->pin_number
) {
452 if (pl_current
->net_name
) {
453 /* yes, add it to the list */
454 pin
= pl_current
->pin_number
;
455 net_name
= pl_current
->net_name
;
457 pairlist
= scm_cons (scm_makfrom0str (pin
),
458 scm_makfrom0str (net_name
));
459 pinslist
= scm_cons (pairlist
, pinslist
);
468 pinslist
= scm_reverse (pinslist
); /* pins are in reverse order on the way
475 SCM
g_get_package_attribute(SCM scm_uref
, SCM scm_wanted_attrib
)
477 SCM scm_return_value
;
481 char *return_value
= NULL
;
483 SCM_ASSERT(scm_is_string (scm_uref
),
484 scm_uref
, SCM_ARG1
, "gnetlist:get-package-attribute");
486 SCM_ASSERT(scm_is_string (scm_wanted_attrib
),
487 scm_wanted_attrib
, SCM_ARG2
, "gnetlist:get-package-attribute");
489 uref
= scm_to_locale_string (scm_uref
);
490 wanted_attrib
= scm_to_locale_string (scm_wanted_attrib
);
492 /* here is where you make it multi page aware */
493 nl_current
= netlist_head
;
495 /* search for the first instance */
496 /* through the entire list */
497 while (nl_current
!= NULL
) {
499 if (nl_current
->component_uref
) {
500 if (strcmp(nl_current
->component_uref
, uref
) == 0) {
503 o_attrib_search_object_attribs_by_name (nl_current
->object_ptr
,
508 nl_current
= nl_current
->next
;
512 scm_return_value
= scm_makfrom0str (return_value
);
514 scm_return_value
= scm_makfrom0str ("unknown");
518 free (wanted_attrib
);
520 return (scm_return_value
);
523 /* takes a uref and pinseq number and returns wanted_attribute associated */
524 /* with that pinseq pin and component */
525 SCM
g_get_attribute_by_pinseq(SCM scm_uref
, SCM scm_pinseq
,
526 SCM scm_wanted_attrib
)
528 SCM scm_return_value
;
533 char *return_value
= NULL
;
534 OBJECT
*o_pin_object
;
536 SCM_ASSERT(scm_is_string (scm_uref
),
537 scm_uref
, SCM_ARG1
, "gnetlist:get-pin-number-seq");
539 SCM_ASSERT(scm_is_string (scm_pinseq
),
540 scm_pinseq
, SCM_ARG2
, "gnetlist:get-pin-number-seq");
543 SCM_ASSERT(scm_is_string (scm_wanted_attrib
),
544 scm_wanted_attrib
, SCM_ARG3
, "gnetlist:get-pin-attribute-seq");
546 uref
= SCM_STRING_CHARS (scm_uref
);
547 pinseq
= SCM_STRING_CHARS (scm_pinseq
);
548 wanted_attrib
= SCM_STRING_CHARS (scm_wanted_attrib
);
551 printf("gnetlist:g_netlist.c:g_get_attribute_by_pinseq -- \n");
552 printf(" wanted uref = %s\n", uref
);
553 printf(" wanted_pin_seq = %s\n", pinseq
);
554 printf(" wanted_attrib = %s\n", wanted_attrib
);
557 /* here is where you make it multi page aware */
558 nl_current
= netlist_head
;
560 /* search for the first instance */
561 /* through the entire list */
562 while (nl_current
!= NULL
) {
564 if (nl_current
->component_uref
) {
565 if (strcmp(nl_current
->component_uref
, uref
) == 0) {
567 o_pin_object
= o_complex_find_pin_by_attribute (nl_current
->object_ptr
,
572 o_attrib_search_object_attribs_by_name (o_pin_object
,
579 /* Don't break until we search the whole netlist to handle slotted */
580 /* parts. 4.28.2007 -- SDB. */
583 nl_current
= nl_current
->next
;
587 scm_return_value
= scm_makfrom0str (return_value
);
589 scm_return_value
= scm_makfrom0str ("unknown");
593 printf("gnetlist:g_netlist.c:g_get_attribute_by_pinseq -- ");
594 printf("return_value: %s\n", return_value
);
597 return (scm_return_value
);
600 /* this takes a pin number and returns the appropriate attribute on that pin*/
601 /* scm_pin is the value associated with the pinnumber= attribute and uref */
602 SCM
g_get_attribute_by_pinnumber(SCM scm_uref
, SCM scm_pin
, SCM
605 SCM scm_return_value
;
611 char *return_value
= NULL
;
614 SCM_ASSERT(scm_is_string (scm_uref
),
615 scm_uref
, SCM_ARG1
, "gnetlist:get-pin-attribute");
617 SCM_ASSERT(scm_is_string (scm_pin
),
618 scm_pin
, SCM_ARG2
, "gnetlist:get-pin-attribute");
620 SCM_ASSERT(scm_is_string (scm_wanted_attrib
),
621 scm_wanted_attrib
, SCM_ARG3
, "gnetlist:get-pin-attribute");
623 uref
= SCM_STRING_CHARS (scm_uref
);
624 pin
= SCM_STRING_CHARS (scm_pin
);
625 wanted_attrib
= SCM_STRING_CHARS (scm_wanted_attrib
);
627 /* here is where you make it multi page aware */
628 nl_current
= netlist_head
;
630 /* search for the first instance */
631 /* through the entire list */
632 while (nl_current
!= NULL
&& !done
) {
633 if (nl_current
->component_uref
) {
634 if (strcmp(nl_current
->component_uref
, uref
) == 0) {
637 o_complex_find_pin_by_attribute (nl_current
->object_ptr
,
642 /* only look for the first occurance of wanted_attrib */
644 o_attrib_search_object_attribs_by_name (pin_object
,
648 printf("GOT IT: %s\n", return_value
);
651 } else if (strcmp("pintype",
652 wanted_attrib
) == 0) {
653 if (nl_current
->cpins
) {
654 CPINLIST
*pinobject
=
655 s_cpinlist_search_pin(nl_current
->cpins
, pin
);
660 printf("Supplied pintype 'pwr' for artificial pin '%s' of '%s'\n",
668 nl_current
= nl_current
->next
;
672 scm_return_value
= scm_makfrom0str (return_value
);
674 scm_return_value
= scm_makfrom0str ("unknown");
677 return (scm_return_value
);
681 /* returns value of attribute otherwise string "none" */
682 /* still highly temp and doesn't work right */
683 SCM
g_get_toplevel_attribute(SCM scm_wanted_attrib
)
688 char *attrib_value
= NULL
;
689 SCM scm_return_value
;
691 SCM_ASSERT(scm_is_string (scm_wanted_attrib
),
692 scm_wanted_attrib
, SCM_ARG1
, "gnetlist:get-toplevel-attribute");
694 wanted_attrib
= SCM_STRING_CHARS (scm_wanted_attrib
);
696 for (p_iter
= geda_list_get_glist (project_current
->pages
); p_iter
!= NULL
;
697 p_iter
= g_list_next (p_iter
)) {
698 p_current
= p_iter
->data
;
700 /* only look for first occurrance of the attribute on each page */
702 o_attrib_search_floating_attribs_by_name (s_page_objects (p_current
),
705 /* Stop when we find the first one */
706 if (attrib_value
!= NULL
)
710 if (attrib_value
!= NULL
) {
711 scm_return_value
= scm_makfrom0str (attrib_value
);
712 g_free (attrib_value
);
714 scm_return_value
= scm_makfrom0str ("not found");
717 return (scm_return_value
);
720 #if 0 /* No longer needed, but the netlist_mode variable is still used */
721 SCM
g_set_netlist_mode(SCM mode
)
725 string
= SCM_STRING_CHARS (mode
);
727 if (strcmp(string
, "gEDA") == 0) {
729 } else if (strcmp(string
, "SPICE") == 0) {
730 netlist_mode
= SPICE
;
731 } else if (strcmp(string
, "TANGO") == 0) {
732 netlist_mode
= TANGO
;
735 printf("netlist_mode: %s %d\n", string
, netlist_mode
);
738 return (scm_from_int (0));
742 /* Given an uref, return a list of used slots in the schematic */
743 /* in the form: (1 2 3 4). Repeated slots are returned. */
744 SCM
g_get_slots(SCM scm_uref
)
749 char *slot_tmp
= NULL
;
750 SCM slots_list
= SCM_EOL
;
754 SCM_ASSERT(scm_is_string (scm_uref
),
755 scm_uref
, SCM_ARG1
, "gnetlist:get-slots-used-of-package");
757 uref
= SCM_STRING_CHARS (scm_uref
);
759 /* here is where you make it multi page aware */
760 nl_current
= netlist_head
;
762 /* search for the first instance */
763 /* through the entire list */
764 while (nl_current
!= NULL
) {
766 if (nl_current
->component_uref
) {
767 if (strcmp(nl_current
->component_uref
, uref
) == 0) {
769 /* first search outside the symbol */
771 o_attrib_search_object_attribs_by_name (nl_current
->object_ptr
,
774 /* When a package has no slot attribute, then assume it's slot number 1 */
776 slot_tmp
=g_strdup("1");
778 slot
= g_strconcat ("#d", slot_tmp
, NULL
);
779 slot_number
= scm_string_to_number(scm_makfrom0str (slot
),
782 if (slot_number
!= SCM_BOOL_F
) {
783 slots_list
= scm_cons (slot_number
, slots_list
);
786 fprintf(stderr
, "Uref %s: Bad slot number: %s.\n", uref
, slot_tmp
);
790 nl_current
= nl_current
->next
;
793 slots_list
= scm_sort_list_x(slots_list
,
794 SCM_VARIABLE_REF (scm_c_module_lookup (
795 scm_current_module (), "<")));
800 /* Given an uref, return a unique list of used slots in the schematic */
801 /* in the form: (1 2 3 4). Repeated slots are NOT returned */
802 SCM
g_get_unique_slots(SCM scm_uref
)
807 char *slot_tmp
= NULL
;
808 SCM slots_list
= SCM_EOL
;
812 SCM_ASSERT(scm_is_string (scm_uref
),
813 scm_uref
, SCM_ARG1
, "gnetlist:get-unique-slots-used-of-package");
815 uref
= SCM_STRING_CHARS (scm_uref
);
817 /* here is where you make it multi page aware */
818 nl_current
= netlist_head
;
820 /* search for the first instance */
821 /* through the entire list */
822 while (nl_current
!= NULL
) {
824 if (nl_current
->component_uref
) {
825 if (strcmp(nl_current
->component_uref
, uref
) == 0) {
827 /* first search outside the symbol */
829 o_attrib_search_object_attribs_by_name (nl_current
->object_ptr
,
832 /* When a package has no slot attribute, then assume it's slot number 1 */
834 slot_tmp
=g_strdup("1");
836 slot
= g_strconcat ("#d", slot_tmp
, NULL
);
837 slot_number
= scm_string_to_number(scm_makfrom0str (slot
),
840 if (slot_number
!= SCM_BOOL_F
) {
841 if (scm_member(slot_number
, slots_list
) == SCM_BOOL_F
) {
842 slots_list
= scm_cons (slot_number
, slots_list
);
846 fprintf(stderr
, "Uref %s: Bad slot number: %s.\n", uref
, slot_tmp
);
850 nl_current
= nl_current
->next
;
853 slots_list
= scm_sort_list_x(slots_list
,
854 SCM_VARIABLE_REF (scm_c_module_lookup (
855 scm_current_module (), "<")));
861 This function returns certain calling flags to the calling guile prog.
862 The calling flags are returned to Guile as a list of option/value pairs [e.g.
863 ((verbose_mode #t) (interactive_mode #f) . . . ) ]
864 It is used primarily to enable refdes sorting during netlisting via
865 the -s flag. Note that this prog is not very flexible -- the allowed
866 calling flags are hard coded into the function. At some point this
867 should be fixed . . .
870 8.2.2005 -- Carlos Nieves Onega
871 Different modes are now included in the backend_params list, as well as
872 the backend parameters given from the command line. Since the function
873 calling-flag? in scheme/gnetlist.scm returns false if the calling flag was
874 not found, it's only necessary to include the flags being true.
876 SCM
g_get_calling_flags()
878 SCM arglist
= SCM_EOL
;
882 aux
= backend_params
;
883 while (aux
!= NULL
) {
884 arglist
= scm_cons (scm_list_n (scm_makfrom0str (aux
->data
),
895 /* -------------------------------------------------------------------- *
896 * This fcn returns the command line with which gnetlist was invoked.
897 * It is used to write the first line of a SPICE file when netlisting
900 * -------------------------------------------------------------------- */
901 SCM
g_get_command_line()
905 commandline
= scm_makfrom0str (command_line
);
907 return (commandline
);
911 /* given a net name, an attribute, and a wanted attribute, return all
912 the given attribute of all the graphical objects connected to that
914 SCM
g_graphical_objs_in_net_with_attrib_get_attrib (SCM scm_netname
, SCM scm_has_attribute
, SCM scm_wanted_attribute
)
919 CPINLIST
*pl_current
;
920 char *wanted_net_name
;
924 char *attrib_value
=NULL
;
925 char *has_attrib_value
= NULL
;
926 char *has_attrib_name
= NULL
;
928 SCM_ASSERT(scm_is_string (scm_netname
), scm_netname
, SCM_ARG1
,
929 "gnetlist:get-attr-of-conn-graph-objs-with-attr");
931 SCM_ASSERT(scm_is_string (scm_wanted_attribute
),
932 scm_wanted_attribute
, SCM_ARG2
,
933 "gnetlist:get-attr-of-conn-graph-objs-with-attr");
935 SCM_ASSERT(scm_is_string (scm_has_attribute
),
936 scm_has_attribute
, SCM_ARG3
,
937 "gnetlist:get-attr-of-conn-graph-objs-with-attr");
939 wanted_net_name
= SCM_STRING_CHARS (scm_netname
);
940 wanted_attrib
= SCM_STRING_CHARS (scm_wanted_attribute
);
941 has_attrib
= SCM_STRING_CHARS (scm_has_attribute
);
943 if (wanted_net_name
== NULL
) {
948 nl_current
= graphical_netlist_head
;
950 /* walk through the list of components, and through the list
951 * of individual pins on each, adding net names to the list
952 * being careful to ignore duplicates, and unconnected pins
954 while (nl_current
!= NULL
) {
955 pl_current
= nl_current
->cpins
;
956 while (pl_current
!= NULL
) {
957 if (pl_current
->net_name
) {
958 net_name
= pl_current
->net_name
;
959 if (strcmp(net_name
, wanted_net_name
) == 0) {
961 if (o_attrib_string_get_name_value (has_attrib
, &has_attrib_name
,
962 &has_attrib_value
) != 0) {
964 o_attrib_search_object_attribs_by_name (nl_current
->object_ptr
,
967 if ( ((has_attrib_value
== NULL
) && (attrib_value
== NULL
)) ||
968 ((has_attrib_value
!= NULL
) && (attrib_value
!= NULL
) &&
969 (strcmp(attrib_value
, has_attrib_value
) == 0)) ) {
970 g_free (attrib_value
);
972 o_attrib_search_object_attribs_by_name (nl_current
->object_ptr
,
975 list
= scm_cons (scm_makfrom0str (attrib_value
), list
);
977 g_free (attrib_value
);
979 g_free (has_attrib_name
);
980 g_free (has_attrib_value
);
984 pl_current
= pl_current
->next
;
986 nl_current
= nl_current
->next
;
997 * This function is in s_rename.c: SCM g_get_renamed_nets(SCM scm_level)