1 /* gEDA - GPL Electronic Design Automation
2 * gattrib -- gEDA component and net attribute manipulation using spreadsheet.
3 * Copyright (C) 2003-2007 Stuart D. Brorson.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
28 /*------------------------------------------------------------------
29 * Gattrib specific includes
30 *------------------------------------------------------------------*/
31 #include <libgeda/libgeda.h> /* geda library fcns */
32 #include "../include/struct.h" /* typdef and struct declarations */
33 #include "../include/prototype.h" /* function prototypes */
34 #include "../include/globals.h"
36 #ifdef HAVE_LIBDMALLOC
41 /*------------------------------------------------------------------*/
42 /*! \brief This fcn is passed a STRING_LIST of name=value pairs, and a
45 * \return It returns 1 (TRUE) if the name is in the STRING_LIST, otherwise
46 * it returns 0 (FALSE).
47 *------------------------------------------------------------------*/
48 int s_attrib_name_in_list(STRING_LIST
*name_value_list
, char *name
)
50 STRING_LIST
*local_list_item
;
53 local_list_item
= name_value_list
;
54 while (local_list_item
!= NULL
) {
55 local_name
= u_basic_breakup_string(local_list_item
->data
, '=', 0);
56 if (strcmp(local_name
, name
) == 0) {
59 local_list_item
= local_list_item
->next
;
65 /*------------------------------------------------------------------*/
66 /*! \brief This fcn takes an object, finds its refdes and returns it.
68 * \return For normal components, it returns a (pointer to a)
69 * string containing the
70 * refdes If the component is slotted, it returns a refdes of the form
71 * refdes.slot. If no refdes is found, it returns NULL.
72 *------------------------------------------------------------------*/
73 char *s_attrib_get_refdes(OBJECT
*object
)
78 OBJECT
*slot_text_object
;
80 /*------ Try to get the refdes -----*/
81 temp_uref
= o_attrib_search_name_single(object
, "refdes", NULL
);
83 temp_uref
= o_attrib_search_name_single(object
, "uref", NULL
); // deprecated
85 printf("WARNING: Found uref=%s, uref= is deprecated, please use refdes=\n", temp_uref
);
86 } else { /* didn't find refdes. Report error to log. */
88 printf("In s_attrib_get_refdes, found non-graphical component with no refdes.\n");
89 printf(". . . . complex_basename = %s.\n", object
->complex_basename
);
96 printf("In s_attrib_get_refdes, found component with refdes %s.\n", temp_uref
);
99 /*------- Now append .slot to refdes if part is slotted -------- */
100 /* Find out if this is a multislotted component */
101 numslots_value
= o_attrib_search_numslots(object
, NULL
);
102 if (numslots_value
!= NULL
) { /* this is a slotted component;
103 append slot number to refdes. */
104 slot_value
= o_attrib_search_slot(object
, &slot_text_object
);
106 printf(". . . , found slotted component with slot = %s\n", slot_value
);
108 temp_uref
= g_strconcat(temp_uref
, ".", slot_value
, NULL
);
112 printf(". . . . returning refdes %s.\n", temp_uref
);