1 /* -*- tab-width: 4 -*-
2  *
3  * Electric(tm) VLSI Design System
4  *
5  * File: global.h
6  * Definitions of interest to all modules
7  * Written by: Steven M. Rubin, Static Free Software
8  *
9  * Copyright (c) 2000 Static Free Software.
10  *
11  * Electric(tm) is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * Electric(tm) is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with Electric(tm); see the file COPYING.  If not, write to
23  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
24  * Boston, Mass 02111-1307, USA.
25  *
26  * Static Free Software
27  * 4119 Alpine Road
28  * Portola Valley, California 94028
29  * info@staticfreesoft.com
30  */
31 
32 #ifndef GLOBAL_H
33 #define GLOBAL_H
34 
35 /* #define DEBUGMEMORY 1 */					/* uncomment to debug memory */
36 /* #define DEBUGPARALLELISM 1 */			/* uncomment to multithreaded code */
37 
38 #include "config.h"
39 
40 /* system includes */
41 #include <stdio.h>
42 #include <ctype.h>
43 #include <time.h>
44 #ifdef TM_IN_SYS_TIME
45 #  include <sys/time.h>
46 #endif
47 #if STDC_HEADERS
48 #  include <stdlib.h>
49 #  include <string.h>
50 #  include <stdarg.h>
51 #  define var_start(x, y) va_start(x, y)
52 #else
53 #  ifndef HAVE_STRCHR
54 #    define estrchr index
55 #  endif
56 #  include <varargs.h>
57 #  define var_start(x, y) va_start(x)
58 #endif
59 #ifdef HAVE_STRINGS_H
60 #  include <strings.h>
61 #endif
62 #ifdef HAVE_STDINT_H
63 #  include <stdint.h>
64 #else
65 #  ifdef HAVE_INTTYPES_H
66 #    include <inttypes.h>
67 #  endif
68 #  ifdef HAVE_DB_H
69 #    include <db.h>
70 #  endif
71 #  if defined(__alpha) && defined(__DECC)
72 #    define   int64_t          long		/* tru64 needs "long" instead of "int" */
73 #    define u_int64_t unsigned long		/* tru64 needs "long" instead of "int" */
74 #  endif
75 #endif
76 
77 #ifdef USEQT
78 #  include <qglobal.h>
79 #endif
80 
81 #ifdef INTERNATIONAL
82 #  ifdef ONUNIX
83 #    include <libintl.h>
84 #    ifdef HAVE_LOCALE_H
85 #      include <locale.h>
86 #    endif
87 #  endif
88 #  ifdef WIN32
89 #    include "../gettext/libgnuintl.h"
90 #  endif
91 #  ifdef MACOS
92 #    include "libgnuintl.h"
93 #  endif
94 #  define  _(string)        gettext(string)
95 #  define TRANSLATE(string) gettext(string)
96 #else
97 #  ifdef _UNICODE
98 #    define  _(string)      (L ## string)	/* translate now */
99 #  else
100 #    define  _(string)      string			/* translate now */
101 #  endif
102 #  define TRANSLATE(string) (string)
103 #endif
104 #ifdef _UNICODE
105 #  define N_(string) (L ## string)			/* will be translated later */
106 #  define M_(string) (L ## string)			/* not used enough to be translated */
107 #  define x_(string) (L ## string)			/* never translate */
108 #  define string1byte(string) estring1byte(string)
109 #  define string2byte(string) estring2byte(string)
110 #else
111 #  define N_(string)  string				/* will be translated later */
112 #  define M_(string)  string				/* not used enough to be translated */
113 #  define x_(string)  string				/* never translate */
114 #  define string1byte(string) string
115 #  define string2byte(string) string
116 #endif
117 #define   b_(string)  string				/* never translate, never make unicode */
118 #define WIDENSTRINGDEFINE(x) x_(x)
119 
120 /* integer sizes */
121 #ifdef WIN32
122 #  if defined(__cplusplus) && !defined(ALLCPLUSPLUS)
123 #    define BOOLEAN         bool
124 #  else
125 #    define BOOLEAN         boolean
126 #  endif
127 #else
128 #  ifdef USEQT
129 #    define BOOLEAN         bool
130 #  else
131 #    define BOOLEAN         Boolean
132 #  endif
133 #endif
134 #ifndef FALSE
135 #  define FALSE             0
136 #endif
137 #ifndef TRUE
138 #  define TRUE              1
139 #endif
140 
141 #ifdef _UNICODE
142 #  include <wchar.h>
143 #  define CHAR            wchar_t			/* 16 bits */
144 #  define UCHAR           wchar_t			/* 16 bits */
145 #  define estrlen         wcslen
146 #  define estrcpy         wcscpy
147 #  define estrncpy        wcsncpy
148 #  define estrcat         wcscat
149 #  define estrncat        wcsncat
150 #  define estrcmp         wcscmp
151 #  define estrncmp        wcsncmp
152 #  define estrchr         wcschr
153 #  define estrrchr        wcsrchr
154 #  define estrstr         wcsstr
155 #  define eatoi           _wtoi
156 #  define eatol           _wtol
157 #  define eatof           _wtof
158 #  ifdef WIN32
159 #    define esnprintf       _snwprintf
160 #  else
161 #    define esnprintf       swprintf
162 #  endif
163 #  define efprintf        fwprintf
164 #  define evsprintf       vswprintf
165 #  define evfprintf       vfwprintf
166 #  define esscanf         swscanf
167 #  define efscanf         fwscanf
168 #  define estrcspn        wcscspn
169 #  define efputs          fputws
170 #else
171 #  define CHAR            char				/* 8 bits */
172 #  define UCHAR           unsigned char		/* 8 bits */
173 #  define estrlen         strlen
174 #  define estrcpy         strcpy
175 #  define estrncpy        strncpy
176 #  define estrcat         strcat
177 #  define estrncat        strncat
178 #  define estrcmp         strcmp
179 #  define estrncmp        strncmp
180 #  define estrchr         strchr
181 #  define estrrchr        strrchr
182 #  define estrstr         strstr
183 #  define eatoi           atoi
184 #  define eatol           atol
185 #  define eatof           atof
186 #  ifdef WIN32
187 #    define esnprintf       _snprintf
188 #  else
189 #    define esnprintf       snprintf
190 #  endif
191 #  define efprintf        fprintf
192 #  define evsprintf       vsprintf
193 #  define evfprintf       vfprintf
194 #  define esscanf         sscanf
195 #  define efscanf         fscanf
196 #  define estrcspn        strcspn
197 #  define efputs          fputs
198 #endif
199 
200 #define CHAR1             char				/* always 8 bits */
201 #define UCHAR1   unsigned char				/* always 8 bits */
202 #define INTBIG            long				/* at least 32 bits, can hold address */
203 #define UINTBIG  unsigned long
204 #define INTSML            short				/* at least 16 bits */
205 #define UINTSML  unsigned short
206 #define INTHUGE    int64_t					/* at least 64 bits */
207 #define UINTHUGE uint64_t
208 #define SIZEOFCHAR    (sizeof (CHAR))		/* bytes per character */
209 #define SIZEOFINTSML  (sizeof (INTSML))		/* bytes per short integer */
210 #define SIZEOFINTBIG  (sizeof (INTBIG))		/* bytes per long integer */
211 #define SIZEOFINTHUGE (sizeof (INTHUGE))	/* bytes per huge integer */
212 #define MAXINTBIG     0x7FFFFFFF			/* largest possible integer */
213 #ifdef WIN32
214 #  define INTHUGECONST(a) (a ## i64)
215 #else
216 #  define INTHUGECONST(a) (a ## LL)
217 #endif
218 
219 /* Use to avoid "unused parameter" warnings */
220 #ifndef Q_UNUSED
221 #  define Q_UNUSED(x) (void)x;
222 #endif
223 
224 /* basic structures */
225 typedef INTBIG        XARRAY[3][3];			/* 3x3 transformation matrix */
226 /** \ingroup Dialogs */
227 /** Definition of rectangle */
228 typedef struct
229 {
230 	INTSML top;          /**< upper y-coordinate of area */
231 	INTSML left;         /**< left x-coordinate of area */
232 	INTSML bottom;       /**< lower y-coordinate of area */
233 	INTSML right;        /**< right x-coordinate of area */
234 } RECTAREA;
235 
236 /* forward declarations for structures */
237 struct Icomcomp;
238 struct Inodeinst;
239 struct Iportarcinst;
240 struct Iportexpinst;
241 struct Inodeproto;
242 struct Iportproto;
243 struct Iarcinst;
244 struct Iarcproto;
245 struct Inetwork;
246 struct Igeom;
247 struct Irtnode;
248 struct Ilibrary;
249 struct Itechnology;
250 
251 #if defined(__cplusplus) && !defined(ALLCPLUSPLUS)
252 extern "C"
253 {
254 #endif
255 
256 /*************************** VARIABLES ****************************/
257 
258 #define NOVARIABLE  ((VARIABLE *)-1)
259 
260 /*
261  * when adding objects to this list, also update:
262  *   "dbtext.c:describeobject()"
263  *   "dblang*"
264  *   "dbvars.c"
265  *   "dbtext.c:db_makestringvar()"
266  *   "usrcom.c:us_nextvars()"
267  *   "usrstatus.c:us_vartypename[]"
268  */
269 /* the meaning of VARIABLE->type */
270 #define VUNKNOWN                   0		/* undefined variable */
271 #define VINTEGER                  01		/* 32-bit integer variable */
272 #define VADDRESS                  02		/* unsigned address */
273 #define VCHAR                     03		/* character variable */
274 #define VSTRING                   04		/* string variable */
275 #define VFLOAT                    05		/* floating point variable */
276 #define VDOUBLE                   06		/* double-precision floating point */
277 #define VNODEINST                 07		/* nodeinst pointer */
278 #define VNODEPROTO               010		/* nodeproto pointer */
279 #define VPORTARCINST             011		/* portarcinst pointer */
280 #define VPORTEXPINST             012		/* portexpinst pointer */
281 #define VPORTPROTO               013		/* portproto pointer */
282 #define VARCINST                 014		/* arcinst pointer */
283 #define VARCPROTO                015		/* arcproto pointer */
284 #define VGEOM                    016		/* geometry pointer */
285 #define VLIBRARY                 017		/* library pointer */
286 #define VTECHNOLOGY              020		/* technology pointer */
287 #define VTOOL                    021		/* tool pointer */
288 #define	VRTNODE					 022		/* R-tree pointer */
289 #define VFRACT                   023		/* fractional integer (scaled by WHOLE) */
290 #define VNETWORK                 024		/* network pointer */
291 
292 #define VVIEW                    026		/* view pointer */
293 #define VWINDOWPART              027		/* window partition pointer */
294 #define VGRAPHICS                030		/* graphics object pointer */
295 #define VSHORT                   031		/* 16-bit integer */
296 #define VCONSTRAINT              032		/* constraint solver */
297 #define VGENERAL                 033		/* general address/type pairs (used only in fixed-length arrays) */
298 #define VWINDOWFRAME             034		/* window frame pointer */
299 #define VPOLYGON                 035		/* polygon pointer */
300 #define VBOOLEAN                 036		/* boolean variable */
301 #define VTYPE                    037		/* all above type fields */
302 #define VCODE1                   040		/* variable is interpreted code (with VCODE2) */
303 #define VDISPLAY                0100		/* display variable (uses textdescript field) */
304 #define VISARRAY                0200		/* set if variable is array of above objects */
305 #define VCREF                   0400		/* variable points into C structure */
306 #define VLENGTH          03777777000		/* array length (0: array is -1 terminated) */
307 #define VLENGTHSH                  9		/* right shift for VLENGTH */
308 #define VCODE2           04000000000		/* variable is interpreted code (with VCODE1) */
309 #define VLISP                 VCODE1		/* variable is LISP */
310 #define VTCL                  VCODE2		/* variable is TCL */
311 #define VJAVA         (VCODE1|VCODE2)		/* variable is Java */
312 #define VDONTSAVE       010000000000		/* set to prevent saving on disk */
313 #define VCANTSET        020000000000		/* set to prevent changing value */
314 
315 /* the meaning of VARIABLE->textdescript */
316 #define VTPOSITION               017		/* 0: position of text relative to point */
317 #define VTPOSCENT                  0		/* 0:   text centered about point */
318 #define VTPOSUP                    1		/* 0:   text centered above point */
319 #define VTPOSDOWN                  2		/* 0:   text centered below point */
320 #define VTPOSLEFT                  3		/* 0:   text centered to left of point */
321 #define VTPOSRIGHT                 4		/* 0:   text centered to right of point */
322 #define VTPOSUPLEFT                5		/* 0:   text centered to upper-left of point */
323 #define VTPOSUPRIGHT               6		/* 0:   text centered to upper-right of point */
324 #define VTPOSDOWNLEFT              7		/* 0:   text centered to lower-left of point */
325 #define VTPOSDOWNRIGHT             8		/* 0:   text centered to lower-right of point */
326 #define VTPOSBOXED                 9		/* 0:   text centered and limited to object size */
327 #define VTDISPLAYPART            060		/* 0: bits telling what to display */
328 #define VTDISPLAYVALUE             0		/* 0:   display value */
329 #define VTDISPLAYNAMEVALUE       040		/* 0:   display name and value */
330 #define VTDISPLAYNAMEVALINH      020		/* 0:   display name, value, 1-level inherit */
331 #define VTDISPLAYNAMEVALINHALL   060		/* 0:   display name, value, any inherit */
332 #define VTITALIC                0100		/* 0: set for italic text */
333 #define VTBOLD                  0200		/* 0: set for bold text */
334 #define VTUNDERLINE             0400		/* 0: set for underline text */
335 #define VTISPARAMETER          01000		/* 0: attribute is parameter (nodeinst only) */
336 #define VTINTERIOR             02000		/* 0: text only appears inside cell */
337 #define VTINHERIT              04000		/* 0: set to inherit value from proto to inst */
338 #define VTXOFF              07770000		/* 0: X offset of text */
339 #define VTXOFFSH                  12		/* 0: right shift of VTXOFF */
340 #define VTXOFFNEG          010000000		/* 0: set if X offset is negative */
341 #define VTYOFF          017760000000		/* 0: Y offset of text */
342 #define VTYOFFSH                  22		/* 0: right shift of VTYOFF */
343 #define VTYOFFNEG       020000000000		/* 0: set if Y offset is negative */
344 #define VTOFFMASKWID               9		/* 0: Width of VTXOFF and VTYOFF */
345 #define VTSIZE                077777		/* 1: size of text */
346 #define VTSIZESH                   0		/* 1: right shift of VTSIZE */
347 #define VTFACE             017700000		/* 1: face of text */
348 #define VTFACESH                  15		/* 1: right shift of VTFACE */
349 #define VTROTATION         060000000		/* 1: rotation of text */
350 #define VTROTATIONSH              22		/* 1: right shift of VTROTATION */
351 #define VTMAXFACE                128		/* 1: maximum value of VTFACE field */
352 #define VTOFFSCALE       03700000000		/* 1: scale of text offset */
353 #define VTOFFSCALESH              24		/* 1: right shift of VTOFFSCALE */
354 #define VTUNITS         034000000000		/* 1: units of text */
355 #define VTUNITSSH                 29		/* 1: right shift of VTUNITS */
356 #define VTUNITSNONE                0		/* 1:   units: none */
357 #define VTUNITSRES                 1		/* 1:   units: resistance */
358 #define VTUNITSCAP                 2		/* 1:   units: capacitance */
359 #define VTUNITSIND                 3		/* 1:   units: inductance */
360 #define VTUNITSCUR                 4		/* 1:   units: current */
361 #define VTUNITSVOLT                5		/* 1:   units: voltage */
362 #define VTUNITSDIST                6		/* 1:   units: distance */
363 #define VTUNITSTIME                7		/* 1:   units: time */
364 
365 #define TEXTDESCRIPTSIZE 2		/* number of words in a text descriptor */
366 
367 #define TDCLEAR(t)     tdclear(t)
368 #define TDCOPY(d, s)   tdcopy(d, s)
369 #define TDDIFF(t1, t2) tddiff(t1, t2)
370 
371 /* macros to get the various fields from a text description */
372 #define TDGETPOS(t)       ((t)[0]&VTPOSITION)
373 #define TDGETSIZE(t)     (((t)[1]&VTSIZE)>>VTSIZESH)
374 #define TDGETFACE(t)     (((t)[1]&VTFACE)>>VTFACESH)
375 #define TDGETROTATION(t) (((t)[1]&VTROTATION)>>VTROTATIONSH)
376 #define TDGETDISPPART(t)  ((t)[0]&VTDISPLAYPART)
377 #define TDGETITALIC(t)    ((t)[0]&VTITALIC)
378 #define TDGETBOLD(t)      ((t)[0]&VTBOLD)
379 #define TDGETUNDERLINE(t) ((t)[0]&VTUNDERLINE)
380 #define TDGETINTERIOR(t)  ((t)[0]&VTINTERIOR)
381 #define TDGETINHERIT(t)   ((t)[0]&VTINHERIT)
382 #define TDGETISPARAM(t)   ((t)[0]&VTISPARAMETER)
383 #define TDGETXOFF(t)     gettdxoffset(t)
384 #define TDGETYOFF(t)     gettdyoffset(t)
385 #define TDGETOFFSCALE(t) (((t)[1]&VTOFFSCALE)>>VTOFFSCALESH)
386 #define TDGETUNITS(t)    (((t)[1]&VTUNITS)>>VTUNITSSH)
387 
388 /* macros to set the various fields from a text description */
389 #define TDSETPOS(t,v)       (t)[0] = ((t)[0] & ~VTPOSITION) | (v)
390 #define TDSETSIZE(t,v)      (t)[1] = ((t)[1] & ~VTSIZE) | ((v) << VTSIZESH)
391 #define TDSETFACE(t,v)      (t)[1] = ((t)[1] & ~VTFACE) | ((v) << VTFACESH)
392 #define TDSETROTATION(t,v)  (t)[1] = ((t)[1] & ~VTROTATION) | ((v) << VTROTATIONSH)
393 #define TDSETDISPPART(t,v)  (t)[0] = ((t)[0] & ~VTDISPLAYPART) | (v)
394 #define TDSETITALIC(t,v)    (t)[0] = ((t)[0] & ~VTITALIC) | (v)
395 #define TDSETBOLD(t,v)      (t)[0] = ((t)[0] & ~VTBOLD) | (v)
396 #define TDSETUNDERLINE(t,v) (t)[0] = ((t)[0] & ~VTUNDERLINE) | (v)
397 #define TDSETINTERIOR(t,v)  (t)[0] = ((t)[0] & ~VTINTERIOR) | (v)
398 #define TDSETINHERIT(t,v)   (t)[0] = ((t)[0] & ~VTINHERIT) | (v)
399 #define TDSETISPARAM(t,v)   (t)[0] = ((t)[0] & ~VTISPARAMETER) | (v)
400 #define TDSETOFF(t,x, y)    settdoffset(t, x, y)
401 #define TDSETOFFSCALE(t,v)  (t)[1] = ((t)[1] & ~VTOFFSCALE) | ((v) << VTOFFSCALESH)
402 #define TDSETUNITS(t,v)     (t)[1] = ((t)[1] & ~VTUNITS) | ((v) << VTUNITSSH)
403 
404 typedef struct
405 {
406 	INTBIG    key;							/* library-specific key to this name */
407 	UINTBIG   type;							/* the type of variables (see above) */
408 	UINTBIG   textdescript[TEXTDESCRIPTSIZE];	/* nature of text that displays variable */
409 	INTBIG    addr;							/* contents of variable */
410 } VARIABLE;
411 
412 extern CHAR  **el_namespace;				/* names in name space */
413 extern INTBIG  el_numnames;					/* number of names in name space */
414 
415 /* some keys to commonly used variable names */
416 extern INTBIG  el_node_name_key;			/* key for "NODE_name" */
417 extern INTBIG  el_arc_name_key;				/* key for "ARC_name" */
418 extern INTBIG  el_arc_radius_key;			/* key for "ARC_radius" */
419 extern INTBIG  el_trace_key;				/* key for "trace" */
420 extern INTBIG  el_cell_message_key;			/* key for "FACET_message" */
421 extern INTBIG  el_schematic_page_size_key;	/* key for "FACET_schematic_page_size" */
422 extern INTBIG  el_transistor_width_key;		/* key for "transistor_width" */
423 extern INTBIG  el_prototype_center_key;		/* key for "prototype_center" */
424 extern INTBIG  el_essential_bounds_key;		/* key for "FACET_essentialbounds" */
425 extern INTBIG  el_node_size_default_key;	/* key for "NODE_size_default" */
426 extern INTBIG  el_arc_width_default_key;	/* key for "ARC_width_default" */
427 extern INTBIG  el_attrkey_area;				/* key for "ATTR_area" */
428 extern INTBIG  el_attrkey_length;			/* key for "ATTR_length" */
429 extern INTBIG  el_attrkey_width;			/* key for "ATTR_width" */
430 extern INTBIG  el_attrkey_M;			    /* key for "ATTR_M" */
431 extern INTBIG  el_techstate_key;			/* key for "TECH_state" */
432 
433 /*************************** MEMORY ALLOCATION ****************************/
434 
435 #define NOCLUSTER	((CLUSTER *)-1)
436 
437 #define CLUSTERFILLING   1					/* set if no need to search entire cluster */
438 
439 typedef struct Icluster
440 {
441 	INTBIG           address;				/* base address of this cluster */
442 	INTBIG           flags;					/* information bits about this cluster */
443 	CHAR             clustername[30];		/* for debugging only */
444 	INTBIG           clustersize;			/* number of pages to allocate at a time */
445 	struct Icluster *nextcluster;			/* next in linked list */
446 } CLUSTER;
447 
448 extern CLUSTER *el_tempcluster;				/* cluster for temporary allocation */
449 extern CLUSTER *db_cluster;					/* database general allocation */
450 
451 /************************** COMMAND COMPLETION ***************************/
452 
453 #define TEMPLATEPARS               5		/* maximum parameters in a template */
454 #define MAXPARS                   20		/* maximum parameters in a command */
455 #define NOCOMCOMP    ((COMCOMP *)-1)
456 #define NOKEYWORD    ((KEYWORD *)-1)
457 #define NOKEY              NOCOMCOMP		/* short form for null keyword */
458 #define TERMKEY      {NULL, 0, {NULL, NULL, NULL, NULL, NULL}}
459 #define NOTOPLIST     (us_patoplist)		/* no routine for the keyword table */
460 #define NONEXTLIST (us_panextinlist)		/* no routine for table slot */
461 #define NOPARAMS       (us_paparams)		/* no routine for table slot */
462 
463 /* bits in COMCOMP->interpret */
464 #define NOFILL                    01		/* if set, don't fill out keyword */
465 #define NOSHOALL                  02		/* if set, suppress options list when null */
466 #define INPUTOPT                  04		/* if set, this can be input option on popup */
467 #define INCLUDENOISE             010		/* if set, include "noise" option in list */
468 #define MULTIOPT                 020		/* if set, allow multiple menu picks */
469 
470 /*
471  * tables of command options use this structure
472  */
473 typedef struct Ikeyword
474 {
475 	CHAR            *name;					/* name of this command */
476 	INTBIG           params;				/* number of parameters to command */
477 	struct Icomcomp *par[TEMPLATEPARS];		/* parameter types */
478 } KEYWORD;
479 
480 /*
481  * this structure defines the basic command parameter
482  */
483 typedef struct Icomcomp
484 {
485 	KEYWORD *ifmatch;						/* list of keywords to search if it matches */
486 	BOOLEAN (*toplist)(CHAR**);				/* reset to top of list of keywords */
487 	CHAR  *(*nextcomcomp)(void);			/* give next keyword in list */
488 	INTBIG (*params)(CHAR*, struct Icomcomp*[], CHAR);	/* set parameters to keyword */
489 	INTBIG   interpret;						/* bits for interpretation */
490 	CHAR    *breakchrs;						/* keyword separation characters */
491 	CHAR    *noise;							/* describe list */
492 	CHAR    *def;							/* default value */
493 } COMCOMP;
494 
495 /*************************** TOOLS ****************************/
496 
497 #define NOTOOL	((TOOL *)-1)
498 
499 /* tool descriptors */
500 typedef struct Itool
501 {
502 	CHAR    *toolname;						/* name of tool */
503 	INTBIG   toolstate;						/* state of tool */
504 	INTBIG   toolindex;						/* tool index */
505 	COMCOMP *parse;							/* parsing structure for tool direction */
506 	CLUSTER *cluster;						/* virtual memory cluster for this tool */
507 
508 	void   (*init)(INTBIG*, CHAR1*[], struct Itool*);		/* initialization */
509 	void   (*done)(void);									/* completion */
510 	void   (*setmode)(INTBIG, CHAR*[]);						/* user-command options */
511 	INTBIG (*request)(CHAR*, va_list);						/* direct call options */
512 	void   (*examinenodeproto)(struct Inodeproto*);			/* to examine an entire cell at once */
513 	void   (*slice)(void);									/* time slice */
514 
515 	void   (*startbatch)(struct Itool*, BOOLEAN);			/* start change broadcast */
516 	void   (*endbatch)(void);								/* end change broadcast */
517 
518 	void   (*startobjectchange)(INTBIG, INTBIG);			/* broadcast that object about to be changed */
519 	void   (*endobjectchange)(INTBIG, INTBIG);				/* broadcast that object done being changed */
520 
521 	void   (*modifynodeinst)(struct Inodeinst*,INTBIG,INTBIG,INTBIG,INTBIG,INTBIG,INTBIG);	/* broadcast modified nodeinst */
522 	void   (*modifynodeinsts)(INTBIG,struct Inodeinst**,INTBIG*,INTBIG*,INTBIG*,INTBIG*,INTBIG*,INTBIG*);	/* broadcast modified nodeinsts */
523 	void   (*modifyarcinst)(struct Iarcinst*,INTBIG,INTBIG,INTBIG,INTBIG,INTBIG,INTBIG);	/* broadcast modified arcinst */
524 	void   (*modifyportproto)(struct Iportproto*, struct Inodeinst*, struct Iportproto*);	/* broadcast modified portproto */
525 	void   (*modifynodeproto)(struct Inodeproto*);			/* broadcast modified nodeproto */
526 	void   (*modifydescript)(INTBIG, INTBIG, INTBIG, UINTBIG*);	/* broadcast modified descriptor */
527 
528 	void   (*newobject)(INTBIG, INTBIG);					/* broadcast new object */
529 	void   (*killobject)(INTBIG, INTBIG);					/* broadcast deleted object */
530 	void   (*newvariable)(INTBIG, INTBIG, INTBIG, INTBIG);	/* broadcast new variable */
531 	void   (*killvariable)(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, UINTBIG*);	/* broadcast deleted variable */
532 	void   (*modifyvariable)(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);	/* broadcast modified array variable entry */
533 	void   (*insertvariable)(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);			/* broadcast inserted array variable entry */
534 	void   (*deletevariable)(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);	/* broadcast deleted array variable entry */
535 
536 	void   (*readlibrary)(struct Ilibrary*);				/* broadcast newly read library */
537 	void   (*eraselibrary)(struct Ilibrary*);				/* broadcast library to be erased */
538 	void   (*writelibrary)(struct Ilibrary*, BOOLEAN);		/* broadcast library writing */
539 
540 	/* variables */
541 	VARIABLE *firstvar;						/* first variable in list */
542 	INTSML    numvar;						/* number of variables in list */
543 } TOOL;
544 
545 extern TOOL      el_tools[];				/* defined in "aidtable.c" */
546 extern INTBIG    el_maxtools;				/* current number of tools */
547 extern TOOL     *us_tool;					/* the User tool object */
548 extern TOOL     *io_tool;					/* the I/O tool object */
549 extern TOOL     *net_tool;					/* the Network tool object */
550 
551 /* the meaning of TOOL->toolstate */
552 #define TOOLON                    01		/* set if tool is on */
553 #define TOOLBG                    02		/* set if tool is running in background */
554 #define TOOLFIX                   04		/* set if tool will fix errors */
555 #define TOOLLANG                 010		/* set if tool is coded in interpretive language */
556 #define TOOLINCREMENTAL          020		/* set if tool functions incrementally */
557 #define TOOLANALYSIS             040		/* set if tool does analysis */
558 #define TOOLSYNTHESIS           0100		/* set if tool does synthesis */
559 
560 /*************************** VIEWS ****************************/
561 
562 #define NOVIEW          ((VIEW *)-1)
563 
564 /* the meaning of VIEW->viewstate */
565 #define TEXTVIEW                  01		/* view contains only text */
566 #define MULTIPAGEVIEW             02		/* view is one of multiple pages */
567 #define PERMANENTVIEW             04		/* view is statically defined and cannot be deleted */
568 
569 typedef struct Iview
570 {
571 	CHAR         *viewname;					/* name of this view */
572 	CHAR         *sviewname;				/* short name of this view */
573 	struct Iview *nextview;					/* next in linked list */
574 	INTBIG        temp1, temp2;				/* working variables */
575 	INTBIG        viewstate;				/* information about the view */
576 
577 	/* variables */
578 	VARIABLE     *firstvar;					/* first variable in list */
579 	INTSML        numvar;					/* number of variables in list */
580 } VIEW;
581 
582 extern VIEW *el_views;						/* list of existing view */
583 extern VIEW *el_unknownview;				/* the unknown view */
584 extern VIEW *el_layoutview;					/* the layout view */
585 extern VIEW *el_schematicview;				/* the schematic view */
586 extern VIEW *el_iconview;					/* the icon view */
587 extern VIEW *el_simsnapview;				/* the simulation-snapshot view */
588 extern VIEW *el_skeletonview;				/* the skeleton view */
589 extern VIEW *el_compview;					/* the compensated view */
590 extern VIEW *el_vhdlview;					/* the VHDL view (text) */
591 extern VIEW *el_verilogview;				/* the Verilog view (text) */
592 extern VIEW *el_netlistview;				/* the netlist view, generic (text) */
593 extern VIEW *el_netlistnetlispview;			/* the netlist view, netlisp (text) */
594 extern VIEW *el_netlistalsview;				/* the netlist view, als (text) */
595 extern VIEW *el_netlistquiscview;			/* the netlist view, quisc (text) */
596 extern VIEW *el_netlistrsimview;			/* the netlist view, rsim (text) */
597 extern VIEW *el_netlistsilosview;			/* the netlist view, silos (text) */
598 extern VIEW *el_docview;					/* the documentation view (text) */
599 
600 /*************************** NODE INSTANCES ****************************/
601 
602 #define NONODEINST  ((NODEINST *)-1)
603 
604 /* the meaning of NODEINST->userbits */
605 #define DEADN                     01		/* node is not in use */
606 #define NHASFARTEXT               02		/* node has text that is far away */
607 #define NEXPAND                   04		/* if on, draw node expanded */
608 #define WIPED                    010		/* set if node not drawn due to wiping arcs */
609 #define NSHORT                   020		/* set if node is to be drawn shortened */
610 /*  used by database:           0140 */
611 /*  used by user:          040177600 */
612 #define NTECHBITS          037400000		/* technology-specific bits for primitives */
613 #define NTECHBITSSH               17		/* right-shift of NTECHBITS */
614 #define NILOCKED          0100000000		/* set if node is locked (can't be changed) */
615 
616 /* node instances */
617 typedef struct Inodeinst
618 {
619 	INTBIG               lowx, highx;		/* bounding X box of nodeinst */
620 	INTBIG               lowy, highy;		/* bounding Y box of nodeinst */
621 	INTSML               transpose;			/* nonzero to transpose before rotation */
622 	INTSML               rotation;			/* angle from normal (0 to 359) */
623 	struct Inodeproto   *proto;				/* current nodeproto */
624 	struct Inodeproto   *parent;			/* cell that contains this nodeinst */
625 	struct Inodeinst    *prevnodeinst;		/* list of instances in parent cell */
626 	struct Inodeinst    *nextnodeinst;
627 	struct Igeom        *geom;				/* relative geometry list pointer */
628 	struct Inodeinst    *previnst;			/* list of others of this type */
629 	struct Inodeinst    *nextinst;
630 	struct Iportarcinst *firstportarcinst;	/* first portarcinst on node */
631 	struct Iportexpinst *firstportexpinst;	/* first portexpinst on node */
632 	UINTBIG              textdescript[TEXTDESCRIPTSIZE];	/* nature of text that displays cell name */
633 	INTBIG               arraysize;			/* extent of array of this node (0 if not) */
634 
635 	/* change information */
636 	CHAR                *changeaddr;		/* change associated with this nodeinst */
637 	INTBIG               changed;			/* clock entry for changes to this nodeinst */
638 
639 	/* tool information */
640 	UINTBIG              userbits;			/* state flags */
641 	INTBIG               temp1, temp2;		/* temporaries */
642 
643 	/* variables */
644 	VARIABLE            *firstvar;			/* first variable in list */
645 	INTSML               numvar;			/* number of variables in list */
646 } NODEINST;
647 
648 /*************************** PORT ARC INSTANCES ****************************/
649 
650 #define NOPORTARCINST ((PORTARCINST *)-1)
651 
652 typedef struct Iportarcinst
653 {
654 	struct Iportproto   *proto;				/* portproto of this portarcinst */
655 	struct Iarcinst     *conarcinst;		/* arcinst connecting to this portarcinst */
656 	struct Iportarcinst *nextportarcinst;	/* next portarcinst in list */
657 
658 	/* variables */
659 	VARIABLE            *firstvar;			/* first variable in list */
660 	INTSML               numvar;			/* number of variables in list */
661 } PORTARCINST;
662 
663 /************************** PORT EXPORT INSTANCES ***************************/
664 
665 #define NOPORTEXPINST ((PORTEXPINST *)-1)
666 
667 typedef struct Iportexpinst
668 {
669 	struct Iportproto   *proto;				/* portproto of this portexpinst */
670 	struct Iportexpinst *nextportexpinst;	/* next portexpinst in list */
671 	struct Iportproto   *exportproto;		/* portproto on parent cell */
672 
673 	/* variables */
674 	VARIABLE            *firstvar;			/* first variable in list */
675 	INTSML               numvar;			/* number of variables in list */
676 } PORTEXPINST;
677 
678 /*************************** NODE PROTOTYPES ****************************/
679 
680 #define NONODEPROTO ((NODEPROTO *)-1)
681 
682 /* the meaning of NODEPROTO->userbits */
683 #define NODESHRINK                01		/* set if nonmanhattan instances shrink */
684 #define WANTNEXPAND               02		/* set if instances should be expanded */
685 #define NFUNCTION               0774		/* node function (from efunction.h) */
686 #define NFUNCTIONSH                2		/* right shift for NFUNCTION */
687 #define ARCSWIPE               01000		/* set if instances can be wiped */
688 #define NSQUARE                02000		/* set if node is to be kept square in size */
689 #define HOLDSTRACE             04000		/* primitive can hold trace information */
690 #define REDOCELLNET           010000		/* set to reevaluate this cell's network */
691 #define WIPEON1OR2            020000		/* set to erase if connected to 1 or 2 arcs */
692 #define LOCKEDPRIM            040000		/* set if primitive is lockable (cannot move) */
693 #define NEDGESELECT          0100000		/* set if primitive is selectable by edge, not area */
694 #define ARCSHRINK            0200000		/* set if nonmanhattan arcs on this shrink */
695 /*  used by database:       01400000 */
696 #define NNOTUSED            02000000		/* set if not used (don't put in menu) */
697 #define NPLOCKED            04000000		/* set if everything in cell is locked */
698 #define NPILOCKED          010000000		/* set if instances in cell are locked */
699 #define INCELLLIBRARY      020000000		/* set if cell is part of a "cell library" */
700 #define TECEDITCELL        040000000		/* set if cell is from a technology-library */
701 /*  used by user:       037700000000 */
702 
703 #define GLOBALNETGROUND            0		/* index into "globalnetworks" for ground net */
704 #define GLOBALNETPOWER             1		/* index into "globalnetworks" for power net */
705 
706 /* macro for looping through all cells in a group */
707 #define FOR_CELLGROUP(np, firstnp) \
708 	for(np = firstnp; np != NONODEPROTO; np = (np->nextcellgrp == firstnp ? NONODEPROTO : np->nextcellgrp))
709 
710 #ifdef __cplusplus
711 class NetCellPrivate;                      /* private network data */
712 #else
713 typedef void NetCellPrivate;
714 #endif
715 
716 typedef struct Inodeproto
717 {
718 	/* used by all tools */
719 	CHAR               *protoname;			/* nodeproto name !!!NEW!!! */
720 	INTBIG              primindex;			/* nonzero if primitive */
721 	INTBIG              lowx, highx;		/* bounds in X */
722 	INTBIG              lowy, highy;		/* bounds in Y */
723 	NODEINST           *firstinst;			/* first in list of instances of this kind */
724 	NODEINST           *firstnodeinst;		/* head of list of nodeinsts in this cell */
725 	struct Iarcinst    *firstarcinst;		/* head of list of arcinsts in this cell */
726 	struct Itechnology *tech;				/* technology with this nodeproto (prim only) */
727 	struct Ilibrary    *lib;				/* library with this nodeproto (cells only) !!!NEW!!! */
728 	struct Inodeproto  *prevnodeproto;		/* previous in library/technology list */
729 	struct Inodeproto  *nextnodeproto;		/* next in library/technology list */
730 	struct Iportproto  *firstportproto;		/* list of ports */
731 	struct Inodeproto  *cachedequivcell;	/* cache of equivalent cell for quick port matching */
732 	struct Inodeproto  *nextcellgrp;		/* next in circular list of cells in group !!!NEW!!! */
733 	struct Inodeproto  *nextcont;			/* next in circular list of cells in continuation !!!NEW!!! */
734 
735 	INTBIG              numportprotos;		/* number of portprotos in this nodeproto */
736 	struct Iportproto **portprotohashtable;	/* hash table of portprotos in this nodeproto */
737 	INTBIG              portprotohashtablesize;	/* size of portproto hash table */
738 
739 	VIEW               *cellview;			/* view of this cell */
740 	INTBIG              version;			/* version number of this cell */
741 	struct Inodeproto  *prevversion;		/* earlier version of this cell */
742 	struct Inodeproto  *newestversion;		/* most recent version of this cell */
743 	UINTBIG             creationdate;		/* date cell was created */
744 	UINTBIG             revisiondate;		/* date cell was last changed */
745 
746 	struct Inetwork    *firstnetwork;		/* nets in this cell */
747     NetCellPrivate     *netd;               /* private network data */
748 	INTBIG              globalnetcount;		/* number of global nets in this cell */
749 	INTBIG             *globalnetchar;		/* global network characteristics in this cell */
750 	struct Inetwork   **globalnetworks;		/* global nets in this cell */
751 	CHAR              **globalnetnames;		/* global net names in this cell */
752 	struct Irtnode     *rtree;				/* top of geometric tree of objects in cell */
753 
754 	/* change information */
755 	CHAR               *changeaddr;			/* change associated with this cell */
756 
757 	/* tool specific */
758 	unsigned            adirty;				/* "dirty" bit for each tool */
759 	UINTBIG             userbits;			/* state flags */
760 	INTBIG              temp1, temp2;		/* temporaries */
761 
762 	/* variables */
763 	VARIABLE           *firstvar;			/* first variable in list */
764 	INTSML              numvar;				/* number of variables in list */
765 } NODEPROTO;
766 
767 /*************************** PORT PROTOTYPES ****************************/
768 
769 #define NOPORTPROTO ((PORTPROTO *)-1)
770 
771 /* the meaning of PORTPROTO->userbits */
772 #define PORTANGLE               0777		/* angle of this port from node center */
773 #define PORTANGLESH                0		/* right shift of PORTANGLE field */
774 #define PORTARANGE           0377000		/* range of valid angles about port angle */
775 #define PORTARANGESH               9		/* right shift of PORTARANGE field */
776 #define PORTNET           0177400000		/* electrical net of primitive port (0-30) */
777                                             /* 31 stands for one-port net */
778 #define PORTNETSH                 17		/* right shift of PORTNET field */
779 #define PORTISOLATED      0200000000		/* set if arcs to this port do not connect */
780 #define PORTDRAWN         0400000000		/* set if this port should always be drawn */
781 #define BODYONLY         01000000000		/* set to exclude this port from the icon */
782 #define STATEBITS       036000000000		/* input/output/power/ground/clock state: */
783 #define STATEBITSSH               27		/* right shift of STATEBITS */
784 #define CLKPORT          02000000000		/*   un-phased clock port */
785 #define C1PORT           04000000000		/*   clock phase 1 */
786 #define C2PORT           06000000000		/*   clock phase 2 */
787 #define C3PORT          010000000000		/*   clock phase 3 */
788 #define C4PORT          012000000000		/*   clock phase 4 */
789 #define C5PORT          014000000000		/*   clock phase 5 */
790 #define C6PORT          016000000000		/*   clock phase 6 */
791 #define INPORT          020000000000		/*   input port */
792 #define OUTPORT         022000000000		/*   output port */
793 #define BIDIRPORT       024000000000		/*   bidirectional port */
794 #define PWRPORT         026000000000		/*   power port */
795 #define GNDPORT         030000000000		/*   ground port */
796 #define REFOUTPORT      032000000000		/*   bias-level reference output port */
797 #define REFINPORT       034000000000		/*   bias-level reference input port */
798 #define REFBASEPORT     036000000000		/*   bias-level reference base port */
799 
800 typedef struct Iportproto
801 {
802 	struct Iarcproto **connects;			/* arc prototypes that can touch this port */
803 	NODEPROTO         *parent;				/* nodeproto that this portproto resides in */
804 	NODEINST          *subnodeinst;			/* subnodeinst that portproto comes from */
805 	PORTEXPINST       *subportexpinst;		/* portexpinst in subnodeinst */
806 	struct Iportproto *subportproto;		/* portproto in above subnodeinst */
807 	struct Iportproto *nextportproto;		/* next in list of port prototypes */
808 	CHAR              *protoname;			/* name of this port prototype */
809 	UINTBIG            textdescript[TEXTDESCRIPTSIZE];		/* nature of text that displays proto name */
810 	struct Iportproto *cachedequivport;		/* cache of equivalent port in other cell */
811 
812 	/* change information */
813 	CHAR              *changeaddr;			/* change associated with this port */
814 
815 	/* for the tools */
816 	UINTBIG            userbits;			/* state flags */
817 	struct Inetwork   *network;				/* network object within cell */
818 	INTBIG             temp1, temp2;		/* temporaries */
819 
820 	/* variables */
821 	VARIABLE          *firstvar;			/* first variable in list */
822 	INTSML             numvar;				/* number of variables in list */
823 } PORTPROTO;
824 
825 /*************************** ARC INSTANCES ****************************/
826 
827 #define NOARCINST    ((ARCINST *)-1)
828 
829 /* the meaning of ARCINST->userbits */
830 #define FIXED                     01		/* fixed-length arc */
831 #define FIXANG                    02		/* fixed-angle arc */
832 #define AHASFARTEXT               04		/* arc has text that is far away */
833 #define DEADA                    020		/* arc is not in use */
834 #define AANGLE                037740		/* angle of arc from end 0 to end 1 */
835 #define AANGLESH                   5		/* bits of right shift for AANGLE field */
836 #define ASHORT                040000		/* set if arc is to be drawn shortened */
837 #define ISHEADNEGATED        0200000		/* set if head end is negated (from Java Electric) */
838 #define NOEXTEND             0400000		/* set if ends do not extend by half width */
839 #define ISNEGATED           01000000		/* set if tail end is negated */
840 #define ISDIRECTIONAL       02000000		/* set if arc aims from end 0 to end 1 */
841 #define NOTEND0             04000000		/* no extension/negation/arrows on end 0 */
842 #define NOTEND1            010000000		/* no extension/negation/arrows on end 1 */
843 #define REVERSEEND         020000000		/* reverse extension/negation/arrow ends */
844 #define CANTSLIDE          040000000		/* set if arc can't slide around in ports */
845 /*  used by database:     0100000000 */
846 /*  used by user:       037600000000 */
847 
848 typedef struct Iarcinst
849 {
850 	/* physical description of arcinst */
851 	struct Iarcproto *proto;				/* arc prototype of this arcinst */
852 	INTBIG            length;				/* length of arcinst */
853 	INTBIG            width;				/* width of arcinst */
854 	INTBIG            endshrink;			/* shrinkage factor on ends */
855 	struct
856 	{
857 		INTBIG        xpos, ypos;			/* position of arcinst end */
858 		NODEINST     *nodeinst;				/* connecting nodeinst */
859 		PORTARCINST  *portarcinst;			/* portarcinst in the connecting nodeinst */
860 	} end[2];								/* for each end of the arcinst */
861 	struct Iarcinst  *prevarcinst;			/* list of arcs in the parent cell */
862 	struct Iarcinst  *nextarcinst;
863 	struct Igeom     *geom;					/* geometry entry */
864 	NODEPROTO        *parent;				/* parent cell */
865 
866 	/* change information */
867 	CHAR             *changeaddr;			/* change associated with this nodeinst */
868 	INTBIG            changed;				/* clock entry for changes to this nodeinst */
869 
870 	/* tool specific */
871 	UINTBIG           userbits;				/* state flags */
872 	struct Inetwork  *network;				/* network object within cell */
873 	INTBIG            temp1, temp2;			/* temporaries */
874 
875 	/* variables */
876 	VARIABLE         *firstvar;				/* first variable in list */
877 	INTSML            numvar;				/* number of variables in list */
878 } ARCINST;
879 
880 /*************************** ARC PROTOTYPES ****************************/
881 
882 #define NOARCPROTO  ((ARCPROTO *)-1)
883 
884 /* the meaning of ARCPROTO->userbits */
885 #define WANTFIX                   01		/* these arcs are fixed-length */
886 #define WANTFIXANG                02		/* these arcs are fixed-angle */
887 #define WANTCANTSLIDE             04		/* set if arcs should not slide in ports */
888 #define WANTNOEXTEND             010		/* set if ends do not extend by half width */
889 #define WANTNEGATED              020		/* set if arcs should be negated */
890 #define WANTDIRECTIONAL          040		/* set if arcs should be directional */
891 #define CANWIPE                 0100		/* set if arcs can wipe wipable nodes */
892 #define CANCURVE                0200		/* set if arcs can curve */
893 #define AFUNCTION             017400		/* arc function (from efunction.h) */
894 #define AFUNCTIONSH                8		/* right shift for AFUNCTION */
895 #define AANGLEINC          017760000		/* angle increment for this type of arc */
896 #define AANGLEINCSH               13		/* right shift for AANGLEINC */
897 #define AEDGESELECT        020000000		/* set if arc is selectable by edge, not area */
898 /*  used by user:       017740000000 */
899 #define ANOTUSED        020000000000		/* set if not used (don't put in menu) */
900 
901 typedef struct Iarcproto
902 {
903 	/* information for all tools */
904 	CHAR               *protoname;			/* full arcproto name */
905 	INTBIG              nominalwidth;		/* default width of arcs */
906 	INTBIG              arcindex;			/* index number of arcproto in technology */
907 	struct Itechnology *tech;				/* technology this arcproto is in */
908 	struct Iarcproto   *nextarcproto;		/* next in list for this technology */
909 
910 	/* information for specific tool */
911 	UINTBIG             userbits;			/* state flags */
912 	INTBIG              temp1, temp2;		/* temporaries */
913 
914 	/* variables */
915 	VARIABLE           *firstvar;			/* first variable in list */
916 	INTSML              numvar;				/* number of variables in list */
917 } ARCPROTO;
918 
919 /**************************** NETWORKS ****************************/
920 
921 #define NONETWORK    ((NETWORK *)-1)
922 
923 typedef struct Inetwork
924 {
925 	INTBIG            netnameaddr;          /* address of name(s) of this network */
926 	INTSML            namecount;			/* number of names */
927 	INTSML            tempname;				/* nonzero if name is temporary (for back annotation) */
928 	INTSML            arccount;				/* number of arcs on this network */
929 	INTSML            arctotal;				/* total size of "arcaddr" array */
930 	INTBIG            arcaddr;				/* address of arc(s) on this network */
931 	INTSML            refcount;				/* number of arcs on network */
932 	INTSML            portcount;			/* number of ports on this network */
933 	INTSML            buslinkcount;			/* number of busses referencing this network */
934 	NODEPROTO        *parent;				/* cell that has this network */
935 	INTSML            globalnet;			/* index to list of global nets (-1 if not global) */
936 	INTSML            buswidth;				/* width of bus */
937 	struct Inetwork **networklist;			/* list of single-wire networks on bus */
938 	struct Inetwork  *nextnetwork;			/* next in linked list */
939 	struct Inetwork  *prevnetwork;			/* previous in linked list */
940 	INTBIG            temp1, temp2;			/* temporaries */
941 
942 	/* variables */
943 	VARIABLE         *firstvar;				/* first variable in list */
944 	INTSML            numvar;				/* number of variables in list */
945 } NETWORK;
946 
947 /**************************** GEOMETRY POINTERS ****************************/
948 
949 #define NOGEOM          ((GEOM *)-1)
950 
951 /*
952  * Each nodeinst and arcinst points to a geometry module.  The module points
953  * back to the nodeinst or arcinst and describes the position relative to
954  * other nodes and arcs.  Geometry modules are also at the leaf positions
955  * in R-trees, which organize them spatially.
956  */
957 typedef struct Igeom
958 {
959 	BOOLEAN        entryisnode;				/* true if node, false if arc */
960 	union          u_entry
961 	{
962 		NODEINST  *ni;
963 		ARCINST   *ai;
964 		void      *blind;
965 	} entryaddr;							/* pointer to the element */
966 	INTBIG         lowx, highx;				/* horizontal bounds */
967 	INTBIG         lowy, highy;				/* vertical bounds */
968 
969 	/* variables */
970 	VARIABLE      *firstvar;				/* first variable in list */
971 	INTSML         numvar;					/* number of variables in list */
972 } GEOM;
973 
974 #define MINRTNODESIZE              4		/* lower bound on R-tree node size */
975 #define MAXRTNODESIZE (MINRTNODESIZE*2)
976 
977 #define NORTNODE      ((RTNODE *)-1)
978 
979 typedef struct Irtnode
980 {
981 	INTBIG          lowx, highx;			/* X bounds of this node */
982 	INTBIG          lowy, highy;			/* Y bounds of this node */
983 	INTSML          total;					/* number of pointers */
984 	INTSML          flag;					/* nonzero if children are terminal */
985 	UINTBIG         pointers[MAXRTNODESIZE];/* pointers */
986 	struct Irtnode *parent;					/* parent node */
987 
988 	/* variables */
989 	VARIABLE       *firstvar;				/* first variable in list */
990 	INTSML          numvar;					/* number of variables in list */
991 } RTNODE;
992 
993 /*************************** LIBRARIES ****************************/
994 
995 #define NOLIBRARY    ((LIBRARY *)-1)
996 
997 /* the meaning of LIBRARY->userbits */
998 #define LIBCHANGEDMAJOR           01		/* library has changed significantly */
999 #define REDOCELLLIB               02		/* recheck networks in library */
1000 #define READFROMDISK              04		/* set if library came from disk */
1001 #define LIBUNITS                 070		/* internal units in library (see INTERNALUNITS) */
1002 #define LIBUNITSSH                 3		/* right shift for LIBUNITS */
1003 #define LIBCHANGEDMINOR         0100		/* library has changed insignificantly */
1004 #define HIDDENLIBRARY           0200		/* library is "hidden" (clipboard library) */
1005 #define UNWANTEDLIB             0400		/* library is unwanted (used during input) */
1006 
1007 typedef struct Ilibrary
1008 {
1009 	NODEPROTO       *firstnodeproto;		/* list of nodeprotos in this library */
1010 	NODEPROTO       *tailnodeproto;			/* end of list of nodeprotos in this library */
1011 	INTBIG           numnodeprotos;			/* number of nodeprotos in this library !!!NEW!!! */
1012 	NODEPROTO      **nodeprotohashtable;	/* hash table of nodeprotos in this library !!!NEW!!! */
1013 	VIEW           **nodeprotoviewhashtable;/* hash table of nodeproto views in this library !!!NEW!!! */
1014 	INTBIG           nodeprotohashtablesize;/* size of nodeproto hash table !!!NEW!!! */
1015 	NETWORK         *freenetwork;			/* free nets in this library !!!NEW!!! */
1016 	CHAR            *libname;				/* name of this library */
1017 	CHAR            *libfile;				/* file this library comes from */
1018 	INTBIG          *lambda;				/* half-nanometers per unit in this library */
1019 	NODEPROTO       *curnodeproto;			/* top cell of this library (if any) */
1020 	struct Ilibrary *nextlibrary;			/* next library in list */
1021 	UINTBIG          userbits;				/* state flags */
1022 	INTBIG           temp1, temp2;			/* temporaries */
1023 	CLUSTER         *cluster;				/* memory cluster for whole library */
1024 
1025 	/* variables */
1026 	VARIABLE        *firstvar;				/* first variable in list */
1027 	INTSML           numvar;				/* number of variables in list */
1028 } LIBRARY;
1029 
1030 extern LIBRARY  *el_curlib;					/* pointer to current library (list head) */
1031 
1032 /*************************** GRAPHICS and POLYGONS ****************************/
1033 
1034 #define NOGRAPHICS  ((GRAPHICS *)-1)
1035 
1036 typedef struct
1037 {
1038 	INTBIG    bits;							/* bit planes to use (color displays) */
1039 	INTBIG    col;							/* color to draw */
1040 	INTSML    colstyle;						/* drawing style for color displays */
1041 	INTSML    bwstyle;						/* drawing style for B&W displays */
1042 	UINTSML   raster[16];					/* 16x16 raster pattern (for stippling) */
1043 
1044 	/* variables */
1045 	VARIABLE *firstvar;						/* first variable in list */
1046 	INTSML    numvar;						/* number of variables in list */
1047 } GRAPHICS;
1048 
1049 
1050 #define NOPOLYGON    ((POLYGON *)-1)
1051 
1052 typedef struct Ipolygon
1053 {
1054 	INTBIG             *xv, *yv;			/* the polygon coordinates */
1055 	INTBIG              limit;				/* maximum number of points in polygon */
1056 	INTBIG              count;				/* current number of points in polygon */
1057 	CLUSTER            *cluster;			/* virtual memory cluster with this polygon */
1058 	INTBIG              style;				/* the polygon style */
1059 	CHAR               *string;				/* string (if text graphics) */
1060 	UINTBIG             textdescript[TEXTDESCRIPTSIZE];	/* text information (if text) */
1061 	struct Itechnology *tech;				/* technology (if text graphics) */
1062 	GRAPHICS           *desc;				/* graphical description of polygon */
1063 	INTBIG              layer;				/* layer number of this polygon */
1064 	PORTPROTO          *portproto;			/* port prototype associated with this polygon */
1065 	struct Ipolygon    *nextpolygon;		/* for linking them into a list */
1066 
1067 	/* variables */
1068 	VARIABLE *firstvar;						/* first variable in list */
1069 	INTSML    numvar;						/* number of variables in list */
1070 } POLYGON;
1071 
1072 typedef struct
1073 {
1074 	POLYGON **polygons;			/* polygons */
1075 	INTBIG   *lx, *hx;			/* X bound of each polygon */
1076 	INTBIG   *ly, *hy;			/* Y bound of each polygon */
1077 	INTBIG    polylisttotal;	/* allocated size of list */
1078 	INTBIG    polylistcount;	/* number of polygons in the list */
1079 } POLYLIST;
1080 
1081 /******************** EDITOR MODULES ********************/
1082 
1083 #define NOEDITOR      ((EDITOR *)-1)
1084 
1085 /* the meaning of EDITOR->state */
1086 #define EDITORTYPE                07		/* type of editor */
1087 #define PACEDITOR                 01		/* editor is point-and-click */
1088 #define EMACSEDITOR               02		/* editor is EMACS-like */
1089 #define EDITORINITED             010		/* set if editor has been initialized */
1090 #define EGRAPHICSOFF             020		/* set if editor graphics is disabled */
1091 #define LINESFIXED               040		/* set if editor disallows line insertion/deletion */
1092 #define TEXTTYPING              0100		/* set if typing into the editor (text undo) */
1093 #define TEXTTYPED               0200		/* set if typed into the editor (text undo) */
1094 
1095 /* an overloaded entry */
1096 #define charposition highlightedline
1097 
1098 typedef struct Ieditor
1099 {
1100 	INTBIG    state;						/* status bits (see above) */
1101 	INTBIG    swid, shei;					/* screen width and height */
1102 	INTBIG    revy;							/* for reversing Y coordinates */
1103 	INTBIG    offx;							/* for adjusting X coordinates */
1104 	INTBIG    maxlines;						/* maximum lines in buffer */
1105 	INTBIG    linecount;					/* actual number of lines in buffer */
1106 	INTBIG    screenlines;					/* number of lines on screen */
1107 	INTBIG    working;						/* line number being changed */
1108 	INTBIG    firstline;					/* top line on screen */
1109 	INTBIG    screenchars;					/* maximum characters across screen */
1110 	INTBIG    mostchars;					/* most characters on any line */
1111 	INTBIG    curline, curchar;				/* current start position */
1112 	INTBIG    endline, endchar;				/* current end position */
1113 	INTBIG    highlightedline;				/* line being highlighted (EMACS only) */
1114 	INTBIG    horizfactor;					/* position of 1st character on left side */
1115 	INTBIG    vthumbpos;					/* Y position of vertical thumb slider */
1116 	INTBIG    hthumbpos;					/* X position of horizontal thumb slider */
1117 	BOOLEAN   dirty;						/* nonzero if buffer has changed */
1118 	INTBIG   *maxchars;						/* number of characters in each line */
1119 	CHAR     *formerline;					/* line being changed: former state */
1120 	CHAR    **textarray;					/* image of screen contents */
1121 	INTBIG    savedbox;						/* where the bits are kept for popups */
1122 	CHAR     *header;						/* header text */
1123 	CHAR     *editobjaddr;					/* variable editing: parent object address */
1124 	INTBIG    editobjtype;					/* variable editing: parent object type */
1125 	CHAR     *editobjqual;					/* variable editing: attribute name on parent */
1126 	VARIABLE *editobjvar;					/* variable editing: actual variable */
1127 	struct Ieditor *nexteditor;				/* next in linked list */
1128 } EDITOR;
1129 
1130 /******************** WINDOW FRAME MODULES ********************/
1131 
1132 #define NOWINDOWFRAME ((WINDOWFRAME *)-1)
1133 
1134 #if !defined(USEQT) && defined(ONUNIX)
1135 typedef struct
1136 {
1137 	XImage              *image;				/* the offscreen buffer that matches the visual */
1138 	int                  wid, hei;			/* size of the offscreen buffer */
1139 	INTBIG               depth;				/* the depth of the screen */
1140 	INTBIG               truedepth;			/* the depth of the buffer */
1141 	INTBIG               colorvalue[256];	/* the color map for 8-bit depth */
1142 	UCHAR1              *addr;				/* the data in "world" */
1143 	UCHAR1             **rowstart;			/* pointers to "addr" */
1144 } WINDOWDISPLAY;
1145 #endif
1146 
1147 #ifdef USEQT
1148 class GraphicsDraw;
1149 #endif
1150 
1151 typedef struct IWindowFrame
1152 {
1153 #ifdef USEQT
1154 	GraphicsDraw        *draw;              /* Qt widget with interior */
1155 #else
1156 #  ifdef MACOS
1157 	GWorldPtr            window;			/* the offscreen buffer for the editing window */
1158 	CGrafPtr             realwindow;		/* the real window */
1159 	void /*Tk_Window*/  *tkwin;				/* the TK window placeholder */
1160 #  endif
1161 #  ifdef WIN32
1162 	void /*CChildFrame*/*wndframe;			/* address of Windows subframe */
1163 	HWND                 realwindow;		/* the real window */
1164 	UCHAR1              *data;				/* raster data for window */
1165 	void /*CDC*/        *hDC;				/* device context for real window */
1166 	HBITMAP              hBitmap;			/* 8-bit offscreen bitmap */
1167 	BITMAPINFO          *bminfo;			/* bit map info structure */
1168 	void /*CFont*/      *hFont;				/* current font in bitmap */
1169 	void /*CDC*/        *hDCOff;			/* device context for the offscreeen bitmap */
1170 	void /*CPalette*/   *hPalette;			/* color information */
1171 	LOGPALETTE          *pColorPalette;		/* color information */
1172 #  endif
1173 #  ifdef ONUNIX
1174  	Widget               toplevelwidget;	/* widget for top-level frame */
1175 	Widget               intermediategraphics;	/* intermediate graphics widget */
1176 	Widget               graphicswidget;	/* drawing widget */
1177 	Widget               menubar;			/* menu in frame */
1178 	Widget               firstmenu;			/* first menu (dummy placeholder) */
1179 	Display             *topdpy;			/* display of frame */
1180 	WINDOWDISPLAY       *wd;				/* structure with offscreen data */
1181 	Window               topwin;			/* window of top-level frame */
1182 	Window               win;				/* window of graphics widget */
1183 	INTBIG               pulldownmenucount;	/* number of pulldown menus */
1184 	Widget              *pulldownmenus;		/* the current pulldown menu handles */
1185 	INTBIG              *pulldownmenusize;	/* the number of entries in a menu */
1186 	Widget             **pulldownmenulist;	/* the entries in a menu */
1187 	CHAR               **pulldowns;			/* the current pulldown menu names */
1188 	GC                   gc;				/* graphics context for drawing */
1189 	GC                   gcinv;				/* graphics context for inverting */
1190 	GC                   gcstip;			/* graphics context for stippling */
1191 	Colormap             colormap;			/* color map */
1192 	UCHAR1              *dataaddr8;			/* offscreen 8-bit data */
1193 	INTBIG               trueheight;		/* full screen dimensions including status */
1194 #  endif
1195 #endif
1196 	UINTBIG              starttime;			/* time when this window was refreshed from offscreen */
1197 	BOOLEAN              offscreendirty;	/* true if offscreen area is "dirty" */
1198 	INTBIG               copyleft, copyright, copytop, copybottom;/* rectangle to copy to screen */
1199 	UCHAR1             **rowstart;			/* start of each row */
1200 	INTBIG               windindex;			/* identifying index of this frame */
1201 	BOOLEAN              floating;			/* true for floating palette window */
1202 	INTBIG               swid, shei;		/* screen dimensions for drawing */
1203 	INTBIG               revy;				/* for reversing Y coordinates */
1204 	struct IWindowFrame *nextwindowframe;	/* next in list */
1205 
1206 	/* variables */
1207 	VARIABLE       *firstvar;				/* first variable in list */
1208 	INTSML          numvar;					/* number of variables in list */
1209 } WINDOWFRAME;
1210 
1211 extern WINDOWFRAME  *el_firstwindowframe;
1212 extern WINDOWFRAME  *el_curwindowframe;		/* current window frame */
1213 
1214 /******************** WINDOW PARTITION MODULES ********************/
1215 
1216 #define NOWINDOWPART      ((WINDOWPART *)-1)
1217 
1218 /* the meaning of WINDOWPART->state */
1219 #define GRIDON                     1		/* grid is to be displayed */
1220 #define GRIDTOOSMALL               2		/* grid is too small to display */
1221 #define WINDOWTYPE               070		/* type of this window */
1222 #define DISPWINDOW               010		/* this is a normal display window */
1223 #define TEXTWINDOW               020		/* this is a text editor window */
1224 #define POPTEXTWINDOW            030		/* this is a popup text editor window */
1225 #define WAVEFORMWINDOW           040		/* this is a signal waveform window */
1226 #define DISP3DWINDOW             050		/* this is a 3-D display window */
1227 #define OVERVIEWWINDOW           060		/* this is an overview window */
1228 #define EXPLORERWINDOW           070		/* this is an "explorer" window */
1229 #define HASOWNFRAME             0100		/* set if window was in its own frame */
1230 #define INPLACEQUEUEREDRAW      0200		/* set if in-place window should be redrawn */
1231 #define INPLACEEDIT             0400		/* set if window displays an "edit in place" */
1232 #define SURROUNDINPLACEEDIT    01000		/* set if window displaying surround of an "edit in place" */
1233 #define WINDOWMODE            016000		/* set if window is in a mode */
1234 #define WINDOWSIMMODE          02000		/*    simulation mode */
1235 #define WINDOWTECEDMODE        04000		/*    technology-edit mode */
1236 #define WINDOWOUTLINEEDMODE   010000		/*    outline-edit mode */
1237 
1238 #define WINDOWMODEBORDERSIZE       3		/* size of border when in a mode */
1239 #define DISPLAYSLIDERSIZE         12		/* size of sliders on the right and bottom */
1240 #define MAXINPLACEDEPTH           50		/* maximum edit-in-place hierarchical depth */
1241 
1242 /* the meaning of the second argument to "WINDOWPART->changehandler" */
1243 #define REPLACETEXTLINE            1
1244 #define DELETETEXTLINE             2
1245 #define INSERTTEXTLINE             3
1246 #define REPLACEALLTEXT             4
1247 
1248 typedef struct
1249 {
1250 	float     eye[3];				/* location of the viewer */
1251 	float     view[3];				/* what the viewer is looking at */
1252 	float     up[3];				/* which way is up */
1253 	float     fieldofview;			/* field of view (in degrees) */
1254 	float     nearplane, farplane;	/* near and far clipping planes */
1255 	float     screenx, screeny;		/* screen width and height */
1256 	float     aspect;				/* aspect ratio */
1257 	float     xform[4][4];			/* overall transformation matrix */
1258 } XFORM3D;
1259 
1260 typedef struct Iwindowpart
1261 {
1262 	INTBIG              uselx, usehx;		/* X: bounds of window drawing area */
1263 	INTBIG              usely, usehy;		/* Y: bounds of window drawing area */
1264 	INTBIG              screenlx,screenhx;	/* X: low and high of window */
1265 	INTBIG              screenly,screenhy;	/* Y: low and high of window */
1266 	INTBIG              framelx, framehx;	/* X: bounds of window frame (global coords) */
1267 	INTBIG              framely, framehy;	/* Y: bounds of window frame (global coords) */
1268 	INTBIG              thumblx, thumbhx;	/* X: bounds of slider thumb (DISPWINDOW) */
1269 	INTBIG              thumbly, thumbhy;	/* Y: bounds of slider thumb (DISPWINDOW) */
1270 	INTBIG              hratio, vratio;		/* percentage of overall when split */
1271 	float               scalex, scaley;		/* X and Y scale from window to drawing area */
1272 	XFORM3D             xf3;				/* 3D information (if DISP3DWINDOW) */
1273 	NODEPROTO          *curnodeproto;		/* cell in window */
1274 	NODEPROTO          *topnodeproto;		/* in-place edit: top cell in window */
1275 	INTBIG              inplacedepth;		/* in-place edit: depth of stack */
1276 	NODEINST           *inplacestack[MAXINPLACEDEPTH];	/* in-place edit: stack */
1277 	XARRAY              intocell;			/* in-place edit: transformation from screen to cell */
1278 	XARRAY              outofcell;			/* in-place edit: transformation from cell to screen */
1279 	INTBIG              gridx,gridy;		/* size of grid in window */
1280 	INTBIG              state;				/* miscellaneous state bits (see above) */
1281 	CHAR               *location;			/* string describing location */
1282 	WINDOWFRAME        *frame;				/* window frame that contains this */
1283 	EDITOR             *editor;				/* structures for editor in this window */
1284 	void               *expwindow;			/* structures for cell explorer in this window */
1285 	struct Iwindowpart *linkedwindowpart;	/* window associated with this */
1286 	BOOLEAN           (*charhandler)(struct Iwindowpart*, INTSML, INTBIG);					/* routine for characters in window */
1287 	void              (*buttonhandler)(struct Iwindowpart*, INTBIG, INTBIG, INTBIG);		/* routine for buttons in window */
1288 	void              (*changehandler)(struct Iwindowpart*, INTBIG, CHAR*, CHAR*, INTBIG);	/* routine for changes to window */
1289 	void              (*termhandler)(struct Iwindowpart*);									/* routine for termination of window */
1290 	void              (*redisphandler)(struct Iwindowpart*);								/* routine for redisplay of window */
1291 	struct Iwindowpart *nextwindowpart;		/* next window in list */
1292 	struct Iwindowpart *prevwindowpart;		/* previous window in list */
1293 
1294 	/* variables */
1295 	VARIABLE           *firstvar;			/* first variable in list */
1296 	INTSML              numvar;				/* number of variables in list */
1297 } WINDOWPART;
1298 
1299 extern WINDOWPART *el_topwindowpart;		/* top window in list */
1300 extern WINDOWPART *el_curwindowpart;		/* current window */
1301 
1302 /*************************** TECHNOLOGIES ****************************/
1303 
1304 /* ===== LAYER DESCRIPTIONS ===== */
1305 
1306 /* definition of a color value */
1307 typedef struct Itech_colormap
1308 {
1309 	INTSML       red, green, blue;			/* color values from 0 to 255 */
1310 } TECH_COLORMAP;
1311 
1312 /* the meaning of TECH_POLYGON->representation */
1313 #define POINTS                     0		/* list of scalable points */
1314 #define BOX                        1		/* a rectangle */
1315 #define ABSPOINTS                  2		/* list of absolute points */
1316 #define MINBOX                     3		/* minimum sized rectangle */
1317 
1318 /* the structure for layers of a node prototype */
1319 typedef struct Itech_polygon
1320 {
1321 	INTSML       layernum;					/* drawing layer in technology */
1322 	INTSML       portnum;					/* the port number in this technology */
1323 	INTSML       count;						/* number of points in polygon */
1324 	INTSML       style;						/* polygon style */
1325 	INTSML       representation;			/* see above list */
1326 	INTBIG      *points;					/* data list */
1327 } TECH_POLYGON;
1328 
1329 /* ===== ARC DESCRIPTIONS ===== */
1330 
1331 /* the structure for layers of an arc prototype */
1332 typedef struct Itech_arclay
1333 {
1334 	INTBIG       lay;						/* index of this layer */
1335 	INTBIG       off;						/* width offset for this layer */
1336 	INTBIG       style;						/* polygon style */
1337 } TECH_ARCLAY;
1338 
1339 /* the structure for an arc prototype */
1340 typedef struct Itech_arcs
1341 {
1342 	CHAR        *arcname;					/* layer name */
1343 	INTBIG       arcwidth;					/* default layer width */
1344 	INTBIG       arcindex;					/* index of this arcinst */
1345 	ARCPROTO    *creation;					/* actual arc prototype created for this */
1346 	INTBIG       laycount;					/* number of layers */
1347 	TECH_ARCLAY *list;						/* list of layers that compose arc */
1348 	UINTBIG      initialbits;				/* initial userbits for this arcproto */
1349 } TECH_ARCS;
1350 
1351 /* ===== PORT DESCRIPTIONS ===== */
1352 
1353 /* the structure for ports of a node prototype */
1354 typedef struct Itech_ports
1355 {
1356 	INTBIG      *portarcs;					/* allowable arcs (list ends with -1) */
1357 	CHAR        *protoname;					/* name of this port */
1358 	PORTPROTO   *addr;						/* address used by later routines */
1359 	UINTBIG      initialbits;				/* initial userbits for this port */
1360 	INTSML       lowxmul,  lowxsum;			/* defines low X of portinst area */
1361 	INTSML       lowymul,  lowysum;			/* defines low Y of portinst area */
1362 	INTSML       highxmul, highxsum;		/* defines high X of portinst area */
1363 	INTSML       highymul, highysum;		/* defines high Y of portinst area */
1364 } TECH_PORTS;
1365 
1366 /* ===== NODE DESCRIPTIONS ===== */
1367 
1368 /* the structure for serpentine MOS transistor description */
1369 typedef struct Itech_serpent
1370 {
1371 	TECH_POLYGON basics;					/* the basic information */
1372 	INTSML       lwidth;					/* the extension of width on the left */
1373 	INTSML       rwidth;					/* the extension of width on the right */
1374 	INTSML       extendt;					/* the extension of length on the top end */
1375 	INTSML       extendb;					/* the extension of length on the bottom end */
1376 } TECH_SERPENT;
1377 
1378 /* the meaning of TECH_NODES->special */
1379 #define SERPTRANS                  1		/* serpentine transistor */
1380 #define POLYGONAL                  2		/* polygonally defined transistor */
1381 #define MULTICUT                   3		/* multi-cut contact */
1382 #define MOSTRANS                   4		/* MOS transistor (nonserpentine) */
1383 
1384 /* the structure for a node prototype */
1385 typedef struct Itech_nodes
1386 {
1387 	CHAR         *nodename;
1388 	INTSML        nodeindex;
1389 	NODEPROTO    *creation;
1390 	INTBIG        xsize, ysize;
1391 	INTSML        portcount;
1392 	TECH_PORTS   *portlist;
1393 	INTSML        layercount;
1394 	TECH_POLYGON *layerlist;
1395 	INTBIG        initialbits;
1396 	INTSML        special;
1397 	INTSML        f1, f2, f3, f4, f5, f6;
1398 	TECH_SERPENT *gra, *ele;
1399 } TECH_NODES;
1400 
1401 /* ===== VARIABLE DESCRIPTIONS ===== */
1402 
1403 /* the structure for a variable */
1404 typedef struct Itech_variables
1405 {
1406 	CHAR *name;								/* attribute name to set */
1407 	CHAR  *value;							/* initial (address/integer) value for attribute */
1408 	float  fvalue;							/* initial (floating) value for attribute */
1409 	INTBIG type;							/* initial type of attribute */
1410 } TECH_VARIABLES;
1411 
1412 /* ===== MAIN STRUCTURE ===== */
1413 
1414 #define NOTECHNOLOGY ((TECHNOLOGY *)-1)
1415 
1416 /* the meaning of TECHNOLOGY->userbits */
1417 #define NONELECTRICAL             01		/* technology is not electrical  */
1418 #define NODIRECTIONALARCS         02		/* has no directional arcs */
1419 #define NONEGATEDARCS             04		/* has no negated arcs */
1420 #define NONSTANDARD              010		/* nonstandard technology (cannot be edited) */
1421 #define STATICTECHNOLOGY         020		/* statically allocated (don't deallocate memory) */
1422 #define NOPRIMTECHNOLOGY         040		/* no primitives in this technology (don't auto-switch to it) */
1423 
1424 /* scaling factor for fixed-point numbers (used in technologies) */
1425 #define WHOLE                    120
1426 
1427 typedef struct Itechnology
1428 {
1429 	CHAR               *techname;			/* name of this technology */
1430 	INTBIG              techindex;			/* 0-based index of this technology */
1431 	INTBIG              deflambda;			/* the default size of a unit */
1432 	NODEPROTO          *firstnodeproto;		/* list of primitive nodeprotos */
1433 	ARCPROTO           *firstarcproto;		/* pointer to type description */
1434 	VARIABLE           *firstvar;			/* first variable in list */
1435 	INTSML              numvar;				/* number of variables in list */
1436 	COMCOMP            *parse;				/* parsing structure for tech direction */
1437 	CLUSTER            *cluster;			/* virtual memory cluster for technology */
1438 	CHAR               *techdescript;		/* description of this technology */
1439 
1440 	INTBIG              layercount;			/* number of layers */
1441 	GRAPHICS          **layers;				/* layer descriptions */
1442 	INTBIG              arcprotocount;		/* number of arcs */
1443 	TECH_ARCS         **arcprotos;			/* raw data for arcs */
1444 	INTBIG              nodeprotocount;		/* number of nodes */
1445 	TECH_NODES        **nodeprotos;			/* raw data for nodes */
1446 	TECH_VARIABLES     *variables;			/* variable descriptions */
1447 
1448 	BOOLEAN           (*init)(struct Itechnology*, INTBIG);			/* process initialization */
1449 	void              (*term)(void);								/* completion */
1450 	void              (*setmode)(INTBIG, CHAR *[]);					/* set operation mode */
1451 	INTBIG            (*request)(CHAR*, va_list);					/* direct call options */
1452 
1453 	/* node description */
1454 	INTBIG            (*nodepolys)(NODEINST*, INTBIG*, WINDOWPART*);	/* returns total real polygons in node */
1455 	INTBIG            (*nodeEpolys)(NODEINST*, INTBIG*, WINDOWPART*);	/* returns total electrical polys in node */
1456 	void              (*shapenodepoly)(NODEINST*, INTBIG, POLYGON*);	/* returns real polygon shape in node */
1457 	void              (*shapeEnodepoly)(NODEINST*, INTBIG, POLYGON*);	/* returns electrical polygon shape in node */
1458 	INTBIG            (*allnodepolys)(NODEINST *ni, POLYLIST *plist, WINDOWPART*, BOOLEAN);	/* returns all real polygons in node */
1459 	INTBIG            (*allnodeEpolys)(NODEINST *ni, POLYLIST *plist, WINDOWPART*, BOOLEAN);	/* returns all electrical polygons in node */
1460 	void              (*nodesizeoffset)(NODEINST*, INTBIG*, INTBIG*, INTBIG*, INTBIG*);	/* returns offset to true size */
1461 
1462 	/* node port description */
1463 	void              (*shapeportpoly)(NODEINST*, PORTPROTO*, POLYGON*, XARRAY, BOOLEAN);/* returns port shape on a node */
1464 
1465 	/* arc description */
1466 	INTBIG            (*arcpolys)(ARCINST*, WINDOWPART*);			/* returns total polygons in arc */
1467 	void              (*shapearcpoly)(ARCINST*, INTBIG, POLYGON*);	/* returns polygon shape in arc */
1468 	INTBIG            (*allarcpolys)(ARCINST *ni, POLYLIST *plist, WINDOWPART*);	/* returns all polygons in arc */
1469 	INTBIG            (*arcwidthoffset)(ARCINST*);					/* returns offset to true width */
1470 
1471 	struct Itechnology *nexttechnology;		/* next in linked list */
1472 	UINTBIG             userbits;			/* state flags */
1473 	INTBIG              temp1, temp2;		/* temporaries */
1474 } TECHNOLOGY;
1475 
1476 extern TECHNOLOGY *el_technologies;			/* defined in "tectable.c" */
1477 extern TECHNOLOGY *el_curtech;				/* pointer to current technology */
1478 extern TECHNOLOGY *el_curlayouttech;		/* last layout technology referenced */
1479 extern INTBIG      el_maxtech;				/* current number of technologies */
1480 
1481 /*************************** CONSTRAINT SYSTEMS ****************************/
1482 
1483 #define NOCONSTRAINT ((CONSTRAINT *)-1)
1484 
1485 typedef struct Iconstraint
1486 {
1487 	CHAR     *conname;						/* constraint system name */
1488 	CHAR     *condesc;						/* constraint system description */
1489 	COMCOMP  *parse;						/* parsing structure for constraint direction */
1490 	CLUSTER  *cluster;						/* virtual memory cluster for constraint */
1491 	VARIABLE *firstvar;						/* first variable in list */
1492 	INTSML    numvar;						/* number of variables in list */
1493 	void    (*init)(struct Iconstraint*);	/* initialize a constraint system */
1494 	void    (*term)(void);					/* terminate a constraint system */
1495 	void    (*setmode)(INTBIG, CHAR*[]);	/* user-command options */
1496 	INTBIG  (*request)(CHAR*, INTBIG);		/* direct call options */
1497 	void    (*solve)(NODEPROTO*);			/* solve a batch of changes */
1498 
1499 	void    (*newobject)(INTBIG,INTBIG);				/* constraint newly created object */
1500 	void    (*killobject)(INTBIG,INTBIG);				/* constraint deleted object */
1501 	BOOLEAN (*setobject)(INTBIG,INTBIG,INTBIG,INTBIG);	/* set constraint properties on object */
1502 
1503 	void    (*modifynodeinst)(NODEINST*,INTBIG,INTBIG,INTBIG,INTBIG,INTBIG,INTBIG);		/* constrain a modified node instance */
1504 	void    (*modifynodeinsts)(INTBIG,NODEINST**,INTBIG*,INTBIG*,INTBIG*,INTBIG*,INTBIG*,INTBIG*);	/* constrain a modified node instances */
1505 	void    (*modifyarcinst)(ARCINST*, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);	/* constrain a modified arc instance */
1506 	void    (*modifyportproto)(PORTPROTO*, NODEINST*, PORTPROTO*);				/* constrain a modified port prototype */
1507 	void    (*modifynodeproto)(NODEPROTO*);										/* constrain a modified node prototype */
1508 	void    (*modifydescript)(INTBIG, INTBIG, INTBIG, UINTBIG*);				/* constrain a modified descriptor */
1509 
1510 	void    (*newlib)(LIBRARY*);			/* constrain a newly created library */
1511 	void    (*killlib)(LIBRARY*);			/* constrain a deleted library */
1512 
1513 	void    (*newvariable)(INTBIG, INTBIG, INTBIG, INTBIG);						/* constrain a newly created variable */
1514 	void    (*killvariable)(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, UINTBIG*);	/* constrain a deleted variable */
1515 	void    (*modifyvariable)(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);	/* constrain a modified array variable entry */
1516 	void    (*insertvariable)(INTBIG, INTBIG, INTBIG, INTBIG);					/* constrain an inserted array variable entry */
1517 	void    (*deletevariable)(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);			/* constrain a deleted array variable entry */
1518 	void    (*setvariable)(void);												/* set constraint properties on variable */
1519 } CONSTRAINT;
1520 
1521 extern CONSTRAINT *el_curconstraint;		/* current constraint solver */
1522 extern CONSTRAINT  el_constraints[];		/* list of constraint solvers */
1523 
1524 /*************************** LISTS ****************************/
1525 
1526 /* extendable lists of INTBIG */
1527 typedef struct
1528 {
1529 	INTBIG  *list;			/* the list of INTBIG */
1530 	INTBIG   count;			/* number of entries in the list */
1531 	INTBIG   total;			/* number of entries allocated for the list */
1532 	CLUSTER *cluster;		/* memory cluster for this list */
1533 } LISTINTBIG;
1534 
1535 LISTINTBIG *newintlistobj(CLUSTER *clus);
1536 void        killintlistobj(LISTINTBIG *li);
1537 void        clearintlistobj(LISTINTBIG *li);
1538 INTBIG     *getintlistobj(LISTINTBIG *li, INTBIG *count);
1539 BOOLEAN     ensureintlistobj(LISTINTBIG *li, INTBIG needed);
1540 BOOLEAN     addtointlistobj(LISTINTBIG *li, INTBIG value, BOOLEAN unique);
1541 
1542 
1543 /* extendable strings */
1544 typedef struct
1545 {
1546 	CHAR    *string;		/* the string */
1547 	INTBIG   count;			/* number of characters in the string */
1548 	INTBIG   total;			/* number of characters allocated for the string */
1549 	CLUSTER *cluster;		/* memory cluster for this string */
1550 } STRINGOBJ;
1551 
1552 STRINGOBJ *newstringobj(CLUSTER *clus);
1553 void       killstringobj(STRINGOBJ *so);
1554 void       clearstringobj(STRINGOBJ *so);
1555 CHAR      *getstringobj(STRINGOBJ *so);
1556 void       addstringtostringobj(CHAR *string, STRINGOBJ *so);
1557 
1558 /*************************** MISCELLANEOUS ****************************/
1559 
1560 #define REGISTER            register
1561 #define EPI               3.14159265		/* Pi */
1562 #define NOSTRING        ((CHAR *)-1)
1563 #define FARTEXTLIMIT              20		/* distance (in lambda) of "far text" */
1564 #define DEFTECH             x_("mocmos")		/* default technology */
1565 #define DEFCONSTR           x_("layout")		/* default constraint system */
1566 #define MINIMUMTEXTSIZE            6		/* minimum text size (smaller text not drawn) */
1567 
1568 /* the sounds available to "ttybeep()" */
1569 #define SOUNDBEEP                  0		/* standard "beep" sound */
1570 #define SOUNDCLICK                 1		/* a subtle "click" sound for wiring */
1571 
1572 /* the meaning of "el_units" */
1573 #define DISPLAYUNITS             017		/* the display units */
1574 #define DISPUNITLAMBDA             0		/*   lambda display (12.3) */
1575 #define DISPUNITINCH              01		/*   inch display (12.3") */
1576 #define DISPUNITCM                02		/*   centimeter display (12.3cm) */
1577 #define DISPUNITMM                04		/*   millimeter display (12.3mm) */
1578 #define DISPUNITMIL              010		/*   mil display (12.3mil) */
1579 #define DISPUNITMIC              011		/*   micron display (12.3u) */
1580 #define DISPUNITCMIC             012		/*   centimicron display (12.3cu) */
1581 #define DISPUNITNM               013		/*   nanometer (millimicron) display (12.3nm) */
1582 #define INTERNALUNITS           0160		/* the internal units */
1583 #define INTERNALUNITSSH            4		/* right shift for INTERNALUNITS */
1584 #define INTUNITHNM                 0		/*   half-nanometer (half millimicron) units */
1585 #define INTUNITHDMIC             020		/*   half-decimicron units */
1586 
1587 /* the meaning of "USER_electrical_units" on USER tool and LIBRARY */
1588 #define INTERNALRESUNITS          017		/* the internal resistance units */
1589 #define INTERNALRESUNITSSH          0		/* right shift for INTERNALRESUNITS */
1590 #define INTRESUNITOHM               0		/*   ohm */
1591 #define INTRESUNITKOHM              1		/*   kilo-ohm */
1592 #define INTRESUNITMOHM              2		/*   mega-ohm */
1593 #define INTRESUNITGOHM              3		/*   giga-ohm */
1594 #define INTERNALCAPUNITS         0360		/* the internal capacitance units */
1595 #define INTERNALCAPUNITSSH          4		/* right shift for INTERNALCAPUNITS */
1596 #define INTCAPUNITFARAD             0		/*   farad */
1597 #define INTCAPUNITMFARAD            1		/*   milli-farad */
1598 #define INTCAPUNITUFARAD            2		/*   micro-farad */
1599 #define INTCAPUNITNFARAD            3		/*   nano-farad */
1600 #define INTCAPUNITPFARAD            4		/*   pico-farad */
1601 #define INTCAPUNITFFARAD            5		/*   femto-farad */
1602 #define INTERNALINDUNITS        07400		/* the internal inductance units */
1603 #define INTERNALINDUNITSSH          8		/* right shift for INTERNALINDUNITS */
1604 #define INTINDUNITHENRY             0		/*   henry */
1605 #define INTINDUNITMHENRY            1		/*   milli-henry */
1606 #define INTINDUNITUHENRY            2		/*   micro-henry */
1607 #define INTINDUNITNHENRY            3		/*   nano-henry */
1608 #define INTERNALCURUNITS      0170000		/* the internal current units */
1609 #define INTERNALCURUNITSSH         12		/* right shift for INTERNALCURUNITS */
1610 #define INTCURUNITAMP               0		/*   amp */
1611 #define INTCURUNITMAMP              1		/*   milli-amp */
1612 #define INTCURUNITUAMP              2		/*   micro-amp */
1613 #define INTERNALVOLTUNITS    03600000		/* the internal voltage units */
1614 #define INTERNALVOLTUNITSSH        16		/* right shift for INTERNALVOLTUNITS */
1615 #define INTVOLTUNITKVOLT            0		/*   kilo-volt */
1616 #define INTVOLTUNITVOLT             1		/*   volt */
1617 #define INTVOLTUNITMVOLT            2		/*   milli-volt */
1618 #define INTVOLTUNITUVOLT            3		/*   micro-volt */
1619 #define INTERNALTIMEUNITS   074000000		/* the internal time units */
1620 #define INTERNALTIMEUNITSSH        20		/* right shift for INTERNALTIMEUNITS */
1621 #define INTTIMEUNITSEC              0		/*   second */
1622 #define INTTIMEUNITMSEC             1		/*   milli-second */
1623 #define INTTIMEUNITUSEC             2		/*   micro-second */
1624 #define INTTIMEUNITNSEC             3		/*   nano-second */
1625 #define INTTIMEUNITPSEC             4		/*   pico-second */
1626 #define INTTIMEUNITFSEC             5		/*   femto-second */
1627 #define ELEUNITDEFAULT          (INTRESUNITOHM<<INTERNALRESUNITSSH)|\
1628 								(INTCAPUNITPFARAD<<INTERNALCAPUNITSSH)|\
1629 								(INTINDUNITNHENRY<<INTERNALINDUNITSSH)|\
1630 								(INTCURUNITMAMP<<INTERNALCURUNITSSH)|\
1631 								(INTVOLTUNITVOLT<<INTERNALVOLTUNITSSH)|\
1632 								(INTTIMEUNITSEC<<INTERNALTIMEUNITSSH)
1633 
1634 /*
1635  * reasons for aborting (the argument to "stopping()")
1636  * (update table "dbtext.c:db_stoppingreason[]" when changing this)
1637  */
1638 #define STOPREASONCONTOUR          0		/* "Contour gather" */
1639 #define STOPREASONDRC              1		/* "DRC" */
1640 #define STOPREASONPLAYBACK         2		/* "Playback" */
1641 #define STOPREASONBINARY           3		/* "Binary" */
1642 #define STOPREASONCIF              4		/* "CIF" */
1643 #define STOPREASONDXF              5		/* "DXF" */
1644 #define STOPREASONEDIF             6		/* "EDIF" */
1645 #define STOPREASONVHDL             7		/* "VHDL" */
1646 #define STOPREASONCOMPACT          8		/* "Compaction" */
1647 #define STOPREASONERC              9		/* "ERC" */
1648 #define STOPREASONCHECKIN         10		/* "Check-in" */
1649 #define STOPREASONLOCK            11		/* "Lock wait" */
1650 #define STOPREASONNCC             12		/* "Network comparison" */
1651 #define STOPREASONPORT            13		/* "Port exploration" */
1652 #define STOPREASONROUTING         14		/* "Routing" */
1653 #define STOPREASONSILCOMP         15		/* "Silicon compiler" */
1654 #define STOPREASONDISPLAY         16		/* "Display" */
1655 #define STOPREASONSIMULATE        17		/* "Simulation" */
1656 #define STOPREASONDECK            18		/* "Deck generation" */
1657 #define STOPREASONSPICE           19		/* "SPICE" */
1658 #define STOPREASONCHECK           20		/* "Check" */
1659 #define STOPREASONARRAY           21		/* "Array" */
1660 #define STOPREASONITERATE         22		/* "Iteration" */
1661 #define STOPREASONREPLACE         23		/* "Replace" */
1662 #define STOPREASONSPREAD          24		/* "Spread" */
1663 #define STOPREASONEXECUTE         25		/* "Execution" */
1664 #define STOPREASONCOMFILE         26		/* "Command file" */
1665 #define STOPREASONSELECT          27		/* "Selection" */
1666 #define STOPREASONTRACK           28		/* "Tracking" */
1667 #define STOPREASONNETWORK         29		/* "Network evaluation" */
1668 
1669 /* special key meanings, found in "ttygetchar()", "getnxtchar()", "getbuckybits()" */
1670 #define SHIFTDOWN                 01		/* set if Shift held down */
1671 #define CONTROLDOWN               02		/* set if Control held down */
1672 #define OPTALTMETDOWN             04		/* set if Option/Alt/Meta held down */
1673 #define COMMANDDOWN              010		/* set if Command held down (Mac only) */
1674 #define ACCELERATORDOWN          020		/* set if accelerator key (Command or Control) held down */
1675 #define SPECIALKEYDOWN           040		/* set if this is a special key */
1676 #define SPECIALKEY             07700		/* the special key typed */
1677 #define SPECIALKEYSH               6		/* right-shift of SPECIALKEY */
1678 #define SPECIALKEYF1               1		/*    Function key F1 */
1679 #define SPECIALKEYF2               2		/*    Function key F2 */
1680 #define SPECIALKEYF3               3		/*    Function key F3 */
1681 #define SPECIALKEYF4               4		/*    Function key F4 */
1682 #define SPECIALKEYF5               5		/*    Function key F5 */
1683 #define SPECIALKEYF6               6		/*    Function key F6 */
1684 #define SPECIALKEYF7               7		/*    Function key F7 */
1685 #define SPECIALKEYF8               8		/*    Function key F8 */
1686 #define SPECIALKEYF9               9		/*    Function key F9 */
1687 #define SPECIALKEYF10             10		/*    Function key F10 */
1688 #define SPECIALKEYF11             11		/*    Function key F11 */
1689 #define SPECIALKEYF12             12		/*    Function key F12 */
1690 #define SPECIALKEYARROWL          13		/*    Left arrow key */
1691 #define SPECIALKEYARROWR          14		/*    Right arrow key */
1692 #define SPECIALKEYARROWU          15		/*    Up arrow key */
1693 #define SPECIALKEYARROWD          16		/*    Down arrow key */
1694 #define SPECIALEND                17		/*    END key */
1695 #define SPECIALCUT                18		/*    Cut key */
1696 #define SPECIALCOPY               19		/*    Copy key */
1697 #define SPECIALPASTE              20		/*    Paste key */
1698 #define SPECIALUNDO               21		/*    Undo key */
1699 
1700 /*
1701  * the "filetype" parameter in "multifileselectin", "describefiletype",
1702  * "setupfiletype", "getfiletype", "xopen", "xcreate"
1703  */
1704 #define FILETYPE               01777		/* type of file */
1705 #define FILETYPEWRITE          02000		/* bit set to write file (instead of read) */
1706 #define FILETYPEAPPEND         04000		/* bit set to append to file (instead of read) */
1707 #define FILETYPETEMPFILE      010000		/* bit set to generate temp filename (write only) */
1708 
1709 /* the "purpose" parameter (cursor shape) for "trackcursor()" */
1710 #define TRACKNORMAL                0		/* standard cursor */
1711 #define TRACKDRAWING               1		/* pen cursor */
1712 #define TRACKDRAGGING              2		/* hand cursor */
1713 #define TRACKSELECTING             3		/* horizontal arrow cursor */
1714 #define TRACKHSELECTING            4		/* arrow cursor */
1715 
1716 extern XARRAY      el_matid;				/* identity matrix */
1717 extern INTBIG      el_pleasestop;			/* nonzero if abort is requested */
1718 extern INTBIG      el_units;				/* display and internal units */
1719 extern CHAR       *el_libdir;				/* pointer to library directory */
1720 extern CHAR       *el_version;				/* current version string */
1721 extern INTBIG      el_filetypetext;			/* plain text disk file descriptor */
1722 
1723 /*************************** DECLARATIONS ****************************/
1724 
1725 /* node routines */
1726 NODEINST    *newnodeinst(NODEPROTO *proto, INTBIG lowx, INTBIG highx, INTBIG lowy, INTBIG highy,
1727 				INTBIG transposition, INTBIG rotation, NODEPROTO *parent);
1728 BOOLEAN      killnodeinst(NODEINST *ni);
1729 void         defaultnodesize(NODEPROTO *np, INTBIG *xs, INTBIG *ys);
1730 void         modifynodeinst(NODEINST *node, INTBIG Dlx, INTBIG Dly, INTBIG Dhx,
1731 				INTBIG Dhy, INTBIG Drotation, INTBIG Dtransposition);
1732 void         modifynodeinsts(INTBIG count, NODEINST **nis, INTBIG *deltalxs, INTBIG *deltalys,
1733 				INTBIG *deltahxs, INTBIG *deltahys, INTBIG *deltarots, INTBIG *deltatranss);
1734 NODEINST    *replacenodeinst(NODEINST *oldnode, NODEPROTO *newproto, BOOLEAN ignoreportnames,
1735 				BOOLEAN allowdeletedports);
1736 INTBIG       nodepolys(NODEINST *ni, INTBIG *reasonable, WINDOWPART *win);
1737 void         shapenodepoly(NODEINST *ni, INTBIG box, POLYGON *poly);
1738 INTBIG       allnodepolys(NODEINST *ni, POLYLIST *plist, WINDOWPART *win, BOOLEAN reasonable);
1739 INTBIG       nodeEpolys(NODEINST *ni, INTBIG *reasonable, WINDOWPART *win);
1740 void         shapeEnodepoly(NODEINST *ni, INTBIG box, POLYGON *poly);
1741 INTBIG       allnodeEpolys(NODEINST *ni, POLYLIST *plist, WINDOWPART *win, BOOLEAN reasonable);
1742 void         nodesizeoffset(NODEINST *ni, INTBIG *lowx, INTBIG *lowy, INTBIG *highx, INTBIG *highy);
1743 void         nodeprotosizeoffset(NODEPROTO *np, INTBIG *lowx, INTBIG *lowy, INTBIG *highx, INTBIG *highy, NODEPROTO *parent);
1744 INTBIG       nodefunction(NODEINST *ni);
1745 CHAR        *nodefunctionname(INTBIG function, NODEINST *ni);
1746 CHAR        *nodefunctionshortname(INTBIG function);
1747 CHAR        *nodefunctionconstantname(INTBIG function);
1748 CHAR        *describenodeinst(NODEINST *ni);
1749 CHAR        *ntdescribenodeinst(NODEINST *ni);
1750 void         transistorsize(NODEINST *ni, INTBIG *length, INTBIG *width);
1751 void         getarcdegrees(NODEINST *ni, double *startoffset, double *endangle);
1752 void         setarcdegrees(NODEINST *ni, double startoffset, double endangle);
1753 void         getarcendpoints(NODEINST *ni, double startoffset, double endangle, INTBIG *fx, INTBIG *fy,
1754 				INTBIG *tx, INTBIG *ty);
1755 void         transistorports(NODEINST *ni, PORTPROTO **gateleft, PORTPROTO **gateright,
1756 				PORTPROTO **activetop, PORTPROTO **activebottom);
1757 INTBIG       lambdaofnode(NODEINST *ni);
1758 VARIABLE    *gettrace(NODEINST *ni);
1759 void         corneroffset(NODEINST *ni, NODEPROTO *proto, INTBIG rotation, INTBIG transpose,
1760 				INTBIG *xoff, INTBIG *yoff, BOOLEAN centerbased);
1761 void         initdummynode(NODEINST *ni);
1762 BOOLEAN      isfet(GEOM *pos);
1763 NODEPROTO   *getpurelayernode(TECHNOLOGY *tech, INTBIG layer, INTBIG function);
1764 void         drcminnodesize(NODEPROTO *np, LIBRARY *lib, INTBIG *sizex, INTBIG *sizey, CHAR **rule);
1765 BOOLEAN      invisiblepinwithoffsettext(NODEINST *ni, INTBIG *x, INTBIG *y, BOOLEAN repair);
1766 BOOLEAN      isinlinepin(NODEINST *ni, ARCINST ***ailist);
1767 
1768 /* arc routines */
1769 ARCINST     *newarcinst(ARCPROTO *proto, INTBIG width, INTBIG initialuserbits, NODEINST *nodeA,
1770 				PORTPROTO *portA, INTBIG xA, INTBIG yA, NODEINST *nodeB, PORTPROTO *portB,
1771 				INTBIG xB, INTBIG yB, NODEPROTO *parent);
1772 BOOLEAN      killarcinst(ARCINST *arc);
1773 INTBIG       defaultarcwidth(ARCPROTO *ap);
1774 BOOLEAN      modifyarcinst(ARCINST *arc, INTBIG Dwidth, INTBIG Dx1, INTBIG Dy1, INTBIG Dx2, INTBIG Dy2);
1775 ARCINST     *aconnect(GEOM *fromgeom, PORTPROTO *fromport, GEOM *togeom, PORTPROTO *toport,
1776 				ARCPROTO *arc, INTBIG x, INTBIG y, ARCINST **arc2, ARCINST **arc3,
1777 				NODEINST **con1, NODEINST **con2, INTBIG ang, BOOLEAN nozigzag, BOOLEAN report);
1778 ARCINST     *replacearcinst(ARCINST *oldarc, ARCPROTO *newproto);
1779 INTBIG       arcpolys(ARCINST *arc, WINDOWPART *win);
1780 void         shapearcpoly(ARCINST *arc, INTBIG box, POLYGON *poly);
1781 INTBIG       allarcpolys(ARCINST *arc, POLYLIST *plist, WINDOWPART *win);
1782 CHAR        *arcfunctionname(INTBIG function);
1783 CHAR        *describearcinst(ARCINST *arc);
1784 CHAR        *describearcproto(ARCPROTO *arcproto);
1785 ARCPROTO    *getarcproto(CHAR *specification);
1786 INTBIG       arcwidthoffset(ARCINST *arc);
1787 INTBIG       arcprotowidthoffset(ARCPROTO *arc);
1788 NODEPROTO   *getpinproto(ARCPROTO *arc);
1789 void         makearcpoly(INTBIG length, INTBIG width, ARCINST *arc, POLYGON *poly, INTBIG style);
1790 BOOLEAN      curvedarcoutline(ARCINST *arc, POLYGON *poly, INTBIG style, INTBIG width);
1791 INTBIG       setshrinkvalue(ARCINST *arc, BOOLEAN extend);
1792 void         determineangle(ARCINST *arc);
1793 INTBIG       lambdaofarc(ARCINST *ai);
1794 BOOLEAN      arcconnects(INTBIG ang, INTBIG lx1, INTBIG hx1, INTBIG ly1, INTBIG hy1, INTBIG lx2, INTBIG hx2,
1795 				INTBIG ly2, INTBIG hy2, INTBIG *x1, INTBIG *y1, INTBIG *x2, INTBIG *y2);
1796 void         initdummyarc(ARCINST *ai);
1797 ARCPROTO    *getarconlayer(INTBIG layer, TECHNOLOGY *tech);
1798 
1799 /* cell routines */
1800 NODEPROTO   *newnodeproto(CHAR *name, LIBRARY *library);
1801 BOOLEAN      killnodeproto(NODEPROTO *cell);
1802 NODEPROTO   *copynodeproto(NODEPROTO *originalcell, LIBRARY *destlibrary, CHAR *name, BOOLEAN useexisting);
1803 NODEPROTO   *getnodeproto(CHAR *specification);
1804 CHAR        *describenodeproto(NODEPROTO *nodeproto);
1805 CHAR        *nldescribenodeproto(NODEPROTO *nodeproto);
1806 void         grabpoint(NODEPROTO *nodeproto, INTBIG *grabx, INTBIG *graby);
1807 BOOLEAN      isachildof(NODEPROTO *parent, NODEPROTO *child);
1808 INTBIG       framesize(INTBIG *x, INTBIG *y, NODEPROTO *np);
1809 INTBIG       framepolys(NODEPROTO *np);
1810 void         framepoly(INTBIG box, POLYGON *poly, NODEPROTO *np);
1811 void         begintraversehierarchy(void);
1812 void         endtraversehierarchy(void);
1813 void         downhierarchy(NODEINST *ni, NODEPROTO *np, INTBIG index);
1814 void         uphierarchy(void);
1815 void         popouthierarchy(INTBIG climb);
1816 INTBIG       getpopouthierarchy(void);
1817 void         sethierarchicalparent(NODEPROTO *np, NODEINST *parentni, WINDOWPART *win, INTBIG thisindex, INTBIG *viewinfo);
1818 void         gettraversalpath(NODEPROTO *here, WINDOWPART *win, NODEINST ***nilist, INTBIG **indexlist, INTBIG *depth, INTBIG maxdepth);
1819 NODEPROTO   *getcurcell(void);
1820 INTBIG       lambdaofcell(NODEPROTO *np);
1821 BOOLEAN      hasresistors(NODEPROTO *np);
1822 NODEINST    *descentparent(NODEPROTO *np, INTBIG *index, WINDOWPART *win, INTBIG *viewinfo);
1823 void        *newhierarchicaltraversal(void);
1824 void         gethierarchicaltraversal(void *snapshot);
1825 void         sethierarchicaltraversal(void *snapshot);
1826 void         killhierarchicaltraversal(void *snapshot);
1827 
1828 /* cell routines */
1829 void         initparameterizedcells(void);
1830 CHAR        *inparameterizedcells(NODEPROTO *np, CHAR *parname);
1831 void         addtoparameterizedcells(NODEPROTO *np, CHAR *parname, CHAR *shortname);
1832 CHAR        *parameterizedname(NODEINST *ni, CHAR *cellname);
1833 
1834 /* export routines */
1835 PORTPROTO   *newportproto(NODEPROTO *cell, NODEINST *nodeincell, PORTPROTO *portinnode, CHAR *name);
1836 BOOLEAN      killportproto(NODEPROTO *cell, PORTPROTO *port);
1837 BOOLEAN      moveportproto(NODEPROTO *cell, PORTPROTO *port, NODEINST *newnode, PORTPROTO *newnodeport);
1838 PORTPROTO   *getportproto(NODEPROTO *cell, CHAR *portname);
1839 void         shapeportpoly(NODEINST *node, PORTPROTO *port, POLYGON *poly, BOOLEAN purpose);
1840 void         shapetransportpoly(NODEINST *node, PORTPROTO *port, POLYGON *poly, XARRAY trans);
1841 void         portposition(NODEINST *node, PORTPROTO *port, INTBIG *x, INTBIG *y);
1842 void         reduceportpoly(POLYGON *poly, NODEINST *node, PORTPROTO *port, INTBIG width, INTBIG angle);
1843 PORTPROTO   *equivalentport(NODEPROTO *cell, PORTPROTO *port, NODEPROTO *equivalentcell);
1844 BOOLEAN      portispower(PORTPROTO *port);
1845 BOOLEAN      portisground(PORTPROTO *port);
1846 BOOLEAN      portisnamedpower(PORTPROTO *port);
1847 BOOLEAN      portisnamedground(PORTPROTO *port);
1848 void         changeallports(PORTPROTO *port);
1849 CHAR        *describeportbits(INTBIG userbits);
1850 
1851 /* view routines */
1852 VIEW        *newview(CHAR *viewname, CHAR *abbreviation);
1853 BOOLEAN      killview(VIEW *view);
1854 BOOLEAN      changecellview(NODEPROTO *cell, VIEW *view);
1855 VIEW        *getview(CHAR *specification);
1856 NODEPROTO   *contentsview(NODEPROTO *cell);
1857 NODEPROTO   *iconview(NODEPROTO *cell);
1858 BOOLEAN     insamecellgrp(NODEPROTO *a, NODEPROTO *b);
1859 BOOLEAN      isiconof(NODEPROTO *subnp, NODEPROTO *cell);
1860 NODEPROTO   *layoutview(NODEPROTO *cell);
1861 NODEPROTO   *anyview(NODEPROTO *cell, VIEW *v);
1862 BOOLEAN      isschematicview(NODEPROTO *cell);
1863 BOOLEAN      isiconview(NODEPROTO *cell);
1864 
1865 /* window routines */
1866 WINDOWPART  *newwindowpart(CHAR *location, WINDOWPART *protowindow);
1867 void         killwindowpart(WINDOWPART *window);
1868 void         copywindowpart(WINDOWPART *dwindow, WINDOWPART *swindow);
1869 INTBIG       truefontsize(INTBIG font, WINDOWPART *window, TECHNOLOGY *tech);
1870 void         computewindowscale(WINDOWPART *window);
1871 INTBIG       applyxscale(WINDOWPART *window, INTBIG value);
1872 INTBIG       applyyscale(WINDOWPART *window, INTBIG value);
1873 
1874 /* variable routines */
1875 VARIABLE    *getval(INTBIG addr, INTBIG  type, INTBIG want, CHAR *name);
1876 VARIABLE    *getvalkey(INTBIG addr, INTBIG type, INTBIG want, INTBIG key);
1877 VARIABLE    *getvalnoeval(INTBIG addr, INTBIG  type, INTBIG want, CHAR *name);
1878 VARIABLE    *getvalkeynoeval(INTBIG addr, INTBIG type, INTBIG want, INTBIG key);
1879 VARIABLE    *evalvar(VARIABLE *var, INTBIG addr, INTBIG type);
1880 VARIABLE    *getparentval(CHAR *name, INTBIG height);
1881 VARIABLE    *getparentvalkey(INTBIG key, INTBIG height);
1882 BOOLEAN      parentvaldefaulted(void);
1883 WINDOWPART  *setvariablewindow(WINDOWPART *win);
1884 BOOLEAN      getcurrentvariableenvironment(INTBIG *addr, INTBIG *type, WINDOWPART **win);
1885 BOOLEAN      getlastvariableobject(INTBIG *addr, INTBIG *type);
1886 #ifdef DEBUGMEMORY
1887 #  define    setval(a, t, n, na, nt) _setval((a), (t), (n), (na), (nt), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
1888   VARIABLE *_setval(INTBIG addr, INTBIG type, CHAR *name, INTBIG newaddr, INTBIG newtype, CHAR*, INTBIG);
1889 #  define    setvalkey(a, t, k, na, nt) _setvalkey((a), (t), (k), (na), (nt), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
1890   VARIABLE *_setvalkey(INTBIG addr, INTBIG type, INTBIG key, INTBIG newaddr, INTBIG newtype, CHAR*, INTBIG);
1891 #  define    setind(a, t, n, i, na) _setind((a), (t), (n), (i), (na), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
1892   BOOLEAN   _setind(INTBIG addr, INTBIG type, CHAR *name, INTBIG aindex, INTBIG newaddr, CHAR*, INTBIG);
1893 #  define    setindkey(a, t, k, i, na) _setindkey((a), (t), (k), (i), (na), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
1894   BOOLEAN   _setindkey(INTBIG addr, INTBIG type, INTBIG key, INTBIG aindex, INTBIG newaddr, CHAR*, INTBIG);
1895 #else
1896   VARIABLE  *setval(INTBIG addr, INTBIG type, CHAR *name, INTBIG newaddr, INTBIG newtype);
1897   VARIABLE  *setvalkey(INTBIG addr, INTBIG type, INTBIG key, INTBIG newaddr, INTBIG newtype);
1898   BOOLEAN    setind(INTBIG addr, INTBIG type, CHAR *name, INTBIG aindex, INTBIG newaddr);
1899   BOOLEAN    setindkey(INTBIG addr, INTBIG type, INTBIG key, INTBIG aindex, INTBIG newaddr);
1900 #endif
1901 BOOLEAN      delval(INTBIG addr, INTBIG type, CHAR *name);
1902 BOOLEAN      delvalkey(INTBIG addr, INTBIG type, INTBIG key);
1903 BOOLEAN      getind(INTBIG addr, INTBIG type, CHAR *name, INTBIG aindex, INTBIG *value);
1904 BOOLEAN      getindkey(INTBIG addr, INTBIG type, INTBIG key, INTBIG aindex, INTBIG *value);
1905 BOOLEAN      insind(INTBIG addr, INTBIG type, CHAR *name, INTBIG aindex, INTBIG newaddr);
1906 BOOLEAN      insindkey(INTBIG addr, INTBIG type, INTBIG key, INTBIG aindex, INTBIG newaddr);
1907 BOOLEAN      delind(INTBIG addr, INTBIG type, CHAR *name, INTBIG aindex);
1908 BOOLEAN      delindkey(INTBIG addr, INTBIG type, INTBIG key, INTBIG aindex);
1909 void         renameval(CHAR *oldname, CHAR *newname);
1910 INTBIG       makekey(CHAR *name);
1911 CHAR        *makename(INTBIG key);
1912 INTBIG       initobjlist(INTBIG addr, INTBIG type, BOOLEAN restrictdirect);
1913 CHAR        *nextobjectlist(VARIABLE **var, INTBIG search);
1914 BOOLEAN      copyvars(INTBIG fromaddr, INTBIG fromtype, INTBIG toaddr, INTBIG totype, BOOLEAN uniquenames);
1915 void         modifydescript(INTBIG addr, INTBIG type, VARIABLE *var, UINTBIG *newdescript);
1916 INTBIG       getlength(VARIABLE *var);
1917 CHAR        *describeobject(INTBIG addr, INTBIG type);
1918 CHAR        *describevariable(VARIABLE *var, INTBIG aindex, INTBIG purpose);
1919 CHAR        *describedisplayedvariable(VARIABLE *var, INTBIG aindex, INTBIG purpose);
1920 CHAR        *describesimplevariable(VARIABLE *var);
1921 void         getsimpletype(CHAR *pt, INTBIG *type, INTBIG *addr, INTBIG units);
1922 void         cacheoptionbitvalues(void);
1923 void         makeoptionstemporary(LIBRARY *lib);
1924 void         restoreoptionstate(LIBRARY *lib);
1925 BOOLEAN      isoptionvariable(INTBIG addr, INTBIG type, CHAR *name);
1926 BOOLEAN      optionshavechanged(void);
1927 BOOLEAN      describeoptions(INTBIG aindex, CHAR **name, INTBIG *bits);
1928 void         explainoptionchanges(INTBIG item, void *dia);
1929 void         explainsavedoptions(INTBIG item, BOOLEAN onlychanged, void *dia);
1930 CHAR        *truevariablename(VARIABLE *var);
1931 void         listalloptions(INTBIG item, void *dia);
1932 BOOLEAN      isdeprecatedvariable(INTBIG addr, INTBIG type, CHAR *name);
1933 
1934 /* change control routines */
1935 void         startobjectchange(INTBIG address, INTBIG type);
1936 void         endobjectchange(INTBIG address, INTBIG type);
1937 INTBIG       undonature(BOOLEAN undo);
1938 INTBIG       undoabatch(TOOL **tool);
1939 INTBIG       redoabatch(TOOL **tool);
1940 void         noundoallowed(void);
1941 void         noredoallowed(void);
1942 INTBIG       historylistsize(INTBIG newsize);
1943 void         setactivity(CHAR *message);
1944 void         showhistorylist(INTBIG batch);
1945 CHAR        *changedvariablename(INTBIG type, INTBIG key, INTBIG subtype);
1946 INTBIG       getcurrentbatchnumber(void);
1947 void         nextchangequiet(void);
1948 void         changesquiet(BOOLEAN quiet);
1949 
1950 /* layer routines */
1951 CHAR        *layername(TECHNOLOGY *tech, INTBIG layer);
1952 INTBIG       layerfunction(TECHNOLOGY *tech, INTBIG layer);
1953 BOOLEAN      layerismetal(INTBIG fun);
1954 BOOLEAN      layerispoly(INTBIG fun);
1955 BOOLEAN      layerisgatepoly(INTBIG fun);
1956 BOOLEAN      layeriscontact(INTBIG fun);
1957 INTBIG       layerfunctionheight(INTBIG layerfunct);
1958 BOOLEAN      samelayer(TECHNOLOGY *tech, INTBIG layer1, INTBIG layer2);
1959 INTBIG       nonpseudolayer(INTBIG layer, TECHNOLOGY *tech);
1960 INTBIG       maxdrcsurround(TECHNOLOGY *tech, LIBRARY *lib, INTBIG layer);
1961 INTBIG       drcmindistance(TECHNOLOGY *tech, LIBRARY *lib, INTBIG layer1, INTBIG size1,
1962 				INTBIG layer2, INTBIG size2, BOOLEAN connected, BOOLEAN multicut, INTBIG *edge,
1963 				CHAR **rule);
1964 INTBIG       drcminwidth(TECHNOLOGY *tech, LIBRARY *lib, INTBIG layer, CHAR **rule);
1965 INTBIG       getecolor(CHAR *colorname);
1966 BOOLEAN      ecolorname(INTBIG color, CHAR **colorname, CHAR **colorsymbol);
1967 BOOLEAN      get3dfactors(TECHNOLOGY *tech, INTBIG layer, float *height, float *thickness);
1968 void         set3dheight(TECHNOLOGY *tech, float *depth);
1969 void         set3dthickness(TECHNOLOGY *tech, float *thickness);
1970 
1971 /* geometric routines */
1972 INTBIG       initsearch(INTBIG lowx, INTBIG highx, INTBIG lowy, INTBIG highy, NODEPROTO *cell);
1973 GEOM        *nextobject(INTBIG initsearchvalue);
1974 void         termsearch(INTBIG initsearchvalue);
1975 void         boundobj(GEOM *object, INTBIG *lowx, INTBIG *highx, INTBIG *lowy, INTBIG *highy);
1976 CHAR        *geomname(GEOM *geom);
1977 NODEPROTO   *geomparent(GEOM *geom);
1978 void         linkgeom(GEOM *geom, NODEPROTO *cell);
1979 void         undogeom(GEOM *geom, NODEPROTO *cell);
1980 void         updategeom(GEOM *geom, NODEPROTO *cell);
1981 BOOLEAN      geomstructure(NODEPROTO *cell);
1982 
1983 /* library routines */
1984 LIBRARY     *getlibrary(CHAR *libname);
1985 LIBRARY     *newlibrary(CHAR *name, CHAR *diskfile);
1986 void         selectlibrary(LIBRARY *library, BOOLEAN changelambda);
1987 void         killlibrary(LIBRARY *library);
1988 void         eraselibrary(LIBRARY *library);
1989 LIBRARY     *whichlibrary(INTBIG, INTBIG);
1990 
1991 /* technology routines */
1992 TECHNOLOGY  *gettechnology(CHAR *techname);
1993 TECHNOLOGY  *whattech(NODEPROTO *cell);
1994 void         addtechnology(TECHNOLOGY *technology);
1995 BOOLEAN      killtechnology(TECHNOLOGY *technology);
1996 void         registertechnologycache(void (*routine)(void), INTBIG count, INTBIG *variablekeys);
1997 void         changedtechnologyvariable(INTBIG key);
1998 void         telltech(TECHNOLOGY *technology, INTBIG count, CHAR *par[]);
1999 INTBIG       asktech(TECHNOLOGY *technology, CHAR *command, ...);
2000 TECHNOLOGY  *defschematictechnology(TECHNOLOGY *deftech);
2001 
2002 /* tool routines */
2003 void         toolturnon(TOOL *tool);
2004 void         toolturnoff(TOOL *tool, BOOLEAN permanently);
2005 void         telltool(TOOL *tool, INTBIG count, CHAR *args[]);
2006 INTBIG       asktool(TOOL *tool, CHAR *command, ...);
2007 TOOL        *gettool(CHAR *toolname);
2008 
2009 /* transformations and mathematics */
2010 void         makeangle(INTBIG rotation, INTBIG transposition, XARRAY matrix);
2011 INTBIG       sine(INTBIG angle);
2012 INTBIG       cosine(INTBIG angle);
2013 INTBIG       pickprime(INTBIG start);
2014 INTBIG       getprime(INTBIG n);
2015 void         makerot(NODEINST *node, XARRAY matrix);
2016 void         makerotI(NODEINST *node, XARRAY matrix);
2017 void         maketrans(NODEINST *node, XARRAY matrix);
2018 void         maketransI(NODEINST *node, XARRAY matrix);
2019 void         transid(XARRAY matrix);
2020 void         transcpy(XARRAY matsource, XARRAY matdest);
2021 void         transmult(XARRAY mata, XARRAY matb, XARRAY matdest);
2022 BOOLEAN      ismanhattan(XARRAY trans);
2023 void         xform(INTBIG x, INTBIG y, INTBIG *newx, INTBIG *newy, XARRAY matrix);
2024 void         xformbox(INTBIG*, INTBIG*, INTBIG*, INTBIG*, XARRAY);
2025 INTBIG       muldiv(INTBIG a, INTBIG b, INTBIG c);
2026 INTBIG       mult(INTBIG a, INTBIG b);
2027 INTBIG       mini(INTBIG a, INTBIG b);
2028 INTBIG       maxi(INTBIG a, INTBIG b);
2029 INTBIG       roundfloat(float v);
2030 INTBIG       rounddouble(double v);
2031 BOOLEAN      floatsequal(float a, float b);
2032 BOOLEAN      doublesequal(double a, double b);
2033 BOOLEAN      floatslessthan(float a, float b);
2034 BOOLEAN      doubleslessthan(double a, double b);
2035 float        floatfloor(float a);
2036 double       doublefloor(double a);
2037 INTBIG       castint(float f);
2038 float        castfloat(INTBIG i);
2039 INTBIG       intsqrt(INTBIG v);
2040 INTBIG       scalefromdispunit(float value, INTBIG dispunit);
2041 float        scaletodispunit(INTBIG value, INTBIG dispunit);
2042 float        scaletodispunitsq(INTBIG value, INTBIG dispunit);
2043 INTBIG       computedistance(INTBIG x1, INTBIG y1, INTBIG x2, INTBIG y2);
2044 INTBIG       figureangle(INTBIG x1, INTBIG y1, INTBIG x2, INTBIG y2);
2045 double       ffigureangle(INTBIG x1, INTBIG y1, INTBIG x2, INTBIG y2);
2046 INTBIG       intersect(INTBIG x1, INTBIG y1, INTBIG angle1, INTBIG x2, INTBIG y2, INTBIG angle2,
2047 				INTBIG *x, INTBIG *y);
2048 INTBIG       fintersect(INTBIG x1, INTBIG y1, double fang1, INTBIG x2, INTBIG y2,
2049 				double fang2, INTBIG *x, INTBIG *y);
2050 BOOLEAN      segintersect(INTBIG fx1, INTBIG fy1, INTBIG tx1, INTBIG ty1,
2051 				INTBIG fx2, INTBIG fy2, INTBIG tx2, INTBIG ty2, INTBIG *ix, INTBIG *iy);
2052 BOOLEAN      isonline(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);
2053 INTBIG       disttoline(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);
2054 INTBIG       closestpointtosegment(INTBIG x1, INTBIG y1, INTBIG x2, INTBIG y2, INTBIG *x, INTBIG *y);
2055 BOOLEAN      findcenters(INTBIG r, INTBIG x1, INTBIG y1, INTBIG x2, INTBIG y2, INTBIG d,
2056 				INTBIG *ix1, INTBIG *iy1, INTBIG *ix2, INTBIG *iy2);
2057 INTBIG       circlelineintersection(INTBIG icx, INTBIG icy, INTBIG isx, INTBIG isy, INTBIG lx1,
2058 				INTBIG ly1, INTBIG lx2, INTBIG ly2, INTBIG *ix1, INTBIG *iy1, INTBIG *ix2, INTBIG *iy2,
2059 				INTBIG tolerance);
2060 BOOLEAN      circletangents(INTBIG x, INTBIG y, INTBIG cx, INTBIG cy, INTBIG sx, INTBIG sy,
2061 				INTBIG *ix1, INTBIG *iy1, INTBIG *ix2, INTBIG *iy2);
2062 void         arcbbox(INTBIG xs, INTBIG ys, INTBIG xe, INTBIG ye, INTBIG xc, INTBIG yc,
2063 				INTBIG *lx, INTBIG *hx, INTBIG *ly, INTBIG *hy);
2064 BOOLEAN      clipline(INTBIG *fx, INTBIG *fy, INTBIG *tx, INTBIG *ty, INTBIG lx, INTBIG hx,
2065 				INTBIG ly, INTBIG hy);
2066 void         cliparc(POLYGON *in, INTBIG lx, INTBIG hx, INTBIG ly, INTBIG hy);
2067 void         subrange(INTBIG low, INTBIG high, INTBIG lowmul, INTBIG lowsum, INTBIG highmul, INTBIG highsum,
2068 				INTBIG *newlow, INTBIG *newhigh, INTBIG lambda);
2069 BOOLEAN      polyinrect(POLYGON *poly, INTBIG lx, INTBIG hx, INTBIG ly, INTBIG hy);
2070 void         clippoly(POLYGON *poly, INTBIG lx, INTBIG hx, INTBIG ly, INTBIG hy);
2071 void         closestpoint(POLYGON *poly, INTBIG *x, INTBIG *y);
2072 INTBIG       getrange(INTBIG low, INTBIG high, INTBIG mul,INTBIG sum, INTBIG lambda);
2073 INTBIG       rotatelabel(INTBIG oldstyle, INTBIG rotation, XARRAY trans);
2074 INTBIG       cropbox(INTBIG *lx, INTBIG *hx, INTBIG *ly, INTBIG *hy, INTBIG bx, INTBIG ux, INTBIG by,
2075 				INTBIG uy);
2076 void         arctopoly(INTBIG cx, INTBIG cy, INTBIG sx, INTBIG sy, INTBIG ex, INTBIG ey, POLYGON *poly,
2077 				INTBIG arcres, INTBIG arcsag);
2078 void         circletopoly(INTBIG cx, INTBIG cy, INTBIG radius, POLYGON *poly, INTBIG arcres, INTBIG arcsag);
2079 void         adjustdisoffset(INTBIG addr, INTBIG type, TECHNOLOGY *tech, POLYGON *poly, UINTBIG *textdescription);
2080 void         vectoradd3d(float *a, float *b, float *sum);
2081 void         vectorsubtract3d(float *a, float *b, float *diff);
2082 void         vectormultiply3d(float *a, float b, float *res);
2083 void         vectordivide3d(float *a, float b, float *res);
2084 float        vectormagnitude3d(float *a);
2085 float        vectordot3d(float *a, float *b);
2086 void         vectornormalize3d(float *a);
2087 void         vectorcross3d(float *a, float *b, float *res);
2088 void         matrixid3d(float xform[4][4]);
2089 void         matrixmult3d(float a[4][4], float b[4][4], float res[4][4]);
2090 void         matrixinvert3d(float mats[4][4], float matd[4][4]);
2091 void         matrixxform3d(float *vec, float mat[4][4], float *res);
2092 
2093 /* polygon routines */
2094 #ifdef DEBUGMEMORY
2095   POLYGON  *_allocpolygon(INTBIG points, CLUSTER *cluster, CHAR*, INTBIG);
2096   POLYLIST *_allocpolylist(CLUSTER *cluster, CHAR*, INTBIG);
2097   BOOLEAN   _ensurepolylist(POLYLIST *list, INTBIG tot, CLUSTER *cluster, CHAR*, INTBIG);
2098 #  define    allocpolygon(p, c) _allocpolygon((p), (c), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
2099 #  define    allocpolylist(c) _allocpolylist((c), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
2100 #  define    ensurepolylist(l, t, c) _ensurepolylist((l), (t), (c), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
2101 #else
2102   POLYGON   *allocpolygon(INTBIG points, CLUSTER *cluster);
2103   POLYLIST  *allocpolylist(CLUSTER *cluster);
2104   BOOLEAN    ensurepolylist(POLYLIST *list, INTBIG tot, CLUSTER *cluster);
2105 #endif
2106 BOOLEAN      needstaticpolygon(POLYGON **, INTBIG points, CLUSTER *cluster);
2107 void         freepolygon(POLYGON *poly);
2108 void         freepolylist(POLYLIST *plist);
2109 BOOLEAN      extendpolygon(POLYGON *poly, INTBIG newcount);
2110 BOOLEAN      polysame(POLYGON *poly1, POLYGON *poly2);
2111 void         polycopy(POLYGON *dpoly, POLYGON *spoly);
2112 BOOLEAN      isinside(INTBIG x, INTBIG y, POLYGON *poly);
2113 float        areapoly(POLYGON *poly);
2114 float        areapoints(INTBIG count, INTBIG *x, INTBIG *y);
2115 void         reversepoly(POLYGON *poly);
2116 void         xformpoly(POLYGON *poly, XARRAY trans);
2117 BOOLEAN      isbox(POLYGON *poly, INTBIG *xl, INTBIG *xh, INTBIG *yl, INTBIG *yh);
2118 void         maketruerect(POLYGON *poly);
2119 INTBIG       polydistance(POLYGON *poly, INTBIG x, INTBIG y);
2120 INTBIG       polyminsize(POLYGON *poly);
2121 INTBIG       polyseparation(POLYGON*, POLYGON*);
2122 BOOLEAN      polyintersect(POLYGON*, POLYGON*);
2123 void         makerectpoly(INTBIG lx, INTBIG ux, INTBIG ly, INTBIG uy, POLYGON *poly);
2124 void         maketruerectpoly(INTBIG lx, INTBIG ux, INTBIG ly, INTBIG uy, POLYGON *poly);
2125 void         makedisparrayvarpoly(GEOM *geom, WINDOWPART *win, VARIABLE *var, POLYGON *poly);
2126 void         getdisparrayvarlinepos(INTBIG addr, INTBIG type, TECHNOLOGY *tech,
2127 				WINDOWPART *win, VARIABLE *var, INTBIG line, INTBIG *x, INTBIG *y, BOOLEAN lowleft);
2128 void         getcenter(POLYGON *poly, INTBIG *x, INTBIG *y);
2129 void         getbbox(POLYGON *poly, INTBIG *lx, INTBIG *hx, INTBIG *ly, INTBIG *hy);
2130 BOOLEAN      polysplithoriz(INTBIG yl, POLYGON *which, POLYGON **abovep, POLYGON **belowp);
2131 BOOLEAN      polysplitvert(INTBIG xl, POLYGON *which, POLYGON **leftp, POLYGON **rightp);
2132 
2133 /* box/polygon merging routines */
2134 void         mrginit(void);
2135 void         mrgterm(void);
2136 void         mrgstorebox(INTBIG layer, TECHNOLOGY *tech, INTBIG length, INTBIG width, INTBIG xc, INTBIG yc);
2137 void         mrgdonecell(void (*writepolygon)(INTBIG layernum, TECHNOLOGY *tech,
2138 				INTBIG *x, INTBIG *y, INTBIG count));
2139 void        *mergenew(CLUSTER *cluster);
2140 void         mergeaddpolygon(void *merge, INTBIG layer, TECHNOLOGY *tech, POLYGON *poly);
2141 void         mergesubpolygon(void *merge, INTBIG layer, TECHNOLOGY *tech, POLYGON *poly);
2142 void         mergeaddmerge(void *merge, void *addmerge, XARRAY trans);
2143 BOOLEAN      mergebbox(void *merge, INTBIG *lx, INTBIG *hx, INTBIG *ly, INTBIG *hy);
2144 void         mergeextract(void *merge, void (*writepolygon)(INTBIG layernum, TECHNOLOGY *tech,
2145 				INTBIG *x, INTBIG *y, INTBIG count));
2146 void         mergedelete(void *merge);
2147 CHAR        *mergedescribe(void *merge);
2148 void         mergeshow(void *vmerge, NODEPROTO *prim, INTBIG showXoff, INTBIG showYoff, CHAR *title);
2149 
2150 /* string manipulation routines */
2151 CHAR        *latoa(INTBIG value, INTBIG lambda);
2152 INTBIG       atola(CHAR *str, INTBIG lambda);
2153 CHAR        *frtoa(INTBIG value);
2154 INTBIG       atofr(CHAR *str);
2155 INTBIG       myatoi(CHAR *str);
2156 BOOLEAN      isanumber(CHAR *str);
2157 CHAR        *hugeinttoa(INTHUGE a);
2158 void         evsnprintf(CHAR *line, INTBIG len, CHAR *msg, va_list ap);
2159 CHAR        *explainduration(float duration);
2160 CHAR        *displayedunits(float value, INTBIG unittype, INTBIG unitscale);
2161 float        figureunits(CHAR *str, INTBIG unittype, INTBIG unitscale);
2162 void         parseelectricversion(CHAR *version, INTBIG *major, INTBIG *minor, INTBIG *detail);
2163 CHAR        *makeplural(CHAR *word, INTBIG amount);
2164 CHAR        *makeabbrev(CHAR *str, BOOLEAN upper);
2165 INTBIG       namesame(CHAR *str1, CHAR *str2);
2166 INTBIG       namesamen(CHAR *str1, CHAR *str2, INTBIG length);
2167 INTBIG       namesamenumeric(CHAR *name1, CHAR *name2);
2168 INTBIG       stringmatch(CHAR *str1, CHAR *str2);
2169 INTBIG       parse(CHAR *keyword, COMCOMP *list, BOOLEAN noise);
2170 void        *initinfstr(void);
2171 void         addtoinfstr(void*, CHAR c);
2172 void         addstringtoinfstr(void*, CHAR *str);
2173 void         formatinfstr(void*, CHAR *msg, ...);
2174 CHAR        *returninfstr(void*);
2175 void        *newstringarray(CLUSTER *cluster);
2176 void         killstringarray(void *sa);
2177 void         clearstrings(void *sa);
2178 void         addtostringarray(void *sa, CHAR *string);
2179 void         stringarraytotextcell(void *sa, NODEPROTO *np, BOOLEAN permanent);
2180 CHAR       **getstringarray(void *sa, INTBIG *count);
2181 CHAR        *getkeyword(CHAR **ptin, CHAR *brk);
2182 CHAR         tonextchar(CHAR **ptin);
2183 CHAR         seenextchar(CHAR **ptin);
2184 void         defaulttextdescript(UINTBIG *textdescript, GEOM *geom);
2185 void         defaulttextsize(INTBIG texttype, UINTBIG *textdescript);
2186 INTBIG       gettdxoffset(UINTBIG *t);
2187 INTBIG       gettdyoffset(UINTBIG *t);
2188 void         settdoffset(UINTBIG *t, INTBIG x, INTBIG y);
2189 void         tdclear(UINTBIG *t);
2190 void         tdcopy(UINTBIG *d, UINTBIG *s);
2191 BOOLEAN      tddiff(UINTBIG *t1, UINTBIG *t2);
2192 void         propervaroffset(INTBIG *x, INTBIG *y);
2193 CHAR        *unitsname(INTBIG units);
2194 void         myencrypt(CHAR *text, CHAR *key);
2195 CHAR        *ectime(time_t *curtime);
2196 #ifdef _UNICODE
2197   CHAR1     *estring1byte(CHAR *string);
2198   CHAR      *estring2byte(CHAR1 *string);
2199 #endif
2200 
2201 /* language interface routines */
2202 CHAR        *languagename(void);
2203 BOOLEAN      languageconverse(INTBIG language);
2204 VARIABLE    *doquerry(CHAR *code, INTBIG language, UINTBIG type);
2205 BOOLEAN      loadcode(CHAR *program, INTBIG language);
2206 
2207 /* error reporting routines */
2208 void         initerrorlogging(CHAR *system);
2209 void        *logerror(CHAR *message, NODEPROTO *cell, INTBIG sortkey);
2210 void         addgeomtoerror(void *errorlist, GEOM *geom, BOOLEAN showit, INTBIG pathlen, NODEINST **path);
2211 void         addexporttoerror(void *errorlist, PORTPROTO *pp, BOOLEAN showit);
2212 void         addlinetoerror(void *errorlist, INTBIG x1, INTBIG y1, INTBIG x2, INTBIG y2);
2213 void         addpolytoerror(void *errorlist, POLYGON *poly);
2214 void         addpointtoerror(void *errorlist, INTBIG x, INTBIG y);
2215 void         termerrorlogging(BOOLEAN explain);
2216 void         sorterrors(void);
2217 INTBIG       numerrors(void);
2218 CHAR        *reportnexterror(INTBIG showhigh, GEOM **g1, GEOM **g2);
2219 CHAR        *reportpreverror(void);
2220 void        *getnexterror(void *e);
2221 CHAR        *describeerror(void *e);
2222 void         reporterror(void *e);
2223 INTBIG       getnumerrorgeom(void *e);
2224 void        *geterrorgeom(void *e, INTBIG index);
2225 CHAR        *describeerrorgeom(void *ehv);
2226 void         showerrorgeom(void *ehv);
2227 void         adviseofchanges(void (*routine)(void));
2228 
2229 /* memory allocation routines */
2230 #ifdef DEBUGMEMORY
2231   INTBIG   *_emalloc(INTBIG size, CLUSTER *cluster, CHAR*, INTBIG);
2232 # define     emalloc(x, c) _emalloc((x), (c), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
2233   BOOLEAN   _allocstring(CHAR **addr, CHAR *str, CLUSTER *cluster, CHAR*, INTBIG);
2234 # define     allocstring(a, s, c) _allocstring((a), (s), (c), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
2235   BOOLEAN   _reallocstring(CHAR **addr, CHAR *str, CLUSTER *cluster, CHAR*, INTBIG);
2236 # define     reallocstring(a, s, c) _reallocstring((a), (s), (c), WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
2237 #else
2238   INTBIG    *emalloc(INTBIG size, CLUSTER *cluster);
2239   BOOLEAN    allocstring(CHAR **addr, CHAR *str, CLUSTER *cluster);
2240   BOOLEAN    reallocstring(CHAR **addr, CHAR *str, CLUSTER *cluster);
2241 #endif
2242 void         efree(CHAR *addr);
2243 CLUSTER     *alloccluster(CHAR *name);
2244 void         freecluster(CLUSTER *cluster);
2245 NODEINST    *allocnodeinst(CLUSTER *cluster);
2246 void         freenodeinst(NODEINST *ni);
2247 ARCINST     *allocarcinst(CLUSTER *cluster);
2248 void         freearcinst(ARCINST *ai);
2249 PORTPROTO   *allocportproto(CLUSTER *cluster);
2250 void         freeportproto(PORTPROTO *pp);
2251 PORTARCINST *allocportarcinst(CLUSTER *cluster);
2252 void         freeportarcinst(PORTARCINST *pi);
2253 PORTEXPINST *allocportexpinst(CLUSTER *cluster);
2254 void         freeportexpinst(PORTEXPINST *pe);
2255 NODEPROTO   *allocnodeproto(CLUSTER *cluster);
2256 void         freenodeproto(NODEPROTO *np);
2257 VIEW        *allocview(void);
2258 void         freeview(VIEW *view);
2259 GEOM        *allocgeom(CLUSTER *cluster);
2260 void         freegeom(GEOM *geom);
2261 RTNODE      *allocrtnode(CLUSTER *cluster);
2262 void         freertnode(RTNODE *rtnode);
2263 LIBRARY     *alloclibrary(void);
2264 void         freelibrary(LIBRARY *lib);
2265 TECHNOLOGY  *alloctechnology(CLUSTER *cluster);
2266 void         freetechnology(TECHNOLOGY *tech);
2267 void         freewindowpart(WINDOWPART *win);
2268 
2269 /* terminal output routines */
2270 void         ttynewcommand(void);
2271 void         ttyputerr(CHAR *format, ...);
2272 void         ttyputmsg(CHAR *format, ...);
2273 void         ttyputverbose(CHAR *format, ...);
2274 void         ttyputinstruction(CHAR *keystroke, INTBIG length, CHAR *meaning);
2275 void         ttyputusage(CHAR *usage);
2276 void         ttyputbadusage(CHAR *command);
2277 void         ttyputnomemory(void);
2278 void         error(CHAR *format, ...);
2279 INTBIG       ttyquiet(INTBIG flag);
2280 void         ttybeep(INTBIG sound, BOOLEAN force);
2281 void         telldatabaseerror(void);
2282 void         ttyclearmessages(void);
2283 
2284 /* terminal input routines */
2285 INTSML       ttygetchar(INTBIG *special);
2286 CHAR        *ttygetline(CHAR *prompt);
2287 CHAR        *ttygetlinemessages(CHAR *prompt);
2288 INTBIG       ttygetparam(CHAR *prompt, COMCOMP *parameter, INTBIG keycount, CHAR *paramstart[]);
2289 INTBIG       ttygetfullparam(CHAR *prompt, COMCOMP *parameter, INTBIG keycount, CHAR *paramstart[]);
2290 BOOLEAN      ttydataready(void);
2291 void         checkforinterrupt(void);
2292 INTBIG       getbuckybits(void);
2293 
2294 /* mouse/tablet input routines */
2295 BOOLEAN      getxy(INTBIG *x, INTBIG *y);
2296 void         gridalign(INTBIG *xcur, INTBIG *ycur, INTBIG alignment, NODEPROTO *cell);
2297 INTBIG       buttoncount(void);
2298 CHAR        *buttonname(INTBIG but, INTBIG *important);
2299 BOOLEAN      doublebutton(INTBIG but);
2300 BOOLEAN      shiftbutton(INTBIG but);
2301 BOOLEAN      contextbutton(INTBIG but);
2302 BOOLEAN      wheelbutton(INTBIG but);
2303 void         waitforbutton(INTBIG *x, INTBIG *y, INTBIG *but);
2304 void         modalloop(BOOLEAN (*charhandler)(INTSML chr, INTBIG special),
2305 				BOOLEAN (*buttonhandler)(INTBIG x, INTBIG y, INTBIG but), INTBIG cursor);
2306 void         trackcursor(BOOLEAN waitforpush, BOOLEAN (*whileup)(INTBIG x, INTBIG y), void (*whendown)(void),
2307 				BOOLEAN (*eachdown)(INTBIG x, INTBIG y), BOOLEAN (*eachchar)(INTBIG x, INTBIG y, INTSML chr),
2308 				void (*done)(void), INTBIG purpose);
2309 void         readtablet(INTBIG *x, INTBIG *y);
2310 void         stoptablet(void);
2311 
2312 /* time routines */
2313 UINTBIG      ticktime(void);
2314 UINTBIG      eventtime(void);
2315 INTBIG       doubleclicktime(void);
2316 void         gotosleep(INTBIG ticks);
2317 void         starttimer(void);
2318 float        endtimer(void);
2319 time_t       getcurrenttime(void);
2320 CHAR        *timetostring(time_t time);
2321 void         parsetime(time_t time, INTBIG *year, INTBIG *month, INTBIG *mday,
2322 				INTBIG *hour, INTBIG *minute, INTBIG *second);
2323 INTBIG       parsemonth(CHAR *monthname);
2324 
2325 /* disk file routines */
2326 CHAR        *truepath(CHAR *path);
2327 CHAR        *fullfilename(CHAR *file);
2328 CHAR        *skippath(CHAR *file);
2329 INTBIG       erename(CHAR *file, CHAR *newfile);
2330 INTBIG       eunlink(CHAR *file);
2331 CHAR        *fileselect(CHAR*, INTBIG, CHAR*);
2332 CHAR        *multifileselectin(CHAR *msg, INTBIG filetype);
2333 INTBIG       fileexistence(CHAR *file);
2334 CHAR        *currentdirectory(void);
2335 CHAR        *hashomedir(void);
2336 BOOLEAN      createdirectory(CHAR *directory);
2337 INTBIG       filesindirectory(CHAR *directory, CHAR ***filelist);
2338 BOOLEAN      lockfile(CHAR *file);
2339 void         unlockfile(CHAR *file);
2340 time_t       filedate(CHAR *file);
2341 INTBIG       filesize(FILE *stream);
2342 BOOLEAN      browsefile(CHAR *filename);
2343 void         describefiletype(INTBIG filetype, CHAR **extension, CHAR **winfilter,
2344 				INTBIG *mactype, BOOLEAN *binary, CHAR **shortname, CHAR **longname);
2345 INTBIG       setupfiletype(CHAR *extension, CHAR *winfilter, INTBIG mactype, BOOLEAN binary,
2346 				CHAR *shortname, CHAR *longname);
2347 INTBIG       getfiletype(CHAR *shortname);
2348 FILE        *efopen(CHAR *filename, CHAR *mode);
2349 FILE        *xopen(CHAR *file, INTBIG filetype, CHAR *otherdir, CHAR **truename);
2350 FILE        *xcreate(CHAR *name, INTBIG filetype, CHAR *prompt, CHAR **truename);
2351 FILE        *xappend(CHAR *file);
2352 void         xclose(FILE *stream);
2353 void         xflushbuf(FILE *stream);
2354 BOOLEAN      xeof(FILE *stream);
2355 void         xseek(FILE *stream, INTBIG pos, INTBIG nature);
2356 INTBIG       xtell(FILE *f);
2357 void         xprintf(FILE *stream, CHAR *format, ...);
2358 INTSML       xgetc(FILE *stream);
2359 void         xungetc(CHAR chr, FILE *stream);
2360 void         xputc(CHAR chr, FILE *stream);
2361 void         xputs(CHAR *str, FILE *stream);
2362 INTBIG       xfread(UCHAR1 *str, INTBIG size, INTBIG count, FILE *stream);
2363 INTBIG       xfwrite(UCHAR1 *str, INTBIG size, INTBIG count, FILE *stream);
2364 BOOLEAN      xfgets(CHAR *str, INTBIG limit, FILE *stream);
2365 
2366 #if !defined(USEQT)
2367 /* channel routines */
2368 INTBIG       eread(int channel, UCHAR1 *addr, INTBIG count);
2369 INTBIG       ewrite(int channel, UCHAR1 *addr, INTBIG count);
2370 INTBIG       eclose(int channels);
2371 INTBIG       epipe(int channels[2]);
2372 INTBIG       channelreplacewithfile(int channel, CHAR *file);
2373 INTBIG       channelreplacewithchannel(int channel, int newchannel);
2374 void         channelrestore(int channel, INTBIG saved);
2375 void         setinteractivemode(int channel);
2376 #endif
2377 
2378 /* miscellaneous routines */
2379 void         changelambda(INTBIG count, TECHNOLOGY **techarray, INTBIG *newlam,
2380 				LIBRARY *whichlib, INTBIG how);
2381 void         changetechnologylambda(TECHNOLOGY *tech, INTBIG newlambda);
2382 INTBIG       figurelambda(GEOM *geom);
2383 void         changeinternalunits(LIBRARY *whichlib, INTBIG oldunits, INTBIG newunits);
2384 NETWORK     *getnetwork(CHAR *name, NODEPROTO *cell);
2385 NETWORK    **getcomplexnetworks(CHAR *name, NODEPROTO *cell);
2386 NETWORK     *getnetonport(NODEINST *node, PORTPROTO *port);
2387 CHAR        *describenetwork(NETWORK *net);
2388 CHAR        *networkname(NETWORK *net, INTBIG i);
2389 void         bringdown(void);
2390 BOOLEAN      stopping(INTBIG reason);
2391 CHAR        *egetenv(CHAR *name);
2392 CHAR        *elanguage(void);
2393 #if !defined(USEQT)
2394 INTBIG       efork(void);
2395 #endif
2396 INTBIG       esystem(CHAR *command);
2397 void         eexec(CHAR *program, CHAR *args[]);
2398 #if !defined(USEQT)
2399 INTBIG       ekill(INTBIG process);
2400 void         ewait(INTBIG process);
2401 #endif
2402 INTBIG       enumprocessors(void);
2403 void         enewthread(void* (*function)(void*), void *argument);
2404 void        *emakemutex(void);
2405 void         emutexlock(void *vmutex);
2406 void         emutexunlock(void *vmutex);
2407 CHAR       **eprinterlist(void);
2408 void         flushscreen(void);
2409 void         exitprogram(void);
2410 void         esort(void *data, INTBIG entries, INTBIG structsize,
2411 				   int (*ordergood)(const void *e1, const void *e2));
2412 int          sort_intbigascending(const void *e1, const void *e2);
2413 int          sort_intbigdescending(const void *e1, const void *e2);
2414 int          sort_stringascending(const void *e1, const void *e2);
2415 int          sort_cellnameascending(const void *e1, const void *e2);
2416 int          sort_exportnameascending(const void *e1, const void *e2);
2417 int          sort_exportnamedescending(const void *e1, const void *e2);
2418 BOOLEAN      ensurevalidmutex(void **mutex, BOOLEAN showerror);
2419 void         setmultiprocesslocks(BOOLEAN on);
2420 #ifdef DEBUGPARALLELISM
2421 #  define NOT_REENTRANT ensurenonparallel(WIDENSTRINGDEFINE(__FILE__), (INTBIG)__LINE__)
2422 #else
2423 #  define NOT_REENTRANT
2424 #endif
2425 void         ensurenonparallel(CHAR *file, INTBIG line);
2426 
2427 /* graphics and control (not documented in Internals Manual) */
2428 void         osprimaryosinit(void);
2429 void         ossecondaryinit(INTBIG, CHAR1*[]);
2430 void         tooltimeslice(void);
2431 void         forceslice(void);
2432 void         graphicsoptions(CHAR *name, INTBIG *argc, CHAR1 **argv);
2433 void         setupenvironment(void);
2434 void         setlibdir(CHAR *libdir);
2435 BOOLEAN      initgraphics(BOOLEAN messages);
2436 void         termgraphics(void);
2437 WINDOWFRAME *newwindowframe(BOOLEAN floating, RECTAREA *r);
2438 void         killwindowframe(WINDOWFRAME*);
2439 void         getpaletteparameters(INTBIG *wid, INTBIG *hei, INTBIG *palettewidth);
2440 void         resetpaletteparameters(void);
2441 void         sizewindowframe(WINDOWFRAME *frame, INTBIG wid, INTBIG hei);
2442 void         movewindowframe(WINDOWFRAME *frame, INTBIG left, INTBIG top);
2443 #ifdef USEQT
2444 void         movedisplay(void);
2445 #endif
2446 void         bringwindowtofront(WINDOWFRAME *frame);
2447 void         adjustwindowframe(INTBIG how);
2448 WINDOWFRAME *getwindowframe(BOOLEAN canfloat);
2449 void         getwindowframesize(WINDOWFRAME *frame, INTBIG *wid, INTBIG *hei);
2450 BOOLEAN      graphicshas(INTBIG want);
2451 void         setdefaultcursortype(INTBIG state);
2452 void         setnormalcursor(INTBIG curs);
2453 void         colormapload(INTBIG *red, INTBIG *green, INTBIG *blue, INTBIG low, INTBIG high);
2454 void         screendrawline(WINDOWPART *win, INTBIG x1, INTBIG y1, INTBIG x2, INTBIG y2, GRAPHICS *desc,
2455 				INTBIG texture);
2456 void         screeninvertline(WINDOWPART *win, INTBIG x1, INTBIG y1, INTBIG x2, INTBIG y2);
2457 void         screendrawpolygon(WINDOWPART *win, INTBIG *x, INTBIG *y, INTBIG count, GRAPHICS *desc);
2458 void         screendrawbox(WINDOWPART *win, INTBIG lowx, INTBIG highx, INTBIG lowy, INTBIG highy, GRAPHICS *desc);
2459 void         screeninvertbox(WINDOWPART *win, INTBIG lowx, INTBIG highx, INTBIG lowy, INTBIG highy);
2460 void         screenmovebox(WINDOWPART *win, INTBIG sx, INTBIG sy, INTBIG wid, INTBIG hei, INTBIG dx, INTBIG dy);
2461 INTBIG       screensavebox(WINDOWPART *win, INTBIG lx, INTBIG hx, INTBIG ly, INTBIG hy);
2462 void         screenmovesavedbox(INTBIG code, INTBIG dx, INTBIG dy);
2463 void         screenrestorebox(INTBIG code, INTBIG destroy);
2464 void         screensettextinfo(WINDOWPART *win, TECHNOLOGY *tech, UINTBIG *descript);
2465 INTBIG       screenfindface(CHAR *facename);
2466 INTBIG       screengetfacelist(CHAR ***list, BOOLEAN all);
2467 CHAR        *screengetdefaultfacename(void);
2468 void         screengettextsize(WINDOWPART *win, CHAR *str, INTBIG *x, INTBIG *y);
2469 void         screendrawtext(WINDOWPART *win, INTBIG atx, INTBIG aty, CHAR *s, GRAPHICS *desc);
2470 BOOLEAN      gettextbits(WINDOWPART *win, CHAR *msg, INTBIG *wid, INTBIG *hei, UCHAR1 ***rowstart);
2471 void         screendrawcircle(WINDOWPART *win, INTBIG atx, INTBIG aty, INTBIG radius, GRAPHICS *desc);
2472 void         screendrawcirclearc(WINDOWPART *win, INTBIG centerx, INTBIG centery, INTBIG p1x, INTBIG p1y,
2473 				INTBIG p2x, INTBIG p2y, GRAPHICS *desc);
2474 void         screendrawdisc(WINDOWPART *win, INTBIG atx, INTBIG aty, INTBIG radius, GRAPHICS *desc);
2475 void         screendrawthickcircle(WINDOWPART *win, INTBIG atx, INTBIG aty, INTBIG radius, GRAPHICS *desc);
2476 void         screendrawthickcirclearc(WINDOWPART *win, INTBIG centerx, INTBIG centery, INTBIG p1x, INTBIG p1y,
2477 				INTBIG p2x, INTBIG p2y, GRAPHICS *desc);
2478 void         screendrawgrid(WINDOWPART *win, POLYGON *obj);
2479 INTSML       getnxtchar(INTBIG *special);
2480 time_t       machinetimeoffset(void);
2481 BOOLEAN      logplayback(CHAR *file);
2482 void         logstartrecord(void);
2483 void         logfinishrecord(void);
2484 void         etrace(INTBIG mode, CHAR *s, ...);
2485 void         getacceleratorstrings(CHAR **acceleratorstring, CHAR **acceleratorprefix);
2486 CHAR        *getinterruptkey(void);
2487 CHAR        *getmessagesstring(CHAR *prompt);
2488 void         putmessagesstring(CHAR *str, BOOLEAN important);
2489 CHAR        *getmessageseofkey(void);
2490 void         setmessagesfont(void);
2491 void         getmessagesframeinfo(INTBIG *top, INTBIG *left, INTBIG *bottom, INTBIG *right);
2492 void         setmessagesframeinfo(INTBIG top, INTBIG left, INTBIG bottom, INTBIG right);
2493 BOOLEAN      closefrontmostmessages(void);
2494 void         clearmessageswindow(void);
2495 BOOLEAN      cutfrommessages(void);
2496 BOOLEAN      copyfrommessages(void);
2497 BOOLEAN      pastetomessages(void);
2498 CHAR        *getcutbuffer(void);
2499 void         setcutbuffer(CHAR *msg);
2500 CHAR        *optionsfilepath(void);
2501 #if defined(WIN32) || defined(USEQT)
2502 void         printewindow(void);
2503 #endif
2504 
2505 /* command completion coroutines (not documented in Internals Manual) */
2506 void         requiredextension(CHAR *extension);
2507 CHAR        *nexttools(void);
2508 CHAR        *nextarcs(void);
2509 CHAR        *nextcells(void);
2510 CHAR        *nextfile(void);
2511 CHAR        *nextlibs(void);
2512 CHAR        *nextnets(void);
2513 CHAR        *nexttechs(void);
2514 CHAR        *nextviews(void);
2515 BOOLEAN      topoftools(CHAR **chrpos);
2516 BOOLEAN      topoffile(CHAR **chrpos);
2517 BOOLEAN      topoflibfile(CHAR **chrpos);
2518 BOOLEAN      topoflibs(CHAR **chrpos);
2519 BOOLEAN      topofnets(CHAR **chrpos);
2520 BOOLEAN      topoftechs(CHAR **chrpos);
2521 BOOLEAN      topofviews(CHAR **chrpos);
2522 BOOLEAN      topofcells(CHAR **chrpos);
2523 BOOLEAN      topofarcs(CHAR **chrpos);
2524 BOOLEAN      us_patoplist(CHAR **chrpos);
2525 INTBIG       us_paparams(CHAR *word, COMCOMP *arr[], CHAR breakc);
2526 CHAR        *us_panextinlist(void);
2527 
2528 #if defined(__cplusplus) && !defined(ALLCPLUSPLUS)
2529 }
2530 #endif
2531 
2532 #if defined(__cplusplus)
2533 
2534 /* EProcess class */
2535 
2536 class EProcessPrivate;
2537 
2538 class EProcess
2539 {
2540 public:
2541 	EProcess();
2542 	~EProcess();
2543 	void clearArguments();
2544 	void addArgument( CHAR *arg );
2545 	void setCommunication( BOOLEAN cStdin, BOOLEAN cStdout, BOOLEAN cStderr );
2546 	BOOLEAN start( CHAR *infile = 0 );
2547 	void wait();
2548 	void kill();
2549 	INTSML getChar();
2550 	void putChar( UCHAR1 ch );
2551 private:
2552 	EProcessPrivate *d;
2553 };
2554 
2555 #endif
2556 
2557 #endif /* GLOBAL_H */
2558