1 /*
2  * calma.h --
3  *
4  * This file defines constants used internally by the calma
5  * module, but not exported to the rest of the world.
6  *
7  *     *********************************************************************
8  *     * Copyright (C) 1985, 1990 Regents of the University of California. *
9  *     * Permission to use, copy, modify, and distribute this              *
10  *     * software and its documentation for any purpose and without        *
11  *     * fee is hereby granted, provided that the above copyright          *
12  *     * notice appear in all copies.  The University of California        *
13  *     * makes no representations about the suitability of this            *
14  *     * software for any purpose.  It is provided "as is" without         *
15  *     * express or implied warranty.  Export of this software outside     *
16  *     * of the United States of America may require an export license.    *
17  *     *********************************************************************
18  *
19  * rcsid $Header: /usr/cvsroot/magic-8.0/calma/calmaInt.h,v 1.2 2010/06/24 12:37:15 tim Exp $
20  */
21 
22 #ifndef _CALMAINT_H
23 #define _CALMAINT_H
24 
25 #include "utils/magic.h"
26 #include "database/database.h"
27 
28 /* Record data types */
29 #define CALMA_NODATA	0	/* No data present */
30 #define CALMA_BITARRAY	1	/* Bit array */
31 #define CALMA_I2	2	/* 2 byte integer */
32 #define CALMA_I4	3	/* 4 byte integer */
33 #define CALMA_R4	4	/* 4 byte real */
34 #define CALMA_R8	5	/* 8 byte real */
35 #define CALMA_ASCII	6	/* ASCII string */
36 
37 /* Record types */
38 #define CALMA_HEADER		0
39 #define CALMA_BGNLIB		1
40 #define CALMA_LIBNAME		2
41 #define CALMA_UNITS		3
42 #define CALMA_ENDLIB		4
43 #define CALMA_BGNSTR		5
44 #define CALMA_STRNAME		6
45 #define CALMA_ENDSTR		7
46 #define CALMA_BOUNDARY		8
47 #define CALMA_PATH		9
48 #define CALMA_SREF		10
49 #define CALMA_AREF		11
50 #define CALMA_TEXT		12
51 #define CALMA_LAYER		13
52 #define CALMA_DATATYPE		14
53 #define CALMA_WIDTH		15
54 #define CALMA_XY		16
55 #define CALMA_ENDEL		17
56 #define CALMA_SNAME		18
57 #define CALMA_COLROW		19
58 #define CALMA_TEXTNODE		20
59 #define CALMA_NODE		21
60 #define CALMA_TEXTTYPE		22
61 #define CALMA_PRESENTATION	23
62 #define CALMA_SPACING		24
63 #define CALMA_STRING		25
64 #define CALMA_STRANS		26
65 #define CALMA_MAG		27
66 #define CALMA_ANGLE		28
67 #define CALMA_UINTEGER		29
68 #define CALMA_USTRING		30
69 #define CALMA_REFLIBS		31
70 #define CALMA_FONTS		32
71 #define CALMA_PATHTYPE		33
72 #define CALMA_GENERATIONS	34
73 #define CALMA_ATTRTABLE		35
74 #define CALMA_STYPTABLE		36
75 #define CALMA_STRTYPE		37
76 #define CALMA_ELFLAGS		38
77 #define CALMA_ELKEY		39
78 #define CALMA_LINKTYPE		40
79 #define CALMA_LINKKEYS		41
80 #define CALMA_NODETYPE		42
81 #define CALMA_PROPATTR		43
82 #define CALMA_PROPVALUE		44
83 #define CALMA_BOX		45
84 #define CALMA_BOXTYPE		46
85 #define CALMA_PLEX		47
86 #define CALMA_BGNEXTN		48
87 #define CALMA_ENDEXTN		49
88 #define CALMA_TAPENUM		50
89 #define CALMA_TAPECODE		51
90 #define CALMA_STRCLASS		52
91 #define CALMA_RESERVED		53
92 #define CALMA_FORMAT		54
93 #define CALMA_MASK		55
94 #define CALMA_ENDMASKS		56
95 #define CALMA_LIBDIRSIZE	57
96 #define CALMA_SRFNAME		58
97 #define CALMA_LIBSECUR		59
98 
99 #define	CALMA_NUMRECORDTYPES	60	/* Number of above types */
100 
101 /* Property types defined for magic */
102 #define CALMA_PROP_USENAME_STD	61	/* To record non-default cell use ids */
103 #define CALMA_PROP_USENAME	98	/* To record non-default cell use ids */
104 #define CALMA_PROP_ARRAY_LIMITS	99	/* To record non-default array limits */
105 
106 /* Flags for transforms */
107 #define	CALMA_STRANS_UPSIDEDOWN	0x8000	/* Mirror about X axis before rot */
108 #define	CALMA_STRANS_ROTATE	0x0002	/* Rotate by absolute angle */
109 
110 /* Path types */
111 #define	CALMAPATH_SQUAREFLUSH	0	/* Square end flush with endpoint */
112 #define	CALMAPATH_ROUND		1	/* Round end */
113 #define	CALMAPATH_SQUAREPLUS	2	/* Square end plus half-width extent */
114 #define	CALMAPATH_CUSTOM	4	/* Endcaps at specified lengths */
115 
116 /* Largest calma layer or data type numbers */
117 #define	CALMA_LAYER_MAX	255
118 
119 #define	CalmaIsValidLayer(n)	((n) >= 0 && (n) <= CALMA_LAYER_MAX)
120 
121 /* Used to index hash tables of (layer, datatype) pairs */
122 typedef struct
123 {
124     int		 clt_layer;
125     int		 clt_type;
126 } CalmaLayerType;
127 
128 /* Biggest calma string */
129 #define	CALMANAMELENGTH		32
130 
131 /* Length of record header */
132 #define	CALMAHEADERLENGTH	4
133 
134 /* Label types */
135 typedef enum { LABEL_TYPE_NONE, LABEL_TYPE_TEXT, LABEL_TYPE_PORT, LABEL_TYPE_CELLID } labelType;
136 
137 /* ------------------------- Input macros ----------------------------- */
138 
139 /* Globals for Calma reading */
140 extern FILE *calmaInputFile;
141 extern char *calmaFilename;
142 extern int  calmaReadScale1;
143 extern int  calmaReadScale2;
144 extern bool calmaLApresent;
145 extern int  calmaLAnbytes;
146 extern int  calmaLArtype;
147 
148 /*
149  * Macros for number representation conversion.
150  */
151 #ifdef ibm032
152 #include <netinet/in.h>    /* as macros in in.h and don't exist as routines */
153 #endif
154 
155 #ifndef	ntohl
156 # ifdef	WORDS_BIGENDIAN
157 # define ntohl(x)        (x)
158 # define ntohs(x)        (x)
159 # define htonl(x)        (x)
160 # define htons(x)        (x)
161 # endif
162 #endif
163 
164 typedef union { char uc[2]; unsigned short us; } TwoByteInt;
165 typedef union { char uc[4]; unsigned int ul; } FourByteInt;
166 
167 /* Macro to read a 2-byte integer */
168 #define	READI2(z) \
169 	{ \
170             TwoByteInt u; \
171             u.uc[0] = getc(calmaInputFile); \
172             u.uc[1] = getc(calmaInputFile); \
173             (z) = (int) ntohs(u.us); \
174 	}
175 
176 /* Macro to read a 4-byte integer */
177 #define	READI4(z) \
178 	{ \
179             FourByteInt u; \
180             u.uc[0] = getc(calmaInputFile); \
181             u.uc[1] = getc(calmaInputFile); \
182             u.uc[2] = getc(calmaInputFile); \
183             u.uc[3] = getc(calmaInputFile); \
184             (z) = (int) ntohl(u.ul); \
185 	}
186 
187 /* Macros for reading and unreading record headers */
188 #define READRH(nb, rt) \
189 	{ \
190 	    if (calmaLApresent) { \
191 		(nb) = calmaLAnbytes; \
192 		(rt) = calmaLArtype; \
193 		calmaLApresent = FALSE; \
194 	    } else { \
195 		READI2(nb); \
196 		if (feof(calmaInputFile)) nb = -1; \
197 		else { \
198 		    (rt) = getc(calmaInputFile); \
199 		    (void) getc(calmaInputFile); \
200 		} \
201 	    } \
202 	}
203 
204 #define UNREADRH(nb, rt) \
205 	{ \
206 	    ASSERT(!calmaLApresent, "UNREADRH"); \
207 	    calmaLApresent = TRUE; \
208 	    calmaLAnbytes = (nb); \
209 	    calmaLArtype = (rt); \
210 	}
211 
212 #define	PEEKRH(nb, rt) \
213 	{ \
214 	    READRH(nb, rt); \
215 	    UNREADRH(nb, rt); \
216 	}
217 
218 /* Other commonly used globals */
219 extern HashTable calmaLayerHash;
220 extern int calmaElementIgnore[];
221 extern CellDef *calmaFindCell();
222 
223 /* (Added by Nishit, 8/18/2004--8/24/2004) */
224 extern CellDef *calmaLookCell();
225 extern void calmaWriteContact();
226 extern CellDef *calmaGetContactCell();
227 extern bool calmaIsContactCell;
228 
229 extern char *calmaRecordName();
230 extern void calmaSkipSet();
231 
232 /* ------------------- Imports from CIF reading ----------------------- */
233 
234 extern CellDef *cifReadCellDef;
235 extern Plane *cifSubcellPlanes[];
236 extern Plane **cifCurReadPlanes;
237 extern HashTable CifCellTable;
238 extern Plane *cifEditCellPlanes[];
239 
240 #endif /* _CALMAINT_H */
241