1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's library
3 * Copyright (C) 1998-2007 Ales Hvezda
4 * Copyright (C) 1998-2007 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
28 #include "libgeda_priv.h"
30 #ifdef HAVE_LIBDMALLOC
34 /*! \todo Finish function documentation!!!
36 * \par Function Description
39 STRETCH
*s_stretch_return_tail(STRETCH
*head
)
41 STRETCH
*s_current
=NULL
;
42 STRETCH
*ret_struct
=NULL
;
45 while ( s_current
!= NULL
) { /* goto end of list */
46 ret_struct
= s_current
;
47 s_current
= s_current
->next
;
53 /*! \todo Finish function documentation!!!
55 * \par Function Description
58 STRETCH
*s_stretch_new_head(void)
62 s_new
= (STRETCH
*) g_malloc(sizeof(STRETCH
));
65 s_new
->connection
= NULL
;
74 /*! \todo Finish function documentation!!!
76 * \par Function Description
79 /*! \todo also does the needed work to make the object visually selected */
80 STRETCH
*s_stretch_add(STRETCH
*head
, OBJECT
*object
,
81 CONN
*connection
, int whichone
)
88 while (s_current
!= NULL
) {
89 if (s_current
->object
) {
90 /*printf("%d %d\n", s_current->object->sid, object->sid);*/
91 if (s_current
->object
->sid
== object
->sid
) {
92 /* printf("already inside\n");*/
93 return(s_stretch_return_tail(head
));
97 s_current
= s_current
->next
;
99 /*printf("Adding: %s\n", object->name);*/
101 s_new
= (STRETCH
*) g_malloc(sizeof(STRETCH
));
102 s_new
->object
= object
;
103 s_new
->connection
= connection
;
104 s_new
->whichone
= whichone
;
107 s_new
->prev
= NULL
; /* setup previous link */
111 tail
= s_stretch_return_tail(head
);
112 s_new
->prev
= tail
; /* setup previous link */
119 /*! \todo Finish function documentation!!!
121 * \par Function Description
125 * it's okay to call this with an o_selected which is not necessarily
128 void s_stretch_remove(STRETCH
*head
, OBJECT
*object
)
132 if (object
== NULL
) {
133 fprintf(stderr
, "Got NULL for s_stretch in s_stretch_remove\n");
139 while (s_current
!= NULL
) {
140 if (s_current
->object
== object
) {
142 s_current
->next
->prev
= s_current
->prev
;
144 s_current
->next
= NULL
;
147 s_current
->prev
->next
= s_current
->next
;
149 s_current
->prev
= NULL
;
151 s_current
->object
= NULL
;
152 s_current
->connection
= NULL
;
153 s_current
->whichone
= -1;
158 s_current
= s_current
->next
;
162 /*! \todo Finish function documentation!!!
164 * \par Function Description
167 /*! \note removes all but the head node */
168 void s_stretch_remove_most(STRETCH
*head
)
173 s_current
= s_stretch_return_tail(head
);
175 while (s_current
!= NULL
) {
176 if (s_current
->object
!= NULL
) {
177 s_prev
= s_current
->prev
;
179 s_current
->object
= NULL
;
180 s_current
->connection
= NULL
;
181 s_current
->whichone
= -1;
190 /* clear out any dangling pointers */
194 /*! \todo Finish function documentation!!!
196 * \par Function Description
199 void s_stretch_print_all(STRETCH
const *head
)
201 STRETCH
const *s_current
;
205 printf("START printing stretch ********************\n");
206 while(s_current
!= NULL
) {
207 if (s_current
->object
) {
208 printf("Object: %s\n", s_current
->object
->name
);
210 printf("Object is NULL\n");
213 if (s_current
->object
) {
214 printf("Connection type: %d\n", s_current
->connection
->type
);
216 printf("Connection is NULL\n");
219 printf("which one: %d\n", s_current
->whichone
);
221 s_current
= s_current
->next
;
223 printf("DONE printing stretch ********************\n");
228 /*! \todo Finish function documentation!!!
230 * \par Function Description
233 void s_stretch_destroy_all(STRETCH
*head
)
238 s_current
= s_stretch_return_tail(head
);
240 while (s_current
!= NULL
) {
241 s_prev
= s_current
->prev
;
243 s_current
->object
= NULL
;
244 s_current
->connection
= NULL
;
245 s_current
->whichone
= -1;