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
30 #ifndef HAVE_VSNPRINTF
44 #include "../include/prototype.h"
46 #ifdef HAVE_LIBDMALLOC
50 /*! \todo Finish function documentation!!!
52 * \par Function Description
55 STRETCH
*s_stretch_return_tail(STRETCH
*head
)
57 STRETCH
*s_current
=NULL
;
58 STRETCH
*ret_struct
=NULL
;
61 while ( s_current
!= NULL
) { /* goto end of list */
62 ret_struct
= s_current
;
63 s_current
= s_current
->next
;
69 /*! \todo Finish function documentation!!!
71 * \par Function Description
74 STRETCH
*s_stretch_return_head(STRETCH
*tail
)
76 STRETCH
*s_current
=NULL
;
77 STRETCH
*ret_struct
=NULL
;
80 while ( s_current
!= NULL
) { /* goto end of list */
81 ret_struct
= s_current
;
82 s_current
= s_current
->prev
;
88 /*! \todo Finish function documentation!!!
90 * \par Function Description
93 STRETCH
*s_stretch_new_head(void)
97 s_new
= (STRETCH
*) g_malloc(sizeof(STRETCH
));
100 s_new
->connection
= NULL
;
101 s_new
->whichone
= -1;
109 /*! \todo Finish function documentation!!!
111 * \par Function Description
114 void s_stretch_destroy_head(STRETCH
*s_head
)
119 /*! \todo Finish function documentation!!!
121 * \par Function Description
124 /*! \todo also does the needed work to make the object visually selected */
125 STRETCH
*s_stretch_add(STRETCH
*head
, OBJECT
*object
,
126 CONN
*connection
, int whichone
)
133 while (s_current
!= NULL
) {
134 if (s_current
->object
) {
135 /*printf("%d %d\n", s_current->object->sid, object->sid);*/
136 if (s_current
->object
->sid
== object
->sid
) {
137 /* printf("already inside\n");*/
138 return(s_stretch_return_tail(head
));
142 s_current
= s_current
->next
;
144 /*printf("Adding: %s\n", object->name);*/
146 s_new
= (STRETCH
*) g_malloc(sizeof(STRETCH
));
147 s_new
->object
= object
;
148 s_new
->connection
= connection
;
149 s_new
->whichone
= whichone
;
152 s_new
->prev
= NULL
; /* setup previous link */
156 tail
= s_stretch_return_tail(head
);
157 s_new
->prev
= tail
; /* setup previous link */
164 /*! \todo Finish function documentation!!!
166 * \par Function Description
170 * it's okay to call this with an o_selected which is not necessarily
173 void s_stretch_remove(STRETCH
*head
, OBJECT
*object
)
177 if (object
== NULL
) {
178 fprintf(stderr
, "Got NULL for s_stretch in s_stretch_remove\n");
184 while (s_current
!= NULL
) {
185 if (s_current
->object
== object
) {
187 s_current
->next
->prev
= s_current
->prev
;
189 s_current
->next
= NULL
;
192 s_current
->prev
->next
= s_current
->next
;
194 s_current
->prev
= NULL
;
196 s_current
->object
= NULL
;
197 s_current
->connection
= NULL
;
198 s_current
->whichone
= -1;
203 s_current
= s_current
->next
;
207 /*! \todo Finish function documentation!!!
209 * \par Function Description
212 /*! \note removes all but the head node */
213 void s_stretch_remove_most(TOPLEVEL
*toplevel
, STRETCH
*head
)
218 s_current
= s_stretch_return_tail(head
);
220 while (s_current
!= NULL
) {
221 if (s_current
->object
!= NULL
) {
222 s_prev
= s_current
->prev
;
224 s_current
->object
= NULL
;
225 s_current
->connection
= NULL
;
226 s_current
->whichone
= -1;
235 /* clear out any dangling pointers */
239 /*! \todo Finish function documentation!!!
241 * \par Function Description
244 void s_stretch_print_all( STRETCH
*head
)
250 printf("START printing stretch ********************\n");
251 while(s_current
!= NULL
) {
252 if (s_current
->object
) {
253 printf("Object: %s\n", s_current
->object
->name
);
255 printf("Object is NULL\n");
258 if (s_current
->object
) {
259 printf("Connection type: %d\n", s_current
->connection
->type
);
261 printf("Connection is NULL\n");
264 printf("which one: %d\n", s_current
->whichone
);
266 s_current
= s_current
->next
;
268 printf("DONE printing stretch ********************\n");
273 /*! \todo Finish function documentation!!!
275 * \par Function Description
278 void s_stretch_destroy_all(STRETCH
*head
)
283 s_current
= s_stretch_return_tail(head
);
285 while (s_current
!= NULL
) {
286 s_prev
= s_current
->prev
;
288 s_current
->object
= NULL
;
289 s_current
->connection
= NULL
;
290 s_current
->whichone
= -1;