sim: constify various APIs

This commit is contained in:
Darryl L. Miles 2025-01-31 19:43:08 +00:00 committed by R. Timothy Edwards
parent 1fbba4408f
commit 6ec826fb8b
5 changed files with 46 additions and 44 deletions

View File

@ -94,7 +94,8 @@ SimConnectFunc(
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;
@ -327,18 +328,18 @@ SimTreeCopyConnect(
* this area. The transform is from
* coords of scx_use to destUse.
*/
TileTypeBitMask *mask, /* Tile types to start from in area. */
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.
*/
@ -354,7 +355,7 @@ SimTreeCopyConnect(
{
TerminalPath tpath;
char pathName[MAXPATHNAME];
TileTypeBitMask *newmask;
const TileTypeBitMask *newmask;
struct conSrArg2 csa2;
TileType newtype;
@ -439,11 +440,11 @@ SimTreeCopyConnect(
bool
efPreferredName(
char *name1,
char *name2)
const char *name1,
const char *name2)
{
int nslashes1, nslashes2;
char *np1, *np2;
const char *np1, *np2;
if( name1[0] == '@' && name1[1] == '=' )
return( TRUE );
@ -556,20 +557,21 @@ SimSrConnect(
* 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.
@ -667,7 +669,7 @@ SimTreeSrTiles(
* 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
@ -712,7 +714,7 @@ SimTreeSrNMTiles(
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
@ -862,12 +864,12 @@ cleanup:
int
SimPutLabel(
CellDef *cellDef, /* Cell in which label is placed */
Rect *rect, /* Location of label, see above for description */
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 */
const char *text, /* Pointer to actual text of label */
TileType type) /* Type of tile to be labeled */
{
Label *lab;

View File

@ -341,7 +341,7 @@ typedef struct /* return value from SimFindOneNode */
char *
SimTxtorLabel(
int nterm,
Transform *tm,
const Transform *tm,
SimTrans *trans)
{
static char name[30];
@ -707,7 +707,7 @@ SimGetNodeName(
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;

View File

@ -98,9 +98,9 @@ void SimStopRsim(void);
*-----------------------------------------------------------------------
*/
char *
const char *
SimGetNodeCommand(
char *cmd)
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
@ -292,7 +292,7 @@ void
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 */
@ -384,7 +384,7 @@ SimConnectRsim(
bool
InitRsim(
char *hello_msg)
const char *hello_msg)
{
char buff[READBUF_SIZE];
char *last;
@ -517,7 +517,7 @@ SimStopRsim(void)
void
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 <options> <filename>\". "
"To escape back to\n"
@ -549,8 +549,8 @@ RsimErrorMsg(void)
void
SimRsimIt(
char *cmd,
char *nodeName)
const char *cmd,
const char *nodeName)
{
static char cmdStr[512];
@ -932,7 +932,7 @@ SimGetReplyLine(
void
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\

View File

@ -259,7 +259,7 @@ simFreeNodeEntry(
TileListElt *
SimSelectArea(
Rect *rect)
const Rect *rect)
{
int plane;
int SimSelectFunc();
@ -434,12 +434,12 @@ SimSelectFunc(
bool
SimSelection(
char *cmd) /* rsim command to apply to the selection */
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;

View File

@ -5,13 +5,13 @@
#include "textio/txcommands.h" /* TxCommand */
#include "windows/windows.h" /* MagWindow */
extern char *SimGetNodeCommand(char *cmd);
extern char *SimGetNodeName(SearchContext *sx, Tile *tp, char *path);
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(char *cmd, char *nodeName);
extern void SimRsimIt(const char *cmd, const char *nodeName);
extern void SimEraseLabels(void);
extern bool efPreferredName(char *name1, char *name2);
extern bool efPreferredName(const char *name1, const char *name2);
extern void SimRsimHandler(MagWindow *w, TxCommand *cmd);
extern void SimInit(void);
@ -34,18 +34,18 @@ extern HashTable SimAbortSeenTbl;
extern void SimGetnode(void);
extern void SimGetsnode(void);
extern void SimGetNodeCleanUp(void);
extern int SimPutLabel(CellDef *cellDef, Rect *rect, int align, char *text, TileType type);
extern int SimSrConnect(CellDef *def, Rect *startArea, TileTypeBitMask *mask, TileTypeBitMask *connect,
Rect *bounds, int (*func)(), ClientData clientData);
extern void SimTreeCopyConnect(SearchContext *scx, TileTypeBitMask *mask, int xMask, TileTypeBitMask *connect,
Rect *area, CellUse *destUse, char *Node_Name);
extern int SimTreeSrNMTiles(SearchContext *scx, TileType dinfo, TileTypeBitMask *mask, int xMask, TerminalPath *tpath,
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, TileTypeBitMask *mask, int xMask, TerminalPath *tpath,
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(char *cmd);
extern bool SimSelection(const char *cmd);
extern void SimRsimMouse(MagWindow *w);
extern int SimFillBuffer(char *buffHead, char **pLastChar, int *charCount);