1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
|
@c -*- mode: Noweb; noweb-doc-mode: texinfo-mode; noweb-code-mode: c-mode -*-
@node File s_stretch.c,,,Top
@chapter File @file{s_stretch.c}
@section File header
@format
@anchor{s_stretch.c - -root-}
@i{<<s_stretch.c : *>>=}@t{
@i{<<s_stretch.c : copyright and license -- @ref{s_stretch.c - copyright and license}>>}
/* DO NOT read or edit this file ! Use ../noweb/s_stretch.nw instead */
@i{<<s_stretch.c : include directives -- @ref{s_stretch.c - include directives}>>}
@i{<<s_stretch.c : s_stretch_return_tail() -- @ref{s_stretch.c - s_stretch_return_tail()}>>}
@i{<<s_stretch.c : s_stretch_return_head() -- @ref{s_stretch.c - s_stretch_return_head()}>>}
@i{<<s_stretch.c : s_stretch_new_head() -- @ref{s_stretch.c - s_stretch_new_head()}>>}
@i{<<s_stretch.c : s_stretch_destroy_head() -- @ref{s_stretch.c - s_stretch_destroy_head()}>>}
@i{<<s_stretch.c : s_stretch_add() -- @ref{s_stretch.c - s_stretch_add()}>>}
@i{<<s_stretch.c : s_stretch_remove() -- @ref{s_stretch.c - s_stretch_remove()}>>}
@i{<<s_stretch.c : s_stretch_remove_most() -- @ref{s_stretch.c - s_stretch_remove_most()}>>}
@i{<<s_stretch.c : s_stretch_print_all() -- @ref{s_stretch.c - s_stretch_print_all()}>>}
@i{<<s_stretch.c : s_stretch_destroy_all() -- @ref{s_stretch.c - s_stretch_destroy_all()}>>}
}
@end format
@format
@anchor{s_stretch.c - copyright and license}
@i{<<s_stretch.c : copyright and license>>=}@t{
/* gEDA - GPL Electronic Design Automation
* libgeda - gEDA's library
* Copyright (C) 1998-2000 Ales V. Hvezda
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
*/
}
@end format
@format
@anchor{s_stretch.c - include directives}
@i{<<s_stretch.c : include directives>>=}@t{
#include <config.h>
#include <stdio.h>
#include <ctype.h>
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_ASSERT_H
#include <assert.h>
#endif
#ifndef HAVE_VSNPRINTF
#include <stdarg.h>
#endif
#include <gtk/gtk.h>
#include <libguile.h>
#include "defines.h"
#include "struct.h"
#include "defines.h"
#include "globals.h"
#include "o_types.h"
#include "colors.h"
#include "../include/prototype.h"
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
#endif
}
@end format
@section Function @code{s_stretch_return_tail()}
@defun s_stretch_return_tail head
@end defun
@format
@anchor{s_stretch.c - s_stretch_return_tail()}
@i{<<s_stretch.c : s_stretch_return_tail()>>=}@t{
STRETCH *
s_stretch_return_tail(STRETCH *head)
@{
STRETCH *s_current=NULL;
STRETCH *ret_struct=NULL;
s_current = head;
while ( s_current != NULL ) @{ /* goto end of list */
ret_struct = s_current;
s_current = s_current->next;
@}
return(ret_struct);
@}
@display
@r{Defines :
@t{s_stretch_return_tail},
-- @ref{s_stretch.c - s_stretch_add()},
-- @ref{s_stretch.c - s_stretch_destroy_all()},
-- @ref{s_stretch.c - s_stretch_remove_most()}.
}
@end display
}
@end format
@section Function @code{s_stretch_return_head()}
@defun s_stretch_return_head tail
@end defun
@format
@anchor{s_stretch.c - s_stretch_return_head()}
@i{<<s_stretch.c : s_stretch_return_head()>>=}@t{
STRETCH *
s_stretch_return_head(STRETCH *tail)
@{
STRETCH *s_current=NULL;
STRETCH *ret_struct=NULL;
s_current = tail;
while ( s_current != NULL ) @{ /* goto end of list */
ret_struct = s_current;
s_current = s_current->prev;
@}
return(ret_struct);
@}
@display
@r{Defines :
.
}
@end display
}
@end format
@section Function @code{s_stretch_new_head()}
@defun s_stretch_new_head
@end defun
@format
@anchor{s_stretch.c - s_stretch_new_head()}
@i{<<s_stretch.c : s_stretch_new_head()>>=}@t{
STRETCH *
s_stretch_new_head(void)
@{
STRETCH *s_new;
s_new = (STRETCH *) malloc(sizeof(STRETCH));
s_new->object = NULL;
s_new->connection = NULL;
s_new->whichone = -1;
s_new->prev = NULL;
s_new->next = NULL;
return(s_new);
@}
@display
@r{Defines :
.
}
@end display
}
@end format
@section Function @code{s_stretch_destroy_head()}
@defun s_stretch_destroy_head s_head
@end defun
@format
@anchor{s_stretch.c - s_stretch_destroy_head()}
@i{<<s_stretch.c : s_stretch_destroy_head()>>=}@t{
void
s_stretch_destroy_head(STRETCH *s_head)
@{
free(s_head);
@}
@display
@r{Defines :
.
}
@end display
}
@end format
@section Function @code{s_stretch_add()}
@defun s_stretch_add head object connection whichone
@end defun
@format
@anchor{s_stretch.c - s_stretch_add()}
@i{<<s_stretch.c : s_stretch_add()>>=}@t{
/* also does the needed work to make the object visually selected */
STRETCH *
s_stretch_add(STRETCH *head, OBJECT *object, CONN *connection, int whichone)
@{
STRETCH *tail;
STRETCH *s_new;
STRETCH *s_current;
s_current = head;
while (s_current != NULL) @{
if (s_current->object) @{
/*printf("%d %d\n", s_current->object->sid, object->sid);*/
if (s_current->object->sid == object->sid) @{
/* printf("already inside\n");*/
return(s_stretch_return_tail(head));
@}
@}
s_current = s_current->next;
@}
/*printf("Adding: %s\n", object->name);*/
s_new = (STRETCH *) malloc(sizeof(STRETCH));
s_new->object = object;
s_new->connection = connection;
s_new->whichone = whichone;
if (head == NULL) @{
s_new->prev = NULL; /* setup previous link */
s_new->next = NULL;
return(s_new);
@} else @{
tail = s_stretch_return_tail(head);
s_new->prev = tail; /* setup previous link */
s_new->next = NULL;
tail->next = s_new;
return(tail->next);
@}
@}
@display
@r{Defines :
.
}
@end display
@display
@r{Uses :
@t{s_stretch_return_tail}, -- @ref{s_stretch.c - s_stretch_return_tail()}.
}
@end display
}
@end format
@section Function @code{s_stretch_remove()}
@defun s_stretch_remove head object
@end defun
@format
@anchor{s_stretch.c - s_stretch_remove()}
@i{<<s_stretch.c : s_stretch_remove()>>=}@t{
/* it's okay to call this with an o_selected which is not necessarily */
/* selected */
void
s_stretch_remove(STRETCH *head, OBJECT *object)
@{
STRETCH *s_current;
if (object == NULL) @{
fprintf(stderr, "Got NULL for s_stretch in s_stretch_remove\n");
return;
@}
s_current = head;
while (s_current != NULL) @{
if (s_current->object == object) @{
if (s_current->next)
s_current->next->prev = s_current->prev;
else
s_current->next = NULL;
if (s_current->prev)
s_current->prev->next = s_current->next;
else
s_current->prev = NULL;
s_current->object = NULL;
s_current->connection = NULL;
s_current->whichone = -1;
free(s_current);
return;
@}
s_current = s_current->next;
@}
@}
@display
@r{Defines :
.
}
@end display
}
@end format
@section Function @code{s_stretch_remove_most()}
@defun s_stretch_remove_most w_current head
@end defun
@format
@anchor{s_stretch.c - s_stretch_remove_most()}
@i{<<s_stretch.c : s_stretch_remove_most()>>=}@t{
/* removes all but the head node */
void
s_stretch_remove_most(TOPLEVEL *w_current, STRETCH *head)
@{
STRETCH *s_current;
STRETCH *s_prev;
s_current = s_stretch_return_tail(head);
while (s_current != NULL) @{
if (s_current->object != NULL) @{
s_prev = s_current->prev;
s_current->object = NULL;
s_current->connection = NULL;
s_current->whichone = -1;
free(s_current);
s_current = s_prev;
@} else @{
break;
@}
@}
/* clear out any dangling pointers */
head->next=NULL;
@}
@display
@r{Defines :
.
}
@end display
@display
@r{Uses :
@t{s_stretch_return_tail}, -- @ref{s_stretch.c - s_stretch_return_tail()}.
}
@end display
}
@end format
@section Function @code{s_stretch_print_all()}
@defun s_stretch_print_all head
@end defun
@format
@anchor{s_stretch.c - s_stretch_print_all()}
@i{<<s_stretch.c : s_stretch_print_all()>>=}@t{
void
s_stretch_print_all( STRETCH *head )
@{
STRETCH *s_current;
s_current = head;
printf("START printing stretch ********************\n");
while(s_current != NULL) @{
if (s_current->object) @{
printf("Object: %s\n", s_current->object->name);
@} else @{
printf("Object is NULL\n");
@}
if (s_current->object) @{
printf("Connection type: %d\n", s_current->connection->type);
@} else @{
printf("Connection is NULL\n");
@}
printf("which one: %d\n", s_current->whichone);
s_current = s_current->next;
@}
printf("DONE printing stretch ********************\n");
printf("\n");
@}
@display
@r{Defines :
.
}
@end display
}
@end format
@section Function @code{s_stretch_destroy_all()}
@defun s_stretch_destroy_all head
@end defun
@format
@anchor{s_stretch.c - s_stretch_destroy_all()}
@i{<<s_stretch.c : s_stretch_destroy_all()>>=}@t{
void
s_stretch_destroy_all(STRETCH *head)
@{
STRETCH *s_current;
STRETCH *s_prev;
s_current = s_stretch_return_tail(head);
while (s_current != NULL) @{
s_prev = s_current->prev;
s_current->object = NULL;
s_current->connection = NULL;
s_current->whichone = -1;
free(s_current);
s_current = s_prev;
@}
@}
@display
@r{Defines :
.
}
@end display
@display
@r{Uses :
@t{s_stretch_return_tail}, -- @ref{s_stretch.c - s_stretch_return_tail()}.
}
@end display
}
@end format
|