Index: trunk/src/netlist2.c =================================================================== --- trunk/src/netlist2.c (revision 23147) +++ trunk/src/netlist2.c (revision 23148) @@ -47,6 +47,29 @@ free(term); } +pcb_net_term_t *pcb_net_term_get(pcb_net_t *net, const char *refdes, const char *term, pcb_bool alloc) +{ + pcb_net_term_t *t; + + /* for allocation this is slow, O(N^2) algorithm, but other than a few + biggish networks like GND, there won't be too many connections anyway) */ + for(t = pcb_termlist_first(&net->conns); t != NULL; ) { + if ((strcmp(t->refdes, refdes) == 0) && (strcmp(t->term, term) == 0)) + return t; + } + + if (alloc) { + t = calloc(sizeof(pcb_net_term_t), 1); + t->type = PCB_OBJ_NET_TERM; + t->refdes = pcb_strdup(refdes); + t->term = pcb_strdup(term); + pcb_termlist_append(&net->conns, t); + return t; + } + + return NULL; +} + pcb_bool pcb_net_name_valid(const char *netname) { for(;*netname != '\0'; netname++) { Index: trunk/src/netlist2.h =================================================================== --- trunk/src/netlist2.h (revision 23147) +++ trunk/src/netlist2.h (revision 23148) @@ -75,6 +75,10 @@ /* Remove a net from a netlist by namel returns 0 on removal, -1 on error */ int pcb_net_del(pcb_netlist_t *nl, const char *netname); +/* Look up (or allocate) a terminal within a net. Returns NULL on error */ +pcb_net_term_t *pcb_net_term_get(pcb_net_t *net, const char *refdes, const char *term, pcb_bool alloc); + + pcb_bool pcb_net_name_valid(const char *netname); Index: trunk/src/obj_common.h =================================================================== --- trunk/src/obj_common.h (revision 23147) +++ trunk/src/obj_common.h (revision 23148) @@ -51,8 +51,9 @@ /* more abstract objects */ PCB_OBJ_NET = 0x0001000, - PCB_OBJ_LAYER = 0x0002000, - PCB_OBJ_LAYERGRP = 0x0004000 + PCB_OBJ_NET_TERM = 0x0002000, + PCB_OBJ_LAYER = 0x0004000, + PCB_OBJ_LAYERGRP = 0x0008000 } pcb_objtype_t; /* Virtual objects for configuring searches; can be used as a bitfield with the above */