home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume18 / treepar / part01 / main.c next >
Encoding:
C/C++ Source or Header  |  1989-03-12  |  2.5 KB  |  111 lines

  1. /* main program for treepar
  2.  *
  3.  * 28.Jul.87  jimmc  Initial definition
  4.  * 14.Aug.87  jimmc  Add place and route stuff
  5.  * 22.Sep.87  jimmc  Define F macro in this file
  6.  * 17.Oct.87  jimmc  Convert to use spin interface
  7.  * 27.Jan.88  jimmc  Add RFeed command
  8.  *  5.Feb.88  jimmc  Moved some routines into misc.c
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include "xalloc.h"
  13.  
  14. extern char *rindex();
  15.  
  16. char *treeparVersion = "treepar v1.1 1.Mar.88";
  17.  
  18. char *Progname;
  19.  
  20. main(argc,argv)
  21. int argc;
  22. char *argv[];
  23. {
  24. int i,j;
  25. char *execval=0;
  26.  
  27.     Progname = rindex(argv[0],'/');
  28.     if (Progname) Progname++; else Progname=argv[0];
  29.  
  30.     PSetup();    /* init the plot drivers */
  31.     applinit();
  32.  
  33.     SPinitsubs();
  34.  
  35.     for (i=1; i<argc; i++) {
  36.         if (argv[i][0]=='-') for (j=1; j>0 && argv[i][j]; j++) {
  37.             switch (argv[i][j]) {
  38.             case 'e':    /* execute */
  39.                 if (argv[i][++j]) execval = argv[i]+j;
  40.                 else if (++i<argc) execval = argv[i];
  41.                 else fatalerr("not enough args for -e");
  42.                 j = -1;
  43.                 break;
  44.             default:
  45.                 fatalerr("unknown switch %c", argv[i][j]);
  46.             }
  47.         }
  48.         else {    /* not a switch */
  49.             fatalerr("unknown argument %s", argv[i]);
  50.         }
  51.     }
  52.  
  53.     if (execval) { SPmainstring(execval); }
  54.     SPmainfile(stdin);
  55.     exit(0);
  56. }
  57.  
  58. /*
  59.  * arg types are:
  60.  * i - integer
  61.  * s - string
  62.  * f - float (double)
  63.  * L - list
  64.  * 
  65.  * define function as F(funcname,"argstr")
  66.  * The first char of argstr is the return type
  67.  */
  68.  
  69. #define F(fnamez,argsz) {\
  70.     extern fnamez();\
  71.     SPdeffunc("fnamez",argsz,fnamez);\
  72. }
  73.  
  74. #define FS(fnamez,argsz) {\
  75.     extern char *fnamez();\
  76.     SPdeffunc("fnamez",argsz,fnamez);\
  77. }
  78.  
  79. applinit()
  80. {
  81. /* routines to read and write the tree text files */
  82. F(NRead,"is");
  83. F(NWrite,"is");
  84. F(NPlot,"iS\"X\"S\"stdout\"");
  85. F(NPlot4,"iS\"X\"S\"stdout\"");
  86. F(NPlotXY,"iS\"X\"S\"stdout\"I2I2");
  87. F(PSetWindow,"vdddd");
  88.  
  89. /* place and route routines */
  90. F(RSelect,"iSN"); /* select rows for boxes and nets */
  91. F(RUnFeed,"i");    /* undo any feedthroughs */
  92. F(RFeed,"i");    /* generate feedthroughs for nets which span rows */
  93. F(RReFeed,"i");    /* UnFeed and Feed */
  94. F(RSpace,"i");    /* generate row datastructs and size them */
  95. F(ROrder,"iSN");    /* order the boxes within each row */
  96. F(RPosition,"i");    /* position boxes within the rows */
  97. F(RRoute,"i");    /* do the channel route */
  98. F(Rpar,"iSN"); /* do all of the place and route stuff */
  99. F(RReFeedpar,"iSN"); /* do RReFeed and the rest */
  100. F(RSpacepar,"iSN"); /* do RSpace and the rest */
  101.  
  102. /* misc routines */
  103. FS(TFlags,"ss");    /* set and get random flags */
  104. FS(TVersion,"s");    /* returns the current version string */
  105.  
  106. /* routines for debugging the lexical analyzer */
  107. F(TkDebugFile,"is");
  108. }
  109.  
  110. /* end */
  111.