diff --git a/database/DBcellbox.c b/database/DBcellbox.c index 55b8f327..836c677e 100644 --- a/database/DBcellbox.c +++ b/database/DBcellbox.c @@ -59,15 +59,15 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ */ char * -DBPrintUseId(scx, name, size, display_only) - SearchContext *scx; /* Pointer to current search context, specifying a +DBPrintUseId( + SearchContext *scx, /* Pointer to current search context, specifying a * cell use and X,Y array indices. */ - char *name; /* Pointer to string into which we will copy the + char *name, /* Pointer to string into which we will copy the * print name of this instance. */ - int size; /* Maximum number of characters to copy into string. */ - bool display_only; /* TRUE if called for displaying only */ + int size, /* Maximum number of characters to copy into string. */ + bool display_only) /* TRUE if called for displaying only */ { CellUse *use = scx->scx_use; char *sp, *id, *ep; diff --git a/database/DBcellsrch.c b/database/DBcellsrch.c index 39913083..3bf5c65b 100644 --- a/database/DBcellsrch.c +++ b/database/DBcellsrch.c @@ -677,7 +677,7 @@ dbCellLabelSrFunc(scx, fp) { Label *lab; Rect *r = &scx->scx_area; - TileTypeBitMask *mask = fp->tf_mask; + const TileTypeBitMask *mask = fp->tf_mask; CellDef *def = scx->scx_use->cu_def; char *tnext; int result; diff --git a/database/DBconnect.c b/database/DBconnect.c index 74af4e4f..8e1af02d 100644 --- a/database/DBconnect.c +++ b/database/DBconnect.c @@ -179,7 +179,6 @@ DBSrConnectOnePlane(startTile, connect, func, clientData) { struct conSrArg csa; int result; - extern int dbSrConnectFunc(); /* Forward declaration. */ result = 0; csa.csa_def = (CellDef *)NULL; @@ -193,7 +192,7 @@ DBSrConnectOnePlane(startTile, connect, func, clientData) csa.csa_clear = FALSE; csa.csa_connect = connect; csa.csa_pNum = -1; - if (dbSrConnectFunc(startTile, &csa) != 0) result = 1; + if (dbSrConnectFunc(startTile, PTR2CD(&csa)) != 0) result = 1; /* Pass 2. Don't call any client function, just clear the marks. * Don't allow any interruptions. @@ -202,7 +201,7 @@ DBSrConnectOnePlane(startTile, connect, func, clientData) SigDisableInterrupts(); csa.csa_clientFunc = NULL; csa.csa_clear = TRUE; - (void) dbSrConnectFunc(startTile, &csa); + (void) dbSrConnectFunc(startTile, PTR2CD(&csa)); SigEnableInterrupts(); return result; @@ -278,8 +277,6 @@ DBSrConnect(def, startArea, mask, connect, bounds, func, clientData) struct conSrArg csa; int startPlane, result; Tile *startTile; /* Starting tile for search. */ - extern int dbSrConnectFunc(); /* Forward declaration. */ - extern int dbSrConnectStartFunc(); result = 0; csa.csa_def = def; @@ -296,7 +293,7 @@ DBSrConnect(def, startArea, mask, connect, bounds, func, clientData) csa.csa_pNum = startPlane; if (DBSrPaintArea((Tile *) NULL, def->cd_planes[startPlane], startArea, mask, - dbSrConnectStartFunc, (ClientData) &startTile) != 0) break; + dbSrConnectStartFunc, PTR2CD(&startTile)) != 0) break; } if (startTile == NULL) return 0; /* The following lets us call DBSrConnect recursively */ @@ -309,7 +306,7 @@ DBSrConnect(def, startArea, mask, connect, bounds, func, clientData) csa.csa_clientDefault = CLIENTDEFAULT; csa.csa_clear = FALSE; csa.csa_connect = connect; - if (dbSrConnectFunc(startTile, &csa) != 0) result = 1; + if (dbSrConnectFunc(startTile, PTR2CD(&csa)) != 0) result = 1; /* Pass 2. Don't call any client function, just clear the marks. * Don't allow any interruptions. @@ -318,17 +315,20 @@ DBSrConnect(def, startArea, mask, connect, bounds, func, clientData) SigDisableInterrupts(); csa.csa_clientFunc = NULL; csa.csa_clear = TRUE; - (void) dbSrConnectFunc(startTile, &csa); + (void) dbSrConnectFunc(startTile, PTR2CD(&csa)); SigEnableInterrupts(); return result; } +/** @typedef cb_database_srpaintarea_t */ int -dbSrConnectStartFunc(tile, pTile) - Tile *tile; /* This will be the starting tile. */ - Tile **pTile; /* We store tile's address here. */ +dbSrConnectStartFunc( + Tile *tile, /* This will be the starting tile. */ + ClientData cdata) /* We store tile's address here. */ + /* (Tile **pTile) */ { + Tile **pTile = (Tile **)CD2PTR(cdata); *pTile = tile; return 1; } @@ -368,8 +368,6 @@ DBSrConnectOnePass(def, startArea, mask, connect, bounds, func, clientData) struct conSrArg csa; int startPlane, result; Tile *startTile; /* Starting tile for search. */ - extern int dbSrConnectFunc(); /* Forward declaration. */ - extern int dbSrConnectStartFunc(); result = 0; csa.csa_def = def; @@ -386,7 +384,7 @@ DBSrConnectOnePass(def, startArea, mask, connect, bounds, func, clientData) csa.csa_pNum = startPlane; if (DBSrPaintArea((Tile *) NULL, def->cd_planes[startPlane], startArea, mask, - dbSrConnectStartFunc, (ClientData) &startTile) != 0) break; + dbSrConnectStartFunc, PTR2CD(&startTile)) != 0) break; } if (startTile == NULL) return 0; /* The following lets us call DBSrConnect recursively */ @@ -399,7 +397,7 @@ DBSrConnectOnePass(def, startArea, mask, connect, bounds, func, clientData) csa.csa_clientDefault = CLIENTDEFAULT; csa.csa_clear = FALSE; csa.csa_connect = connect; - if (dbSrConnectFunc(startTile, &csa) != 0) result = 1; + if (dbSrConnectFunc(startTile, PTR2CD(&csa)) != 0) result = 1; return result; } @@ -465,16 +463,18 @@ dbcFindTileFunc(tile, arg) */ int -dbSrConnectFunc(tile, csa) - Tile *tile; /* Tile that is connected. */ - struct conSrArg *csa; /* Contains information about the search. */ +dbSrConnectFunc( + Tile *tile, /* Tile that is connected. */ + ClientData cdata) /* Contains information about the search. */ + /* (struct conSrArg *csa) */ { + struct conSrArg *csa = (struct conSrArg *)CD2PTR(cdata); Tile *t2; Rect tileArea; int i, pNum; int result = 0; bool callClient; - TileTypeBitMask *connectMask; + const TileTypeBitMask *connectMask; TileType loctype, checktype; PlaneMask planes; @@ -731,6 +731,8 @@ dbSrConnectFunc(tile, csa) * ---------------------------------------------------------------------------- */ +/** @typedef cb_database_srpaintnmarea_t */ +/** @typedef cb_database_srpaintarea_t */ int dbcUnconnectFunc(tile, clientData) Tile *tile; /* Current tile */ @@ -826,7 +828,7 @@ dbcConnectLabelFunc(scx, lab, tpath, csa2) CellDef *orig_def = scx->scx_use->cu_def; Label *slab; int lidx = lab->lab_port; - TileTypeBitMask *connectMask; + const TileTypeBitMask *connectMask; /* Check for equivalent ports. For any found, call */ /* DBTreeSrTiles recursively on the type and area */ @@ -940,7 +942,8 @@ dbcConnectFunc(tile, cx) { struct conSrArg2 *csa2; Rect tileArea, newarea; - TileTypeBitMask *connectMask, notConnectMask; + const TileTypeBitMask *connectMask; + TileTypeBitMask notConnectMask; Rect *srArea; SearchContext *scx = cx->tc_scx; SearchContext scx2; @@ -1155,7 +1158,7 @@ DBTreeCopyConnect(scx, mask, xMask, connect, area, doLabels, destUse) */ { struct conSrArg2 csa2; - TileTypeBitMask *newmask; + const TileTypeBitMask *newmask; TileType newtype; unsigned char searchtype; diff --git a/database/database.h.in b/database/database.h.in index c5f9f964..b6aee7b9 100644 --- a/database/database.h.in +++ b/database/database.h.in @@ -647,7 +647,7 @@ typedef struct treeFilter { int (*tf_func)(); /* Client's filter function */ ClientData tf_arg; /* Client's argument to pass to filter */ - TileTypeBitMask *tf_mask; /* Only process tiles with these types */ + const TileTypeBitMask *tf_mask; /* Only process tiles with these types */ int tf_xmask; /* Expand mask */ PlaneMask tf_planes; /* Mask of planes which will be visited */ TileType tf_dinfo; /* Info for processing triangular areas */ @@ -685,7 +685,7 @@ struct conSrArg { CellDef *csa_def; /* Definition being searched. */ int csa_pNum; /* Index of plane being searched */ - TileTypeBitMask *csa_connect; /* Table indicating what connects + const TileTypeBitMask *csa_connect; /* Table indicating what connects * to what. */ int (*csa_clientFunc)(); /* Client function to call. */ @@ -700,19 +700,19 @@ struct conSrArg typedef struct { Rect area; /* Area to process */ - TileTypeBitMask *connectMask; /* Connection mask for search */ + const TileTypeBitMask *connectMask; /* Connection mask for search */ TileType dinfo; /* Info about triangular search areas */ } conSrArea; struct conSrArg2 { CellUse *csa2_use; /* Destination use */ - TileTypeBitMask *csa2_connect; /* Table indicating what connects + const TileTypeBitMask *csa2_connect;/* Table indicating what connects * to what. */ SearchContext *csa2_topscx; /* Original top-level search context */ int csa2_xMask; /* Cell window mask for search */ - Rect *csa2_bounds; /* Area that limits the search */ + const Rect *csa2_bounds; /* Area that limits the search */ Stack *csa2_stack; /* Stack of full csa2_list entries */ conSrArea *csa2_list; /* List of areas to process */ @@ -879,7 +879,7 @@ extern void DBSetTrans(); extern void DBArrayOverlap(); extern void DBComputeArrayArea(); extern Transform *DBGetArrayTransform(); -extern char *DBPrintUseId(); +extern char *DBPrintUseId(SearchContext *scx, char *name, int size, bool display_only); /* Massive copying */ extern void DBCellCopyPaint(); @@ -955,6 +955,9 @@ extern int DBArraySr(); extern bool DBNearestLabel(); extern int DBSrLabelLoc(); extern TileType DBTransformDiagonal(); +extern int dbcUnconnectFunc(Tile *tile, ClientData clientData); /* (notused) */ +extern int dbSrConnectFunc(Tile *tile, ClientData clientData); /* (struct conSrArg *csa) */ +extern int dbSrConnectStartFunc(Tile *tile, ClientData clientData); /* cb_database_srpaintarea_t (Tile **pTile) */ /* C99 compat */ extern void DBEraseValid(); diff --git a/sim/SimDBstuff.c b/sim/SimDBstuff.c index 1c74f950..fdbb44b0 100644 --- a/sim/SimDBstuff.c +++ b/sim/SimDBstuff.c @@ -46,13 +46,6 @@ #include "utils/styles.h" #include "graphics/graphics.h" -/* Forward declarations */ - -extern char *DBPrintUseId(); -extern int dbcUnconnectFunc(); -extern void SimInitScxStk(); -extern void SimPopScx(); -extern void SimMakePathname(); static char bestName[256]; @@ -83,9 +76,9 @@ static char bestName[256]; */ int -SimConnectFunc(tile, cx) - Tile *tile; /* Tile found. */ - TreeContext *cx; /* Describes context of search. The client +SimConnectFunc( + Tile *tile, /* Tile found. */ + TreeContext *cx) /* Describes context of search. The client * data is a pointer to the list head of * the conSrArg2's describing the areas * left to check. @@ -94,7 +87,8 @@ SimConnectFunc(tile, cx) struct conSrArg2 *csa2; Rect tileArea, *srArea, newarea; SearchContext *scx = cx->tc_scx; - TileTypeBitMask notConnectMask, *connectMask; + TileTypeBitMask notConnectMask; + const TileTypeBitMask *connectMask; TileType loctype, ctype; TileType dinfo = 0; int i, pNum; @@ -318,8 +312,8 @@ SimConnectFunc(tile, cx) #define MAXPATHNAME 256 void -SimTreeCopyConnect(scx, mask, xMask, connect, area, destUse, Node_Name) - SearchContext *scx; /* Describes starting area. The +SimTreeCopyConnect( + SearchContext *scx, /* Describes starting area. The * scx_use field gives the root of * the hierarchy to search, and the * scx_area field gives the starting @@ -327,26 +321,26 @@ SimTreeCopyConnect(scx, mask, xMask, connect, area, destUse, Node_Name) * this area. The transform is from * coords of scx_use to destUse. */ - TileTypeBitMask *mask; /* Tile types to start from in area. */ - int xMask; /* Information must be expanded in all + const TileTypeBitMask *mask, /* Tile types to start from in area. */ + int xMask, /* Information must be expanded in all * of the windows indicated by this * mask. Use 0 to consider all info * regardless of expansion. */ - TileTypeBitMask *connect; /* Points to table that defines what + const TileTypeBitMask *connect, /* Points to table that defines what * each tile type is considered to * connect to. Use DBConnectTbl as * a default. */ - Rect *area; /* The resulting information is + const Rect *area, /* The resulting information is * clipped to this area. Pass * TiPlaneRect to get everything. */ - CellUse *destUse; /* Result use in which to place + CellUse *destUse, /* Result use in which to place * anything connected to material of * type mask in area of rootUse. */ - char *Node_Name; /* Name of node returned. + char *Node_Name) /* Name of node returned. * NOTE: Don't call this "NodeName", * because that conflicts with reserved * words in some compilers. @@ -354,7 +348,7 @@ SimTreeCopyConnect(scx, mask, xMask, connect, area, destUse, Node_Name) { TerminalPath tpath; char pathName[MAXPATHNAME]; - TileTypeBitMask *newmask; + const TileTypeBitMask *newmask; struct conSrArg2 csa2; TileType newtype; @@ -438,11 +432,12 @@ SimTreeCopyConnect(scx, mask, xMask, connect, area, destUse, Node_Name) */ bool -efPreferredName(name1, name2) - char *name1, *name2; +efPreferredName( + const char *name1, + const char *name2) { int nslashes1, nslashes2; - char *np1, *np2; + const char *np1, *np2; if( name1[0] == '@' && name1[1] == '=' ) return( TRUE ); @@ -550,38 +545,36 @@ efPreferredName(name1, name2) */ int -SimSrConnect(def, startArea, mask, connect, bounds, func, clientData) - CellDef *def; /* Cell definition in which to carry out +SimSrConnect( + CellDef *def, /* Cell definition in which to carry out * the connectivity search. Only paint * in this definition is considered. */ - Rect *startArea; /* Area to search for an initial tile. Only + const Rect *startArea, /* Area to search for an initial tile. Only * tiles OVERLAPPING the area are considered. * This area should have positive x and y * dimensions. */ - TileTypeBitMask *mask; /* Only tiles of one of these types are used + const TileTypeBitMask *mask,/* Only tiles of one of these types are used * as initial tiles. */ - TileTypeBitMask *connect; /* Pointer to a table indicating what tile + const TileTypeBitMask *connect, + /* Pointer to a table indicating what tile * types connect to what other tile types. * Each entry gives a mask of types that * connect to tiles of a given type. */ - Rect *bounds; /* Area, in coords of scx->scx_use->cu_def, + const Rect *bounds, /* Area, in coords of scx->scx_use->cu_def, * that limits the search: only tiles * overalapping this area will be returned. * Use TiPlaneRect to search everywhere. */ - int (*func)(); /* Function to apply at each connected tile. */ - ClientData clientData; /* Client data for above function. */ - + int (*func)(), /* Function to apply at each connected tile. */ + ClientData clientData) /* Client data for above function. */ { struct conSrArg csa; int startPlane, result; Tile *startTile; /* Starting tile for search. */ - extern int dbSrConnectFunc(); /* Forward declaration. */ - extern int dbSrConnectStartFunc(); result = 0; csa.csa_def = def; @@ -597,7 +590,7 @@ SimSrConnect(def, startArea, mask, connect, bounds, func, clientData) { if (DBSrPaintArea((Tile *) NULL, def->cd_planes[startPlane], startArea, mask, - dbSrConnectStartFunc, (ClientData) &startTile) != 0) break; + dbSrConnectStartFunc, PTR2CD(&startTile)) != 0) break; } if (startTile == NULL) return 0; @@ -608,7 +601,7 @@ SimSrConnect(def, startArea, mask, connect, bounds, func, clientData) csa.csa_clear = FALSE; csa.csa_connect = connect; csa.csa_pNum = startPlane; - if (dbSrConnectFunc(startTile, &csa) != 0) result = 1; + if (dbSrConnectFunc(startTile, PTR2CD(&csa)) != 0) result = 1; return result; } @@ -661,28 +654,28 @@ SimSrConnect(def, startArea, mask, connect, bounds, func, clientData) */ int -SimTreeSrTiles(scx, mask, xMask, tpath, func, cdarg) - SearchContext *scx; /* Pointer to search context specifying +SimTreeSrTiles( + SearchContext *scx, /* Pointer to search context specifying * a cell use to search, an area in the * coordinates of the cell's def, and a * transform back to "root" coordinates. */ - TileTypeBitMask *mask; /* Only tiles with a type for which + const TileTypeBitMask *mask,/* Only tiles with a type for which * a bit in this mask is on are processed. */ - int xMask; /* All subcells are visited recursively + int xMask, /* All subcells are visited recursively * until we encounter uses whose flags, * when anded with xMask, are not * equal to xMask. */ - TerminalPath *tpath; /* Pointer to a structure describing a + TerminalPath *tpath, /* Pointer to a structure describing a * partially filled-in terminal pathname. * Add new components as encountered. */ - int (*func)(); /* Function to apply at each qualifying tile */ - ClientData cdarg; /* Client data for above function */ + int (*func)(), /* Function to apply at each qualifying tile */ + ClientData cdarg) /* Client data for above function */ { - int SimCellTileSrFunc(); + int SimCellTileSrFunc(SearchContext *scx, ClientData cdata); /* cb_database_cellsrarea_t (TreeFilter *fp) */ TreeFilter filter; filter.tf_func = func; @@ -693,7 +686,7 @@ SimTreeSrTiles(scx, mask, xMask, tpath, func, cdarg) filter.tf_tpath = tpath; filter.tf_dinfo = 0; - return SimCellTileSrFunc(scx, &filter); + return SimCellTileSrFunc(scx, PTR2CD(&filter)); } /* @@ -703,31 +696,31 @@ SimTreeSrTiles(scx, mask, xMask, tpath, func, cdarg) */ int -SimTreeSrNMTiles(scx, dinfo, mask, xMask, tpath, func, cdarg) - SearchContext *scx; /* Pointer to search context specifying +SimTreeSrNMTiles( + SearchContext *scx, /* Pointer to search context specifying * a cell use to search, an area in the * coordinates of the cell's def, and a * transform back to "root" coordinates. */ - TileType dinfo; /* Type containing information about the + TileType dinfo, /* Type containing information about the * triangular area to search. */ - TileTypeBitMask *mask; /* Only tiles with a type for which + const TileTypeBitMask *mask,/* Only tiles with a type for which * a bit in this mask is on are processed. */ - int xMask; /* All subcells are visited recursively + int xMask, /* All subcells are visited recursively * until we encounter uses whose flags, * when anded with xMask, are not * equal to xMask. */ - TerminalPath *tpath; /* Pointer to a structure describing a + TerminalPath *tpath, /* Pointer to a structure describing a * partially filled-in terminal pathname. * Add new components as encountered. */ - int (*func)(); /* Function to apply at each qualifying tile */ - ClientData cdarg; /* Client data for above function */ + int (*func)(), /* Function to apply at each qualifying tile */ + ClientData cdarg) /* Client data for above function */ { - int SimCellTileSrFunc(); + int SimCellTileSrFunc(SearchContext *scx, ClientData cdata); /* cb_database_cellsrarea_t (TreeFilter *fp) */ TreeFilter filter; filter.tf_func = func; @@ -738,18 +731,20 @@ SimTreeSrNMTiles(scx, dinfo, mask, xMask, tpath, func, cdarg) filter.tf_planes = DBTechTypesToPlanes(mask); filter.tf_tpath = tpath; - return SimCellTileSrFunc(scx, &filter); + return SimCellTileSrFunc(scx, PTR2CD(&filter)); } /* * Filter procedure applied to subcells by SimTreeSrTiles(). */ +/** @typedef cb_database_cellsrarea_t */ int -SimCellTileSrFunc(scx, fp) - SearchContext *scx; - TreeFilter *fp; +SimCellTileSrFunc( + SearchContext *scx, + ClientData cdata) /* (TreeFilter *fp) */ { + TreeFilter *fp = (TreeFilter *)CD2PTR(cdata); TreeContext context; TerminalPath *tp; CellDef *def = scx->scx_use->cu_def; @@ -818,7 +813,7 @@ SimCellTileSrFunc(scx, fp) * in our tile plane. */ - if (DBCellSrArea(scx, SimCellTileSrFunc, (ClientData) fp)) + if (DBCellSrArea(scx, SimCellTileSrFunc, PTR2CD(fp))) result = 1; cleanup: @@ -860,15 +855,15 @@ SimCellTileSrFunc(scx, fp) */ int -SimPutLabel(cellDef, rect, align, text, type) - CellDef *cellDef; /* Cell in which label is placed */ - Rect *rect; /* Location of label; see above for description */ - int align; /* Orientation/alignment of text. If this is < 0, +SimPutLabel( + CellDef *cellDef, /* Cell in which label is placed */ + const Rect *rect, /* Location of label, see above for description */ + int align, /* Orientation/alignment of text. If this is < 0, * an orientation will be picked to keep the text * inside the cell boundary. */ - char *text; /* Pointer to actual text of label */ - TileType type; /* Type of tile to be labeled */ + const char *text, /* Pointer to actual text of label */ + TileType type) /* Type of tile to be labeled */ { Label *lab; int len, x1, x2, y1, y2, tmp, labx, laby; @@ -963,9 +958,9 @@ SimPutLabel(cellDef, rect, align, text, type) */ void -SimRsimHandler(w, cmd) - MagWindow *w; /* Window containing cursor. */ - TxCommand *cmd; /* Describes what happened. */ +SimRsimHandler( + MagWindow *w, /* Window containing cursor. */ + TxCommand *cmd) /* Describes what happened. */ { static int buttonCorner = TOOL_ILG; diff --git a/sim/SimExtract.c b/sim/SimExtract.c index eb7f0981..0ca46712 100644 --- a/sim/SimExtract.c +++ b/sim/SimExtract.c @@ -114,8 +114,8 @@ PlaneMask SimFetPlanes; */ void -SimAddDefList(newdef) - CellDef *newdef; +SimAddDefList( + CellDef *newdef) { DefListElt *d; @@ -163,7 +163,7 @@ SimAddDefList(newdef) */ void -SimInitDefList() +SimInitDefList(void) { DefListElt *p, *q; @@ -194,8 +194,8 @@ SimInitDefList() */ void -SimAddNodeList(newnode) - NodeRegion *newnode; +SimAddNodeList( + NodeRegion *newnode) { if( NodeRegList != (NodeRegion *) NULL ) newnode->nreg_next = NodeRegList; @@ -220,7 +220,7 @@ SimAddNodeList(newnode) */ void -SimFreeNodeRegs() +SimFreeNodeRegs(void) { NodeRegion *p, *q; @@ -239,7 +239,8 @@ SimFreeNodeRegs() * to the region being searched. *---------------------------------------------------------------- */ -int SimInitConnTables() +int +SimInitConnTables(void) { int i, t, sd, p; ExtDevice *devptr; @@ -337,10 +338,11 @@ typedef struct /* return value from SimFindOneNode */ * *---------------------------------------------------------------- */ -char *SimTxtorLabel( nterm, tm, trans ) - int nterm; - Transform *tm; - SimTrans *trans; +char * +SimTxtorLabel( + int nterm, + const Transform *tm, + SimTrans *trans) { static char name[30]; Rect r1, r2; @@ -356,18 +358,20 @@ char *SimTxtorLabel( nterm, tm, trans ) return( name ); } -int SimSDTransFunc( tile, ptile ) - Tile *tile; - Tile **ptile; +int +SimSDTransFunc( + Tile *tile, + Tile **ptile) { *ptile = tile; return( 1 ); } -int SimTransTerms( bp, trans ) - Boundary *bp; - SimTrans *trans; +int +SimTransTerms( + Boundary *bp, + SimTrans *trans) { TransTerm *term; Tile *tile = bp->b_outside; @@ -427,9 +431,10 @@ int SimTransTerms( bp, trans ) } -int SimTermNum( trans, reg ) - SimTrans *trans; - NodeRegion *reg; +int +SimTermNum( + SimTrans *trans, + NodeRegion *reg) { int i, changed; TransTerm *p1, *p2, tmp; @@ -470,10 +475,10 @@ int SimTermNum( trans, reg ) int -SimTransistorTile(tile, pNum, arg) - Tile *tile; - int pNum; - FindRegion *arg; +SimTransistorTile( + Tile *tile, + int pNum, + FindRegion *arg) { int i; TileType t; @@ -494,10 +499,11 @@ SimTransistorTile(tile, pNum, arg) } -int SimFindTxtor( tile, pNum, arg ) - Tile *tile; - int pNum; - FindRegion *arg; +int +SimFindTxtor( + Tile *tile, + int pNum, + FindRegion *arg) { TileType type; @@ -549,9 +555,9 @@ int SimFindTxtor( tile, pNum, arg ) */ NodeSpec * -SimFindOneNode( sx, tile ) - SearchContext *sx; - Tile *tile; +SimFindOneNode( + SearchContext *sx, + Tile *tile) { CellDef *def = sx->scx_use->cu_def; NodeRegion *reg; @@ -696,12 +702,12 @@ SimFindOneNode( sx, tile ) */ char * -SimGetNodeName(sx, tp, path) - SearchContext *sx; /* current search context */ - Tile *tp; /* tile in this cell which is part +SimGetNodeName( + SearchContext *sx, /* current search context */ + Tile *tp, /* tile in this cell which is part * of the node */ - char *path; /* path name of hierarchy of search */ + const char *path) /* path name of hierarchy of search */ { CellDef *def = sx->scx_use->cu_def; NodeRegion *nodeList; @@ -820,7 +826,7 @@ SimGetNodeName(sx, tp, path) */ void -SimGetNodeCleanUp() +SimGetNodeCleanUp(void) { SimFreeNodeRegs(); SimInitDefList(); diff --git a/sim/SimRsim.c b/sim/SimRsim.c index 5088e8c3..170991d0 100644 --- a/sim/SimRsim.c +++ b/sim/SimRsim.c @@ -23,6 +23,7 @@ #ifdef RSIM_MODULE #include +#include #include #include #include @@ -50,7 +51,7 @@ /* C99 compat */ #include "textio/textio.h" -static bool InitRsim(); +static bool InitRsim(const char *hello_msg); #define BUF_SIZE 1024 #define LINEBUF_SIZE 256 @@ -74,14 +75,13 @@ static char keyBoardBuf[BUF_SIZE]; static bool RsimJustStarted = TRUE; static char rsim_prompt[20]; static int prompt_len; -static int rsim_pid; +static pid_t rsim_pid; bool SimRsimRunning = FALSE; bool SimHasCoords = FALSE; -bool SimGetReplyLine(); /* Forward declaration */ -void SimStopRsim(); +void SimStopRsim(void); /* *----------------------------------------------------------------------- @@ -99,9 +99,9 @@ void SimStopRsim(); *----------------------------------------------------------------------- */ -char * -SimGetNodeCommand(cmd) - char *cmd; +const char * +SimGetNodeCommand( + const char *cmd) { /* This table is used to define which Rsim commands are applied to * each node in the selection. Depending on the command, you @@ -110,7 +110,7 @@ SimGetNodeCommand(cmd) * step the clock once for every node in the selection. */ - static char *RsimNodeCommands[] = + static const char *RsimNodeCommands[] = { "?", "!", @@ -153,17 +153,17 @@ SimGetNodeCommand(cmd) */ bool -SimStartRsim(argv) - char *argv[]; /* list of rsim args for the fork */ +SimStartRsim( + char *argv[]) /* list of rsim args for the fork */ { - int child; + pid_t child; int magToRsimPipe[2]; int rsimToMagPipe[2]; - char *getenv(); char rsimfile[256]; char *cad = BIN_DIR; - char *src, *dst; + const char *src; + char *dst; /* don't start another rsim if one is already running */ @@ -289,10 +289,10 @@ SimStartRsim(argv) */ void -SimConnectRsim(escRsim) - bool escRsim; /* TRUE if we should escape back to Magic */ +SimConnectRsim( + bool escRsim) /* TRUE if we should escape back to Magic */ { - static char HELLO_MSG[] = + static const char HELLO_MSG[] = "Type \"q\" to quit simulator or \".\" to escape back to Magic.\n"; char *replyLine; /* used to hold one line of the Rsim reply */ @@ -382,9 +382,9 @@ SimConnectRsim(escRsim) *----------------------------------------------------------------------- */ -bool -InitRsim(hello_msg) - char *hello_msg; +static bool +InitRsim( + const char *hello_msg) { char buff[READBUF_SIZE]; char *last; @@ -463,9 +463,9 @@ InitRsim(hello_msg) */ void -SimStopRsim() +SimStopRsim(void) { - int pid; + pid_t pid; if (SimRsimRunning) { @@ -515,9 +515,9 @@ SimStopRsim() */ void -RsimErrorMsg() +RsimErrorMsg(void) { - static char msg[] = "The simulator must be running before this command " + static const char msg[] = "The simulator must be running before this command " "can be executed. To do\n" "this enter the command \"rsim \". " "To escape back to\n" @@ -548,9 +548,9 @@ RsimErrorMsg() */ void -SimRsimIt(cmd, nodeName) - char *cmd; - char *nodeName; +SimRsimIt( + const char *cmd, + const char *nodeName) { static char cmdStr[512]; @@ -619,12 +619,12 @@ SimRsimIt(cmd, nodeName) */ int -SimFillBuffer(buffHead, pLastChar, charCount) - char *buffHead; /* ptr to start of buffer */ - char **pLastChar; /* used to return ptr to last char +SimFillBuffer( + char *buffHead, /* ptr to start of buffer */ + char **pLastChar, /* used to return ptr to last char * in the buffer. */ - int *charCount; /* number of chars in the buffer */ + int *charCount) /* number of chars in the buffer */ { int charsRead = 0; char *temp; @@ -716,10 +716,10 @@ SimFillBuffer(buffHead, pLastChar, charCount) */ void -SimShiftChars(buffStart, lineStart, lastChar) - char *buffStart; /* beginning of buffer */ - char **lineStart; /* ptr to first valid char in buffer */ - char **lastChar; /* ptr to last valid char in buffer */ +SimShiftChars( + char *buffStart, /* beginning of buffer */ + char **lineStart, /* ptr to first valid char in buffer */ + char **lastChar) /* ptr to last valid char in buffer */ { char *temp; char *temp1; @@ -754,9 +754,9 @@ SimShiftChars(buffStart, lineStart, lastChar) */ char * -SimFindNewLine(buffStart, buffEnd) - char *buffStart; /* first char in buffer */ - char *buffEnd; /* last char in buffer */ +SimFindNewLine( + char *buffStart, /* first char in buffer */ + char *buffEnd) /* last char in buffer */ { char *sp; @@ -800,8 +800,8 @@ SimFindNewLine(buffStart, buffEnd) */ bool -SimGetReplyLine(replyLine) - char **replyLine; +SimGetReplyLine( + char **replyLine) { static char simReadBuff[READBUF_SIZE]; /* buffer in which to read the * rsim reply before processing @@ -923,9 +923,9 @@ SimGetReplyLine(replyLine) */ void -SimInit() +SimInit(void) { - static char *rsimdoc = + static const char *rsimdoc = "You are currently using the \"rsim\" tool. The button actions are:\n\ left - move the box so its lower-left corner is at cursor position\n\ right - resize box by moving upper-right corner to cursor position\n\ diff --git a/sim/SimSelect.c b/sim/SimSelect.c index 41290dea..ca27d36d 100644 --- a/sim/SimSelect.c +++ b/sim/SimSelect.c @@ -19,7 +19,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)SimSelect.c 4.14 MAGIC (Berkeley) 10/3/85"; +static const char sccsid[] = "@(#)SimSelect.c 4.14 MAGIC (Berkeley) 10/3/85"; #endif /* not lint */ #include @@ -125,17 +125,17 @@ bool SimRsimRunning = FALSE; /* Always false if there's no rsim module */ */ char * -SimSelectNode(scx, type, xMask, buffer) - SearchContext *scx; /* Area to tree-search for material. The +SimSelectNode( + SearchContext *scx, /* Area to tree-search for material. The * transform must map to EditRoot coordinates. */ - TileType type; /* The type of material to be considered. */ - int xMask; /* Indicates window (or windows) where cells + TileType type, /* The type of material to be considered. */ + int xMask, /* Indicates window (or windows) where cells * must be expanded for their contents to be * considered. 0 means treat everything as * expanded. */ - char *buffer; /* buffer to hold node name */ + char *buffer) /* buffer to hold node name */ { TileTypeBitMask mask; char *strptr; @@ -180,7 +180,7 @@ SimSelectNode(scx, type, xMask, buffer) } int -NullFunc() +NullFunc(void) { return(0); } @@ -202,8 +202,8 @@ NullFunc() */ void -SimFreeNodeList(List) - TileListElt **List; +SimFreeNodeList( + TileListElt **List) { TileListElt *current; TileListElt *temp; @@ -219,8 +219,9 @@ SimFreeNodeList(List) } TileListElt * -simFreeNodeEntry(list, entry) - TileListElt *list, *entry; +simFreeNodeEntry( + TileListElt *list, + TileListElt *entry) { TileListElt *prev, *curr; @@ -257,10 +258,11 @@ simFreeNodeEntry(list, entry) */ TileListElt * -SimSelectArea(Rect *rect) +SimSelectArea( + const Rect *rect) { int plane; - int SimSelectFunc(); + int SimSelectFunc(Tile *tile, ClientData cdata); /* cb_database_srpaintarea_t (TileListElt **pHead) */ /* only need to extract node names if the selection has changed or * if node aliases are to be printed. @@ -276,7 +278,7 @@ SimSelectArea(Rect *rect) { (void) DBSrPaintArea((Tile *) NULL, SelectDef->cd_planes[plane], &TiPlaneRect, &DBAllButSpaceAndDRCBits, - SimSelectFunc, (ClientData) &NodeList); + SimSelectFunc, PTR2CD(&NodeList)); } HashKill(&SimAbortSeenTbl); @@ -316,11 +318,13 @@ SimSelectArea(Rect *rect) * ---------------------------------------------------------------------------- */ +/** @typedef cb_database_srpaintarea_t */ int -SimSelectFunc(tile, pHead) - Tile *tile; /* Tile in SelectDef. */ - TileListElt **pHead; /* list of node names found */ +SimSelectFunc( + Tile *tile, /* Tile in SelectDef. */ + ClientData cdata) /* list of node names found (TileListElt **pHead) */ { + TileListElt **pHead = (TileListElt **)CD2PTR(cdata); TileTypeBitMask mask; SearchContext scx; DBWclientRec *crec; @@ -431,13 +435,13 @@ SimSelectFunc(tile, pHead) */ bool -SimSelection(cmd) - char *cmd; /* rsim command to apply to the selection */ +SimSelection( + const char *cmd) /* rsim command to apply to the selection */ { - static char Hstring[] = "RSIM=1"; - static char Lstring[] = "RSIM=0"; - static char Xstring[] = "RSIM=X"; - static char QUESTstring[] = "?"; + static const char Hstring[] = "RSIM=1"; + static const char Lstring[] = "RSIM=0"; + static const char Xstring[] = "RSIM=X"; + static const char QUESTstring[] = "?"; char timeString[256]; TileListElt *current, *node_list; @@ -445,7 +449,7 @@ SimSelection(cmd) char *strPtr; bool goodReply; - extern void RsimErrorMsg(); + extern void RsimErrorMsg(void); timeString[0] = 0; @@ -606,9 +610,9 @@ the selection.\n"); */ void -SimAddLabels(SelectNodeList, rootuse) - TileListElt *SelectNodeList; - CellDef *rootuse; /* the root cell def for the window */ +SimAddLabels( + TileListElt *SelectNodeList, + CellDef *rootuse) /* the root cell def for the window */ { TileListElt *current; @@ -652,8 +656,8 @@ SimAddLabels(SelectNodeList, rootuse) */ void -SimRsimMouse(w) - MagWindow *w; +SimRsimMouse( + MagWindow *w) { CellUse *cu; @@ -720,7 +724,7 @@ SimRsimMouse(w) */ void -SimGetnode() +SimGetnode(void) { TileListElt *current; @@ -765,7 +769,7 @@ SimGetnode() */ void -SimGetsnode() +SimGetsnode(void) { TileListElt *current; @@ -813,7 +817,7 @@ SimGetsnode() */ void -SimEraseLabels() +SimEraseLabels(void) { SimDefListElt *p; diff --git a/sim/SimSelect.c.new b/sim/SimSelect.c.new deleted file mode 100644 index 2dcca425..00000000 --- a/sim/SimSelect.c.new +++ /dev/null @@ -1,915 +0,0 @@ -/* SimSelect.c - - * - * This file provides routines to make selections for Rsim by copying - * things into a special cell named "__SELECT__". It is based - * on code in the select module. - * - * ********************************************************************* - * * Copyright (C) 1985, 1990 Regents of the University of California. * - * * Permission to use, copy, modify, and distribute this * - * * software and its documentation for any purpose and without * - * * fee is hereby granted, provided that the above copyright * - * * notice appear in all copies. The University of California * - * * makes no representations about the suitability of this * - * * software for any purpose. It is provided "as is" without * - * * express or implied warranty. Export of this software outside * - * * of the United States of America may require an export license. * - * ********************************************************************* - * of California - */ - -#ifndef lint -static char sccsid[] = "@(#)SimSelect.c 4.14 MAGIC (Berkeley) 10/3/85"; -#endif /* not lint */ - -#include -#ifdef SYSV -#include -#else -#include -#endif - -#include "tcltk/tclmagic.h" -#include "utils/magic.h" -#include "utils/geometry.h" -#include "tiles/tile.h" -#include "utils/hash.h" -#include "database/database.h" -#include "windows/windows.h" -#include "dbwind/dbwind.h" -#include "undo/undo.h" -#include "commands/commands.h" -#include "select/selInt.h" -#include "main/main.h" -#include "utils/malloc.h" -#include "utils/signals.h" -#include "sim/sim.h" - -/* Two cells worth of information are kept around by the selection - * module. SelectDef and SelectUse are for the cells whose contents - * are the current selection. Select2Def and Select2Use provide a - * temporary working space for procedures that manipulate the selection. - * for example, Select2Def is used to hold nets or regions while they - * are being extracted by SelectRegion or SelectNet. Once completely - * extracted, information is copied to SelectDef. Changes to - * SelectDef are undo-able and redo-able (so that the undo package - * can deal with selection changes), but changes to Select2Def are - * not undo-able (undoing is always disabled when the cell is modified). - */ - -extern CellDef *SelectDef, *Select2Def; -extern CellUse *SelectUse, *Select2Use; - -typedef struct def_list_elt -{ - CellDef *dl_def; - struct def_list_elt *dl_next; - bool dl_isMarked; -} SimDefListElt; - -static SimDefListElt *SimCellLabList = (SimDefListElt *) NULL; - /* list of all the cell defs we have - * put RSIM labels in - */ - -/* Data structure for node names extracted from the current selection. For - * each node, save the node name, a tile which lies in the node, and - * the text for the label corresponding to the node's rsim value. - */ - -typedef struct TLE { - char *tl_nodeName; - Tile *tl_nodeTile; - char *tl_simLabel; - struct TLE *tl_next; -} TileListElt; - - -TileListElt *NodeList = (TileListElt *) NULL; - /* list of all nodes in the selected area */ -HashTable SimNodeNameTbl; /* node names found in the selected area */ -HashTable SimGetnodeTbl; /* node names to abort name search on */ -HashTable SimGNAliasTbl; /* node name aliases found during search */ -HashTable SimAbortSeenTbl; /* aborted node names found during search */ - -bool SimRecomputeSel = TRUE; /* selection has changed */ -bool SimInitGetnode = TRUE; /* Getnode called for the 1st time */ -bool SimGetnodeAlias = FALSE; /* if node aliases are to be printed */ -bool SimSawAbortString; /* if saw string to abort name search */ -bool SimIsGetnode; /* true if command was issued from Getnode */ -bool SimUseCoords; /* true if we should use trans. position */ -bool SimIgnoreGlobals = TRUE; /* If FALSE, node names ending in "!" */ - /* are treated as global node names. */ - -#ifndef RSIM_MODULE -bool SimRsimRunning = FALSE; /* Always false if there's no rsim module */ -#endif - -/* - * ---------------------------------------------------------------------------- - * - * SimSelectNode -- - * - * This procedure selects an entire node. It is similar to SelectNet. - * - * Results: - * Returns the node name. - * - * Side effects: - * Starting from material of type "type" under scx, this procedure - * finds all material in all expanded cells that are electrically- - * connected to the starting material through a chain of expanded - * cells. - * - * ---------------------------------------------------------------------------- - */ - -char * -SimSelectNode(scx, type, xMask, buffer) - SearchContext *scx; /* Area to tree-search for material. The - * transform must map to EditRoot coordinates. - */ - TileType type; /* The type of material to be considered. */ - int xMask; /* Indicates window (or windows) where cells - * must be expanded for their contents to be - * considered. 0 means treat everything as - * expanded. - */ - char *buffer; /* buffer to hold node name */ -{ - TileTypeBitMask mask; - char *strptr; - - TTMaskZero(&mask); - TTMaskSetType(&mask, type); - - /* Clear out the temporary selection cell and yank all of the - * connected paint into it. - */ - - UndoDisable(); - DBCellClearDef(Select2Def); - SimTreeCopyConnect(scx, &mask, xMask, DBConnectTbl, - &TiPlaneRect, Select2Use, buffer); - UndoEnable(); - - /* Strip out path if name is global (ends with a "!") */ - /* and flag SimIgnoreGlobals is not set. */ - - if (!SimIgnoreGlobals) - { - strptr = buffer + strlen(buffer) - 1; - if (*strptr == '!') { - *strptr = '\0'; - while (strptr != buffer) { - if (*strptr == '/') { - strptr++; - break; - } - strptr--; - } - } - else { - strptr = buffer; - } - } - else - strptr = buffer; - - return(strptr); -} - -NullFunc() -{ - return(0); -} - -/* - * ---------------------------------------------------------------------------- - * SimFreeNodeList - * - * This procedure frees all space allocated for the node list - * data structure. - * - * Results: - * None. - * - * Side effects: - * After the list has been deallocated, the head pointer is set to - * a NULL value. - * ---------------------------------------------------------------------------- - */ - -void -SimFreeNodeList(List) - TileListElt **List; -{ - TileListElt *current; - TileListElt *temp; - - temp = *List; - while (temp != NULL) { - current = temp; - temp = temp->tl_next; - freeMagic(current->tl_nodeName); - freeMagic(current); - } - *List = (TileListElt *) NULL; -} - -TileListElt * -simFreeNodeEntry(list, entry) - TileListElt *list, *entry; -{ - TileListElt *prev, *curr; - - prev = list; - for( curr = prev->tl_next; curr != NULL; prev = curr,curr = curr->tl_next ) - if( curr == entry ) - { - prev->tl_next = curr->tl_next; - freeMagic( entry->tl_nodeName ); - freeMagic( entry ); - return( prev ); /* next element in list */ - } - - /* should never get here */ - return(entry); -} - -/* - * ---------------------------------------------------------------------------- - * SimSelectArea - * - * This procedure checks the current selected paint in the circuit and - * extracts the names of all the nodes in the selected area. - * - * Results: - * Returns a list of node name data structures. - * - * Side Effects: - * The tiles of the selection cell definition are first marked in the - * search algorithm. After finishing the search, these marks are - * erased. - * - * ---------------------------------------------------------------------------- - */ - -typedef struct { - TileListElt *NodeList; - MagWindow *window; - SearchContext *scx; -} SimSelData; - - -TileListElt * -SimSelectArea(Rect *rect) -{ - int plane; - int SimSelectFunc(); - SimSelData simseldata; - SearchContext scx; - - /* only need to extract node names if the selection has changed or - * if node aliases are to be printed. - */ - - if (SimRecomputeSel || (SimGetnodeAlias && SimIsGetnode)) { - SimFreeNodeList(&NodeList); - HashInit(&SimAbortSeenTbl, 20, HT_STRINGKEYS); - - /* find all nodes in the current selection */ - - simseldata.NodeList = NodeList; - simseldata.scx = &scx; - simseldata.window = CmdGetRootPoint((Point *) NULL, &scx.scx_area); - if (rect != NULL) scx.scx_area = *rect; - if (simseldata.window != NULL) - { - for (plane = PL_TECHDEPBASE; plane < DBNumPlanes; plane++) - { - (void) DBSrPaintArea((Tile *) NULL, SelectDef->cd_planes[plane], - &TiPlaneRect, &DBAllButSpaceAndDRCBits, - SimSelectFunc, (ClientData) &simseldata); - } - } - - HashKill(&SimAbortSeenTbl); - ExtResetTiles(SelectDef, (ClientData) MINFINITY); - SimGetNodeCleanUp(); - SimRecomputeSel = FALSE; - } - if (SigInterruptPending) { - - /* if caught an interrupt, be sure to recompute the selection - * next time around. - */ - - SimRecomputeSel = TRUE; - } - return(NodeList); -} - - -/* - * ---------------------------------------------------------------------------- - * SimSelectFunc - * - * This procedure is called for each tile in the current selection. - * It first checks to see if the node the tile belongs to has not - * yet been visited. If it has not been visited, then the node name - * is extracted and all other tiles in the selection which belong to - * this node are marked. - * - * Results: - * Return 0 to keep the search going. - * - * Side effects: - * The tiles in the selection cell definition are left marked. - * It is the responsibility of the calling function to erase these - * tile marks when finished. - * ---------------------------------------------------------------------------- - */ - -int -SimSelectFunc(tile, simseldata) - Tile *tile; /* Tile in SelectDef. */ - SimSelData simseldata; - -{ - TileListElt **pHead; /* list of node names found */ - TileTypeBitMask mask; - SearchContext scx; - DBWclientRec *crec; - MagWindow *window; - char nameBuff[256], *nodeName; - TileListElt *newNodeTile; - TileType type; - bool coord; - - window = simseldata->window; - - /* check to see if the node has already been extracted */ - - if (tile->ti_client == (ClientData) 1) { - return(0); - } - -#ifdef NONMANHATTAN - if (IsSplit(tile)) - { - type = (SplitSide(tile)) ? SplitRightType(tile): - SplitLeftType(tile); - } - else -#endif - type = TiGetTypeExact(tile); - - /* get the tile's area, and initialize the tile's search context. */ - - TITORECT(tile, &scx.scx_area); - -#ifdef NONMANHATTAN - /* make sure that search context isn't placed on an empty */ - /* corner of a split tile. */ - if (IsSplit(tile)) - { - if (SplitSide(tile)) - scx.scx_area.r_xbot = scx.scx_area.r_xtop - 1; - if (!(SplitDirection(tile) ^ SplitSide(tile))) - scx.scx_area.r_ybot = scx.scx_area.r_ytop - 1; - } -#endif - - scx.scx_area.r_xtop = scx.scx_area.r_xbot + 1; - scx.scx_area.r_ytop = scx.scx_area.r_ybot + 1; - - scx.scx_use = (CellUse *) window->w_surfaceID; - scx.scx_trans = GeoIdentityTransform; - crec = (DBWclientRec *) window->w_clientData; - - TTMaskZero(&mask); - TTMaskSetType(&mask, type); - TTMaskAndMask(&mask, &crec->dbw_visibleLayers); - TTMaskAndMask(&mask, &DBAllButSpaceAndDRCBits); - - /* Check if the area is above a layer which is not visible. */ - - if (TTMaskIsZero(&mask)) { - return(0); - } - - /* mark all other tiles in the selection that are part of this node */ - - SimSrConnect(SelectDef, &scx.scx_area, &DBAllButSpaceAndDRCBits, - DBConnectTbl, &TiPlaneRect, NullFunc, (ClientData) NULL); - - /* Pick a tile type to use for selection. */ - - for (type = TT_TECHDEPBASE; type < DBNumTypes; type += 1) - { - if (TTMaskHasType(&mask, type)) break; - } - - nodeName = SimSelectNode(&scx, type, 0, nameBuff); - - /* add the node name to the list only if it has not been seen yet */ - - coord = (nodeName[0] == '@' && nodeName[1] == '=') ? TRUE : FALSE; - - if(coord || HashLookOnly(&SimNodeNameTbl, nodeName) == (HashEntry *) NULL) - { - if( ! coord ) - HashFind(&SimNodeNameTbl, nodeName); - newNodeTile = (TileListElt *) mallocMagic((unsigned) (sizeof (TileListElt))); - newNodeTile->tl_nodeName = (char *) mallocMagic((unsigned) (strlen(nodeName) + 1)); - strcpy(newNodeTile->tl_nodeName, nodeName); - newNodeTile->tl_nodeTile = tile; - newNodeTile->tl_next = *pHead; - *pHead = newNodeTile; - } - return(0); -} - -#ifdef RSIM_MODULE - -/* - * ---------------------------------------------------------------------------- - * SimSelection - * - * This procedure applies the specified rsim command to the list of - * nodes in the current selection and also attaches the rsim node - * value string to each node. - * - * Results: - * returns FALSE if no nodes are in the selection. - * - * Side effects: - * None. - * - * ---------------------------------------------------------------------------- - */ - -bool -SimSelection(cmd) - char *cmd; /* rsim command to apply to the selection */ -{ - static char Hstring[] = "RSIM=1"; - static char Lstring[] = "RSIM=0"; - static char Xstring[] = "RSIM=X"; - static char QUESTstring[] = "?"; - - char timeString[256]; - TileListElt *current, *node_list; - char *replyLine; - char *strPtr; - bool goodReply; - - extern RsimErrorMsg(); - - timeString[0] = 0; - - /* check to see if Rsim has been started yet */ - - if (!SimRsimRunning) { - RsimErrorMsg(); - return(FALSE); - } - - /* get the list of all nodes in the selection */ - - SimIsGetnode = FALSE; - SimUseCoords = SimHasCoords; - - HashInit(&SimNodeNameTbl, 60, HT_STRINGKEYS); - node_list = SimSelectArea((Rect *)NULL); - - if (node_list == (TileListElt *) NULL) { - TxPrintf("You must select paint (rather than a cell) to use Rsim on \ -the selection.\n"); - goto bad; - } - - /* Walk the list of node names, apply the rsim command to each node, - * and then process the results. - */ - - for (current = node_list; current != NULL; current = current->tl_next) - { - current->tl_simLabel = QUESTstring; - SimRsimIt(cmd, current->tl_nodeName); - - if (!SimGetReplyLine(&replyLine)) { - goto bad; - } - - if (!replyLine) { - /* Rsim's reponse to the command was just a prompt. We are done - * with the current node, so process the next node in the - * selection. - */ - continue; - } - - /* check for node names not recognized by Rsim */ - - if (strncmp(replyLine, "time = ", 7) == 0) { - if (timeString[0] == 0) { - strcpy(timeString, replyLine); - } - TxPrintf("%s not recognized in sim file\n", current->tl_nodeName); - while(replyLine) { - /* swallow Rsim reply until no more is left */ - if (!SimGetReplyLine(&replyLine)) { - goto bad; - } - } - continue; - } - - /* update the node value label strings */ - - if (*cmd == 'd') - { - char *name = current->tl_nodeName; - bool coord = (name[0] == '@' && name[1] == '=') ? TRUE : FALSE; - - strPtr = strrchr( replyLine, '=' ); - if( strPtr == NULL ) - strPtr = QUESTstring; - else if( coord ) - { - *strPtr = '\0'; - name = replyLine; - if( HashLookOnly(&SimNodeNameTbl, name) == (HashEntry *) NULL) - { - freeMagic(current->tl_nodeName); - current->tl_nodeName = (char *) mallocMagic((unsigned) (strlen(name) + 1)); - strcpy(current->tl_nodeName, name); - HashFind(&SimNodeNameTbl, current->tl_nodeName); - *strPtr++ = '='; - } - else - { - current = simFreeNodeEntry( node_list, current ); - *strPtr = '='; - } - } - else - strPtr++; - - switch (*strPtr) { - case '1' : - current->tl_simLabel = Hstring; - break; - case '0' : - current->tl_simLabel = Lstring; - break; - case 'X' : - current->tl_simLabel = Xstring; - break; - case '=' : - break; - default : - current->tl_simLabel = QUESTstring; - break; - } - } - - /* read all lines of the Rsim reply */ - - goodReply = TRUE; - for (;replyLine; goodReply = SimGetReplyLine(&replyLine)) { - if (!goodReply) { - goto bad; - } - if (!strncmp(replyLine, "time = ", 7)) { - if (!(timeString[0])) { - strcpy(timeString, replyLine); - } - continue; - } else if( *strPtr != '=' ) { - TxPrintf("%s\n", replyLine); - } - } - } - if (timeString[0] != 0) { - TxPrintf("%s\n", timeString); - } - - HashKill(&SimNodeNameTbl); - return(TRUE); - - bad: - HashKill(&SimNodeNameTbl); - return(FALSE); -} - - -#endif - -/* - * ---------------------------------------------------------------------------- - * SimAddLabels - * - * This procedure adds the node value labels to the Magic database - * so they will be displayed in the layout. - * - * Results: - * None. - * - * Side effects: - * The cell modified flags are deliberately not set when these labels - * are added to the database. - * - * ---------------------------------------------------------------------------- - */ - -void -SimAddLabels(SelectNodeList, rootuse) - TileListElt *SelectNodeList; - CellDef *rootuse; /* the root cell def for the window */ -{ - - TileListElt *current; - Rect selectBox; - int pos; - - /* walk the list of selected nodes, add the node value label to the - * database. - */ - - for (current = SelectNodeList; current != (TileListElt *) NULL; - current = current->tl_next) { - if (*(current->tl_simLabel) == '?') { - continue; - } - TiToRect(current->tl_nodeTile, &selectBox); - pos = SimPutLabel(rootuse, &selectBox, GEO_CENTER, - current->tl_simLabel, TT_SPACE); - DBReComputeBbox(rootuse); - DBWLabelChanged(rootuse, current->tl_simLabel, &selectBox, - pos, DBW_ALLWINDOWS); - } -} - -#ifdef RSIM_MODULE - -/* - * ---------------------------------------------------------------------------- - * SimRsimMouse - * - * This procedure erases the old rsim node labels and display the - * node labels of the current selection. - * - * Results: - * None. - * - * Side effects: - * None. - * - * ---------------------------------------------------------------------------- - */ - -void -SimRsimMouse(w) - MagWindow *w; -{ - - CellUse *cu; - bool sawcell; - SimDefListElt *dummy; - - if ((w == (MagWindow *) NULL) || (w->w_client != DBWclientID)) - { - TxError("Put the cursor in a layout window\n"); - return; - } - - cu = (CellUse *)w->w_surfaceID; /* get root cell use for wind */ - - /* check to see if the cell def is already in our list */ - sawcell = FALSE; - for (dummy = SimCellLabList; dummy; dummy = dummy->dl_next) { - if (dummy->dl_def == cu->cu_def) { - sawcell = TRUE; - break; - } - } - - if (!sawcell) { - /* add the cell def to the list */ - if (SimCellLabList == (SimDefListElt *) NULL) { - SimCellLabList = (SimDefListElt *) mallocMagic((unsigned) (sizeof(SimDefListElt))); - SimCellLabList->dl_isMarked = FALSE; - SimCellLabList->dl_def = cu->cu_def; - SimCellLabList->dl_next = (SimDefListElt *) NULL; - dummy = SimCellLabList; - } - else { - dummy = (SimDefListElt *) mallocMagic((unsigned) (sizeof(SimDefListElt))); - dummy->dl_isMarked = FALSE; - dummy->dl_next = SimCellLabList; - dummy->dl_def = cu->cu_def; - SimCellLabList= dummy; - } - } - - SimEraseLabels(); - if (SimSelection("d")) { - dummy->dl_isMarked = TRUE; - SimAddLabels(NodeList, dummy->dl_def); - } -} - -#endif - -/*------------------------------------------------------*/ -/* Experimental for DEF output. . . */ -/* Function "func" is a callback process for each node. */ -/* SimGetnode and SimGetsnode can both be recast as */ -/* operating off of this function. */ -/* */ -/* "func" should be cast as: */ -/* int func(Tile *tile, char *nodeName, ClientData cd); */ -/*------------------------------------------------------*/ - -void -SimProcessNode(func, shortnames, area, clientdata) - ((int *)func)(); - bool shortnames; - Rect *area; - ClientData clientdata; -{ - TileListElt *current; - - /* get the list of node names */ - - SimIsGetnode = TRUE; - SimUseCoords = shortnames; - - HashInit(&SimNodeNameTbl, 60, HT_STRINGKEYS); - current = SimSelectArea(area); - HashKill(&SimNodeNameTbl); - - if (current == (TileListElt *) NULL) { - TxPrintf("You must select paint (not a cell) to use getnode.\n"); - return; - } - - for (; current != (TileListElt *) NULL; current = current->tl_next) - if ((*func)(current->tl_nodeTile, current->tl_nodeName, clientdata) == 1) - break; -} - -/* - * ---------------------------------------------------------------------------- - * SimGetnode - * - * This procedure prints the node names of all selected nodes. - * - * Results: - * None. - * - * Side effects: - * None. - * - * ---------------------------------------------------------------------------- - */ - -void -SimGetnode() -{ - int SimGetnodeFunc(); - SimProcessNode(SimGetnodeFunc, FALSE, NULL, (ClientData)NULL); -} - -void -SimGetsnode() -{ - int SimGetnodeFunc(); - SimProcessNode(SimGetnodeFunc, TRUE, NULL, (ClientData)NULL); -} - -int -SimGetnodeFunc(tile, nodeName, clientdata) - Tile *tile; - char *nodeName; - ClientData clientdata; -{ -#ifdef MAGIC_WRAPPER - /* Return the node name as the result of the command */ - Tcl_AppendElement(magicinterp, nodeName); -#else - TxPrintf("node name : %s\n", nodeName); -#endif - return 0; /* Continue the list */ -} - -void -OLD_SimGetnode() -{ - TileListElt *current; - - /* get the list of node names */ - - SimIsGetnode = TRUE; - SimUseCoords = FALSE; - - HashInit(&SimNodeNameTbl, 60, HT_STRINGKEYS); - current = SimSelectArea((Rect *)NULL); - HashKill(&SimNodeNameTbl); - - if (current == (TileListElt *) NULL) { - TxPrintf("You must select paint (not a cell) to use getnode.\n"); - return; - } - - for (; current != (TileListElt *) NULL; current = current->tl_next) - { -#ifdef MAGIC_WRAPPER - /* Return the node name as the result of the command */ - Tcl_AppendElement(magicinterp, current->tl_nodeName); -#else - TxPrintf("node name : %s\n", current->tl_nodeName); -#endif - } -} - -/* - * ---------------------------------------------------------------------------- - * SimGetsnode - * - * This procedure prints the short node names of all selected nodes. - * - * Results: - * None. - * - * Side effects: - * None. - * - * ---------------------------------------------------------------------------- - */ - -void -OLD_SimGetsnode() -{ - TileListElt *current; - - /* get the list of node names */ - - SimIsGetnode = TRUE; - SimUseCoords = TRUE; - - HashInit(&SimNodeNameTbl, 60, HT_STRINGKEYS); - current = SimSelectArea((Rect *)NULL); - HashKill(&SimNodeNameTbl); - - if (current == (TileListElt *) NULL) { - TxPrintf("You must select paint (not a cell) to use getnode.\n"); - return; - } - - for (; current != (TileListElt *) NULL; current = current->tl_next) - { -#ifdef MAGIC_WRAPPER - /* Return the node short name as the result of the command */ - Tcl_AppendElement(magicinterp, current->tl_nodeName); -#else - TxPrintf("short node name : %s\n", current->tl_nodeName); -#endif - } -} - - - -/* - * ---------------------------------------------------------------------------- - * SimEraseLabels - * - * This procedure erases the RSIM labels from any cell defs they - * may have been added to. - * - * Results: - * None. - * - * Side effects: - * Removes the RSIM labels from "marked" cell defs. - * - * ---------------------------------------------------------------------------- - */ - -void -SimEraseLabels() -{ - SimDefListElt *p; - - for (p = SimCellLabList; p; p = p->dl_next) { - if (p->dl_isMarked) { - p->dl_isMarked = FALSE; - DBEraseLabelsByContent(p->dl_def, (Rect *)NULL, -1, -1, "RSIM=X"); - DBEraseLabelsByContent(p->dl_def, (Rect *)NULL, -1, -1, "RSIM=1"); - DBEraseLabelsByContent(p->dl_def, (Rect *)NULL, -1, -1, "RSIM=0"); - } - } -} diff --git a/sim/sim.h b/sim/sim.h index 36fa4169..a5495bf8 100644 --- a/sim/sim.h +++ b/sim/sim.h @@ -2,16 +2,18 @@ #define _SIM_H #include "utils/magic.h" +#include "textio/txcommands.h" /* TxCommand */ +#include "windows/windows.h" /* MagWindow */ -extern char *SimGetNodeCommand(); -extern char *SimGetNodeName(); -extern char *SimSelectNode(); -extern bool SimGetReplyLine(); -extern void SimRsimIt(); -extern void SimEraseLabels(); -extern bool efPreferredName(); -extern void SimRsimHandler(); -extern void SimInit(); +extern const char *SimGetNodeCommand(const char *cmd); +extern char *SimGetNodeName(SearchContext *sx, Tile *tp, const char *path); +extern char *SimSelectNode(SearchContext *scx, TileType type, int xMask, char *buffer); +extern bool SimGetReplyLine(char **replyLine); +extern void SimRsimIt(const char *cmd, const char *nodeName); +extern void SimEraseLabels(void); +extern bool efPreferredName(const char *name1, const char *name2); +extern void SimRsimHandler(MagWindow *w, TxCommand *cmd); +extern void SimInit(void); extern bool SimRecomputeSel; extern bool SimInitGetnode; @@ -29,18 +31,22 @@ extern HashTable SimGetnodeTbl; extern HashTable SimAbortSeenTbl; /* C99 compat */ -extern void SimGetnode(); -extern void SimGetsnode(); -extern void SimGetNodeCleanUp(); -extern int SimPutLabel(); -extern int SimSrConnect(); -extern void SimTreeCopyConnect(); -extern int SimTreeSrNMTiles(); -extern int SimTreeSrTiles(); -extern bool SimStartRsim(); -extern void SimConnectRsim(); -extern bool SimSelection(); -extern void SimRsimMouse(); -extern int SimFillBuffer(); +extern void SimGetnode(void); +extern void SimGetsnode(void); +extern void SimGetNodeCleanUp(void); +extern int SimPutLabel(CellDef *cellDef, const Rect *rect, int align, const char *text, TileType type); +extern int SimSrConnect(CellDef *def, const Rect *startArea, const TileTypeBitMask *mask, const TileTypeBitMask *connect, + const Rect *bounds, int (*func)(), ClientData clientData); +extern void SimTreeCopyConnect(SearchContext *scx, const TileTypeBitMask *mask, int xMask, const TileTypeBitMask *connect, + const Rect *area, CellUse *destUse, char *Node_Name); +extern int SimTreeSrNMTiles(SearchContext *scx, TileType dinfo, const TileTypeBitMask *mask, int xMask, TerminalPath *tpath, + int (*func)(), ClientData cdarg); +extern int SimTreeSrTiles(SearchContext *scx, const TileTypeBitMask *mask, int xMask, TerminalPath *tpath, + int (*func)(), ClientData cdarg); +extern bool SimStartRsim(char *argv[]); +extern void SimConnectRsim(bool escRsim); +extern bool SimSelection(const char *cmd); +extern void SimRsimMouse(MagWindow *w); +extern int SimFillBuffer(char *buffHead, char **pLastChar, int *charCount); #endif /* _SIM_H */