1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
|
/*
* irTestCmd.c --
*
* Code to process the `*iroute' command.
* `*iroute' is a wizard command for debugging and testing.
*
* *********************************************************************
* * Copyright (C) 1987, 1990 Michael H. Arnold, Walter S. Scott, and *
* * the 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. *
* *********************************************************************
*/
#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-7.5/irouter/irTestCmd.c,v 1.2 2006/07/28 23:12:49 tim Exp $";
#endif /* not lint */
#include <stdio.h>
#include "utils/magic.h"
#include "utils/geometry.h"
#include "utils/hash.h"
#include "tiles/tile.h"
#include "database/database.h"
#include "utils/signals.h"
#include "textio/textio.h"
#include "irouter/irouter.h"
#include "graphics/graphics.h"
#include "windows/windows.h"
#include "dbwind/dbwind.h"
#include "dbwind/dbwtech.h"
#include "textio/txcommands.h"
#include "utils/main.h"
#include "utils/utils.h"
#include "commands/commands.h"
#include "utils/styles.h"
#include "utils/malloc.h"
#include "utils/list.h"
#include "../mzrouter/mzrouter.h"
#include "irouter/irInternal.h"
/* Subcommand table - declared here since its referenced before defined */
typedef struct
{
char *sC_name; /* name of iroute subcommand */
void (*sC_proc)(); /* Procedure implementing this subcommand */
char *sC_commentString;
char *sC_usage;
} TestCmdTableE;
extern TestCmdTableE irTestCommands[];
/*
* ----------------------------------------------------------------------------
*
* irDebugTstCmd --
*
* irouter wizard command (`:*iroute') to set/clear debug flags.
*
* Results:
* None.
*
* Side effects:
* Modify debug flags.
*
* ----------------------------------------------------------------------------
*/
void
irDebugTstCmd(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
int result;
bool value;
if (cmd->tx_argc > 4)
{
TxPrintf("Too many args on '*iroute debug'\n");
return;
}
else if (cmd->tx_argc == 4)
{
/* two args, set or clear first arg according to second */
result = SetNoisyBool(&value,cmd->tx_argv[3], (FILE *) NULL);
if (result == 0)
{
TxPrintf("\n");
DebugSet(irDebugID,1,&(cmd->tx_argv[2]),(bool) value);
}
else
TxError("Unknown boolean value %s\n", cmd->tx_argv[2]);
}
else
{
/* list current values of flags */
DebugShow(irDebugID);
}
return;
}
/*
* ----------------------------------------------------------------------------
*
* irHelpTstCmd --
*
* irouter wizard command (`:*iroute') to print help info on irouter wizard
* commands.
*
* Results:
* None.
*
* Side effects:
* See above.
*
* ----------------------------------------------------------------------------
*/
void
irHelpTstCmd(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
int n;
int which;
if(cmd->tx_argc == 2)
{
/* No arg, so print summary of commands */
for(n=0; irTestCommands[n].sC_name!=NULL; n++)
{
TxPrintf("*iroute %s - %s\n",
irTestCommands[n].sC_name,
irTestCommands[n].sC_commentString);
}
TxPrintf("\n*iroute help [subcmd] - ");
TxPrintf("Print usage info for subcommand.\n");
}
else
{
/* Lookup subcommand in table, and printed associated help info */
which = LookupStruct(
cmd->tx_argv[2],
(char **) irTestCommands,
sizeof irTestCommands[0]);
/* Process result of lookup */
if (which >= 0)
{
/* subcommand found - print out its comment string and usage */
TxPrintf("*iroute %s - %s\n",
irTestCommands[which].sC_name,
irTestCommands[which].sC_commentString);
TxPrintf("Usage: *iroute %s\n",
irTestCommands[which].sC_usage);
}
else if (which == -1)
{
/* ambiguous subcommand - complain */
TxError("Ambiguous *iroute subcommand: \"%s\"\n", cmd->tx_argv[2]);
}
else
{
/* unrecognized subcommand - complain */
TxError("Unrecognized iroute subcommand: \"%s\"\n",
cmd->tx_argv[2]);
TxError("Valid *iroute subcommands are: ");
for (n = 0; irTestCommands[n].sC_name; n++)
TxError(" %s", irTestCommands[n].sC_name);
TxError("\n");
}
}
return;
}
/*
* ----------------------------------------------------------------------------
*
* irParmsTstCmd --
*
* irouter wizard command (`:*iroute') to dump parms.
* commands.
*
* Results:
* None.
*
* Side effects:
* Dump routelayers and routecontacts.
*
* ----------------------------------------------------------------------------
*/
void
irParmsTstCmd(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
MZPrintRLs(irRouteLayers);
TxMore("");
MZPrintRCs(irRouteContacts);
return;
}
/*--------------------------- Command Table ------------------------------ */
TestCmdTableE irTestCommands[] = {
"debug", irDebugTstCmd,
"set or clear debug flags",
"debug [flag] [value]",
"help", irHelpTstCmd,
"summarize *iroute subcommands",
"help [subcommand]",
"parms", irParmsTstCmd,
"print internal data structures",
"parms",
0
}, *irTestCmdP;
/*
* ----------------------------------------------------------------------------
*
* IRTest --
*
* Command interface for testing the interactive router.
*
* Results:
* None.
*
* Side effects:
* Depends on the command; see below.
*
* Organization:
* We select a procedure based on the first keyword (argv[0])
* and call it to do the work of implementing the rule. Each
* such procedure is of the following form:
*
* int
* proc(argc, argv)
* int argc;
* char *argv[];
* {
* }
*
* ----------------------------------------------------------------------------
*/
void
IRTest(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
int n;
int which;
if(cmd->tx_argc == 1)
{
/* No subcommand specified. */
TxPrintf("Must specify subcommand.");
TxPrintf(" (type '*iroute help' for summary)\n");
}
else
{
/* Lookup subcommand in table */
which = LookupStruct(
cmd->tx_argv[1],
(char **) irTestCommands,
sizeof irTestCommands[0]);
/* Process result of lookup */
if (which >= 0)
{
/* subcommand found - call proc that implements it */
irTestCmdP = &irTestCommands[which];
(*irTestCmdP->sC_proc)(w,cmd);
}
else if (which == -1)
{
/* ambiguous subcommand - complain */
TxError("Ambiguous subcommand: \"%s\"\n", cmd->tx_argv[1]);
}
else
{
/* unrecognized subcommand - complain */
TxError("Unrecognized subcommand: \"%s\"\n", cmd->tx_argv[1]);
TxError("Valid subcommands:");
for (n = 0; irTestCommands[n].sC_name; n++)
TxError(" %s", irTestCommands[n].sC_name);
TxError("\n");
}
}
return;
}
|