00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 00037 /* ======================================================================= 00038 * ======================================================================= 00039 * 00040 * Module: annotations.c 00041 * $Revision: 1.2 $ 00042 * $Date: 02/11/07 23:41:19-00:00 $ 00043 * $Author: fchow@keyresearch.com $ 00044 * $Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/SCCS/s.annotations.cxx $ 00045 * 00046 * Description: 00047 * ============ 00048 * 00049 * Module to create and access annotations that can be attached to 00050 * any arbitrary data structure. 00051 * 00052 * See annotations.h for description. 00053 * 00054 * ======================================================================= 00055 * ======================================================================= 00056 */ 00057 00058 #include "defs.h" 00059 #include "errors.h" 00060 #include "mempool.h" 00061 #include "cgir.h" 00062 #include "annotations.h" 00063 00064 00065 extern ANNOTATION * 00066 ANNOT_Add ( 00067 ANNOTATION *annot_list, 00068 ANNOTATION_KIND kind, 00069 void *information, 00070 MEM_POOL *pool) 00071 { 00072 ANNOTATION *new_a = TYPE_MEM_POOL_ALLOC (ANNOTATION, pool); 00073 ANNOTATION *list, *next; 00074 00075 ANNOT_next(new_a) = NULL; 00076 ANNOT_info(new_a) = information; 00077 ANNOT_kind(new_a) = kind; 00078 00079 /* The new annotation is added at the end of the annotations list. 00080 * This maintains the order in which annotations are added. Some 00081 * clients care about this. 00082 */ 00083 for (list = annot_list; list != NULL; list = next) { 00084 next = ANNOT_next(list); 00085 if (next == NULL) { 00086 ANNOT_next(list) = new_a; 00087 break; 00088 } 00089 } 00090 if (annot_list == NULL) annot_list = new_a; 00091 return annot_list; 00092 00093 } 00094 00095 extern ANNOTATION * 00096 ANNOT_Unlink ( 00097 ANNOTATION *annot_list, 00098 ANNOTATION *this1) 00099 { 00100 ANNOTATION *list, *next; 00101 00102 if ( annot_list == this1 ) { 00103 return ANNOT_next(annot_list); 00104 } 00105 00106 for (list = annot_list; list != NULL; list = next) { 00107 next = ANNOT_next(list); 00108 if ( next == this1 ) { 00109 ANNOT_next(list) = ANNOT_next(next); 00110 break; 00111 } 00112 } 00113 00114 return annot_list; 00115 } 00116 00117 extern ANNOTATION * 00118 ANNOT_Get (ANNOTATION *list, ANNOTATION_KIND kind) 00119 { 00120 ANNOTATION_KIND cur_kind; 00121 00122 while (list != NULL) { 00123 cur_kind = ANNOT_kind(list); 00124 if (cur_kind == kind) { 00125 break; 00126 } 00127 list = ANNOT_next(list); 00128 } 00129 return list; 00130 } 00131
1.5.6