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 
22 #include <config.h>
23 #include <missing.h>
24 
25 #include <stdio.h>
26 #ifdef HAVE_STRING_H
27 #include <string.h>
28 #endif
29 #include <math.h>
30 
31 #include <libgeda/libgeda.h>
32 
33 #include "../include/globals.h"
34 #include "../include/prototype.h"
35 
36 #ifdef HAVE_LIBDMALLOC
37 #include <dmalloc.h>
38 #endif
39 
40 SCM
vams_get_attribs_list(OBJECT * object)41 vams_get_attribs_list (OBJECT *object)
42 {
43   SCM list = SCM_EOL;
44   OBJECT *o_current;
45   GList *a_iter;
46   OBJECT *a_current;
47   int val;
48   char* found_name = NULL;
49 
50   o_current = object;
51 
52   /* search outside the symbol (attached attributes only) */
53   a_iter = o_current->attribs;
54   while(a_iter != NULL) {
55     a_current = a_iter->data;
56     if (a_current->text && a_current->text->string) {
57       val = o_attrib_get_name_value (a_current, &found_name, NULL);
58 
59       if (val) {
60         list = scm_cons (scm_from_utf8_string (found_name), list);
61       }
62 
63       g_free (found_name);
64     }
65     a_iter = g_list_next (a_iter);
66   }
67 
68   return list;
69 }
70 
71 SCM
vams_get_package_attributes(SCM scm_uref)72 vams_get_package_attributes(SCM scm_uref)
73 {
74   NETLIST *nl_current;
75   char *uref;
76 
77   SCM_ASSERT(scm_is_string (scm_uref), scm_uref, SCM_ARG1,
78              "gnetlist:vams-get-package-attributes");
79 
80   uref = scm_to_utf8_string (scm_uref);
81 
82   /* here is where you make it multi page aware */
83   nl_current = netlist_head;
84 
85   /* search for the first instance */
86   /* through the entire list */
87   while(nl_current != NULL) {
88 
89     if (nl_current->component_uref &&
90         strcmp(nl_current->component_uref, uref) == 0) {
91       free (uref);
92       return vams_get_attribs_list (nl_current->object_ptr);
93     }
94     nl_current = nl_current->next;
95   }
96 
97   free (uref);
98   return SCM_EOL;
99 }
100