gnetlist
|
00001 /* gEDA - GPL Electronic Design Automation 00002 * gnetlist - gEDA Netlist 00003 * Copyright (C) 1998-2010 Ales Hvezda 00004 * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details) 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #include <config.h> 00022 00023 #include <stdio.h> 00024 #include <ctype.h> 00025 #ifdef HAVE_STDLIB_H 00026 #include <stdlib.h> 00027 #endif 00028 #ifdef HAVE_ASSERT_H 00029 #include <assert.h> 00030 #endif 00031 #ifdef HAVE_STRING_H 00032 #include <string.h> 00033 #endif 00034 00035 #include <libgeda/libgeda.h> 00036 00037 #include "../include/globals.h" 00038 #include "../include/prototype.h" 00039 00040 #ifdef HAVE_LIBDMALLOC 00041 #include <dmalloc.h> 00042 #endif 00043 00044 /* hack rename this to be s_return_tail */ 00045 /* update object_tail or any list of that matter */ 00046 CPINLIST *s_cpinlist_return_tail(CPINLIST * head) 00047 { 00048 CPINLIST *pl_current = NULL; 00049 CPINLIST *ret_struct = NULL; 00050 00051 pl_current = head; 00052 while (pl_current != NULL) { /* goto end of list */ 00053 ret_struct = pl_current; 00054 pl_current = pl_current->next; 00055 } 00056 00057 return (ret_struct); 00058 } 00059 00060 /* hack rename this to be s_return_head */ 00061 /* update object_tail or any list of that matter */ 00062 CPINLIST *s_cpinlist_return_head(CPINLIST * tail) 00063 { 00064 CPINLIST *pl_current = NULL; 00065 CPINLIST *ret_struct = NULL; 00066 00067 pl_current = tail; 00068 while (pl_current != NULL) { /* goto end of list */ 00069 ret_struct = pl_current; 00070 pl_current = pl_current->prev; 00071 } 00072 00073 return (ret_struct); 00074 } 00075 00076 00077 /* returns new node */ 00078 CPINLIST *s_cpinlist_add(CPINLIST * ptr) 00079 { 00080 CPINLIST *new_node; 00081 00082 new_node = (CPINLIST *) g_malloc(sizeof(CPINLIST)); 00083 00084 /* setup node information */ 00085 new_node->plid = 0; 00086 new_node->type = PIN_TYPE_NET; 00087 new_node->pin_number = NULL; 00088 new_node->pin_label = NULL; 00089 new_node->net_name = NULL; 00090 new_node->nets = NULL; 00091 00092 /* Setup link list stuff */ 00093 new_node->next = NULL; 00094 00095 if (ptr == NULL) { 00096 new_node->prev = NULL; /* setup previous link */ 00097 return (new_node); 00098 } else { 00099 new_node->prev = ptr; /* setup previous link */ 00100 ptr->next = new_node; 00101 return (ptr->next); 00102 } 00103 } 00104 00105 void s_cpinlist_print(CPINLIST * ptr) 00106 { 00107 CPINLIST *pl_current = NULL; 00108 00109 pl_current = ptr; 00110 00111 if (pl_current == NULL) { 00112 return; 00113 } 00114 00115 while (pl_current != NULL) { 00116 00117 if (pl_current->plid != -1) { 00118 if (pl_current->pin_number) { 00119 printf(" pin %s", pl_current->pin_number); 00120 } else { 00121 printf(" pin ?"); 00122 } 00123 00124 if (pl_current->pin_label) { 00125 printf(" (%s)", pl_current->pin_label); 00126 } else { 00127 printf(" ()"); 00128 } 00129 00130 if (pl_current->net_name) { 00131 printf(" %s", pl_current->net_name); 00132 } else { 00133 printf(" Null net name"); 00134 } 00135 00136 00137 printf("\n"); 00138 00139 00140 if (pl_current->nets) { 00141 s_net_print(pl_current->nets); 00142 } 00143 } 00144 00145 pl_current = pl_current->next; 00146 } 00147 } 00148 00149 CPINLIST *s_cpinlist_search_pin(CPINLIST * ptr, char *pin_number) 00150 { 00151 CPINLIST *pl_current = NULL; 00152 00153 pl_current = ptr; 00154 00155 if (pl_current == NULL) { 00156 return (NULL); 00157 } 00158 00159 while (pl_current != NULL) { 00160 00161 if (pl_current->plid != -1 && (pl_current->pin_number != NULL)) { 00162 00163 if (strcmp(pl_current->pin_number, pin_number) == 0) { 00164 00165 #if DEBUG 00166 printf("equal: %s %s\n", 00167 pl_current->pin_number, pin_number); 00168 #endif 00169 00170 return (pl_current); 00171 } 00172 } 00173 00174 pl_current = pl_current->next; 00175 } 00176 00177 return (NULL); 00178 }