3 echo "This script will create the gen_list contrib files in the current"
4 echo "directory. Do you wish to continue? [y/n]"
9 if [[ ${ans} != [Yy]* ]]; then
15 typeset fileList="Makefile README addr_clean.pl gen_list.c gen_list.h isa.c
16 isa.h main.c malloc_police.c malloc_police.h rec_char.c rec_char.h
17 rec_charptr.c rec_charptr.h rec_double.c rec_double.h rec_long.c
18 rec_long.h rec_malloc_police.c rec_malloc_police.h"
21 for i in ${fileList}; do
25 ####################################
28 ## -e "s/^\(#${i}:\)\(.*\)/\2/"
29 ## Find lines belonging to
30 ## this file and remove the
34 ## Jump to label print if the
35 ## above s command matched
38 ## This command is skipped
39 ## when the s command fails.
40 ## This will remove any
44 ## The last thing sed does
45 ## is print the data. So,
46 ## by now, we only print
47 ## lines belonging to the file.
49 ####################################
51 sed -e "s/^\(#${i}:\)\(.*\)/\2/" \
63 #Makefile:PROGRAM = test_list
65 #Makefile:SRC = main.c isa.c gen_list.c rec_char.c rec_charptr.c rec_double.c rec_long.c rec_malloc_police.c malloc_police.c
66 #Makefile:OBJS = main.o isa.o gen_list.o rec_char.o rec_charptr.o rec_double.o rec_long.o rec_malloc_police.o malloc_police.o
68 #Makefile:all : $(PROGRAM)
70 #Makefile:$(PROGRAM) : $(OBJS)
71 #Makefile: gcc $(CFLAGS) -o $(PROGRAM) $(OBJS)
74 #Makefile: rm -f $(OBJS)
76 #Makefile:clobber: clean
77 #Makefile: rm -f $(PROGRAM)
80 #README:This list supports:
81 #README: copy construction,
82 #README: "virtual" destruction,
84 #README: comparison (equal comparison currently supported).
86 #README:With the "object oriented" nature of the list, nodes, and records; it is
87 #README:easily concievable that sorted lists and hash tables could be implemented
88 #README:with little extra effort.
91 #README:Philosophical point:
93 #README:I am sure there is room for improvement with this design. I am
94 #README:submitting this as a generic doubly linked list recomendation for IJB.
95 #README:Whatever the "collective" decides is fine with me.
97 #README:This implementation uses the "naming space" of gen_list, derived_rec,
98 #README:construct, copy construct, stream, destruct, etc... These are open to
99 #README:argument. I just used what was familiar to me and others in the "OO"
100 #README:community. If these need changed to be adopted ... "so be it".
103 #README:Implementation point:
105 #README:I assume this is too late for a "3.0" release. As I work for an
106 #README:airline, the whole past summer has been hectic (not to mention the
107 #README:last 4 months); but things have begun to settle down and I am
108 #README:following the IJB lists a bit more closely. And I would like to say
109 #README:"HOLY CRAP!" .. you guys have accompolished a lot! Way to go.
111 #README:But, the adoption of a better linked list package should at least be
112 #README:high on the next release list (if not the current one). If you choose
113 #README:this submission or not, so be it. But as a "data structure" man, I
114 #README:think IJB's linked lists need addressing.
117 #README:List/Enlist note:
119 #README:I have noticed the list.c file. If this generic list is adopted, I
120 #README:think all existing functionallity could be duplicated with the
121 #README:"copy_contruct", "equal", and "destruct" `virtuals'. This would also
122 #README:eliminate and/or enhance the other manually maintained lists in IJB.
127 #README:Since the generic list defined a "stream" virtual, it could be programmed
128 #README:that the list could print itself whenever a FATAL error occurs. A user (or
129 #README:programmer) could read the list and hopefully determine the cause of the
133 #README:Potential note:
135 #README:Think of the possibilites of a linked list, sorted list, and/or a hash
136 #README:list. Think of a request to a web site that has been referenced
137 #README:before. If a hash list keep track of all block requests and regexp
138 #README:change commands, then a site could be blocked and/or modified without
139 #README:ever consulting the actions lists again. What a speed up!
141 #README:What if some of the current lists were kept in sorted lists? Then a
142 #README:search for a particular record could be a binary search instead of a
143 #README:linear search.
145 #README:The actions file(s) and regexp files(s) could be inserted into the
146 #README:list from front to back order (or visa versa) and the processing would
147 #README:take place in actual file order (which is more natural); rather than
148 #README:in reverse order (as it is today).
151 #README:Thank you for you time and attention to this contribution. If it is
152 #README:"blessed" by the group, I am available to give time to integrating
153 #README:this into IJB.
155 #README:Let me know what y'all think about this package.
161 #addr_clean.pl:#!/usr/bin/perl
163 #addr_clean.pl:## *********************************************************************
165 #addr_clean.pl:## * File : $Source: addr_clean.pl,v $
167 #addr_clean.pl:## * Purpose : Cleans addresses out of ./test_list and replaces
168 #addr_clean.pl:## * them with "english" replacements.
170 #addr_clean.pl:## * Usage : ./test_list | ./addr_clean.pl
172 #addr_clean.pl:## * Copyright : This program is free software; you can redistribute it
173 #addr_clean.pl:## * and/or modify it under the terms of the GNU General
174 #addr_clean.pl:## * Public License as published by the Free Software
175 #addr_clean.pl:## * Foundation; either version 2 of the License, or (at
176 #addr_clean.pl:## * your option) any later version.
178 #addr_clean.pl:## * This program is distributed in the hope that it will
179 #addr_clean.pl:## * be useful, but WITHOUT ANY WARRANTY; without even the
180 #addr_clean.pl:## * implied warranty of MERCHANTABILITY or FITNESS FOR A
181 #addr_clean.pl:## * PARTICULAR PURPOSE. See the GNU General Public
182 #addr_clean.pl:## * License for more details.
184 #addr_clean.pl:## * The GNU General Public License should be included with
185 #addr_clean.pl:## * this file. If not, you can view it at
186 #addr_clean.pl:## * http://www.gnu.org/copyleft/gpl.html
187 #addr_clean.pl:## * or write to the Free Software Foundation, Inc., 59
188 #addr_clean.pl:## * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
190 #addr_clean.pl:## **********************************************************************/
192 #addr_clean.pl:use strict;
195 #addr_clean.pl:my $nMaxList = 0;
196 #addr_clean.pl:my $nMaxNode = 0;
197 #addr_clean.pl:my $nMaxRec = 0;
198 #addr_clean.pl:my %aaTranslation;
199 #addr_clean.pl:my $strLine;
201 #addr_clean.pl:while ( $strLine = <STDIN> )
203 #addr_clean.pl: if ( $strLine =~ m!(list.*=\s*)(0x[0-9a-f]+)! )
205 #addr_clean.pl: my $str1 = $1;
206 #addr_clean.pl: my $str2 = $2;
208 #addr_clean.pl: if ( ! defined $aaTranslation{$str2} )
210 #addr_clean.pl: $aaTranslation{$str2} = "list" . ++ $nMaxList;
212 #addr_clean.pl: $strLine =~ s!(list.*=\s*)(0x[0-9a-f]+)!$str1($aaTranslation{$str2})!;
216 #addr_clean.pl: if ( $strLine =~ m!(node.*=\s*)(0x[0-9a-f]+)! )
218 #addr_clean.pl: my $str1 = $1;
219 #addr_clean.pl: my $str2 = $2;
221 #addr_clean.pl: if ( ! defined $aaTranslation{$str2} )
223 #addr_clean.pl: $aaTranslation{$str2} = "node" . ++ $nMaxNode;
225 #addr_clean.pl: $strLine =~ s!(node.*=\s*)(0x[0-9a-f]+)!$str1($aaTranslation{$str2})!;
229 #addr_clean.pl: if ( $strLine =~ m!(rec.*=\s*(iter_. \.\.\. )?)(0x[0-9a-f]+)! )
231 #addr_clean.pl: my $str1 = $1;
232 #addr_clean.pl: my $str2 = $3;
234 #addr_clean.pl: if ( ! defined $aaTranslation{$str2} )
236 #addr_clean.pl: $aaTranslation{$str2} = "rec" . ++ $nMaxRec;
238 #addr_clean.pl: $strLine =~ s!(rec.*=\s*(iter_. \.\.\. )?)(0x[0-9a-f]+)!$str1($aaTranslation{$str2})!;
242 #addr_clean.pl: ## Catch the copy constuct syntax
244 #addr_clean.pl: if ( $strLine =~ m!(list.*=>\s*)(0x[0-9a-f]+)! )
246 #addr_clean.pl: my $str1 = $1;
247 #addr_clean.pl: my $str2 = $2;
249 #addr_clean.pl: if ( ! defined $aaTranslation{$str2} )
251 #addr_clean.pl: $aaTranslation{$str2} = "list" . ++ $nMaxList;
253 #addr_clean.pl: $strLine =~ s!(list.*=>\s*)(0x[0-9a-f]+)!$str1($aaTranslation{$str2})!;
257 #addr_clean.pl: if ( $strLine =~ m!(node.*=>\s*)(0x[0-9a-f]+)! )
259 #addr_clean.pl: my $str1 = $1;
260 #addr_clean.pl: my $str2 = $2;
262 #addr_clean.pl: if ( ! defined $aaTranslation{$str2} )
264 #addr_clean.pl: $aaTranslation{$str2} = "node" . ++ $nMaxNode;
266 #addr_clean.pl: $strLine =~ s!(node.*=>\s*)(0x[0-9a-f]+)!$str1($aaTranslation{$str2})!;
270 #addr_clean.pl: if ( $strLine =~ m!(rec.*=>\s*)(0x[0-9a-f]+)! )
272 #addr_clean.pl: my $str1 = $1;
273 #addr_clean.pl: my $str2 = $2;
275 #addr_clean.pl: if ( ! defined $aaTranslation{$str2} )
277 #addr_clean.pl: $aaTranslation{$str2} = "rec" . ++ $nMaxRec;
279 #addr_clean.pl: $strLine =~ s!(rec.*=>\s*)(0x[0-9a-f]+)!$str1($aaTranslation{$str2})!;
282 #addr_clean.pl: print( $strLine );
287 #gen_list.c:const char gen_list_rcs[] = "$Id: gen_list.c,v 1.1 2001/10/25 03:40:48 rodney.stromlund Exp $";
288 #gen_list.c:/*********************************************************************
290 #gen_list.c: * File : $Source: /cvsroot/ijbswa/current/gen_list.c,v $
292 #gen_list.c: * Purpose : To create some functions to do generic doubly linked
293 #gen_list.c: * list management.
295 #gen_list.c: * Copyright : Written by and Copyright (C) 2001 the SourceForge
296 #gen_list.c: * IJBSWA team. http://ijbswa.sourceforge.net
298 #gen_list.c: * This program is free software; you can redistribute it
299 #gen_list.c: * and/or modify it under the terms of the GNU General
300 #gen_list.c: * Public License as published by the Free Software
301 #gen_list.c: * Foundation; either version 2 of the License, or (at
302 #gen_list.c: * your option) any later version.
304 #gen_list.c: * This program is distributed in the hope that it will
305 #gen_list.c: * be useful, but WITHOUT ANY WARRANTY; without even the
306 #gen_list.c: * implied warranty of MERCHANTABILITY or FITNESS FOR A
307 #gen_list.c: * PARTICULAR PURPOSE. See the GNU General Public
308 #gen_list.c: * License for more details.
310 #gen_list.c: * The GNU General Public License should be included with
311 #gen_list.c: * this file. If not, you can view it at
312 #gen_list.c: * http://www.gnu.org/copyleft/gpl.html
313 #gen_list.c: * or write to the Free Software Foundation, Inc., 59
314 #gen_list.c: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
316 #gen_list.c: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
317 #gen_list.c: * and edit IJB, correctly.
319 #gen_list.c: * Revisions :
320 #gen_list.c: * $Log: gen_list.c,v $
322 #gen_list.c: *********************************************************************/
325 #gen_list.c:#include <malloc.h>
326 #gen_list.c:#include <stdio.h>
327 #gen_list.c:#include <stdlib.h>
328 #gen_list.c:#include <string.h>
330 #gen_list.c:#include "gen_list.h"
331 #gen_list.c:#include "malloc_police.h"
333 #gen_list.c:const char gen_list_h_rcs[] = GEN_LIST_H_VERSION;
336 #gen_list.c:/* This is used (for the moment) to cut out all the */
337 #gen_list.c:/* extra verbige of the malloc_police module. After */
338 #gen_list.c:/* all, we do not want to see construct/destruct of a */
339 #gen_list.c:/* class that is supposed to be "in the background". */
341 #gen_list.c:/* But it could lead to broader usage. */
343 #gen_list.c:int list_is_quiet = 0;
346 #gen_list.c:#define CALL_VT_REC_COPY_CONSTRUCT(rec) (((rec_copy_construct)(rec)->vtable[ VT_REC_COPY_CONSTRUCT ])( rec ))
347 #gen_list.c:#define CALL_VT_REC_DESTRUCT(rec) (((rec_destruct)(rec)->vtable[ VT_REC_DESTRUCT ])( rec ))
348 #gen_list.c:#define CALL_VT_REC_STREAM(rec) (((rec_stream)(rec)->vtable[ VT_REC_STREAM ])( rec ))
349 #gen_list.c:#define CALL_VT_REC_EQUAL(rec,eq_rec) (((rec_equal)((rec)->vtable[ VT_REC_EQUAL ]))( rec, eq_rec ))
352 #gen_list.c:/*********************************************************************
354 #gen_list.c: * Function : gen_list_rec_construct
356 #gen_list.c: * Description : Called from a derived list record class ONLY.
357 #gen_list.c: * This function "construct" a classs: malloc_ed,
358 #gen_list.c: * vtable, isa, and sizeof_rec "attributes".
360 #gen_list.c: * Parameters :
361 #gen_list.c: * 1 : The record. If NULL, malloc is called.
362 #gen_list.c: * 2 : isa (prounced "is a") ... type of the record.
363 #gen_list.c: * 3 : Memory image size of this record.
364 #gen_list.c: * ... : The "virtuals" for this record. NOTE: this list
365 #gen_list.c: * may increase if more "virtuals" are added.
367 #gen_list.c: * Returns : A pointer to the record (either the orig record
368 #gen_list.c: * or the malloc_ed copy.
370 #gen_list.c: *********************************************************************/
371 #gen_list.c:struct gen_list_rec *gen_list_rec_construct( enum GEN_LIST_ISA isa, int sizeof_rec, const t_vtable _vtable )
373 #gen_list.c: struct gen_list_rec *this_rec = (struct gen_list_rec *)MALLOC( sizeof_rec );
374 #gen_list.c: this_rec->vtable = _vtable;
375 #gen_list.c: this_rec->isa = isa;
376 #gen_list.c: this_rec->sizeof_rec = sizeof_rec;
378 #gen_list.c: return( this_rec );
383 #gen_list.c:/*********************************************************************
385 #gen_list.c: * Function : gen_list_rec_copy_construct
387 #gen_list.c: * Description : Makes a copy of the current existing record. All
388 #gen_list.c: * inherited properties (isa, vtable, malloc_ed, ...)
389 #gen_list.c: * are kept in tact after the copy.
391 #gen_list.c: * Parameters :
392 #gen_list.c: * 1 : Existing record.
393 #gen_list.c: * 2 : New record.
395 #gen_list.c: * Returns : The newly constructed copy record.
397 #gen_list.c: *********************************************************************/
398 #gen_list.c:struct gen_list_rec *gen_list_rec_copy_construct( const struct gen_list_rec *this_rec )
400 #gen_list.c: struct gen_list_rec *copy_rec = (struct gen_list_rec *)MALLOC( this_rec->sizeof_rec );
401 #gen_list.c: copy_rec->vtable = this_rec->vtable;
402 #gen_list.c: copy_rec->isa = this_rec->isa;
403 #gen_list.c: copy_rec->sizeof_rec = this_rec->sizeof_rec;
405 #gen_list.c: return( copy_rec );
410 #gen_list.c:/*********************************************************************
412 #gen_list.c: * Function : gen_list_rec_destruct
414 #gen_list.c: * Description : Destruct the record. Including free_ing the memory
415 #gen_list.c: * if applicable.
417 #gen_list.c: * Parameters :
418 #gen_list.c: * 1 : The record.
420 #gen_list.c: * Returns : NULL
422 #gen_list.c: *********************************************************************/
423 #gen_list.c:struct gen_list_rec *gen_list_rec_destruct( struct gen_list_rec *this_rec )
425 #gen_list.c: FREE( this_rec );
426 #gen_list.c: return( NULL );
431 #gen_list.c:/*********************************************************************
433 #gen_list.c: * Function : gen_list_rec_stream
435 #gen_list.c: * Description : Displays all attributes on the STDOUT stream.
437 #gen_list.c: * Parameters :
438 #gen_list.c: * 1 : The record.
440 #gen_list.c: * Returns : The record.
442 #gen_list.c: *********************************************************************/
443 #gen_list.c:const struct gen_list_rec *gen_list_rec_stream( const struct gen_list_rec *this_rec )
445 #gen_list.c: LIST_SHOW( printf( "\t\tstream rec isa = %s\n", isa_ra[ this_rec->isa ] ) );
446 #gen_list.c: return( this_rec );
451 #gen_list.c:/*********************************************************************
453 #gen_list.c: * Function : gen_list_rec_equal
455 #gen_list.c: * Description : Compares two records to see if they are equal.
457 #gen_list.c: * Parameters :
458 #gen_list.c: * 1 : A record.
459 #gen_list.c: * 2 : Another record.
461 #gen_list.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
463 #gen_list.c: *********************************************************************/
464 #gen_list.c:int gen_list_rec_equal( const struct gen_list_rec *this_rec, const struct gen_list_rec *eq_rec )
466 #gen_list.c: if ( NULL == this_rec && NULL == eq_rec )
468 #gen_list.c: return( 1 );
471 #gen_list.c: if ( ( NULL == this_rec && NULL != eq_rec ) ||
472 #gen_list.c: ( NULL != this_rec && NULL == eq_rec ) )
474 #gen_list.c: return( 0 );
477 #gen_list.c: if ( ( this_rec->isa != eq_rec->isa ) ||
478 #gen_list.c: ( this_rec->sizeof_rec != eq_rec->sizeof_rec ) )
480 #gen_list.c: LIST_SHOW( printf( "INFORMATION: sorry, but comparing different rec types is unsupported at this time.\n" ) );
481 #gen_list.c: return( 0 );
484 #gen_list.c: return( 1 );
489 #gen_list.c:/*
\f*********************************************************************/
492 #gen_list.c:struct gen_list_node
494 #gen_list.c: /* private: */
495 #gen_list.c: struct gen_list_node *next;
496 #gen_list.c: struct gen_list_node *prev;
498 #gen_list.c: struct gen_list_rec *rec;
500 #gen_list.c:/* public: */
501 #gen_list.c:extern struct gen_list_node * gen_list_node_construct( struct gen_list_rec *_rec );
502 #gen_list.c:extern struct gen_list_node * gen_list_node_copy_construct( const struct gen_list_node *this_node );
503 #gen_list.c:extern struct gen_list_node * gen_list_node_destruct( struct gen_list_node *this_node );
504 #gen_list.c:extern struct gen_list_node * gen_list_node_remove( struct gen_list_node *this_node );
506 #gen_list.c:extern struct gen_list_node * gen_list_node_set_next( struct gen_list_node *this_node, struct gen_list_node *_next );
507 #gen_list.c:extern struct gen_list_node * gen_list_node_set_prev( struct gen_list_node *this_node, struct gen_list_node *_prev );
509 #gen_list.c:extern struct gen_list_node * gen_list_node_get_next( const struct gen_list_node *this_node );
510 #gen_list.c:extern struct gen_list_node * gen_list_node_get_prev( const struct gen_list_node *this_node );
512 #gen_list.c:extern const struct gen_list_rec * gen_list_node_stream( const struct gen_list_node *this_node );
513 #gen_list.c:extern int gen_list_node_equal( const struct gen_list_node *this_node, const struct gen_list_node *eq_node );
515 #gen_list.c:/* struct/class COMPLETE */
518 #gen_list.c:/*********************************************************************
520 #gen_list.c: * Function : gen_list_node_construct
522 #gen_list.c: * Description : Constructs a generic list node and sets its record.
524 #gen_list.c: * Parameters :
525 #gen_list.c: * 1 : The node. If NULL, malloc is called.
526 #gen_list.c: * 2 : The nodes record contents.
528 #gen_list.c: * Returns : A pointer to the node (either the orig node
529 #gen_list.c: * or the malloc_ed copy.
531 #gen_list.c: *********************************************************************/
532 #gen_list.c:struct gen_list_node *gen_list_node_construct( struct gen_list_rec *_rec )
534 #gen_list.c: struct gen_list_node *this_node = (struct gen_list_node *)MALLOC( sizeof( struct gen_list_node ) );
536 #gen_list.c: LIST_SHOW( printf( "\
537 #gen_list.c:\tconstruct new node\t\t= %p
538 #gen_list.c:\tconstruct new node->rec\t= %p\n\n", (const void *)this_node, (const void *)_rec ) );
540 #gen_list.c: this_node->rec = _rec;
541 #gen_list.c: this_node->next = NULL;
542 #gen_list.c: this_node->prev = NULL;
544 #gen_list.c: return( this_node );
549 #gen_list.c:/*********************************************************************
551 #gen_list.c: * Function : gen_list_node_copy_construct
553 #gen_list.c: * Description : Makes a copy of the current node.
555 #gen_list.c: * Parameters :
556 #gen_list.c: * 1 : Existing node.
557 #gen_list.c: * 2 : New node.
559 #gen_list.c: * Returns : The newly constructed copy node.
561 #gen_list.c: *********************************************************************/
562 #gen_list.c:struct gen_list_node *gen_list_node_copy_construct( const struct gen_list_node *this_node )
564 #gen_list.c: struct gen_list_node *copy_node = (struct gen_list_node *)MALLOC( sizeof( struct gen_list_node ) );
566 #gen_list.c: LIST_SHOW( printf( "\tcopy construct new node = %p => %p\n\n", (const void *)this_node, (const void *)copy_node ) );
568 #gen_list.c: copy_node->rec = CALL_VT_REC_COPY_CONSTRUCT( this_node->rec );
569 #gen_list.c: copy_node->next = NULL;
570 #gen_list.c: copy_node->prev = NULL;
572 #gen_list.c: return( copy_node );
577 #gen_list.c:/*********************************************************************
579 #gen_list.c: * Function : gen_list_node_destruct
581 #gen_list.c: * Description : Destruct the node. Including free_ing the memory
582 #gen_list.c: * if applicable.
584 #gen_list.c: * Parameters :
585 #gen_list.c: * 1 : The node.
587 #gen_list.c: * Returns : NULL
589 #gen_list.c: *********************************************************************/
590 #gen_list.c:struct gen_list_node *gen_list_node_destruct( struct gen_list_node *this_node )
592 #gen_list.c: LIST_SHOW( printf( "\
593 #gen_list.c:\tdestruct this_node\t\t\t= %p
594 #gen_list.c:\tdestruct this_node->rec\t\t= %p
595 #gen_list.c:\tdestruct this_node->next\t= %p
596 #gen_list.c:\tdestruct this_node->prev\t= %p\n\n", (const void *)this_node, (const void *)this_node->rec, (const void *)this_node->next, (const void *)this_node->prev ) );
598 #gen_list.c: if ( NULL != this_node->rec )
600 #gen_list.c: CALL_VT_REC_DESTRUCT( this_node->rec );
603 #gen_list.c: FREE( this_node );
604 #gen_list.c: return( NULL );
609 #gen_list.c:/*********************************************************************
611 #gen_list.c: * Function : gen_list_node_remove
613 #gen_list.c: * Description : Destruct the node. Including free_ing the memory
614 #gen_list.c: * if applicable.
616 #gen_list.c: * Parameters :
617 #gen_list.c: * 1 : The node.
619 #gen_list.c: * Returns : NULL
621 #gen_list.c: *********************************************************************/
622 #gen_list.c:struct gen_list_node *gen_list_node_remove( struct gen_list_node *this_node )
624 #gen_list.c: LIST_SHOW( printf( "\
625 #gen_list.c:\tremove this_node\t\t\t= %p
626 #gen_list.c:\tremove this_node->rec\t= %p
627 #gen_list.c:\tremove this_node->next\t= %p
628 #gen_list.c:\tremove this_node->prev\t= %p\n\n", (const void *)this_node, (const void *)this_node->rec, (const void *)this_node->next, (const void *)this_node->prev ) );
630 #gen_list.c: FREE( this_node );
631 #gen_list.c: return( NULL );
636 #gen_list.c:/*********************************************************************
638 #gen_list.c: * Function : gen_list_node_set_next
640 #gen_list.c: * Description : Sets the next node in the list series. Used mainly
641 #gen_list.c: * when constructing and adding/removing nodes.
643 #gen_list.c: * Parameters :
644 #gen_list.c: * 1 : The node.
645 #gen_list.c: * 2 : The next node.
647 #gen_list.c: * Returns : The node.
649 #gen_list.c: *********************************************************************/
650 #gen_list.c:struct gen_list_node *gen_list_node_set_next( struct gen_list_node *this_node, struct gen_list_node *_next )
652 #gen_list.c: this_node->next = _next;
653 #gen_list.c: return( this_node );
658 #gen_list.c:/*********************************************************************
660 #gen_list.c: * Function : gen_list_node_set_prev
662 #gen_list.c: * Description : Sets the previous node in the list series. Used mainly
663 #gen_list.c: * when constructing and adding/removing nodes.
665 #gen_list.c: * Parameters :
666 #gen_list.c: * 1 : The node.
667 #gen_list.c: * 2 : The previous node.
669 #gen_list.c: * Returns : The node.
671 #gen_list.c: *********************************************************************/
672 #gen_list.c:struct gen_list_node *gen_list_node_set_prev( struct gen_list_node *this_node, struct gen_list_node *_prev )
674 #gen_list.c: this_node->prev = _prev;
675 #gen_list.c: return( this_node );
680 #gen_list.c:/*********************************************************************
682 #gen_list.c: * Function : gen_list_node_get_next
684 #gen_list.c: * Description : Gets the next node in the list series. Used mainly
685 #gen_list.c: * for traversing a list.
687 #gen_list.c: * Parameters :
688 #gen_list.c: * 1 : The node.
690 #gen_list.c: * Returns : The next node.
692 #gen_list.c: *********************************************************************/
693 #gen_list.c:struct gen_list_node *gen_list_node_get_next( const struct gen_list_node *this_node )
695 #gen_list.c: return( this_node->next );
700 #gen_list.c:/*********************************************************************
702 #gen_list.c: * Function : gen_list_node_get_prev
704 #gen_list.c: * Description : Gets the previous node in the list series. Used mainly
705 #gen_list.c: * for traversing a list.
707 #gen_list.c: * Parameters :
708 #gen_list.c: * 1 : The node.
710 #gen_list.c: * Returns : The previous node.
712 #gen_list.c: *********************************************************************/
713 #gen_list.c:struct gen_list_node *gen_list_node_get_prev( const struct gen_list_node *this_node )
715 #gen_list.c: return( this_node->prev );
720 #gen_list.c:/*********************************************************************
722 #gen_list.c: * Function : gen_list_node_stream
724 #gen_list.c: * Description : Displays all attributes on the STDOUT stream,
725 #gen_list.c: * including the contents of the nodes record.
727 #gen_list.c: * Parameters :
728 #gen_list.c: * 1 : The record.
730 #gen_list.c: * Returns : The result of streaming the nodes record.
732 #gen_list.c: *********************************************************************/
733 #gen_list.c:const struct gen_list_rec *gen_list_node_stream( const struct gen_list_node *this_node )
735 #gen_list.c: LIST_SHOW( printf( "\
736 #gen_list.c:\tstream this_node\t\t\t= %p
737 #gen_list.c:\tstream this_node->rec\t= %p
738 #gen_list.c:\tstream this_node->next\t= %p
739 #gen_list.c:\tstream this_node->prev\t= %p\n\n", (const void *)this_node, (const void *)this_node->rec, (const void *)this_node->next, (const void *)this_node->prev ) );
741 #gen_list.c: return( CALL_VT_REC_STREAM( this_node->rec ) );
746 #gen_list.c:/*********************************************************************
748 #gen_list.c: * Function : gen_list_node_equal
750 #gen_list.c: * Description : Compares two nodes (and their records) to see if they are equal.
752 #gen_list.c: * Parameters :
753 #gen_list.c: * 1 : A node.
754 #gen_list.c: * 2 : Another node.
756 #gen_list.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
758 #gen_list.c: *********************************************************************/
759 #gen_list.c:int gen_list_node_equal( const struct gen_list_node *this_node, const struct gen_list_node *eq_node )
761 #gen_list.c: if ( NULL == this_node && NULL == eq_node )
763 #gen_list.c: return( 1 );
766 #gen_list.c: if ( ( NULL == this_node && NULL != eq_node ) ||
767 #gen_list.c: ( NULL != this_node && NULL == eq_node ) )
769 #gen_list.c: return( 0 );
772 #gen_list.c: return( gen_list_rec_equal( this_node->rec, eq_node->rec ) );
777 #gen_list.c:/*
\f*********************************************************************/
780 #gen_list.c:/* private: */
781 #gen_list.c:/*********************************************************************
783 #gen_list.c: * Function : gen_list_insert_node
785 #gen_list.c: * Description : Inserts a node (not a record!) into a list. This
786 #gen_list.c: * is (currently) only used in copy construction.
788 #gen_list.c: * Parameters :
789 #gen_list.c: * 1 : The list.
790 #gen_list.c: * 2 : A new node to insert into the list.
792 #gen_list.c: * Returns : The node.
794 #gen_list.c: *********************************************************************/
795 #gen_list.c:const struct gen_list_node *gen_list_insert_node( struct gen_list *this_list, struct gen_list_node *node )
797 #gen_list.c: gen_list_node_set_next( node, NULL );
799 #gen_list.c: if ( NULL == this_list->first )
801 #gen_list.c: this_list->first = node;
804 #gen_list.c: if ( NULL == this_list->last )
806 #gen_list.c: this_list->last = node;
810 #gen_list.c: gen_list_node_set_next( this_list->last, node );
811 #gen_list.c: gen_list_node_set_prev( node, this_list->last );
812 #gen_list.c: this_list->last = node;
815 #gen_list.c: this_list->last = node;
817 #gen_list.c: return( node );
822 #gen_list.c:/*********************************************************************
824 #gen_list.c: * Function : gen_list_construct
826 #gen_list.c: * Description : Constructs a generic list.
828 #gen_list.c: * Parameters : None
830 #gen_list.c: * Returns : A pointer to the list (either the orig list
831 #gen_list.c: * or the malloc_ed copy.
833 #gen_list.c: *********************************************************************/
834 #gen_list.c:struct gen_list *gen_list_construct()
836 #gen_list.c: struct gen_list *this_list = (struct gen_list *)MALLOC( sizeof( struct gen_list ) );
837 #gen_list.c: LIST_SHOW( printf( "construct new list = %p\n\n", (const void *)this_list ) );
839 #gen_list.c: this_list->first = NULL;
840 #gen_list.c: this_list->last = NULL;
842 #gen_list.c: return( this_list );
847 #gen_list.c:/*********************************************************************
849 #gen_list.c: * Function : gen_list_copy_construct
851 #gen_list.c: * Description : Makes a copy of the current list.
853 #gen_list.c: * Parameters :
854 #gen_list.c: * 1 : Existing list.
855 #gen_list.c: * 2 : New list.
857 #gen_list.c: * Returns : The newly constructed copy list.
859 #gen_list.c: *********************************************************************/
860 #gen_list.c:struct gen_list *gen_list_copy_construct( const struct gen_list *this_list )
862 #gen_list.c: struct gen_list_node *curr = this_list->first;
863 #gen_list.c: struct gen_list *copy_list = (struct gen_list *)MALLOC( sizeof( struct gen_list ) );
865 #gen_list.c: LIST_SHOW( printf( "copy construct new list = %p => %p\n\n", (const void *)this_list, (const void *)copy_list ) );
867 #gen_list.c: copy_list->first = NULL;
868 #gen_list.c: copy_list->last = NULL;
871 #gen_list.c: while ( NULL != curr )
873 #gen_list.c: struct gen_list_node *copy_node = gen_list_node_copy_construct( curr );
874 #gen_list.c: gen_list_insert_node( copy_list, copy_node );
875 #gen_list.c: curr = gen_list_node_get_next( curr );
878 #gen_list.c: return( copy_list );
883 #gen_list.c:/*********************************************************************
885 #gen_list.c: * Function : gen_list_destruct
887 #gen_list.c: * Description : Destruct the list. Including free_ing the memory
888 #gen_list.c: * if applicable.
890 #gen_list.c: * Parameters :
891 #gen_list.c: * 1 : The list.
893 #gen_list.c: * Returns : NULL
895 #gen_list.c: *********************************************************************/
896 #gen_list.c:struct gen_list *gen_list_destruct( struct gen_list *this_list )
898 #gen_list.c: struct gen_list_node *curr = this_list->first;
900 #gen_list.c: LIST_SHOW( printf( "\
901 #gen_list.c:destruct this_list\t\t\t= %p
902 #gen_list.c:destruct this_list->first\t= %p
903 #gen_list.c:destruct this_list->last\t= %p\n\n", (const void *)this_list, (const void *)this_list->first, (const void *)this_list->last ) );
905 #gen_list.c: while ( NULL != curr )
907 #gen_list.c: struct gen_list_node *next = gen_list_node_get_next( curr );
908 #gen_list.c: gen_list_node_destruct( curr );
909 #gen_list.c: curr = next;
912 #gen_list.c: FREE( this_list );
913 #gen_list.c: return( NULL );
918 #gen_list.c:/*********************************************************************
920 #gen_list.c: * Function : gen_list_remove_all
922 #gen_list.c: * Description : Destruct the list. Including free_ing the memory
923 #gen_list.c: * if applicable.
925 #gen_list.c: * Parameters :
926 #gen_list.c: * 1 : The list.
928 #gen_list.c: * Returns : NULL
930 #gen_list.c: *********************************************************************/
931 #gen_list.c:struct gen_list *gen_list_remove_all( struct gen_list *this_list )
933 #gen_list.c: struct gen_list_node *curr = this_list->first;
935 #gen_list.c: LIST_SHOW( printf( "\
936 #gen_list.c:remove_all this_list\t\t\t\t= %p
937 #gen_list.c:remove_all this_list->first\t= %p
938 #gen_list.c:remove_all this_list->last\t\t= %p\n\n", (const void *)this_list, (const void *)this_list->first, (const void *)this_list->last ) );
940 #gen_list.c: while ( NULL != curr )
942 #gen_list.c: struct gen_list_node *next = gen_list_node_get_next( curr );
943 #gen_list.c: gen_list_node_remove( curr );
944 #gen_list.c: curr = next;
947 #gen_list.c: this_list->first = this_list->last = NULL;
948 #gen_list.c: return( this_list );
953 #gen_list.c:/*********************************************************************
955 #gen_list.c: * Function : gen_list_remove
957 #gen_list.c: * Description : A record from the list and return it if found. This
958 #gen_list.c: * will allow a futher call to rec_destruct.
960 #gen_list.c: * Parameters :
961 #gen_list.c: * 1 : The list.
962 #gen_list.c: * 2 : The record to be removed.
964 #gen_list.c: * Returns : rec if found and removed, NULL otherwise.
966 #gen_list.c: *********************************************************************/
967 #gen_list.c:struct gen_list_rec *gen_list_remove( struct gen_list *this_list, struct gen_list_rec *rec )
969 #gen_list.c: struct gen_list_node *curr = this_list->first;
971 #gen_list.c: LIST_SHOW( printf( "\
972 #gen_list.c:remove this_list\t\t\t= %p
973 #gen_list.c:remove this_list->first\t= %p
974 #gen_list.c:remove this_list->last\t= %p
975 #gen_list.c:remove rec\t\t\t\t\t= %p\n\n", (const void *)this_list, (const void *)this_list->first, (const void *)this_list->last, rec ) );
977 #gen_list.c: while ( NULL != curr )
979 #gen_list.c: /* Grab these values before the are destroyed. */
980 #gen_list.c: struct gen_list_node *prev = gen_list_node_get_prev( curr );
981 #gen_list.c: struct gen_list_node *next = gen_list_node_get_next( curr );
983 #gen_list.c: /* Access to rec, next, prev of gen_list_node is allowed since it is private to gen_list */
984 #gen_list.c: if ( curr->rec == rec )
986 #gen_list.c: /* Destruct the node, but not the record. */
987 #gen_list.c: gen_list_node_remove( curr );
989 #gen_list.c: if ( NULL == prev )
991 #gen_list.c: /************************************************/
992 #gen_list.c: /* This is the first node in the list. */
993 #gen_list.c: /* Picture: */
994 #gen_list.c: /* [first] ---------------------> [next] */
995 #gen_list.c: /* [NULL] <---------------------- [next->prev] */
996 #gen_list.c: /************************************************/
997 #gen_list.c: this_list->first = next;
999 #gen_list.c: if ( NULL == next )
1001 #gen_list.c: /* Since next is NULL, then this is an empty list. */
1002 #gen_list.c: this_list->last = NULL;
1006 #gen_list.c: /* Since next is not NULL, then there is another node to make first. */
1007 #gen_list.c: gen_list_node_set_prev( next, NULL );
1010 #gen_list.c: else if ( NULL == next )
1012 #gen_list.c: /************************************************/
1013 #gen_list.c: /* This is the last node in the list. */
1014 #gen_list.c: /* Picture: */
1015 #gen_list.c: /* [last] ----------------------> [prev] */
1016 #gen_list.c: /* [prev->next] ----------------> [NULL] */
1017 #gen_list.c: /************************************************/
1018 #gen_list.c: this_list->last = prev;
1020 #gen_list.c: if ( NULL == prev )
1022 #gen_list.c: /* Since prev is NULL, then this is an empty list. */
1023 #gen_list.c: this_list->first = NULL;
1027 #gen_list.c: /* Since prev is NULL, then there is another node to make last. */
1028 #gen_list.c: gen_list_node_set_next( prev, NULL );
1033 #gen_list.c: /************************************************/
1034 #gen_list.c: /* This is a middle node in the list. */
1035 #gen_list.c: /* Picture: */
1036 #gen_list.c: /* [prev->next] ----------------> [next] */
1037 #gen_list.c: /* [removing middle] */
1038 #gen_list.c: /* [prev] <---------------------- [next->prev] */
1039 #gen_list.c: /************************************************/
1040 #gen_list.c: gen_list_node_set_next( prev, next );
1041 #gen_list.c: gen_list_node_set_prev( next, prev );
1044 #gen_list.c: return( rec );
1046 #gen_list.c: curr = next;
1049 #gen_list.c: return( NULL );
1054 #gen_list.c:/*********************************************************************
1056 #gen_list.c: * Function : gen_list_get_first
1058 #gen_list.c: * Description : Gets the first record in the list.
1060 #gen_list.c: * Parameters :
1061 #gen_list.c: * 1 : The list.
1063 #gen_list.c: * Returns : The first node.
1065 #gen_list.c: *********************************************************************/
1066 #gen_list.c:struct gen_list_rec *gen_list_get_first( const struct gen_list *this_list )
1068 #gen_list.c: if ( NULL == this_list->first )
1070 #gen_list.c: return( NULL );
1073 #gen_list.c: /* Access to rec of gen_list_node is allowed since it is private to gen_list */
1074 #gen_list.c: return( this_list->first->rec );
1079 #gen_list.c:/*********************************************************************
1081 #gen_list.c: * Function : gen_list_get_last
1083 #gen_list.c: * Description : Gets the last record in the list.
1085 #gen_list.c: * Parameters :
1086 #gen_list.c: * 1 : The list.
1088 #gen_list.c: * Returns : The last node.
1090 #gen_list.c: *********************************************************************/
1091 #gen_list.c:struct gen_list_rec *gen_list_get_last( const struct gen_list *this_list )
1093 #gen_list.c: if ( NULL == this_list->last )
1095 #gen_list.c: return( NULL );
1098 #gen_list.c: /* Access to rec of gen_list_node is allowed since it is private to gen_list */
1099 #gen_list.c: return( this_list->last->rec );
1104 #gen_list.c:/*********************************************************************
1106 #gen_list.c: * Function : gen_list_insert
1108 #gen_list.c: * Description : Inserts a record into the list. This is the
1109 #gen_list.c: * primary API interface for inserting a record.
1111 #gen_list.c: * Parameters :
1112 #gen_list.c: * 1 : The list.
1113 #gen_list.c: * 2 : A new record to insert into the list.
1115 #gen_list.c: * Returns : The node.
1117 #gen_list.c: *********************************************************************/
1118 #gen_list.c:const struct gen_list_node *gen_list_insert( struct gen_list *this_list, struct gen_list_rec *_rec )
1120 #gen_list.c: return( gen_list_insert_node( this_list, gen_list_node_construct( _rec ) ) );
1125 #gen_list.c:/*********************************************************************
1127 #gen_list.c: * Function : gen_list_stream
1129 #gen_list.c: * Description : Displays all attributes on the STDOUT stream,
1130 #gen_list.c: * including the contents of the nodes.
1132 #gen_list.c: * Parameters :
1133 #gen_list.c: * 1 : The list.
1135 #gen_list.c: * Returns : The list.
1137 #gen_list.c: *********************************************************************/
1138 #gen_list.c:const struct gen_list *gen_list_stream( const struct gen_list *this_list )
1140 #gen_list.c: const struct gen_list_node *curr = this_list->first;
1142 #gen_list.c: LIST_SHOW( printf( "\
1143 #gen_list.c:stream this_list\t\t\t= %p
1144 #gen_list.c:stream this_list->first\t= %p
1145 #gen_list.c:stream this_list->last\t= %p\n\n", (const void *)this_list, (const void *)this_list->first, (const void *)this_list->last ) );
1147 #gen_list.c: while ( NULL != curr )
1149 #gen_list.c: struct gen_list_node *next = gen_list_node_get_next( curr );
1150 #gen_list.c: gen_list_node_stream( curr );
1151 #gen_list.c: curr = next;
1154 #gen_list.c: return( this_list );
1159 #gen_list.c:/*********************************************************************
1161 #gen_list.c: * Function : gen_list_equal
1163 #gen_list.c: * Description : Compares two lists (and their nodes) to see if they are equal.
1165 #gen_list.c: * Parameters :
1166 #gen_list.c: * 1 : A list.
1167 #gen_list.c: * 2 : Another list.
1169 #gen_list.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
1171 #gen_list.c: *********************************************************************/
1172 #gen_list.c:int gen_list_equal( const struct gen_list *this_list, const struct gen_list *eq_list )
1174 #gen_list.c: struct gen_list_node *c1 = this_list->first;
1175 #gen_list.c: struct gen_list_node *c2 = eq_list->first;
1176 #gen_list.c: int eq = 1;
1178 #gen_list.c: if ( ( NULL == c1 && NULL != c2 ) || ( NULL != c1 && NULL == c2 ) )
1180 #gen_list.c: return( 0 );
1183 #gen_list.c: while ( ( eq ) && ( NULL != c1 ) && ( NULL != c2 ) )
1185 #gen_list.c: /* Access to rec of gen_list_node is allowed since it is private to gen_list */
1186 #gen_list.c: eq = CALL_VT_REC_EQUAL( c1->rec, c2->rec );
1187 #gen_list.c: if ( NULL != c1 )
1189 #gen_list.c: c1 = gen_list_node_get_next( c1 );
1192 #gen_list.c: if ( NULL != c2 )
1194 #gen_list.c: c2 = gen_list_node_get_next( c2 );
1199 #gen_list.c: if ( NULL == c1 && NULL == c2 )
1201 #gen_list.c: return( 1 );
1204 #gen_list.c: return( eq );
1209 #gen_list.c:/*********************************************************************
1211 #gen_list.c: * Function : gen_list_find
1213 #gen_list.c: * Description : Find a record that matches the one passed to this
1214 #gen_list.c: * function.
1215 #gen_list.c: * NOTE: this function receives a RECORD and not a NODE.
1216 #gen_list.c: * Some implementation issues might be easier addressed
1217 #gen_list.c: * if a node was passed ... but for the time being, I
1218 #gen_list.c: * would like to keep the use/programmer isolated from
1219 #gen_list.c: * the node structure/class.
1221 #gen_list.c: * Parameters :
1222 #gen_list.c: * 1 : The list.
1223 #gen_list.c: * 2 : The record to find.
1225 #gen_list.c: * Returns : NULL => none found, anything else is a pointer to the record.
1227 #gen_list.c: *********************************************************************/
1228 #gen_list.c:struct gen_list_rec *gen_list_find( const struct gen_list *this_list, struct gen_list_rec *rec )
1230 #gen_list.c: const struct gen_list_node *curr = this_list->first;
1231 #gen_list.c: int eq = 0;
1233 #gen_list.c: if ( NULL == curr && NULL == rec )
1235 #gen_list.c: return( (struct gen_list_rec *)1 );
1238 #gen_list.c: if ( ( NULL == curr && NULL != rec ) ||
1239 #gen_list.c: ( NULL != curr && NULL == rec ) )
1241 #gen_list.c: return( 0 );
1244 #gen_list.c: /* Access to rec of gen_list_node is allowed since it is private to gen_list */
1245 #gen_list.c: if ( curr->rec->isa != rec->isa )
1247 #gen_list.c: LIST_SHOW( printf( "INFORMATION: sorry, but comparing different list types is unsupported at this time.\n" ) );
1248 #gen_list.c: return( 0 );
1251 #gen_list.c: if ( NULL == curr )
1253 #gen_list.c: return( NULL );
1257 #gen_list.c: while ( ( !eq ) && ( NULL != curr ) )
1259 #gen_list.c: struct gen_list_node *next = gen_list_node_get_next( curr );
1261 #gen_list.c: eq = CALL_VT_REC_EQUAL( curr->rec, rec );
1263 #gen_list.c: if ( eq )
1265 #gen_list.c: return( curr->rec );
1268 #gen_list.c: curr = next;
1272 #gen_list.c: return( NULL );
1277 #gen_list.c:/*********************************************************************
1279 #gen_list.c: * Function : gen_list_iterate
1281 #gen_list.c: * Description : Pass over the list, calling "iter" for every record.
1282 #gen_list.c: * If the "iter" function returns a non-NULL value,
1283 #gen_list.c: * return it and stop iterating.
1285 #gen_list.c: * Parameters :
1286 #gen_list.c: * 1 : The list.
1287 #gen_list.c: * 2 : The iterator function.
1289 #gen_list.c: * Returns : Whatever the iterator does, or NULL if the entire
1290 #gen_list.c: * list was processed.
1292 #gen_list.c: *********************************************************************/
1293 #gen_list.c:struct gen_list_rec *gen_list_iterate( struct gen_list *this_list, rec_iterate iter )
1295 #gen_list.c: struct gen_list_node *curr = this_list->first;
1297 #gen_list.c: if ( NULL == curr )
1299 #gen_list.c: return( NULL );
1302 #gen_list.c: while ( NULL != curr )
1304 #gen_list.c: /* Access to rec of gen_list_node is allowed since it is private to gen_list */
1305 #gen_list.c: struct gen_list_node *next = gen_list_node_get_next( curr );
1306 #gen_list.c: struct gen_list_rec *r = iter( curr->rec );
1308 #gen_list.c: if ( NULL != r )
1310 #gen_list.c: return( r );
1313 #gen_list.c: curr = next;
1317 #gen_list.c: return( NULL );
1322 #gen_list.c:/*********************************************************************
1324 #gen_list.c: * Function : gen_list_iterate
1326 #gen_list.c: * Description : Pass over the list (in reverse order), calling "iter"
1327 #gen_list.c: * for every record. If the "iter" function returns
1328 #gen_list.c: * a non-NULL value, return it and stop iterating.
1330 #gen_list.c: * Parameters :
1331 #gen_list.c: * 1 : The list.
1332 #gen_list.c: * 2 : The iterator function.
1334 #gen_list.c: * Returns : Whatever the iterator does, or NULL if the entire
1335 #gen_list.c: * list was processed.
1337 #gen_list.c: *********************************************************************/
1338 #gen_list.c:struct gen_list_rec *gen_list_iterate_reverse( struct gen_list *this_list, rec_iterate iter )
1340 #gen_list.c: struct gen_list_node *curr = this_list->last;
1342 #gen_list.c: if ( NULL == curr )
1344 #gen_list.c: return( NULL );
1347 #gen_list.c: while ( NULL != curr )
1349 #gen_list.c: /* Access to rec of gen_list_node is allowed since it is private to gen_list */
1350 #gen_list.c: struct gen_list_node *prev = gen_list_node_get_prev( curr );
1351 #gen_list.c: struct gen_list_rec *r = iter( curr->rec );
1353 #gen_list.c: if ( NULL != r )
1355 #gen_list.c: return( r );
1358 #gen_list.c: curr = prev;
1362 #gen_list.c: return( NULL );
1367 #gen_list.h:#ifndef GEN_LIST_H_INCLUDED
1368 #gen_list.h:#define GEN_LIST_H_INCLUDED
1369 #gen_list.h:#define GEN_LIST_H_VERSION "$Id: gen_list.h,v 1.1 2001/07/29 18:50:04 rodney.stromlund Exp $"
1370 #gen_list.h:/*********************************************************************
1372 #gen_list.h: * File : $Source: /cvsroot/ijbswa/current/gen_list.h,v $
1374 #gen_list.h: * Purpose : To create some functions to do generic doubly linked
1375 #gen_list.h: * list management.
1377 #gen_list.h: * Copyright : Written by and Copyright (C) 2001 the SourceForge
1378 #gen_list.h: * IJBSWA team. http://ijbswa.sourceforge.net
1380 #gen_list.h: * This program is free software; you can redistribute it
1381 #gen_list.h: * and/or modify it under the terms of the GNU General
1382 #gen_list.h: * Public License as published by the Free Software
1383 #gen_list.h: * Foundation; either version 2 of the License, or (at
1384 #gen_list.h: * your option) any later version.
1386 #gen_list.h: * This program is distributed in the hope that it will
1387 #gen_list.h: * be useful, but WITHOUT ANY WARRANTY; without even the
1388 #gen_list.h: * implied warranty of MERCHANTABILITY or FITNESS FOR A
1389 #gen_list.h: * PARTICULAR PURPOSE. See the GNU General Public
1390 #gen_list.h: * License for more details.
1392 #gen_list.h: * The GNU General Public License should be included with
1393 #gen_list.h: * this file. If not, you can view it at
1394 #gen_list.h: * http://www.gnu.org/copyleft/gpl.html
1395 #gen_list.h: * or write to the Free Software Foundation, Inc., 59
1396 #gen_list.h: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1398 #gen_list.h: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
1399 #gen_list.h: * and edit IJB, correctly.
1401 #gen_list.h: * Revisions :
1402 #gen_list.h: * $Log: gen_list.h,v $
1404 #gen_list.h: *********************************************************************/
1407 #gen_list.h:#ifdef __cplusplus
1408 #gen_list.h:extern "C" {
1411 #gen_list.h:#include "isa.h"
1414 #gen_list.h:extern int list_is_quiet;
1416 #gen_list.h:#define LIST_SHOW(stmt) if ( ! list_is_quiet ) { stmt; }
1419 #gen_list.h:struct gen_list_rec;
1420 #gen_list.h:typedef struct gen_list_rec * (*rec_copy_construct)( struct gen_list_rec *copy_rec );
1421 #gen_list.h:typedef struct gen_list_rec * (*rec_destruct)( struct gen_list_rec *this_rec );
1422 #gen_list.h:typedef const struct gen_list_rec * (*rec_stream)( const struct gen_list_rec *this_rec );
1423 #gen_list.h:typedef int (*rec_equal)( const struct gen_list_rec *this_rec, const struct gen_list_rec *eq_rec );
1424 #gen_list.h:typedef struct gen_list_rec * (*rec_iterate)( struct gen_list_rec *this_rec );
1426 #gen_list.h:typedef void * (*rec_method)( void *this_rec, ... );
1429 #gen_list.h:enum VT_ENTRIES
1431 #gen_list.h: VT_REC_COPY_CONSTRUCT,
1432 #gen_list.h: VT_REC_DESTRUCT,
1433 #gen_list.h: VT_REC_STREAM,
1434 #gen_list.h: VT_REC_EQUAL,
1435 #gen_list.h: VT_REC_MAX
1439 #gen_list.h:typedef const rec_method *t_vtable;
1442 #gen_list.h:struct gen_list_rec
1444 #gen_list.h: /* private: */
1445 #gen_list.h: t_vtable vtable;
1446 #gen_list.h: enum GEN_LIST_ISA isa;
1447 #gen_list.h: int sizeof_rec;
1448 #gen_list.h: /* contents HERE */
1450 #gen_list.h:/* public: */
1451 #gen_list.h:extern struct gen_list_rec * gen_list_rec_construct( enum GEN_LIST_ISA isa, int sizeof_rec, const t_vtable _vtable );
1452 #gen_list.h:extern struct gen_list_rec * gen_list_rec_copy_construct( const struct gen_list_rec *this_rec );
1453 #gen_list.h:extern struct gen_list_rec * gen_list_rec_destruct( struct gen_list_rec *this_rec );
1454 #gen_list.h:extern const struct gen_list_rec * gen_list_rec_stream( const struct gen_list_rec *this_rec );
1455 #gen_list.h:extern int gen_list_rec_equal( const struct gen_list_rec *this_rec, const struct gen_list_rec *eq_rec );
1457 #gen_list.h:/* struct/class COMPLETE */
1460 #gen_list.h:/*
\f*********************************************************************/
1462 #gen_list.h:/* private: to gen_list */
1463 #gen_list.h:struct gen_list_node;
1466 #gen_list.h:struct gen_list
1468 #gen_list.h: /* private: */
1469 #gen_list.h: struct gen_list_node *first;
1470 #gen_list.h: struct gen_list_node *last;
1472 #gen_list.h:/* gen_list_insert_node */
1474 #gen_list.h:/* public: */
1475 #gen_list.h:extern struct gen_list * gen_list_construct();
1476 #gen_list.h:extern struct gen_list * gen_list_copy_construct( const struct gen_list *this_list );
1477 #gen_list.h:extern struct gen_list * gen_list_destruct( struct gen_list *this_list );
1478 #gen_list.h:extern struct gen_list * gen_list_remove_all( struct gen_list *this_list );
1479 #gen_list.h:extern struct gen_list_rec * gen_list_remove( struct gen_list *this_list, struct gen_list_rec *_rec );
1480 #gen_list.h:extern struct gen_list_rec * gen_list_get_first( const struct gen_list *this_list );
1481 #gen_list.h:extern struct gen_list_rec * gen_list_get_last( const struct gen_list *this_list );
1482 #gen_list.h:extern const struct gen_list_node * gen_list_insert( struct gen_list *this_list, struct gen_list_rec *_rec );
1483 #gen_list.h:extern const struct gen_list * gen_list_stream( const struct gen_list *this_list );
1484 #gen_list.h:extern int gen_list_equal( const struct gen_list *this_list, const struct gen_list *eq_list );
1485 #gen_list.h:extern struct gen_list_rec * gen_list_find( const struct gen_list *this_list, struct gen_list_rec *rec );
1486 #gen_list.h:extern struct gen_list_rec * gen_list_iterate( struct gen_list *this_list, rec_iterate iter );
1487 #gen_list.h:/* struct/class COMPLETE */
1490 #gen_list.h:#ifdef __cplusplus
1491 #gen_list.h:} /* extern "C" */
1494 #gen_list.h:#endif /* ndef GEN_LIST_H_INCLUDED */
1497 #gen_list.h: Local Variables:
1498 #gen_list.h: tab-width: 3
1503 #isa.c:const char isa_rcs[] = "$Id: isa.c,v 1.1 2001/11/30 21:55:51 rodney Exp $";
1504 #isa.c:/*********************************************************************
1506 #isa.c: * File : $Source: /home/rodney/devl/ijb_beta/contrib/isa.c,v $
1508 #isa.c: * Purpose : Pronounced "is a". To create "english" translations
1509 #isa.c: * for all linked "classes".
1511 #isa.c: * NOTE: this header file must appear once and only once
1512 #isa.c: * per project.
1514 #isa.c: * Copyright : Written by and Copyright (C) 2001 the SourceForge
1515 #isa.c: * IJBSWA team. http://ijbswa.sourceforge.net
1517 #isa.c: * This program is free software; you can redistribute it
1518 #isa.c: * and/or modify it under the terms of the GNU General
1519 #isa.c: * Public License as published by the Free Software
1520 #isa.c: * Foundation; either version 2 of the License, or (at
1521 #isa.c: * your option) any later version.
1523 #isa.c: * This program is distributed in the hope that it will
1524 #isa.c: * be useful, but WITHOUT ANY WARRANTY; without even the
1525 #isa.c: * implied warranty of MERCHANTABILITY or FITNESS FOR A
1526 #isa.c: * PARTICULAR PURPOSE. See the GNU General Public
1527 #isa.c: * License for more details.
1529 #isa.c: * The GNU General Public License should be included with
1530 #isa.c: * this file. If not, you can view it at
1531 #isa.c: * http://www.gnu.org/copyleft/gpl.html
1532 #isa.c: * or write to the Free Software Foundation, Inc., 59
1533 #isa.c: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1535 #isa.c: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
1536 #isa.c: * and edit IJB, correctly.
1538 #isa.c: * Revisions :
1539 #isa.c: * $Log: isa.c,v $
1540 #isa.c: * Revision 1.1 2001/11/30 21:55:51 rodney
1541 #isa.c: * Initial revision
1544 #isa.c: *********************************************************************/
1547 #isa.c:#include <malloc.h>
1548 #isa.c:#include <stdio.h>
1549 #isa.c:#include <stdlib.h>
1550 #isa.c:#include <string.h>
1552 #isa.c:#include "gen_list.h"
1553 #isa.c:#include "isa.h"
1555 #isa.c:const char isa_h_rcs[] = ISA_H_VERSION;
1558 #isa.c:/* Pronounce "ra" phonectically and you get "array", which this variable is. */
1559 #isa.c:char *isa_ra[] =
1561 #isa.c: "GEN_LIST_REC",
1562 #isa.c: "REC_MALLOC_POLICE",
1564 #isa.c: "REC_CHARPTR",
1565 #isa.c: "REC_DOUBLE",
1571 #isa.h:#ifndef ISA_H_INCLUDED
1572 #isa.h:#define ISA_H_INCLUDED
1573 #isa.h:#define ISA_H_VERSION "$Id: isa.h,v 1.1 2001/07/29 18:50:04 rodney.stromlund Exp $"
1574 #isa.h:/*********************************************************************
1576 #isa.h: * File : $Source: /cvsroot/ijbswa/current/isa.h,v $
1578 #isa.h: * Purpose : Pronounced "is a". To create "english" translations
1579 #isa.h: * for all linked "classes".
1581 #isa.h: * NOTE: this header file must appear once and only once
1582 #isa.h: * per project.
1584 #isa.h: * Copyright : Written by and Copyright (C) 2001 the SourceForge
1585 #isa.h: * IJBSWA team. http://ijbswa.sourceforge.net
1587 #isa.h: * This program is free software; you can redistribute it
1588 #isa.h: * and/or modify it under the terms of the GNU General
1589 #isa.h: * Public License as published by the Free Software
1590 #isa.h: * Foundation; either version 2 of the License, or (at
1591 #isa.h: * your option) any later version.
1593 #isa.h: * This program is distributed in the hope that it will
1594 #isa.h: * be useful, but WITHOUT ANY WARRANTY; without even the
1595 #isa.h: * implied warranty of MERCHANTABILITY or FITNESS FOR A
1596 #isa.h: * PARTICULAR PURPOSE. See the GNU General Public
1597 #isa.h: * License for more details.
1599 #isa.h: * The GNU General Public License should be included with
1600 #isa.h: * this file. If not, you can view it at
1601 #isa.h: * http://www.gnu.org/copyleft/gpl.html
1602 #isa.h: * or write to the Free Software Foundation, Inc., 59
1603 #isa.h: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1605 #isa.h: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
1606 #isa.h: * and edit IJB, correctly.
1608 #isa.h: * Revisions :
1609 #isa.h: * $Log: isa.h,v $
1611 #isa.h: *********************************************************************/
1614 #isa.h:#ifdef __cplusplus
1619 #isa.h:enum GEN_LIST_ISA
1621 #isa.h: ISA_GEN_LIST_REC,
1622 #isa.h: ISA_MALLOC_POLICE,
1624 #isa.h: ISA_CHARPTR,
1631 #isa.h:/* Pronounce "ra" phonectically and you get "array", which this variable is. */
1632 #isa.h:extern char *isa_ra[];
1635 #isa.h:#ifdef __cplusplus
1636 #isa.h:} /* extern "C" */
1639 #isa.h:#endif /* ndef ISA_H_INCLUDED */
1642 #isa.h: Local Variables:
1643 #isa.h: tab-width: 3
1648 #main.c:const char main_rcs[] = "$Id: main.c,v 1.1 2001/10/25 03:40:48 rodney.stromlund Exp $";
1649 #main.c:/*********************************************************************
1651 #main.c: * File : $Source: /cvsroot/ijbswa/current/gen_list.c,v $
1653 #main.c: * Purpose : To test "generic list" creation and manipulation.
1655 #main.c: * Copyright : Written by and Copyright (C) 2001 the SourceForge
1656 #main.c: * IJBSWA team. http://ijbswa.sourceforge.net
1658 #main.c: * This program is free software; you can redistribute it
1659 #main.c: * and/or modify it under the terms of the GNU General
1660 #main.c: * Public License as published by the Free Software
1661 #main.c: * Foundation; either version 2 of the License, or (at
1662 #main.c: * your option) any later version.
1664 #main.c: * This program is distributed in the hope that it will
1665 #main.c: * be useful, but WITHOUT ANY WARRANTY; without even the
1666 #main.c: * implied warranty of MERCHANTABILITY or FITNESS FOR A
1667 #main.c: * PARTICULAR PURPOSE. See the GNU General Public
1668 #main.c: * License for more details.
1670 #main.c: * The GNU General Public License should be included with
1671 #main.c: * this file. If not, you can view it at
1672 #main.c: * http://www.gnu.org/copyleft/gpl.html
1673 #main.c: * or write to the Free Software Foundation, Inc., 59
1674 #main.c: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1676 #main.c: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
1677 #main.c: * and edit IJB, correctly.
1679 #main.c: * Note : This output assumes (per IJB standards) that tabs are
1680 #main.c: * set to 3 characters. If you run this in a terminal,
1681 #main.c: * you may want to run this as so:
1682 #main.c: * >./test_list 2>&1 | expand -t3 | ./addr_clean.pl
1683 #main.c: * This will expand the tab to 3 columns and then replace
1684 #main.c: * "0x" style addresses with more human readable ones.
1686 #main.c: * Revisions :
1687 #main.c: * $Log: main.c,v $
1689 #main.c: *********************************************************************/
1692 #main.c:#include <malloc.h>
1693 #main.c:#include <stdio.h>
1694 #main.c:#include <stdlib.h>
1695 #main.c:#include <string.h>
1697 #main.c:#include "gen_list.h"
1698 #main.c:#include "rec_char.h"
1699 #main.c:#include "rec_charptr.h"
1700 #main.c:#include "rec_double.h"
1701 #main.c:#include "rec_long.h"
1702 #main.c:#include "malloc_police.h"
1705 #main.c:extern const char isa_rcs[];
1706 #main.c:extern const char isa_h_rcs[];
1707 #main.c:extern const char gen_list_rcs[];
1708 #main.c:extern const char gen_list_h_rcs[];
1709 #main.c:extern const char malloc_police_rcs[];
1710 #main.c:extern const char malloc_police_h_rcs[];
1711 #main.c:extern const char rec_charptr_rcs[];
1712 #main.c:extern const char rec_charptr_h_rcs[];
1713 #main.c:extern const char rec_long_rcs[];
1714 #main.c:extern const char rec_long_h_rcs[];
1715 #main.c:extern const char rec_double_rcs[];
1716 #main.c:extern const char rec_double_h_rcs[];
1717 #main.c:extern const char rec_char_rcs[];
1718 #main.c:extern const char rec_char_h_rcs[];
1719 #main.c:extern const char rec_malloc_police_rcs[];
1720 #main.c:extern const char rec_malloc_police_h_rcs[];
1721 #main.c:extern const char main_rcs[];
1724 #main.c:/*********************************************************************
1726 #main.c: * Function : my_custom_charptr_iterator_1
1728 #main.c: * Description : This funtion is called once for every record in a
1729 #main.c: * list. Or at least until we return non-NULL. BTW,
1730 #main.c: * this function always returns NULL, thus it will
1731 #main.c: * iterate over the entire list.
1733 #main.c: * Parameters :
1734 #main.c: * 1 : The record.
1736 #main.c: * Returns : NULL
1738 #main.c: *********************************************************************/
1739 #main.c:struct derived_rec_charptr *my_custom_charptr_iterator_1( struct derived_rec_charptr *this_rec )
1742 #main.c:\t\tcharptr iterator_1 this_rec\t\t\t\t= iter_1 ... %p
1743 #main.c:\t\tcharptr iterator_1 this_rec->contents\t= iter_1 ... %s\n\n", (const void *)this_rec, this_rec->contents );
1744 #main.c: return( NULL );
1749 #main.c:/*********************************************************************
1751 #main.c: * Function : my_custom_charptr_iterator_2
1753 #main.c: * Description : This funtion is called once for every record in a
1754 #main.c: * list. Or at least until we return non-NULL. BTW,
1755 #main.c: * this function always returns non-NULL, thus it will
1756 #main.c: * iterate over only 1 record.
1758 #main.c: * Parameters :
1759 #main.c: * 1 : The record.
1761 #main.c: * Returns : The record.
1763 #main.c: *********************************************************************/
1764 #main.c:struct derived_rec_charptr *my_custom_charptr_iterator_2( struct derived_rec_charptr *this_rec )
1767 #main.c:\t\tcharptr iterator_1 this_rec\t\t\t\t= iter_2 ... %p
1768 #main.c:\t\tcharptr iterator_1 this_rec->contents\t= iter_2 ... %s\n\n", (const void *)this_rec, this_rec->contents );
1769 #main.c: return( this_rec );
1774 #main.c:/*********************************************************************
1776 #main.c: * Function : main
1778 #main.c: * Description : Test the doubly linked list as it is so far.
1780 #main.c: * Parameters : None
1782 #main.c: * Returns : N/A
1784 #main.c: *********************************************************************/
1785 #main.c:int main( int argc, const char **argv )
1787 #main.c: struct gen_list *lcharptr;
1788 #main.c: struct gen_list *llong;
1789 #main.c: struct gen_list *ldouble;
1790 #main.c: struct gen_list *lchar;
1792 #main.c: struct gen_list *lcharptr_c;
1793 #main.c: struct gen_list *llong_c;
1794 #main.c: struct gen_list *ldouble_c;
1795 #main.c: struct gen_list *lchar_c;
1797 #main.c: struct gen_list_rec *f_rec;
1799 #main.c: struct gen_list *no_own_list;
1800 #main.c: struct gen_list_rec *no_own_rec1;
1801 #main.c: struct gen_list_rec *no_own_rec2;
1802 #main.c: struct gen_list_rec *no_own_rec3;
1804 #main.c: printf( "\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n",
1805 #main.c: gen_list_rcs,
1806 #main.c: gen_list_h_rcs,
1809 #main.c: malloc_police_rcs,
1810 #main.c: malloc_police_h_rcs,
1811 #main.c: rec_char_rcs,
1812 #main.c: rec_char_h_rcs,
1813 #main.c: rec_charptr_rcs,
1814 #main.c: rec_charptr_h_rcs,
1815 #main.c: rec_long_rcs,
1816 #main.c: rec_long_h_rcs,
1817 #main.c: rec_double_rcs,
1818 #main.c: rec_double_h_rcs,
1819 #main.c: rec_malloc_police_rcs,
1820 #main.c: rec_malloc_police_h_rcs,
1821 #main.c: main_rcs );
1824 #main.c: /* Force a memory leak to test the strdup/malloc/free police. */
1825 #main.c: /* NOTE: this should trigger the alphanum check of allocated memory. */
1826 #main.c: strcpy( MALLOC( 60 ), "Force a memory leak to test the strdup/malloc/free police." );
1829 #main.c: printf( "** -- Calling gen_list_construct to constuct a charptr list -- **\n" );
1830 #main.c: lcharptr = gen_list_construct();
1832 #main.c: gen_list_insert( lcharptr, (struct gen_list_rec *)derived_rec_charptr_construct( "Rodney Stromlund" ) );
1833 #main.c: gen_list_insert( lcharptr, f_rec = (struct gen_list_rec *)derived_rec_charptr_construct( "RJS" ) );
1834 #main.c: gen_list_insert( lcharptr, (struct gen_list_rec *)derived_rec_charptr_construct( "jammin!" ) );
1836 #main.c: printf( "** -- Calling gen_list_stream to test streaming a charptr list -- **\n" );
1837 #main.c: gen_list_stream( lcharptr );
1839 #main.c: printf( "** -- Calling gen_list_find to find the 2nd charptr record -- **\n" );
1840 #main.c: f_rec = gen_list_find( lcharptr, f_rec );
1841 #main.c: printf( "Found rec = %p\n", f_rec );
1842 #main.c: derived_rec_charptr_stream( (const struct derived_rec_charptr *)f_rec );
1845 #main.c: printf( "** -- Calling gen_list_copy_construct to test copy construct the charptr list -- **\n" );
1846 #main.c: lcharptr_c = gen_list_copy_construct( lcharptr );
1848 #main.c: printf( "** -- Calling gen_list_equal to see if the copied list is the same as the orig -- **
1849 #main.c:** -- NOTE: they will NOT be because the charptr copy constructor changes the string contents -- **\n" );
1850 #main.c: printf( "Are these 2 equal? => %d\n\n", gen_list_equal( lcharptr, lcharptr_c ) );
1852 #main.c: printf( "** -- Calling gen_list_stream to stream a copied charptr list -- **\n" );
1853 #main.c: gen_list_stream( lcharptr_c );
1856 #main.c: printf( "** -- Calling gen_list_construct to constuct a long list -- **\n" );
1857 #main.c: llong = gen_list_construct();
1860 #main.c: gen_list_insert( llong, no_own_rec1 = (struct gen_list_rec *)derived_rec_long_construct( 1 ) );
1861 #main.c: gen_list_insert( llong, no_own_rec2 = (struct gen_list_rec *)derived_rec_long_construct( 100 ) );
1862 #main.c: gen_list_insert( llong, no_own_rec3 = (struct gen_list_rec *)derived_rec_long_construct( 200 ) );
1864 #main.c: printf( "** -- Calling gen_list_stream to test streaming a long list -- **\n" );
1865 #main.c: gen_list_stream( llong );
1868 #main.c: printf( "** -- Calling gen_list_copy_construct to test copy construct the long list -- **\n" );
1869 #main.c: llong_c = gen_list_copy_construct( llong );
1871 #main.c: printf( "** -- Calling gen_list_stream to stream a copied long list -- **\n" );
1872 #main.c: gen_list_stream( llong_c );
1874 #main.c: printf( "** -- Calling gen_list_construct to test a no-owner long list -- **\n" );
1875 #main.c: no_own_list = gen_list_construct();
1876 #main.c: gen_list_insert( no_own_list, no_own_rec1 );
1877 #main.c: gen_list_insert( no_own_list, no_own_rec2 );
1878 #main.c: gen_list_insert( no_own_list, no_own_rec3 );
1880 #main.c: printf( "** -- Calling gen_list_stream to stream a no-owner list -- **\n" );
1881 #main.c: gen_list_stream( no_own_list );
1883 #main.c: printf( "** -- Calling gen_list_equal to see if list and no-owner list are equal NOTE: they should be. -- **\n" );
1884 #main.c: printf( "Are these 2 equal? => %d\n\n", gen_list_equal( llong, no_own_list ) );
1887 #main.c: printf( "** -- Calling gen_list_construct to constuct a double list -- **\n" );
1888 #main.c: ldouble = gen_list_construct();
1890 #main.c: gen_list_insert( ldouble, (struct gen_list_rec *)derived_rec_double_construct( 3.0 ) );
1891 #main.c: gen_list_insert( ldouble, (struct gen_list_rec *)derived_rec_double_construct( 3.1 ) );
1892 #main.c: gen_list_insert( ldouble, (struct gen_list_rec *)derived_rec_double_construct( 3.14 ) );
1894 #main.c: printf( "** -- Calling gen_list_stream to test streaming a double list -- **\n" );
1895 #main.c: gen_list_stream( ldouble );
1898 #main.c: printf( "** -- Calling gen_list_copy_construct to test copy construct the double list -- **\n" );
1899 #main.c: ldouble_c = gen_list_copy_construct( ldouble );
1901 #main.c: printf( "** -- Calling gen_list_stream to stream a copied double list -- **\n" );
1902 #main.c: gen_list_stream( ldouble_c );
1905 #main.c: printf( "** -- Calling gen_list_construct to constuct a char list -- **\n" );
1906 #main.c: lchar = gen_list_construct();
1908 #main.c: gen_list_insert( lchar, (struct gen_list_rec *)derived_rec_char_construct( '1' ) );
1909 #main.c: gen_list_insert( lchar, (struct gen_list_rec *)derived_rec_char_construct( 'A' ) );
1910 #main.c: gen_list_insert( lchar, (struct gen_list_rec *)derived_rec_char_construct( 'a' ) );
1912 #main.c: printf( "** -- Calling gen_list_stream to test streaming a char list -- **\n" );
1913 #main.c: gen_list_stream( lchar );
1916 #main.c: printf( "** -- Calling gen_list_copy_construct to test copy construct the char list -- **\n" );
1917 #main.c: lchar_c = gen_list_copy_construct( lchar );
1919 #main.c: printf( "** -- Calling gen_list_equal to see if the copied list is the same as the orig NOTE: they should be. -- **\n" );
1920 #main.c: printf( "Are these 2 equal? => %d\n\n", gen_list_equal( lchar, lchar_c ) );
1922 #main.c: printf( "** -- Calling gen_list_stream to stream a copied char list -- **\n" );
1923 #main.c: gen_list_stream( lchar_c );
1926 #main.c: printf( "** -- Calling gen_list_iterate to iterate a charptr list -- **
1927 #main.c:** -- NOTE: this iterator (my_custom_charptr_iterator_1) will iterate the whole list. -- **\n" );
1928 #main.c: gen_list_iterate( lcharptr, (rec_iterate)my_custom_charptr_iterator_1 );
1930 #main.c: printf( "** -- Calling gen_list_iterate to iterate a copied charptr list -- **
1931 #main.c:** -- NOTE: this iterator (my_custom_charptr_iterator_2) will return after the first iteration. -- **\n" );
1932 #main.c: gen_list_iterate( lcharptr_c, (rec_iterate)my_custom_charptr_iterator_2 );
1935 #main.c: printf( "** -- Calling gen_list_iterate_reverse to iterate a charptr list -- **
1936 #main.c:** -- NOTE: this iterator (my_custom_charptr_iterator_1) will iterate the whole list. -- **\n" );
1937 #main.c: gen_list_iterate_reverse( lcharptr, (rec_iterate)my_custom_charptr_iterator_1 );
1939 #main.c: printf( "** -- Calling gen_list_iterate_reverse to iterate a copied charptr list -- **
1940 #main.c:** -- NOTE: this iterator (my_custom_charptr_iterator_2) will return after the first iteration. -- **\n" );
1941 #main.c: gen_list_iterate_reverse( lcharptr_c, (rec_iterate)my_custom_charptr_iterator_2 );
1944 #main.c: printf( "** -- Calling gen_list_equal to see if 2 different typed lists are equal NOTE: they should not be. -- **\n" );
1945 #main.c: printf( "Are these 2 equal? => %d\n\n", gen_list_equal( lcharptr, llong ) );
1948 #main.c: printf( "** -- Calling gen_list_remove_all to erase a no-owner list -- **\n" );
1949 #main.c: no_own_list = gen_list_remove_all( no_own_list );
1951 #main.c: printf( "** -- Calling gen_list_destruct to destruct a no-owner list -- **\n" );
1952 #main.c: no_own_list = gen_list_destruct( no_own_list );
1955 #main.c: printf( "** -- Calling gen_list_remove to remove the first record of a copied charptr list -- **\n" );
1956 #main.c: derived_rec_charptr_destruct( (struct derived_rec_charptr *)gen_list_remove( lcharptr_c, gen_list_get_first( lcharptr_c ) ) );
1958 #main.c: printf( "** -- Calling gen_list_remove to remove the last record of a copied long list -- **\n" );
1959 #main.c: derived_rec_long_destruct( (struct derived_rec_long *)gen_list_remove( llong_c, gen_list_get_last( llong_c ) ) );
1961 #main.c: printf( "** -- Calling gen_list_remove to remove the middle record of an original charptr list -- **\n" );
1962 #main.c: derived_rec_charptr_destruct( (struct derived_rec_charptr *)gen_list_remove( lcharptr, f_rec ) );
1964 #main.c: printf( "** -- Calling gen_list_remove to remove the all 3 records of a copied char list (first to last) -- **\n" );
1965 #main.c: derived_rec_char_destruct( (struct derived_rec_char *)gen_list_remove( lchar_c, gen_list_get_first( lchar_c ) ) );
1966 #main.c: derived_rec_char_destruct( (struct derived_rec_char *)gen_list_remove( lchar_c, gen_list_get_first( lchar_c ) ) );
1967 #main.c: derived_rec_char_destruct( (struct derived_rec_char *)gen_list_remove( lchar_c, gen_list_get_first( lchar_c ) ) );
1969 #main.c: printf( "** -- Calling gen_list_remove to remove the all 3 records of the original char list (last to first) -- **\n" );
1970 #main.c: derived_rec_char_destruct( (struct derived_rec_char *)gen_list_remove( lchar, gen_list_get_last( lchar ) ) );
1971 #main.c: derived_rec_char_destruct( (struct derived_rec_char *)gen_list_remove( lchar, gen_list_get_last( lchar ) ) );
1972 #main.c: derived_rec_char_destruct( (struct derived_rec_char *)gen_list_remove( lchar, gen_list_get_last( lchar ) ) );
1975 #main.c: printf( "** -- Calling gen_list_destruct to destruct the original charptr list (less the middle record) -- **\n" );
1976 #main.c: lcharptr = gen_list_destruct( lcharptr );
1977 #main.c: printf( "** -- Calling gen_list_destruct to destruct the copied charptr list (less the first record) -- **\n" );
1978 #main.c: lcharptr_c = gen_list_destruct( lcharptr_c );
1980 #main.c: printf( "** -- Calling gen_list_destruct to destruct the original long list -- **\n" );
1981 #main.c: llong = gen_list_destruct( llong );
1982 #main.c: printf( "** -- Calling gen_list_destruct to destruct the copied long list (less the last record) -- **\n" );
1983 #main.c: llong_c = gen_list_destruct( llong_c );
1985 #main.c: printf( "** -- Calling gen_list_destruct to destruct the original double list -- **\n" );
1986 #main.c: ldouble = gen_list_destruct( ldouble );
1987 #main.c: printf( "** -- Calling gen_list_destruct to destruct the copied double list -- **\n" );
1988 #main.c: ldouble_c = gen_list_destruct( ldouble_c );
1990 #main.c: printf( "** -- Calling gen_list_destruct to destruct the original char list (less all records last to first) -- **\n" );
1991 #main.c: lchar = gen_list_destruct( lchar );
1992 #main.c: printf( "** -- Calling gen_list_destruct to destruct the copied char list (less all records first to last) -- **\n" );
1993 #main.c: lchar_c = gen_list_destruct( lchar_c );
1996 #main.c: /* Force another memory leak to test the strdup/malloc/free police. */
1997 #main.c: /* NOTE: this should trigger the alphanum check of allocated memory. */
1998 #main.c: STRDUP( "Force another memory leak to test the strdup/malloc/free police." );
2000 #main.c: /* Force a memory leak in a list and also in 2 nodes. */
2001 #main.c: /* NOTE: this should NOT trigger the alphanum check of allocated memory. */
2002 #main.c: gen_list_construct();
2004 #main.c: /* NOTE: this should trigger 1 NON check (for the node) */
2005 #main.c: /* followed by 1 alphanum check for the charptr string. */
2006 #main.c: derived_rec_charptr_construct( "Leaky charptr node." );
2008 #main.c: /* NOTE: this should NOT trigger the alphanum check of allocated memory. */
2009 #main.c: derived_rec_char_construct( 'Z' );
2012 #main.c: printf( "\ndone" );
2013 #main.c: return( 0 );
2019 #main.c: Local Variables:
2020 #main.c: tab-width: 3
2025 #malloc_police.c:const char malloc_police_rcs[] = "$Id: malloc_police.c,v 1.1 2001/10/25 03:40:48 rodney.stromlund Exp $";
2026 #malloc_police.c:/*********************************************************************
2028 #malloc_police.c: * File : $Source: /cvsroot/ijbswa/current/gen_list.c,v $
2030 #malloc_police.c: * Purpose : This module uses the rec_malloc_police to build a
2031 #malloc_police.c: * list of allocated and freed memory. When the
2032 #malloc_police.c: * program exits, we will print a list of all memory
2033 #malloc_police.c: * that was allocated, but never freed. This could
2034 #malloc_police.c: * be most helpful to developers and debugers.
2036 #malloc_police.c: * Copyright : Written by and Copyright (C) 2001 the SourceForge
2037 #malloc_police.c: * IJBSWA team. http://ijbswa.sourceforge.net
2039 #malloc_police.c: * This program is free software; you can redistribute it
2040 #malloc_police.c: * and/or modify it under the terms of the GNU General
2041 #malloc_police.c: * Public License as published by the Free Software
2042 #malloc_police.c: * Foundation; either version 2 of the License, or (at
2043 #malloc_police.c: * your option) any later version.
2045 #malloc_police.c: * This program is distributed in the hope that it will
2046 #malloc_police.c: * be useful, but WITHOUT ANY WARRANTY; without even the
2047 #malloc_police.c: * implied warranty of MERCHANTABILITY or FITNESS FOR A
2048 #malloc_police.c: * PARTICULAR PURPOSE. See the GNU General Public
2049 #malloc_police.c: * License for more details.
2051 #malloc_police.c: * The GNU General Public License should be included with
2052 #malloc_police.c: * this file. If not, you can view it at
2053 #malloc_police.c: * http://www.gnu.org/copyleft/gpl.html
2054 #malloc_police.c: * or write to the Free Software Foundation, Inc., 59
2055 #malloc_police.c: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2057 #malloc_police.c: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
2058 #malloc_police.c: * and edit IJB, correctly.
2060 #malloc_police.c: * Revisions :
2061 #malloc_police.c: * $Log: malloc_police.c,v $
2063 #malloc_police.c: *********************************************************************/
2066 #malloc_police.c:#include <ctype.h>
2067 #malloc_police.c:#include <malloc.h>
2068 #malloc_police.c:#include <stdio.h>
2069 #malloc_police.c:#include <stdlib.h>
2070 #malloc_police.c:#include <string.h>
2072 #malloc_police.c:#include "gen_list.h"
2073 #malloc_police.c:#include "malloc_police.h"
2074 #malloc_police.c:#include "rec_malloc_police.h"
2076 #malloc_police.c:const char malloc_police_h_rcs[] = MALLOC_POLICE_H_VERSION;
2079 #malloc_police.c:/* When we need to allocate malloc_police records, we */
2080 #malloc_police.c:/* will do recursion infinately. This variable will */
2081 #malloc_police.c:/* stop the STRDUP, MALLOC, and FREE replacements from */
2082 #malloc_police.c:/* trying to log these allocations. */
2084 #malloc_police.c:char recursion_protect = 0;
2086 #malloc_police.c:struct gen_list *get_police_list();
2087 #malloc_police.c:static char called_once = 0;
2088 #malloc_police.c:static const char *leak_report_header = "%s****************************** MEMORY LEAK REPORT %s ******************************%s";
2091 #malloc_police.c:/*********************************************************************
2093 #malloc_police.c: * Function : police_list_release_iterator
2095 #malloc_police.c: * Description : Iterator for the police list. We will report
2096 #malloc_police.c: * "leaked" memory for the developer to correct.
2098 #malloc_police.c: * Parameters :
2099 #malloc_police.c: * 1 : The record.
2101 #malloc_police.c: * Returns : NULL
2103 #malloc_police.c: *********************************************************************/
2104 #malloc_police.c:struct derived_rec_malloc_police *police_list_release_iterator( struct derived_rec_malloc_police *this_rec )
2106 #malloc_police.c: if ( ! called_once )
2108 #malloc_police.c: called_once = 1;
2109 #malloc_police.c: fprintf( stderr, leak_report_header, "\n\n", "BEGIN", "\n\n" );
2112 #malloc_police.c: fprintf( stderr, "\
2113 #malloc_police.c:\t\tmalloc_police leaked memory iterator this_rec\t\t\t\t\t= %p
2114 #malloc_police.c:\t\tmalloc_police leaked memory iterator this_rec->alloced_addr\t= %p
2115 #malloc_police.c:\t\tmalloc_police leaked memory iterator this_rec->source_where\t= %s
2116 #malloc_police.c:\t\tmalloc_police leaked memory iterator this_rec->sz\t\t\t\t= %ld\n",
2117 #malloc_police.c: (const void *)this_rec,
2118 #malloc_police.c: this_rec->alloced_addr,
2119 #malloc_police.c: this_rec->source_where,
2120 #malloc_police.c: this_rec->sz
2121 #malloc_police.c: );
2123 #malloc_police.c: if (
2124 #malloc_police.c: this_rec->sz >= 3 &&
2125 #malloc_police.c: isalnum( ((const char *)this_rec->alloced_addr)[ 0 ] ) &&
2126 #malloc_police.c: isalnum( ((const char *)this_rec->alloced_addr)[ 1 ] ) &&
2127 #malloc_police.c: isalnum( ((const char *)this_rec->alloced_addr)[ 2 ] ) )
2129 #malloc_police.c: /* If the memory starts with 3 alpha-numerics,
2130 #malloc_police.c: * assume a string was allocated. This might be
2131 #malloc_police.c: * a little dangerous for production code, but I
2132 #malloc_police.c: * will take the risk for development payoff
2133 #malloc_police.c: * (at least for now ...) */
2135 #malloc_police.c: fprintf( stderr, "\
2136 #malloc_police.c:\t\tAlpha numeric found, assuming a string was allocated\t\t\t= %s\n",
2137 #malloc_police.c: this_rec->alloced_addr
2138 #malloc_police.c: );
2141 #malloc_police.c: fprintf( stderr, "\n" );
2143 #malloc_police.c: return( NULL );
2148 #malloc_police.c:/*********************************************************************
2150 #malloc_police.c: * Function : release_police_list
2152 #malloc_police.c: * Description : Iterates the police_list and reports "leaked" memory.
2153 #malloc_police.c: * It will then free the list itself.
2155 #malloc_police.c: * Parameters : None
2157 #malloc_police.c: * Returns : None.
2159 #malloc_police.c: *********************************************************************/
2160 #malloc_police.c:void release_police_list()
2162 #malloc_police.c: struct gen_list *police_list = get_police_list();
2163 #malloc_police.c: fflush( stdout );
2164 #malloc_police.c: gen_list_iterate( police_list, (rec_iterate)police_list_release_iterator );
2166 #malloc_police.c: if ( called_once )
2168 #malloc_police.c: called_once = 0;
2169 #malloc_police.c: fprintf( stderr, leak_report_header, "", "END", "\n" );
2175 #malloc_police.c:/*********************************************************************
2177 #malloc_police.c: * Function : get_police_list
2179 #malloc_police.c: * Description : Get the police malloc/strdup/free list. Generate
2180 #malloc_police.c: * a new one if it does not yet exist.
2182 #malloc_police.c: * Parameters : None
2184 #malloc_police.c: * Returns : The police list.
2186 #malloc_police.c: *********************************************************************/
2187 #malloc_police.c:struct gen_list *get_police_list()
2189 #malloc_police.c: static struct gen_list *police_list = NULL;
2191 #malloc_police.c: if ( NULL == police_list )
2193 #malloc_police.c: recursion_protect ++;
2194 #malloc_police.c: list_is_quiet ++;
2196 #malloc_police.c: police_list = gen_list_construct();
2197 #malloc_police.c: atexit( release_police_list );
2199 #malloc_police.c: recursion_protect --;
2200 #malloc_police.c: list_is_quiet --;
2203 #malloc_police.c: return( police_list );
2208 #malloc_police.c:/*********************************************************************
2210 #malloc_police.c: * Function : police_strdup
2212 #malloc_police.c: * Description : Save the results of the strdup into our linked list.
2213 #malloc_police.c: * This will be checked against latter free(s).
2215 #malloc_police.c: * Parameters :
2216 #malloc_police.c: * 1 : The string to be duplicated.
2217 #malloc_police.c: * 2 : Filename where the strdup occured.
2218 #malloc_police.c: * 3 : Line# of where the strdup occured.
2220 #malloc_police.c: * Returns : Pointer to newly allocated memory.
2222 #malloc_police.c: * NOTE : This could replace the custom strdup for __MINGW32__
2223 #malloc_police.c: * systems. We only need to copy the conditionally
2224 #malloc_police.c: * compiled code here and eliminate the strdup copy.
2226 #malloc_police.c: *********************************************************************/
2227 #malloc_police.c:char *police_strdup( const char *s, const char *filename, long lineno )
2229 #malloc_police.c: char *ret = strdup( s );
2231 #malloc_police.c: if ( 0 == recursion_protect )
2233 #malloc_police.c: char buffer[ 255 ];
2234 #malloc_police.c: sprintf( buffer, "strdup : %s @ %ld for %ld (%s)", filename, lineno, strlen( s ) + 1, s );
2236 #malloc_police.c: recursion_protect ++;
2237 #malloc_police.c: list_is_quiet ++;
2239 #malloc_police.c: gen_list_insert(
2240 #malloc_police.c: get_police_list(),
2241 #malloc_police.c: (struct gen_list_rec *)derived_rec_malloc_police_construct( ret, buffer, strlen( s ) + 1 )
2242 #malloc_police.c: );
2244 #malloc_police.c: recursion_protect --;
2245 #malloc_police.c: list_is_quiet --;
2248 #malloc_police.c: return( ret );
2253 #malloc_police.c:/*********************************************************************
2255 #malloc_police.c: * Function : police_malloc
2257 #malloc_police.c: * Description : Save the results of the malloc into our linked list.
2258 #malloc_police.c: * This will be checked against latter free(s).
2260 #malloc_police.c: * Parameters :
2261 #malloc_police.c: * 1 : The size of the memory to be malloc(ed).
2262 #malloc_police.c: * 2 : Filename where the malloc occured.
2263 #malloc_police.c: * 3 : Line# of where the malloc occured.
2265 #malloc_police.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
2267 #malloc_police.c: *********************************************************************/
2268 #malloc_police.c:void *police_malloc( size_t sz, const char *filename, long lineno )
2270 #malloc_police.c: void *ret = malloc( sz );
2272 #malloc_police.c: if ( 0 == recursion_protect )
2274 #malloc_police.c: char buffer[ 255 ];
2275 #malloc_police.c: sprintf( buffer, "malloc : %s @ %ld for %ld", filename, lineno, sz );
2277 #malloc_police.c: recursion_protect ++;
2278 #malloc_police.c: list_is_quiet ++;
2280 #malloc_police.c: gen_list_insert(
2281 #malloc_police.c: get_police_list(),
2282 #malloc_police.c: (struct gen_list_rec *)derived_rec_malloc_police_construct( ret, buffer, sz )
2283 #malloc_police.c: );
2285 #malloc_police.c: recursion_protect --;
2286 #malloc_police.c: list_is_quiet --;
2289 #malloc_police.c: return( ret );
2294 #malloc_police.c:/*********************************************************************
2296 #malloc_police.c: * Function : police_free
2298 #malloc_police.c: * Description : Frees the memory allocation and removes the address
2299 #malloc_police.c: * from the linked list. Anything left in this list
2300 #malloc_police.c: * is "leaked" memory.
2302 #malloc_police.c: * Parameters :
2303 #malloc_police.c: * 1 : Pointer to the memory to be freed.
2304 #malloc_police.c: * 2 : Filename where the free occured.
2305 #malloc_police.c: * 3 : Line# of where the free occured.
2307 #malloc_police.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
2309 #malloc_police.c: *********************************************************************/
2310 #malloc_police.c:void police_free( void *ptr, const char *filename, long lineno )
2312 #malloc_police.c: if ( 0 == recursion_protect )
2314 #malloc_police.c: struct derived_rec_malloc_police *rec;
2315 #malloc_police.c: struct gen_list_rec *fRec;
2316 #malloc_police.c: struct gen_list *l = get_police_list();
2318 #malloc_police.c: recursion_protect ++;
2319 #malloc_police.c: list_is_quiet ++;
2321 #malloc_police.c: rec = derived_rec_malloc_police_construct( ptr, "FREEING POLICE RECORD.", 23 );
2322 #malloc_police.c: fRec = gen_list_find( l, (struct gen_list_rec *)rec );
2323 #malloc_police.c: derived_rec_malloc_police_destruct( rec );
2325 #malloc_police.c: if ( NULL == fRec )
2327 #malloc_police.c: fprintf( stderr, "\nERROR: free failed to find corresponding strdup/malloc : %s @ %ld\n", filename, lineno );
2329 #malloc_police.c: else
2331 #malloc_police.c: derived_rec_malloc_police_destruct( (struct derived_rec_malloc_police *)gen_list_remove( l, fRec ) );
2334 #malloc_police.c: recursion_protect --;
2335 #malloc_police.c: list_is_quiet --;
2338 #malloc_police.c: free( ptr );
2343 #malloc_police.h:#ifndef MALLOC_POLICE_H_INCLUDED
2344 #malloc_police.h:#define MALLOC_POLICE_H_INCLUDED
2345 #malloc_police.h:#define MALLOC_POLICE_H_VERSION "$Id: malloc_police.h,v 1.1 2001/07/29 18:50:04 rodney.stromlund Exp $"
2346 #malloc_police.h:/*********************************************************************
2348 #malloc_police.h: * File : $Source: /cvsroot/ijbswa/current/rec_char.h,v $
2350 #malloc_police.h: * Purpose : This module uses the rec_malloc_police to build a
2351 #malloc_police.h: * list of allocated and freed memory. When the
2352 #malloc_police.h: * program exits, we will print a list of all memory
2353 #malloc_police.h: * that was allocated, but never freed. This could
2354 #malloc_police.h: * be most helpful to developers and debugers.
2356 #malloc_police.h: * Copyright : Written by and Copyright (C) 2001 the SourceForge
2357 #malloc_police.h: * IJBSWA team. http://ijbswa.sourceforge.net
2359 #malloc_police.h: * This program is free software; you can redistribute it
2360 #malloc_police.h: * and/or modify it under the terms of the GNU General
2361 #malloc_police.h: * Public License as published by the Free Software
2362 #malloc_police.h: * Foundation; either version 2 of the License, or (at
2363 #malloc_police.h: * your option) any later version.
2365 #malloc_police.h: * This program is distributed in the hope that it will
2366 #malloc_police.h: * be useful, but WITHOUT ANY WARRANTY; without even the
2367 #malloc_police.h: * implied warranty of MERCHANTABILITY or FITNESS FOR A
2368 #malloc_police.h: * PARTICULAR PURPOSE. See the GNU General Public
2369 #malloc_police.h: * License for more details.
2371 #malloc_police.h: * The GNU General Public License should be included with
2372 #malloc_police.h: * this file. If not, you can view it at
2373 #malloc_police.h: * http://www.gnu.org/copyleft/gpl.html
2374 #malloc_police.h: * or write to the Free Software Foundation, Inc., 59
2375 #malloc_police.h: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2377 #malloc_police.h: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
2378 #malloc_police.h: * and edit IJB, correctly.
2380 #malloc_police.h: * Revisions :
2381 #malloc_police.h: * $Log: malloc_police.h,v $
2383 #malloc_police.h: *********************************************************************/
2386 #malloc_police.h:#ifdef __cplusplus
2387 #malloc_police.h:extern "C" {
2388 #malloc_police.h:#endif
2391 #malloc_police.h:char *police_strdup( const char *s, const char *filename, long lineno );
2392 #malloc_police.h:void *police_malloc( size_t sz, const char *filename, long lineno );
2393 #malloc_police.h:void police_free( void *ptr, const char *filename, long lineno );
2395 #malloc_police.h:#define STRDUP(s) police_strdup( s, __FILE__, __LINE__ )
2396 #malloc_police.h:#define MALLOC(sz) police_malloc( sz, __FILE__, __LINE__ )
2397 #malloc_police.h:#define FREE(ptr) police_free( ptr, __FILE__, __LINE__ )
2400 #malloc_police.h:#ifdef __cplusplus
2401 #malloc_police.h:} /* extern "C" */
2402 #malloc_police.h:#endif
2404 #malloc_police.h:#endif /* ndef MALLOC_POLICE_H_INCLUDED */
2407 #malloc_police.h: Local Variables:
2408 #malloc_police.h: tab-width: 3
2409 #malloc_police.h: end:
2413 #rec_char.c:const char rec_char_rcs[] = "$Id: rec_char.c,v 1.1 2001/10/25 03:40:48 rodney.stromlund Exp $";
2414 #rec_char.c:/*********************************************************************
2416 #rec_char.c: * File : $Source: /cvsroot/ijbswa/current/gen_list.c,v $
2418 #rec_char.c: * Purpose : A "derived class" of gen_list_rec.
2420 #rec_char.c: * Copyright : Written by and Copyright (C) 2001 the SourceForge
2421 #rec_char.c: * IJBSWA team. http://ijbswa.sourceforge.net
2423 #rec_char.c: * This program is free software; you can redistribute it
2424 #rec_char.c: * and/or modify it under the terms of the GNU General
2425 #rec_char.c: * Public License as published by the Free Software
2426 #rec_char.c: * Foundation; either version 2 of the License, or (at
2427 #rec_char.c: * your option) any later version.
2429 #rec_char.c: * This program is distributed in the hope that it will
2430 #rec_char.c: * be useful, but WITHOUT ANY WARRANTY; without even the
2431 #rec_char.c: * implied warranty of MERCHANTABILITY or FITNESS FOR A
2432 #rec_char.c: * PARTICULAR PURPOSE. See the GNU General Public
2433 #rec_char.c: * License for more details.
2435 #rec_char.c: * The GNU General Public License should be included with
2436 #rec_char.c: * this file. If not, you can view it at
2437 #rec_char.c: * http://www.gnu.org/copyleft/gpl.html
2438 #rec_char.c: * or write to the Free Software Foundation, Inc., 59
2439 #rec_char.c: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2441 #rec_char.c: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
2442 #rec_char.c: * and edit IJB, correctly.
2444 #rec_char.c: * Revisions :
2445 #rec_char.c: * $Log: rec_char.c,v $
2447 #rec_char.c: *********************************************************************/
2450 #rec_char.c:#include <malloc.h>
2451 #rec_char.c:#include <stdio.h>
2452 #rec_char.c:#include <stdlib.h>
2453 #rec_char.c:#include <string.h>
2455 #rec_char.c:#include "gen_list.h"
2456 #rec_char.c:#include "rec_char.h"
2458 #rec_char.c:const char rec_char_h_rcs[] = REC_CHAR_H_VERSION;
2461 #rec_char.c:static const rec_method rec_char_vtable[] =
2463 #rec_char.c: (rec_method)derived_rec_char_copy_construct,
2464 #rec_char.c: (rec_method)derived_rec_char_destruct,
2465 #rec_char.c: (rec_method)derived_rec_char_stream,
2466 #rec_char.c: (rec_method)derived_rec_char_equal
2470 #rec_char.c:/*********************************************************************
2472 #rec_char.c: * Function : derived_rec_char_construct
2474 #rec_char.c: * Description : A simple derived record class that contains 1 string.
2476 #rec_char.c: * Parameters :
2477 #rec_char.c: * 1 : The record
2478 #rec_char.c: * 2 : The string to contain.
2480 #rec_char.c: * Returns : A pointer to the constructed record.
2482 #rec_char.c: *********************************************************************/
2483 #rec_char.c:struct derived_rec_char *derived_rec_char_construct( const char _contents )
2485 #rec_char.c: struct derived_rec_char *this_rec = (struct derived_rec_char *)gen_list_rec_construct(
2486 #rec_char.c: ISA_CHAR,
2487 #rec_char.c: sizeof( struct derived_rec_char ),
2488 #rec_char.c: rec_char_vtable
2491 #rec_char.c: this_rec->contents = _contents;
2493 #rec_char.c: LIST_SHOW( printf( "\
2494 #rec_char.c:\t\tchar construct new rec\t\t\t\t= %p
2495 #rec_char.c:\t\tchar construct new rec contents\t= %c\n\n", (const void *)this_rec, this_rec->contents ) );
2497 #rec_char.c: return( this_rec );
2502 #rec_char.c:/*********************************************************************
2504 #rec_char.c: * Function : derived_rec_char_copy_construct
2506 #rec_char.c: * Description : Copies one char record to another.
2508 #rec_char.c: * Parameters :
2509 #rec_char.c: * 1 : Existing record.
2510 #rec_char.c: * 2 : Copy record.
2512 #rec_char.c: * Returns : The newly constructed copy record.
2514 #rec_char.c: *********************************************************************/
2515 #rec_char.c:struct derived_rec_char *derived_rec_char_copy_construct( const struct derived_rec_char *this_rec )
2517 #rec_char.c: struct derived_rec_char *copy_rec = (struct derived_rec_char *)gen_list_rec_copy_construct( (struct gen_list_rec *)this_rec );
2518 #rec_char.c: copy_rec->contents = this_rec->contents;
2520 #rec_char.c: LIST_SHOW( printf( "\
2521 #rec_char.c:\t\tchar copy construct new gen rec\t\t\t\t= %p => %p
2522 #rec_char.c:\t\tchar copy construct new gen rec contents\t= %c\n\n", (const void *)this_rec, (const void *)copy_rec, copy_rec->contents ) );
2524 #rec_char.c: return( copy_rec );
2529 #rec_char.c:/*********************************************************************
2531 #rec_char.c: * Function : derived_rec_char_destruct
2533 #rec_char.c: * Description : Destruct the char record.
2535 #rec_char.c: * Parameters :
2536 #rec_char.c: * 1 : The record.
2538 #rec_char.c: * Returns : NULL
2540 #rec_char.c: *********************************************************************/
2541 #rec_char.c:struct derived_rec_char *derived_rec_char_destruct( struct derived_rec_char *this_rec )
2543 #rec_char.c: LIST_SHOW( printf( "\
2544 #rec_char.c:\t\tchar destruct this_rec\t\t\t\t= %p
2545 #rec_char.c:\t\tchar destruct this_rec->contents\t= %c\n\n", (const void *)this_rec, this_rec->contents ) );
2547 #rec_char.c: this_rec->contents = '!';
2548 #rec_char.c: return( (struct derived_rec_char *)gen_list_rec_destruct( (struct gen_list_rec *)this_rec ) );
2553 #rec_char.c:/*********************************************************************
2555 #rec_char.c: * Function : derived_rec_char_stream
2557 #rec_char.c: * Description : Displays all char attributes on the STDOUT stream.
2559 #rec_char.c: * Parameters :
2560 #rec_char.c: * 1 : The record.
2562 #rec_char.c: * Returns : The record.
2564 #rec_char.c: *********************************************************************/
2565 #rec_char.c:const struct derived_rec_char *derived_rec_char_stream( const struct derived_rec_char *this_rec )
2567 #rec_char.c: this_rec = (struct derived_rec_char *)gen_list_rec_stream(
2568 #rec_char.c: (struct gen_list_rec *)this_rec
2570 #rec_char.c: LIST_SHOW( printf( "\
2571 #rec_char.c:\t\tchar stream this_rec\t\t\t\t\t= %p
2572 #rec_char.c:\t\tchar stream this_rec->contents\t= %c\n\n", (const void *)this_rec, this_rec->contents ) );
2574 #rec_char.c: return( this_rec );
2579 #rec_char.c:/*********************************************************************
2581 #rec_char.c: * Function : derived_rec_char_equal
2583 #rec_char.c: * Description : Compares two char records to see if they are equal.
2585 #rec_char.c: * Parameters :
2586 #rec_char.c: * 1 : A record.
2587 #rec_char.c: * 2 : Another record.
2589 #rec_char.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
2591 #rec_char.c: *********************************************************************/
2592 #rec_char.c:int derived_rec_char_equal( const struct derived_rec_char *this_rec, const struct derived_rec_char *eq_rec )
2594 #rec_char.c: if ( ! gen_list_rec_equal( (const struct gen_list_rec *)this_rec, (struct gen_list_rec *)eq_rec ) )
2596 #rec_char.c: return( 0 );
2598 #rec_char.c: return( this_rec->contents == eq_rec->contents );
2603 #rec_char.h:#ifndef REC_CHAR_H_INCLUDED
2604 #rec_char.h:#define REC_CHAR_H_INCLUDED
2605 #rec_char.h:#define REC_CHAR_H_VERSION "$Id: rec_char.h,v 1.1 2001/07/29 18:50:04 rodney.stromlund Exp $"
2606 #rec_char.h:/*********************************************************************
2608 #rec_char.h: * File : $Source: /cvsroot/ijbswa/current/rec_char.h,v $
2610 #rec_char.h: * Purpose : A "derived class" of gen_list_rec.
2612 #rec_char.h: * Copyright : Written by and Copyright (C) 2001 the SourceForge
2613 #rec_char.h: * IJBSWA team. http://ijbswa.sourceforge.net
2615 #rec_char.h: * This program is free software; you can redistribute it
2616 #rec_char.h: * and/or modify it under the terms of the GNU General
2617 #rec_char.h: * Public License as published by the Free Software
2618 #rec_char.h: * Foundation; either version 2 of the License, or (at
2619 #rec_char.h: * your option) any later version.
2621 #rec_char.h: * This program is distributed in the hope that it will
2622 #rec_char.h: * be useful, but WITHOUT ANY WARRANTY; without even the
2623 #rec_char.h: * implied warranty of MERCHANTABILITY or FITNESS FOR A
2624 #rec_char.h: * PARTICULAR PURPOSE. See the GNU General Public
2625 #rec_char.h: * License for more details.
2627 #rec_char.h: * The GNU General Public License should be included with
2628 #rec_char.h: * this file. If not, you can view it at
2629 #rec_char.h: * http://www.gnu.org/copyleft/gpl.html
2630 #rec_char.h: * or write to the Free Software Foundation, Inc., 59
2631 #rec_char.h: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2633 #rec_char.h: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
2634 #rec_char.h: * and edit IJB, correctly.
2636 #rec_char.h: * Revisions :
2637 #rec_char.h: * $Log: rec_char.h,v $
2639 #rec_char.h: *********************************************************************/
2642 #rec_char.h:#ifdef __cplusplus
2643 #rec_char.h:extern "C" {
2647 #rec_char.h:struct derived_rec_char
2649 #rec_char.h: /* private: */
2650 #rec_char.h: struct gen_list_rec parent_rec;
2651 #rec_char.h: char contents;
2654 #rec_char.h:/* public: */
2655 #rec_char.h:extern struct derived_rec_char * derived_rec_char_construct( const char _contents );
2656 #rec_char.h:extern struct derived_rec_char * derived_rec_char_copy_construct( const struct derived_rec_char *this_rec );
2657 #rec_char.h:extern struct derived_rec_char * derived_rec_char_destruct( struct derived_rec_char *this_rec );
2658 #rec_char.h:extern const struct derived_rec_char *derived_rec_char_stream( const struct derived_rec_char *this_rec );
2659 #rec_char.h:extern int derived_rec_char_equal( const struct derived_rec_char *this_rec, const struct derived_rec_char *eq_rec );
2661 #rec_char.h:/* struct/class COMPLETE */
2664 #rec_char.h:#ifdef __cplusplus
2665 #rec_char.h:} /* extern "C" */
2668 #rec_char.h:#endif /* ndef REC_CHAR_H_INCLUDED */
2671 #rec_char.h: Local Variables:
2672 #rec_char.h: tab-width: 3
2677 #rec_charptr.c:const char rec_charptr_rcs[] = "$Id: rec_charptr.c,v 1.1 2001/10/25 03:40:48 rodney.stromlund Exp $";
2678 #rec_charptr.c:/*********************************************************************
2680 #rec_charptr.c: * File : $Source: /cvsroot/ijbswa/current/gen_list.c,v $
2682 #rec_charptr.c: * Purpose : A "derived class" of gen_list_rec.
2684 #rec_charptr.c: * Copyright : Written by and Copyright (C) 2001 the SourceForge
2685 #rec_charptr.c: * IJBSWA team. http://ijbswa.sourceforge.net
2687 #rec_charptr.c: * This program is free software; you can redistribute it
2688 #rec_charptr.c: * and/or modify it under the terms of the GNU General
2689 #rec_charptr.c: * Public License as published by the Free Software
2690 #rec_charptr.c: * Foundation; either version 2 of the License, or (at
2691 #rec_charptr.c: * your option) any later version.
2693 #rec_charptr.c: * This program is distributed in the hope that it will
2694 #rec_charptr.c: * be useful, but WITHOUT ANY WARRANTY; without even the
2695 #rec_charptr.c: * implied warranty of MERCHANTABILITY or FITNESS FOR A
2696 #rec_charptr.c: * PARTICULAR PURPOSE. See the GNU General Public
2697 #rec_charptr.c: * License for more details.
2699 #rec_charptr.c: * The GNU General Public License should be included with
2700 #rec_charptr.c: * this file. If not, you can view it at
2701 #rec_charptr.c: * http://www.gnu.org/copyleft/gpl.html
2702 #rec_charptr.c: * or write to the Free Software Foundation, Inc., 59
2703 #rec_charptr.c: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2705 #rec_charptr.c: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
2706 #rec_charptr.c: * and edit IJB, correctly.
2708 #rec_charptr.c: * Revisions :
2709 #rec_charptr.c: * $Log: rec_charptr.c,v $
2711 #rec_charptr.c: *********************************************************************/
2714 #rec_charptr.c:#include <malloc.h>
2715 #rec_charptr.c:#include <stdio.h>
2716 #rec_charptr.c:#include <stdlib.h>
2717 #rec_charptr.c:#include <string.h>
2719 #rec_charptr.c:#include "gen_list.h"
2720 #rec_charptr.c:#include "rec_charptr.h"
2721 #rec_charptr.c:#include "malloc_police.h"
2723 #rec_charptr.c:const char rec_charptr_h_rcs[] = REC_CHARPTR_H_VERSION;
2726 #rec_charptr.c:static const rec_method rec_charptr_vtable[] =
2728 #rec_charptr.c: (rec_method)derived_rec_charptr_copy_construct,
2729 #rec_charptr.c: (rec_method)derived_rec_charptr_destruct,
2730 #rec_charptr.c: (rec_method)derived_rec_charptr_stream,
2731 #rec_charptr.c: (rec_method)derived_rec_charptr_equal
2735 #rec_charptr.c:/*********************************************************************
2737 #rec_charptr.c: * Function : derived_rec_charptr_construct
2739 #rec_charptr.c: * Description : A simple derived record class that contains 1 string.
2741 #rec_charptr.c: * Parameters :
2742 #rec_charptr.c: * 1 : The record
2743 #rec_charptr.c: * 2 : The string to contain.
2745 #rec_charptr.c: * Returns : A pointer to the constructed record.
2747 #rec_charptr.c: *********************************************************************/
2748 #rec_charptr.c:struct derived_rec_charptr *derived_rec_charptr_construct( const char *_contents )
2750 #rec_charptr.c: struct derived_rec_charptr *this_rec = (struct derived_rec_charptr *)gen_list_rec_construct(
2751 #rec_charptr.c: ISA_CHARPTR,
2752 #rec_charptr.c: sizeof( struct derived_rec_charptr ),
2753 #rec_charptr.c: rec_charptr_vtable
2756 #rec_charptr.c: this_rec->contents = STRDUP( _contents );
2758 #rec_charptr.c: LIST_SHOW( printf( "\
2759 #rec_charptr.c:\t\tcharptr construct new rec\t\t\t\t= %p
2760 #rec_charptr.c:\t\tcharptr construct new rec contents\t= %s\n\n", (const void *)this_rec, this_rec->contents ) );
2762 #rec_charptr.c: return( this_rec );
2767 #rec_charptr.c:/*********************************************************************
2769 #rec_charptr.c: * Function : derived_rec_charptr_copy_construct
2771 #rec_charptr.c: * Description : Copies one charptr record to another.
2773 #rec_charptr.c: * Parameters :
2774 #rec_charptr.c: * 1 : Existing record.
2775 #rec_charptr.c: * 2 : Copy record.
2777 #rec_charptr.c: * Returns : The newly constructed copy record.
2779 #rec_charptr.c: *********************************************************************/
2780 #rec_charptr.c:struct derived_rec_charptr *derived_rec_charptr_copy_construct( const struct derived_rec_charptr *this_rec )
2782 #rec_charptr.c: int len;
2783 #rec_charptr.c: char *new_contents;
2785 #rec_charptr.c: struct derived_rec_charptr *copy_rec = (struct derived_rec_charptr *)gen_list_rec_copy_construct( (struct gen_list_rec *)this_rec );
2787 #rec_charptr.c: len = strlen( this_rec->contents );
2788 #rec_charptr.c: len += sizeof( "COPY " );
2790 #rec_charptr.c: copy_rec->contents = (char *)MALLOC( len );
2791 #rec_charptr.c: strcpy( copy_rec->contents, "COPY " );
2792 #rec_charptr.c: strcat( copy_rec->contents, this_rec->contents );
2794 #rec_charptr.c: LIST_SHOW( printf( "\
2795 #rec_charptr.c:\t\tcharptr copy construct new gen rec\t\t\t\t= %p => %p
2796 #rec_charptr.c:\t\tcharptr copy construct new gen rec contents\t= %s\n\n", (const void *)this_rec, (const void *)copy_rec, copy_rec->contents ) );
2799 #rec_charptr.c: return( copy_rec );
2804 #rec_charptr.c:/*********************************************************************
2806 #rec_charptr.c: * Function : derived_rec_charptr_destruct
2808 #rec_charptr.c: * Description : Destruct the charptr record.
2810 #rec_charptr.c: * Parameters :
2811 #rec_charptr.c: * 1 : The record.
2813 #rec_charptr.c: * Returns : NULL
2815 #rec_charptr.c: *********************************************************************/
2816 #rec_charptr.c:struct derived_rec_charptr *derived_rec_charptr_destruct( struct derived_rec_charptr *this_rec )
2818 #rec_charptr.c: LIST_SHOW( printf( "\
2819 #rec_charptr.c:\t\tcharptr destruct this_rec\t\t\t\t= %p
2820 #rec_charptr.c:\t\tcharptr destruct this_rec->contents\t= %s\n\n", (const void *)this_rec, (const void *)this_rec->contents ) );
2822 #rec_charptr.c: memset( this_rec->contents, '!', strlen( this_rec->contents ) );
2823 #rec_charptr.c: FREE( this_rec->contents );
2824 #rec_charptr.c: return( (struct derived_rec_charptr *)gen_list_rec_destruct( (struct gen_list_rec *)this_rec ) );
2829 #rec_charptr.c:/*********************************************************************
2831 #rec_charptr.c: * Function : derived_rec_charptr_stream
2833 #rec_charptr.c: * Description : Displays all charptr attributes on the STDOUT stream.
2835 #rec_charptr.c: * Parameters :
2836 #rec_charptr.c: * 1 : The record.
2838 #rec_charptr.c: * Returns : The record.
2840 #rec_charptr.c: *********************************************************************/
2841 #rec_charptr.c:const struct derived_rec_charptr *derived_rec_charptr_stream( const struct derived_rec_charptr *this_rec )
2843 #rec_charptr.c: this_rec = (struct derived_rec_charptr *)gen_list_rec_stream(
2844 #rec_charptr.c: (struct gen_list_rec *)this_rec
2846 #rec_charptr.c: LIST_SHOW( printf( "\
2847 #rec_charptr.c:\t\tcharptr stream this_rec\t\t\t\t\t= %p
2848 #rec_charptr.c:\t\tcharptr stream this_rec->contents\t= %s\n\n", (const void *)this_rec, this_rec->contents ) );
2850 #rec_charptr.c: return( this_rec );
2855 #rec_charptr.c:/*********************************************************************
2857 #rec_charptr.c: * Function : derived_rec_charptr_equal
2859 #rec_charptr.c: * Description : Compares two charptr records to see if they are equal.
2861 #rec_charptr.c: * Parameters :
2862 #rec_charptr.c: * 1 : A record.
2863 #rec_charptr.c: * 2 : Another record.
2865 #rec_charptr.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
2867 #rec_charptr.c: *********************************************************************/
2868 #rec_charptr.c:int derived_rec_charptr_equal( const struct derived_rec_charptr *this_rec, const struct derived_rec_charptr *eq_rec )
2870 #rec_charptr.c: if ( ! gen_list_rec_equal( (const struct gen_list_rec *)this_rec, (struct gen_list_rec *)eq_rec ) )
2872 #rec_charptr.c: return( 0 );
2874 #rec_charptr.c: return( 0 == strcmp( this_rec->contents, eq_rec->contents ) );
2879 #rec_charptr.h:#ifndef REC_CHARPTR_H_INCLUDED
2880 #rec_charptr.h:#define REC_CHARPTR_H_INCLUDED
2881 #rec_charptr.h:#define REC_CHARPTR_H_VERSION "$Id: rec_charptr.h,v 1.1 2001/07/29 18:50:04 rodney.stromlund Exp $"
2882 #rec_charptr.h:/*********************************************************************
2884 #rec_charptr.h: * File : $Source: /cvsroot/ijbswa/current/rec_char.h,v $
2886 #rec_charptr.h: * Purpose : A "derived class" of gen_list_rec.
2888 #rec_charptr.h: * Copyright : Written by and Copyright (C) 2001 the SourceForge
2889 #rec_charptr.h: * IJBSWA team. http://ijbswa.sourceforge.net
2891 #rec_charptr.h: * This program is free software; you can redistribute it
2892 #rec_charptr.h: * and/or modify it under the terms of the GNU General
2893 #rec_charptr.h: * Public License as published by the Free Software
2894 #rec_charptr.h: * Foundation; either version 2 of the License, or (at
2895 #rec_charptr.h: * your option) any later version.
2897 #rec_charptr.h: * This program is distributed in the hope that it will
2898 #rec_charptr.h: * be useful, but WITHOUT ANY WARRANTY; without even the
2899 #rec_charptr.h: * implied warranty of MERCHANTABILITY or FITNESS FOR A
2900 #rec_charptr.h: * PARTICULAR PURPOSE. See the GNU General Public
2901 #rec_charptr.h: * License for more details.
2903 #rec_charptr.h: * The GNU General Public License should be included with
2904 #rec_charptr.h: * this file. If not, you can view it at
2905 #rec_charptr.h: * http://www.gnu.org/copyleft/gpl.html
2906 #rec_charptr.h: * or write to the Free Software Foundation, Inc., 59
2907 #rec_charptr.h: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2909 #rec_charptr.h: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
2910 #rec_charptr.h: * and edit IJB, correctly.
2912 #rec_charptr.h: * Revisions :
2913 #rec_charptr.h: * $Log: rec_charptr.h,v $
2915 #rec_charptr.h: *********************************************************************/
2918 #rec_charptr.h:#ifdef __cplusplus
2919 #rec_charptr.h:extern "C" {
2920 #rec_charptr.h:#endif
2923 #rec_charptr.h:struct derived_rec_charptr
2925 #rec_charptr.h: /* private: */
2926 #rec_charptr.h: struct gen_list_rec parent_rec;
2927 #rec_charptr.h: char *contents;
2930 #rec_charptr.h:/* public: */
2931 #rec_charptr.h:extern struct derived_rec_charptr * derived_rec_charptr_construct( const char *_contents );
2932 #rec_charptr.h:extern struct derived_rec_charptr * derived_rec_charptr_copy_construct( const struct derived_rec_charptr *this_rec );
2933 #rec_charptr.h:extern struct derived_rec_charptr * derived_rec_charptr_destruct( struct derived_rec_charptr *this_rec );
2934 #rec_charptr.h:extern const struct derived_rec_charptr *derived_rec_charptr_stream( const struct derived_rec_charptr *this_rec );
2935 #rec_charptr.h:extern int derived_rec_charptr_equal( const struct derived_rec_charptr *this_rec, const struct derived_rec_charptr *eq_rec );
2937 #rec_charptr.h:/* struct/class COMPLETE */
2940 #rec_charptr.h:#ifdef __cplusplus
2941 #rec_charptr.h:} /* extern "C" */
2942 #rec_charptr.h:#endif
2944 #rec_charptr.h:#endif /* ndef REC_CHARPTR_H_INCLUDED */
2947 #rec_charptr.h: Local Variables:
2948 #rec_charptr.h: tab-width: 3
2949 #rec_charptr.h: end:
2953 #rec_double.c:const char rec_double_rcs[] = "$Id: rec_double.c,v 1.1 2001/10/25 03:40:48 rodney.stromlund Exp $";
2954 #rec_double.c:/*********************************************************************
2956 #rec_double.c: * File : $Source: /cvsroot/ijbswa/current/gen_list.c,v $
2958 #rec_double.c: * Purpose : A "derived class" of gen_list_rec.
2960 #rec_double.c: * Copyright : Written by and Copyright (C) 2001 the SourceForge
2961 #rec_double.c: * IJBSWA team. http://ijbswa.sourceforge.net
2963 #rec_double.c: * This program is free software; you can redistribute it
2964 #rec_double.c: * and/or modify it under the terms of the GNU General
2965 #rec_double.c: * Public License as published by the Free Software
2966 #rec_double.c: * Foundation; either version 2 of the License, or (at
2967 #rec_double.c: * your option) any later version.
2969 #rec_double.c: * This program is distributed in the hope that it will
2970 #rec_double.c: * be useful, but WITHOUT ANY WARRANTY; without even the
2971 #rec_double.c: * implied warranty of MERCHANTABILITY or FITNESS FOR A
2972 #rec_double.c: * PARTICULAR PURPOSE. See the GNU General Public
2973 #rec_double.c: * License for more details.
2975 #rec_double.c: * The GNU General Public License should be included with
2976 #rec_double.c: * this file. If not, you can view it at
2977 #rec_double.c: * http://www.gnu.org/copyleft/gpl.html
2978 #rec_double.c: * or write to the Free Software Foundation, Inc., 59
2979 #rec_double.c: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2981 #rec_double.c: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
2982 #rec_double.c: * and edit IJB, correctly.
2984 #rec_double.c: * Revisions :
2985 #rec_double.c: * $Log: rec_double.c,v $
2987 #rec_double.c: *********************************************************************/
2990 #rec_double.c:#include <malloc.h>
2991 #rec_double.c:#include <stdio.h>
2992 #rec_double.c:#include <stdlib.h>
2993 #rec_double.c:#include <string.h>
2995 #rec_double.c:#include "gen_list.h"
2996 #rec_double.c:#include "rec_double.h"
2998 #rec_double.c:const char rec_double_h_rcs[] = REC_DOUBLE_H_VERSION;
3001 #rec_double.c:static const rec_method rec_double_vtable[] =
3003 #rec_double.c: (rec_method)derived_rec_double_copy_construct,
3004 #rec_double.c: (rec_method)derived_rec_double_destruct,
3005 #rec_double.c: (rec_method)derived_rec_double_stream,
3006 #rec_double.c: (rec_method)derived_rec_double_equal
3010 #rec_double.c:/*********************************************************************
3012 #rec_double.c: * Function : derived_rec_double_construct
3014 #rec_double.c: * Description : A simple derived record class that contains 1 string.
3016 #rec_double.c: * Parameters :
3017 #rec_double.c: * 1 : The record
3018 #rec_double.c: * 2 : The string to contain.
3020 #rec_double.c: * Returns : A pointer to the constructed record.
3022 #rec_double.c: *********************************************************************/
3023 #rec_double.c:struct derived_rec_double *derived_rec_double_construct( const double _contents )
3025 #rec_double.c: struct derived_rec_double *this_rec = (struct derived_rec_double *)gen_list_rec_construct(
3026 #rec_double.c: ISA_DOUBLE,
3027 #rec_double.c: sizeof( struct derived_rec_double ),
3028 #rec_double.c: rec_double_vtable
3031 #rec_double.c: this_rec->contents = _contents;
3033 #rec_double.c: LIST_SHOW( printf( "\
3034 #rec_double.c:\t\tdouble construct new rec\t\t\t\t= %p
3035 #rec_double.c:\t\tdouble construct new rec contents\t= %8.2lf\n\n", (const void *)this_rec, this_rec->contents ) );
3037 #rec_double.c: return( this_rec );
3042 #rec_double.c:/*********************************************************************
3044 #rec_double.c: * Function : derived_rec_double_copy_construct
3046 #rec_double.c: * Description : Copies one double record to another.
3048 #rec_double.c: * Parameters :
3049 #rec_double.c: * 1 : Existing record.
3050 #rec_double.c: * 2 : Copy record.
3052 #rec_double.c: * Returns : The newly constructed copy record.
3054 #rec_double.c: *********************************************************************/
3055 #rec_double.c:struct derived_rec_double *derived_rec_double_copy_construct( const struct derived_rec_double *this_rec )
3057 #rec_double.c: struct derived_rec_double *copy_rec = (struct derived_rec_double *)gen_list_rec_copy_construct( (struct gen_list_rec *)this_rec );
3058 #rec_double.c: copy_rec->contents = - this_rec->contents;
3060 #rec_double.c: LIST_SHOW( printf( "\
3061 #rec_double.c:\t\tdouble copy construct new gen rec\t\t\t\t= %p => %p
3062 #rec_double.c:\t\tdouble copy construct new gen rec contents\t= %8.2lf\n\n", (const void *)this_rec, (const void *)copy_rec, copy_rec->contents ) );
3064 #rec_double.c: return( copy_rec );
3069 #rec_double.c:/*********************************************************************
3071 #rec_double.c: * Function : derived_rec_double_destruct
3073 #rec_double.c: * Description : Destruct the double record.
3075 #rec_double.c: * Parameters :
3076 #rec_double.c: * 1 : The record.
3078 #rec_double.c: * Returns : NULL
3080 #rec_double.c: *********************************************************************/
3081 #rec_double.c:struct derived_rec_double *derived_rec_double_destruct( struct derived_rec_double *this_rec )
3083 #rec_double.c: LIST_SHOW( printf( "\
3084 #rec_double.c:\t\tdouble destruct this_rec\t\t\t\t= %p
3085 #rec_double.c:\t\tdouble destruct this_rec->contents\t= %8.2lf\n\n", (const void *)this_rec, this_rec->contents ) );
3087 #rec_double.c: this_rec->contents = -1.1111;
3088 #rec_double.c: return( (struct derived_rec_double *)gen_list_rec_destruct( (struct gen_list_rec *)this_rec ) );
3093 #rec_double.c:/*********************************************************************
3095 #rec_double.c: * Function : derived_rec_double_stream
3097 #rec_double.c: * Description : Displays all double attributes on the STDOUT stream.
3099 #rec_double.c: * Parameters :
3100 #rec_double.c: * 1 : The record.
3102 #rec_double.c: * Returns : The record.
3104 #rec_double.c: *********************************************************************/
3105 #rec_double.c:const struct derived_rec_double *derived_rec_double_stream( const struct derived_rec_double *this_rec )
3107 #rec_double.c: this_rec = (struct derived_rec_double *)gen_list_rec_stream(
3108 #rec_double.c: (struct gen_list_rec *)this_rec
3110 #rec_double.c: LIST_SHOW( printf( "\
3111 #rec_double.c:\t\tdouble stream this_rec\t\t\t\t= %p
3112 #rec_double.c:\t\tdouble stream this_rec->contents\t= %8.2lf\n\n", (const void *)this_rec, this_rec->contents ) );
3114 #rec_double.c: return( this_rec );
3119 #rec_double.c:/*********************************************************************
3121 #rec_double.c: * Function : derived_rec_double_equal
3123 #rec_double.c: * Description : Compares two double records to see if they are equal.
3125 #rec_double.c: * Parameters :
3126 #rec_double.c: * 1 : A record.
3127 #rec_double.c: * 2 : Another record.
3129 #rec_double.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
3131 #rec_double.c: *********************************************************************/
3132 #rec_double.c:int derived_rec_double_equal( const struct derived_rec_double *this_rec, const struct derived_rec_double *eq_rec )
3134 #rec_double.c: if ( ! gen_list_rec_equal( (const struct gen_list_rec *)this_rec, (struct gen_list_rec *)eq_rec ) )
3136 #rec_double.c: return( 0 );
3138 #rec_double.c: return( this_rec->contents == eq_rec->contents );
3143 #rec_double.h:#ifndef REC_DOUBLE_H_INCLUDED
3144 #rec_double.h:#define REC_DOUBLE_H_INCLUDED
3145 #rec_double.h:#define REC_DOUBLE_H_VERSION "$Id: rec_double.h,v 1.1 2001/07/29 18:50:04 rodney.stromlund Exp $"
3146 #rec_double.h:/*********************************************************************
3148 #rec_double.h: * File : $Source: /cvsroot/ijbswa/current/rec_double.h,v $
3150 #rec_double.h: * Purpose : gen_A "derived class" of gen_list_rec.
3152 #rec_double.h: * Copyright : Written by and Copyright (C) 2001 the SourceForge
3153 #rec_double.h: * IJBSWA team. http://ijbswa.sourceforge.net
3155 #rec_double.h: * This program is free software; you can redistribute it
3156 #rec_double.h: * and/or modify it under the terms of the GNU General
3157 #rec_double.h: * Public License as published by the Free Software
3158 #rec_double.h: * Foundation; either version 2 of the License, or (at
3159 #rec_double.h: * your option) any later version.
3161 #rec_double.h: * This program is distributed in the hope that it will
3162 #rec_double.h: * be useful, but WITHOUT ANY WARRANTY; without even the
3163 #rec_double.h: * implied warranty of MERCHANTABILITY or FITNESS FOR A
3164 #rec_double.h: * PARTICULAR PURPOSE. See the GNU General Public
3165 #rec_double.h: * License for more details.
3167 #rec_double.h: * The GNU General Public License should be included with
3168 #rec_double.h: * this file. If not, you can view it at
3169 #rec_double.h: * http://www.gnu.org/copyleft/gpl.html
3170 #rec_double.h: * or write to the Free Software Foundation, Inc., 59
3171 #rec_double.h: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3173 #rec_double.h: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
3174 #rec_double.h: * and edit IJB, correctly.
3176 #rec_double.h: * Revisions :
3177 #rec_double.h: * $Log: rec_double.h,v $
3179 #rec_double.h: *********************************************************************/
3182 #rec_double.h:#ifdef __cplusplus
3183 #rec_double.h:extern "C" {
3184 #rec_double.h:#endif
3187 #rec_double.h:struct derived_rec_double
3189 #rec_double.h: /* private: */
3190 #rec_double.h: struct gen_list_rec parent_rec;
3191 #rec_double.h: double contents;
3194 #rec_double.h:/* public: */
3195 #rec_double.h:extern struct derived_rec_double * derived_rec_double_construct( const double _contents );
3196 #rec_double.h:extern struct derived_rec_double * derived_rec_double_copy_construct( const struct derived_rec_double *this_rec );
3197 #rec_double.h:extern struct derived_rec_double * derived_rec_double_destruct( struct derived_rec_double *this_rec );
3198 #rec_double.h:extern const struct derived_rec_double *derived_rec_double_stream( const struct derived_rec_double *this_rec );
3199 #rec_double.h:extern int derived_rec_double_equal( const struct derived_rec_double *this_rec, const struct derived_rec_double *eq_rec );
3201 #rec_double.h:/* struct/class COMPLETE */
3204 #rec_double.h:#ifdef __cplusplus
3205 #rec_double.h:} /* extern "C" */
3206 #rec_double.h:#endif
3208 #rec_double.h:#endif /* ndef REC_DOUBLE_H_INCLUDED */
3211 #rec_double.h: Local Variables:
3212 #rec_double.h: tab-width: 3
3217 #rec_long.c:const char rec_long_rcs[] = "$Id: rec_long.c,v 1.1 2001/10/25 03:40:48 rodney.stromlund Exp $";
3218 #rec_long.c:/*********************************************************************
3220 #rec_long.c: * File : $Source: /cvsroot/ijbswa/current/gen_list.c,v $
3222 #rec_long.c: * Purpose : A "derived class" of gen_list_rec.
3224 #rec_long.c: * Copyright : Written by and Copyright (C) 2001 the SourceForge
3225 #rec_long.c: * IJBSWA team. http://ijbswa.sourceforge.net
3227 #rec_long.c: * This program is free software; you can redistribute it
3228 #rec_long.c: * and/or modify it under the terms of the GNU General
3229 #rec_long.c: * Public License as published by the Free Software
3230 #rec_long.c: * Foundation; either version 2 of the License, or (at
3231 #rec_long.c: * your option) any later version.
3233 #rec_long.c: * This program is distributed in the hope that it will
3234 #rec_long.c: * be useful, but WITHOUT ANY WARRANTY; without even the
3235 #rec_long.c: * implied warranty of MERCHANTABILITY or FITNESS FOR A
3236 #rec_long.c: * PARTICULAR PURPOSE. See the GNU General Public
3237 #rec_long.c: * License for more details.
3239 #rec_long.c: * The GNU General Public License should be included with
3240 #rec_long.c: * this file. If not, you can view it at
3241 #rec_long.c: * http://www.gnu.org/copyleft/gpl.html
3242 #rec_long.c: * or write to the Free Software Foundation, Inc., 59
3243 #rec_long.c: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3245 #rec_long.c: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
3246 #rec_long.c: * and edit IJB, correctly.
3248 #rec_long.c: * Revisions :
3249 #rec_long.c: * $Log: rec_long.c,v $
3251 #rec_long.c: *********************************************************************/
3254 #rec_long.c:#include <malloc.h>
3255 #rec_long.c:#include <stdio.h>
3256 #rec_long.c:#include <stdlib.h>
3257 #rec_long.c:#include <string.h>
3259 #rec_long.c:#include "gen_list.h"
3260 #rec_long.c:#include "rec_long.h"
3262 #rec_long.c:const char rec_long_h_rcs[] = REC_LONG_H_VERSION;
3265 #rec_long.c:static const rec_method rec_long_vtable[] =
3267 #rec_long.c: (rec_method)derived_rec_long_copy_construct,
3268 #rec_long.c: (rec_method)derived_rec_long_destruct,
3269 #rec_long.c: (rec_method)derived_rec_long_stream,
3270 #rec_long.c: (rec_method)derived_rec_long_equal
3274 #rec_long.c:/*********************************************************************
3276 #rec_long.c: * Function : derived_rec_long_construct
3278 #rec_long.c: * Description : A simple derived record class that contains 1 string.
3280 #rec_long.c: * Parameters :
3281 #rec_long.c: * 1 : The record
3282 #rec_long.c: * 2 : The string to contain.
3284 #rec_long.c: * Returns : A pointer to the constructed record.
3286 #rec_long.c: *********************************************************************/
3287 #rec_long.c:struct derived_rec_long *derived_rec_long_construct( const long _contents )
3289 #rec_long.c: struct derived_rec_long *this_rec = (struct derived_rec_long *)gen_list_rec_construct(
3290 #rec_long.c: ISA_LONG,
3291 #rec_long.c: sizeof( struct derived_rec_long ),
3292 #rec_long.c: rec_long_vtable
3295 #rec_long.c: this_rec->contents = _contents;
3297 #rec_long.c: LIST_SHOW( printf( "\
3298 #rec_long.c:\t\tlong construct new rec\t\t\t\t= %p
3299 #rec_long.c:\t\tlong construct new rec contents\t= %d\n\n", (const void *)this_rec, this_rec->contents ) );
3301 #rec_long.c: return( this_rec );
3306 #rec_long.c:/*********************************************************************
3308 #rec_long.c: * Function : derived_rec_long_copy_construct
3310 #rec_long.c: * Description : Copies one long record to another.
3312 #rec_long.c: * Parameters :
3313 #rec_long.c: * 1 : Existing record.
3314 #rec_long.c: * 2 : Copy record.
3316 #rec_long.c: * Returns : The newly constructed copy record.
3318 #rec_long.c: *********************************************************************/
3319 #rec_long.c:struct derived_rec_long *derived_rec_long_copy_construct( const struct derived_rec_long *this_rec )
3321 #rec_long.c: struct derived_rec_long *copy_rec = (struct derived_rec_long *)gen_list_rec_copy_construct( (struct gen_list_rec *)this_rec );
3322 #rec_long.c: copy_rec->contents = - this_rec->contents;
3324 #rec_long.c: LIST_SHOW( printf( "\
3325 #rec_long.c:\t\tlong copy construct new gen rec\t\t\t\t= %p => %p
3326 #rec_long.c:\t\tlong copy construct new gen rec contents\t= %d\n\n", (const void *)this_rec, (const void *)copy_rec, copy_rec->contents ) );
3328 #rec_long.c: return( copy_rec );
3333 #rec_long.c:/*********************************************************************
3335 #rec_long.c: * Function : derived_rec_long_destruct
3337 #rec_long.c: * Description : Destruct the long record.
3339 #rec_long.c: * Parameters :
3340 #rec_long.c: * 1 : The record.
3342 #rec_long.c: * Returns : NULL
3344 #rec_long.c: *********************************************************************/
3345 #rec_long.c:struct derived_rec_long *derived_rec_long_destruct( struct derived_rec_long *this_rec )
3347 #rec_long.c: LIST_SHOW( printf( "\
3348 #rec_long.c:\t\tlong destruct this_rec\t\t\t\t= %p
3349 #rec_long.c:\t\tlong destruct this_rec->contents\t= %d\n\n", (const void *)this_rec, this_rec->contents ) );
3351 #rec_long.c: this_rec->contents = -1;
3352 #rec_long.c: return( (struct derived_rec_long *)gen_list_rec_destruct( (struct gen_list_rec *)this_rec ) );
3357 #rec_long.c:/*********************************************************************
3359 #rec_long.c: * Function : derived_rec_long_stream
3361 #rec_long.c: * Description : Displays all long attributes on the STDOUT stream.
3363 #rec_long.c: * Parameters :
3364 #rec_long.c: * 1 : The record.
3366 #rec_long.c: * Returns : The record.
3368 #rec_long.c: *********************************************************************/
3369 #rec_long.c:const struct derived_rec_long *derived_rec_long_stream( const struct derived_rec_long *this_rec )
3371 #rec_long.c: this_rec = (struct derived_rec_long *)gen_list_rec_stream(
3372 #rec_long.c: (struct gen_list_rec *)this_rec
3374 #rec_long.c: LIST_SHOW( printf( "\
3375 #rec_long.c:\t\tlong stream this_rec\t\t\t\t\t= %p
3376 #rec_long.c:\t\tlong stream this_rec->contents\t= %d\n\n", (const void *)this_rec, this_rec->contents ) );
3378 #rec_long.c: return( this_rec );
3383 #rec_long.c:/*********************************************************************
3385 #rec_long.c: * Function : derived_rec_long_equal
3387 #rec_long.c: * Description : Compares two long records to see if they are equal.
3389 #rec_long.c: * Parameters :
3390 #rec_long.c: * 1 : A record.
3391 #rec_long.c: * 2 : Another record.
3393 #rec_long.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
3395 #rec_long.c: *********************************************************************/
3396 #rec_long.c:int derived_rec_long_equal( const struct derived_rec_long *this_rec, const struct derived_rec_long *eq_rec )
3398 #rec_long.c: if ( ! gen_list_rec_equal( (const struct gen_list_rec *)this_rec, (struct gen_list_rec *)eq_rec ) )
3400 #rec_long.c: return( 0 );
3402 #rec_long.c: return( this_rec->contents == eq_rec->contents );
3407 #rec_long.h:#ifndef REC_LONG_H_INCLUDED
3408 #rec_long.h:#define REC_LONG_H_INCLUDED
3409 #rec_long.h:#define REC_LONG_H_VERSION "$Id: rec_long.h,v 1.1 2001/07/29 18:50:04 rodney.stromlund Exp $"
3410 #rec_long.h:/*********************************************************************
3412 #rec_long.h: * File : $Source: /cvsroot/ijbswa/current/rec_long.h,v $
3414 #rec_long.h: * Purpose : A "derived class" of gen_list_rec.
3416 #rec_long.h: * Copyright : Written by and Copyright (C) 2001 the SourceForge
3417 #rec_long.h: * IJBSWA team. http://ijbswa.sourceforge.net
3419 #rec_long.h: * This program is free software; you can redistribute it
3420 #rec_long.h: * and/or modify it under the terms of the GNU General
3421 #rec_long.h: * Public License as published by the Free Software
3422 #rec_long.h: * Foundation; either version 2 of the License, or (at
3423 #rec_long.h: * your option) any later version.
3425 #rec_long.h: * This program is distributed in the hope that it will
3426 #rec_long.h: * be useful, but WITHOUT ANY WARRANTY; without even the
3427 #rec_long.h: * implied warranty of MERCHANTABILITY or FITNESS FOR A
3428 #rec_long.h: * PARTICULAR PURPOSE. See the GNU General Public
3429 #rec_long.h: * License for more details.
3431 #rec_long.h: * The GNU General Public License should be included with
3432 #rec_long.h: * this file. If not, you can view it at
3433 #rec_long.h: * http://www.gnu.org/copyleft/gpl.html
3434 #rec_long.h: * or write to the Free Software Foundation, Inc., 59
3435 #rec_long.h: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3437 #rec_long.h: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
3438 #rec_long.h: * and edit IJB, correctly.
3440 #rec_long.h: * Revisions :
3441 #rec_long.h: * $Log: rec_long.h,v $
3443 #rec_long.h: *********************************************************************/
3446 #rec_long.h:#ifdef __cplusplus
3447 #rec_long.h:extern "C" {
3451 #rec_long.h:struct derived_rec_long
3453 #rec_long.h: /* private: */
3454 #rec_long.h: struct gen_list_rec parent_rec;
3455 #rec_long.h: long contents;
3458 #rec_long.h:/* public: */
3459 #rec_long.h:extern struct derived_rec_long * derived_rec_long_construct( const long _contents );
3460 #rec_long.h:extern struct derived_rec_long * derived_rec_long_copy_construct( const struct derived_rec_long *this_rec );
3461 #rec_long.h:extern struct derived_rec_long * derived_rec_long_destruct( struct derived_rec_long *this_rec );
3462 #rec_long.h:extern const struct derived_rec_long *derived_rec_long_stream( const struct derived_rec_long *this_rec );
3463 #rec_long.h:extern int derived_rec_long_equal( const struct derived_rec_long *this_rec, const struct derived_rec_long *eq_rec );
3465 #rec_long.h:/* struct/class COMPLETE */
3468 #rec_long.h:#ifdef __cplusplus
3469 #rec_long.h:} /* extern "C" */
3472 #rec_long.h:#endif /* ndef REC_LONG_H_INCLUDED */
3475 #rec_long.h: Local Variables:
3476 #rec_long.h: tab-width: 3
3481 #rec_malloc_police.c:const char rec_malloc_police_rcs[] = "$Id: rec_malloc_police.c,v 1.1 2001/10/25 03:40:48 rodney.stromlund Exp $";
3482 #rec_malloc_police.c:/*********************************************************************
3483 #rec_malloc_police.c: *
3484 #rec_malloc_police.c: * File : $Source: /cvsroot/ijbswa/current/gen_list.c,v $
3485 #rec_malloc_police.c: *
3486 #rec_malloc_police.c: * Purpose : A "derived class" of gen_list_rec.
3487 #rec_malloc_police.c: * This class helps to build a list of allocated and
3488 #rec_malloc_police.c: * freed memory. When the program exits, we will print
3489 #rec_malloc_police.c: * a list of all memory that was allocated, but never
3490 #rec_malloc_police.c: * freed. This could be most helpful to developers
3491 #rec_malloc_police.c: * and debugers.
3492 #rec_malloc_police.c: *
3493 #rec_malloc_police.c: * Copyright : Written by and Copyright (C) 2001 the SourceForge
3494 #rec_malloc_police.c: * IJBSWA team. http://ijbswa.sourceforge.net
3495 #rec_malloc_police.c: *
3496 #rec_malloc_police.c: * This program is free software; you can redistribute it
3497 #rec_malloc_police.c: * and/or modify it under the terms of the GNU General
3498 #rec_malloc_police.c: * Public License as published by the Free Software
3499 #rec_malloc_police.c: * Foundation; either version 2 of the License, or (at
3500 #rec_malloc_police.c: * your option) any later version.
3501 #rec_malloc_police.c: *
3502 #rec_malloc_police.c: * This program is distributed in the hope that it will
3503 #rec_malloc_police.c: * be useful, but WITHOUT ANY WARRANTY; without even the
3504 #rec_malloc_police.c: * implied warranty of MERCHANTABILITY or FITNESS FOR A
3505 #rec_malloc_police.c: * PARTICULAR PURPOSE. See the GNU General Public
3506 #rec_malloc_police.c: * License for more details.
3507 #rec_malloc_police.c: *
3508 #rec_malloc_police.c: * The GNU General Public License should be included with
3509 #rec_malloc_police.c: * this file. If not, you can view it at
3510 #rec_malloc_police.c: * http://www.gnu.org/copyleft/gpl.html
3511 #rec_malloc_police.c: * or write to the Free Software Foundation, Inc., 59
3512 #rec_malloc_police.c: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3513 #rec_malloc_police.c: *
3514 #rec_malloc_police.c: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
3515 #rec_malloc_police.c: * and edit IJB, correctly.
3516 #rec_malloc_police.c: *
3517 #rec_malloc_police.c: * Revisions :
3518 #rec_malloc_police.c: * $Log: rec_malloc_police.c,v $
3519 #rec_malloc_police.c: *
3520 #rec_malloc_police.c: *********************************************************************/
3521 #rec_malloc_police.c:
\f
3522 #rec_malloc_police.c:
3523 #rec_malloc_police.c:#include <stdio.h>
3524 #rec_malloc_police.c:
3525 #rec_malloc_police.c:#include "gen_list.h"
3526 #rec_malloc_police.c:#include "malloc_police.h"
3527 #rec_malloc_police.c:#include "rec_malloc_police.h"
3528 #rec_malloc_police.c:
3529 #rec_malloc_police.c:const char rec_malloc_police_h_rcs[] = REC_MALLOC_POLICE_H_VERSION;
3530 #rec_malloc_police.c:
3531 #rec_malloc_police.c:
3532 #rec_malloc_police.c:static const rec_method rec_malloc_police_vtable[] =
3533 #rec_malloc_police.c:{
3534 #rec_malloc_police.c: (rec_method)derived_rec_malloc_police_copy_construct,
3535 #rec_malloc_police.c: (rec_method)derived_rec_malloc_police_destruct,
3536 #rec_malloc_police.c: (rec_method)derived_rec_malloc_police_stream,
3537 #rec_malloc_police.c: (rec_method)derived_rec_malloc_police_equal
3538 #rec_malloc_police.c:};
3539 #rec_malloc_police.c:
3540 #rec_malloc_police.c:
3541 #rec_malloc_police.c:/*********************************************************************
3542 #rec_malloc_police.c: *
3543 #rec_malloc_police.c: * Function : derived_rec_malloc_police_construct
3544 #rec_malloc_police.c: *
3545 #rec_malloc_police.c: * Description : A simple derived record class that contains 1 string.
3546 #rec_malloc_police.c: *
3547 #rec_malloc_police.c: * Parameters :
3548 #rec_malloc_police.c: * 1 : The record
3549 #rec_malloc_police.c: * 2 : The string to contain.
3550 #rec_malloc_police.c: *
3551 #rec_malloc_police.c: * Returns : A pointer to the constructed record.
3552 #rec_malloc_police.c: *
3553 #rec_malloc_police.c: *********************************************************************/
3554 #rec_malloc_police.c:struct derived_rec_malloc_police *derived_rec_malloc_police_construct( void *_alloced_addr, char *_source_where, size_t _sz )
3555 #rec_malloc_police.c:{
3556 #rec_malloc_police.c: struct derived_rec_malloc_police *this_rec;
3557 #rec_malloc_police.c: list_is_quiet ++;
3558 #rec_malloc_police.c:
3559 #rec_malloc_police.c: this_rec = (struct derived_rec_malloc_police *)gen_list_rec_construct(
3560 #rec_malloc_police.c: ISA_MALLOC_POLICE,
3561 #rec_malloc_police.c: sizeof( struct derived_rec_malloc_police ),
3562 #rec_malloc_police.c: rec_malloc_police_vtable
3563 #rec_malloc_police.c: );
3564 #rec_malloc_police.c:
3565 #rec_malloc_police.c: this_rec->alloced_addr = _alloced_addr;
3566 #rec_malloc_police.c: this_rec->source_where = STRDUP( _source_where );
3567 #rec_malloc_police.c: this_rec->sz = _sz;
3568 #rec_malloc_police.c:
3569 #rec_malloc_police.c:/* LIST_SHOW( printf( "\ */
3570 #rec_malloc_police.c:/* \t\tmalloc_police construct new rec\t\t\t\t\t= %p */
3571 #rec_malloc_police.c:/* \t\tmalloc_police construct new rec alloced_addr = %p */
3572 #rec_malloc_police.c:/* \t\tmalloc_police construct new rec source_where = %s */
3573 #rec_malloc_police.c:/* \t\tmalloc_police construct new rec sz\t\t\t\t\t= %ld\n\n", */
3574 #rec_malloc_police.c:/* (const void *)this_rec, */
3575 #rec_malloc_police.c:/* this_rec->alloced_addr, */
3576 #rec_malloc_police.c:/* this_rec->source_where, */
3577 #rec_malloc_police.c:/* this_rec->sz */
3578 #rec_malloc_police.c:/* ) ); */
3579 #rec_malloc_police.c:
3580 #rec_malloc_police.c: list_is_quiet --;
3581 #rec_malloc_police.c:
3582 #rec_malloc_police.c: return( this_rec );
3583 #rec_malloc_police.c:
3584 #rec_malloc_police.c:}
3585 #rec_malloc_police.c:
3586 #rec_malloc_police.c:
3587 #rec_malloc_police.c:/*********************************************************************
3588 #rec_malloc_police.c: *
3589 #rec_malloc_police.c: * Function : derived_rec_malloc_police_copy_construct
3590 #rec_malloc_police.c: *
3591 #rec_malloc_police.c: * Description : Copies one malloc_police record to another.
3592 #rec_malloc_police.c: *
3593 #rec_malloc_police.c: * Parameters :
3594 #rec_malloc_police.c: * 1 : Existing record.
3595 #rec_malloc_police.c: * 2 : Copy record.
3596 #rec_malloc_police.c: *
3597 #rec_malloc_police.c: * Returns : The newly constructed copy record.
3598 #rec_malloc_police.c: *
3599 #rec_malloc_police.c: *********************************************************************/
3600 #rec_malloc_police.c:struct derived_rec_malloc_police *derived_rec_malloc_police_copy_construct( const struct derived_rec_malloc_police *this_rec )
3601 #rec_malloc_police.c:{
3602 #rec_malloc_police.c: int len;
3603 #rec_malloc_police.c: char *new_contents;
3604 #rec_malloc_police.c: struct derived_rec_malloc_police *copy_rec;
3605 #rec_malloc_police.c:
3606 #rec_malloc_police.c: list_is_quiet ++;
3607 #rec_malloc_police.c:
3608 #rec_malloc_police.c: copy_rec = (struct derived_rec_malloc_police *)gen_list_rec_copy_construct( (struct gen_list_rec *)this_rec );
3609 #rec_malloc_police.c:
3610 #rec_malloc_police.c: copy_rec->alloced_addr = this_rec->alloced_addr;
3611 #rec_malloc_police.c: copy_rec->source_where = STRDUP( this_rec->source_where );
3612 #rec_malloc_police.c: copy_rec->sz = this_rec->sz;
3613 #rec_malloc_police.c:
3614 #rec_malloc_police.c:/* LIST_SHOW( printf( "\ */
3615 #rec_malloc_police.c:/* \t\tmalloc_police copy construct new gen rec = %p => %p */
3616 #rec_malloc_police.c:/* \t\tmalloc_police copy construct new gen rec alloced_addr = %p */
3617 #rec_malloc_police.c:/* \t\tmalloc_police copy construct new gen rec source_where = %s */
3618 #rec_malloc_police.c:/* \t\tmalloc_police copy construct new gen rec sz\t\t\t\t\t= %ld\n\n", */
3619 #rec_malloc_police.c:/* (const void *)this_rec, (const void *)copy_rec, */
3620 #rec_malloc_police.c:/* copy_rec->alloced_addr, */
3621 #rec_malloc_police.c:/* copy_rec->source_where, */
3622 #rec_malloc_police.c:/* copy_rec->sz */
3623 #rec_malloc_police.c:/* ) ); */
3624 #rec_malloc_police.c:
3625 #rec_malloc_police.c: list_is_quiet --;
3626 #rec_malloc_police.c:
3627 #rec_malloc_police.c: return( copy_rec );
3628 #rec_malloc_police.c:
3629 #rec_malloc_police.c:}
3630 #rec_malloc_police.c:
3631 #rec_malloc_police.c:
3632 #rec_malloc_police.c:/*********************************************************************
3633 #rec_malloc_police.c: *
3634 #rec_malloc_police.c: * Function : derived_rec_malloc_police_destruct
3635 #rec_malloc_police.c: *
3636 #rec_malloc_police.c: * Description : Destruct the malloc_police record.
3637 #rec_malloc_police.c: *
3638 #rec_malloc_police.c: * Parameters :
3639 #rec_malloc_police.c: * 1 : The record.
3640 #rec_malloc_police.c: *
3641 #rec_malloc_police.c: * Returns : NULL
3642 #rec_malloc_police.c: *
3643 #rec_malloc_police.c: *********************************************************************/
3644 #rec_malloc_police.c:struct derived_rec_malloc_police *derived_rec_malloc_police_destruct( struct derived_rec_malloc_police *this_rec )
3645 #rec_malloc_police.c:{
3646 #rec_malloc_police.c: struct derived_rec_malloc_police *d;
3647 #rec_malloc_police.c: list_is_quiet ++;
3648 #rec_malloc_police.c:
3649 #rec_malloc_police.c:/* LIST_SHOW( printf( "\ */
3650 #rec_malloc_police.c:/* \t\tmalloc_police destruct this_rec\t\t\t\t\t\t= %p */
3651 #rec_malloc_police.c:/* \t\tmalloc_police destruct this_rec->alloced_addr\t= %p */
3652 #rec_malloc_police.c:/* \t\tmalloc_police destruct this_rec->source_where\t= %s, */
3653 #rec_malloc_police.c:/* \t\tmalloc_police destruct this_rec->sz\t\t\t\t\t= %ld\n\n", */
3654 #rec_malloc_police.c:/* (const void *)this_rec, */
3655 #rec_malloc_police.c:/* this_rec->alloced_addr, */
3656 #rec_malloc_police.c:/* this_rec->source_where, */
3657 #rec_malloc_police.c:/* this_rec->sz */
3658 #rec_malloc_police.c:/* ) ); */
3659 #rec_malloc_police.c:
3660 #rec_malloc_police.c: memset( this_rec->source_where, '!', strlen( this_rec->source_where ) );
3661 #rec_malloc_police.c: FREE( this_rec->source_where );
3662 #rec_malloc_police.c:
3663 #rec_malloc_police.c: d = (struct derived_rec_malloc_police *)gen_list_rec_destruct( (struct gen_list_rec *)this_rec );
3664 #rec_malloc_police.c: list_is_quiet --;
3665 #rec_malloc_police.c:
3666 #rec_malloc_police.c: return( d );
3667 #rec_malloc_police.c:
3668 #rec_malloc_police.c:}
3669 #rec_malloc_police.c:
3670 #rec_malloc_police.c:
3671 #rec_malloc_police.c:/*********************************************************************
3672 #rec_malloc_police.c: *
3673 #rec_malloc_police.c: * Function : derived_rec_malloc_police_stream
3674 #rec_malloc_police.c: *
3675 #rec_malloc_police.c: * Description : Displays all malloc_police attributes on the STDOUT stream.
3676 #rec_malloc_police.c: *
3677 #rec_malloc_police.c: * Parameters :
3678 #rec_malloc_police.c: * 1 : The record.
3679 #rec_malloc_police.c: *
3680 #rec_malloc_police.c: * Returns : The record.
3681 #rec_malloc_police.c: *
3682 #rec_malloc_police.c: *********************************************************************/
3683 #rec_malloc_police.c:const struct derived_rec_malloc_police *derived_rec_malloc_police_stream( const struct derived_rec_malloc_police *this_rec )
3684 #rec_malloc_police.c:{
3685 #rec_malloc_police.c: list_is_quiet ++;
3686 #rec_malloc_police.c:
3687 #rec_malloc_police.c: this_rec = (struct derived_rec_malloc_police *)gen_list_rec_stream(
3688 #rec_malloc_police.c: (struct gen_list_rec *)this_rec
3689 #rec_malloc_police.c: );
3690 #rec_malloc_police.c: LIST_SHOW( printf( "\
3691 #rec_malloc_police.c:\t\tmalloc_police stream this_rec\t\t\t\t\t= %p
3692 #rec_malloc_police.c:\t\tmalloc_police stream this_rec->alloced_addr\t= %p
3693 #rec_malloc_police.c:\t\tmalloc_police stream this_rec->source_where\t= %s
3694 #rec_malloc_police.c:\t\tmalloc_police stream this_rec->sz\t\t\t\t= %ld\n\n",
3695 #rec_malloc_police.c: (const void *)this_rec,
3696 #rec_malloc_police.c: this_rec->alloced_addr,
3697 #rec_malloc_police.c: this_rec->source_where,
3698 #rec_malloc_police.c: this_rec->sz
3699 #rec_malloc_police.c: ) );
3700 #rec_malloc_police.c:
3701 #rec_malloc_police.c: list_is_quiet --;
3702 #rec_malloc_police.c: return( this_rec );
3703 #rec_malloc_police.c:
3704 #rec_malloc_police.c:}
3705 #rec_malloc_police.c:
3706 #rec_malloc_police.c:
3707 #rec_malloc_police.c:/*********************************************************************
3708 #rec_malloc_police.c: *
3709 #rec_malloc_police.c: * Function : derived_rec_malloc_police_equal
3710 #rec_malloc_police.c: *
3711 #rec_malloc_police.c: * Description : Compares two malloc_police records to see if they are equal.
3712 #rec_malloc_police.c: *
3713 #rec_malloc_police.c: * Parameters :
3714 #rec_malloc_police.c: * 1 : A record.
3715 #rec_malloc_police.c: * 2 : Another record.
3716 #rec_malloc_police.c: *
3717 #rec_malloc_police.c: * Returns : 0 => NOT EQUAL, anything else is EQUAL.
3718 #rec_malloc_police.c: *
3719 #rec_malloc_police.c: *********************************************************************/
3720 #rec_malloc_police.c:int derived_rec_malloc_police_equal( const struct derived_rec_malloc_police *this_rec, const struct derived_rec_malloc_police *eq_rec )
3721 #rec_malloc_police.c:{
3722 #rec_malloc_police.c: list_is_quiet ++;
3723 #rec_malloc_police.c:
3724 #rec_malloc_police.c: if ( ! gen_list_rec_equal( (const struct gen_list_rec *)this_rec, (struct gen_list_rec *)eq_rec ) )
3725 #rec_malloc_police.c: {
3726 #rec_malloc_police.c: return( 0 );
3727 #rec_malloc_police.c: }
3728 #rec_malloc_police.c:
3729 #rec_malloc_police.c: list_is_quiet --;
3730 #rec_malloc_police.c: return( this_rec->alloced_addr == eq_rec->alloced_addr );
3731 #rec_malloc_police.c:
3732 #rec_malloc_police.c:}
3735 #rec_malloc_police.h:#ifndef REC_MALLOC_POLICE_H_INCLUDED
3736 #rec_malloc_police.h:#define REC_MALLOC_POLICE_H_INCLUDED
3737 #rec_malloc_police.h:#define REC_MALLOC_POLICE_H_VERSION "$Id: rec_malloc_police.h,v 1.1 2001/07/29 18:50:04 rodney.stromlund Exp $"
3738 #rec_malloc_police.h:/*********************************************************************
3739 #rec_malloc_police.h: *
3740 #rec_malloc_police.h: * File : $Source: /cvsroot/ijbswa/current/rec_char.h,v $
3741 #rec_malloc_police.h: *
3742 #rec_malloc_police.h: * Purpose : A "derived class" of gen_list_rec.
3743 #rec_malloc_police.h: * This class helps to build a list of allocated and
3744 #rec_malloc_police.h: * freed memory. When the program exits, we will print
3745 #rec_malloc_police.h: * a list of all memory that was allocated, but never
3746 #rec_malloc_police.h: * freed. This could be most helpful to developers
3747 #rec_malloc_police.h: * and debugers.
3748 #rec_malloc_police.h: *
3749 #rec_malloc_police.h: * Copyright : Written by and Copyright (C) 2001 the SourceForge
3750 #rec_malloc_police.h: * IJBSWA team. http://ijbswa.sourceforge.net
3751 #rec_malloc_police.h: *
3752 #rec_malloc_police.h: * This program is free software; you can redistribute it
3753 #rec_malloc_police.h: * and/or modify it under the terms of the GNU General
3754 #rec_malloc_police.h: * Public License as published by the Free Software
3755 #rec_malloc_police.h: * Foundation; either version 2 of the License, or (at
3756 #rec_malloc_police.h: * your option) any later version.
3757 #rec_malloc_police.h: *
3758 #rec_malloc_police.h: * This program is distributed in the hope that it will
3759 #rec_malloc_police.h: * be useful, but WITHOUT ANY WARRANTY; without even the
3760 #rec_malloc_police.h: * implied warranty of MERCHANTABILITY or FITNESS FOR A
3761 #rec_malloc_police.h: * PARTICULAR PURPOSE. See the GNU General Public
3762 #rec_malloc_police.h: * License for more details.
3763 #rec_malloc_police.h: *
3764 #rec_malloc_police.h: * The GNU General Public License should be included with
3765 #rec_malloc_police.h: * this file. If not, you can view it at
3766 #rec_malloc_police.h: * http://www.gnu.org/copyleft/gpl.html
3767 #rec_malloc_police.h: * or write to the Free Software Foundation, Inc., 59
3768 #rec_malloc_police.h: * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3769 #rec_malloc_police.h: *
3770 #rec_malloc_police.h: * VI users : Please "set tabstop=3 shiftwidth=3" to view this file,
3771 #rec_malloc_police.h: * and edit IJB, correctly.
3772 #rec_malloc_police.h: *
3773 #rec_malloc_police.h: * Revisions :
3774 #rec_malloc_police.h: * $Log: rec_malloc_police.h,v $
3775 #rec_malloc_police.h: *
3776 #rec_malloc_police.h: *********************************************************************/
3777 #rec_malloc_police.h:
\f
3778 #rec_malloc_police.h:
3779 #rec_malloc_police.h:#ifdef __cplusplus
3780 #rec_malloc_police.h:extern "C" {
3781 #rec_malloc_police.h:#endif
3782 #rec_malloc_police.h:
3783 #rec_malloc_police.h:
3784 #rec_malloc_police.h:struct derived_rec_malloc_police
3785 #rec_malloc_police.h:{
3786 #rec_malloc_police.h: /* private: */
3787 #rec_malloc_police.h: struct gen_list_rec parent_rec;
3788 #rec_malloc_police.h: void *alloced_addr;
3789 #rec_malloc_police.h: char *source_where;
3790 #rec_malloc_police.h: size_t sz;
3791 #rec_malloc_police.h:};
3792 #rec_malloc_police.h:
3793 #rec_malloc_police.h:/* public: */
3794 #rec_malloc_police.h:extern struct derived_rec_malloc_police * derived_rec_malloc_police_construct( void *_alloced_addr, char *_source_where, size_t _sz );
3795 #rec_malloc_police.h:extern struct derived_rec_malloc_police * derived_rec_malloc_police_copy_construct( const struct derived_rec_malloc_police *this_rec );
3796 #rec_malloc_police.h:extern struct derived_rec_malloc_police * derived_rec_malloc_police_destruct( struct derived_rec_malloc_police *this_rec );
3797 #rec_malloc_police.h:extern const struct derived_rec_malloc_police *derived_rec_malloc_police_stream( const struct derived_rec_malloc_police *this_rec );
3798 #rec_malloc_police.h:extern int derived_rec_malloc_police_equal( const struct derived_rec_malloc_police *this_rec, const struct derived_rec_malloc_police *eq_rec );
3799 #rec_malloc_police.h:
3800 #rec_malloc_police.h:/* struct/class COMPLETE */
3801 #rec_malloc_police.h:
3802 #rec_malloc_police.h:
3803 #rec_malloc_police.h:#ifdef __cplusplus
3804 #rec_malloc_police.h:} /* extern "C" */
3805 #rec_malloc_police.h:#endif
3806 #rec_malloc_police.h:
3807 #rec_malloc_police.h:
3808 #rec_malloc_police.h:#endif /* ndef REC_MALLOC_POLICE_H_INCLUDED */
3809 #rec_malloc_police.h:
3810 #rec_malloc_police.h:/*
3811 #rec_malloc_police.h: Local Variables:
3812 #rec_malloc_police.h: tab-width: 3
3813 #rec_malloc_police.h: end:
3814 #rec_malloc_police.h:*/
3817 ###########################################################################
3818 ## Description: makeInsertableFile
3819 ## Use this function to make a file suitable for insertion into this
3820 ## script. This file (x), will contain all of the files listed.
3826 ## Return status: (0) - Everything is Okay, anything else is an error
3827 ###########################################################################
3829 function makeInsertableFile {
3833 for i in ${fileList}; do
3834 sed -e "s/^/#${i}:/" ${i} >> x