home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / msc.c < prev    next >
Internet Message Format  |  1994-03-04  |  4KB

  1. Date: Tue, 12 Jul 88 17:58:23 cdt
  2. From: wucs1!wubios!david@uunet.UU.NET (David Camp)
  3. Subject: MSC.C
  4.  
  5. Gregory,
  6.      Here is another useful utility.
  7. -David-
  8.  
  9. *-------------------------------------------------------------------------*
  10. | (314) 362-3635                     Mr. David J. Camp                    |
  11. | Room 1108D               ^         Box 8067, Biostatistics              |
  12. | 706 South Euclid       < * >       Washington University Medical School |
  13. |                          v         660 South Euclid                     |
  14. | Bitnet: david%wubios@wucfua.wustl  Saint Louis, MO 63110                |
  15. | Internet: david%wubios@wucfua.wustl.edu                                 |
  16. *-------------------------------------------------------------------------*
  17.  
  18. /* MSC.C -- A program to pass arguments from a file to CL */
  19. /* written by David J. Camp */
  20. /*     of the Division of Biostatistics, Box 8067 */
  21. /*            Washington University Medical School */
  22. /*            Saint Louis, MO 63110 */
  23.  
  24. /*
  25.  
  26.      While attempting to preprocess a file with the Microsoft C 5.0 CL
  27. command, I wanted to use a command line with many '=' signs.  I
  28. encountered the Dos line limit.  I tried to use the CL environment
  29. variable to extend the line, but the SET command would not allow '=' signs
  30. in the assigned string.  Thus I wrote MSC.C, a program to read command
  31. line options from a file, and call CL as a child process (using the
  32. system() function).  I tested it on my data, and it seems to work well.
  33. Just edit a file with one or more lines of CL command line options, and
  34. type 'msc filename' at the Dos prompt.  It is suitable for inclusion in
  35. MAKE files.  I use ECHO options >file, ECHO more-options >>file, msc file.
  36.  
  37. Good Computing!  
  38.  
  39. -David-
  40.  
  41. *-------------------------------------------------------------------------*
  42. | (314) 362-3635                     Mr. David J. Camp                    |
  43. | Room 1108D               ^         Box 8067, Biostatistics              |
  44. | 706 South Euclid       < * >       Washington University Medical School |
  45. |                          v         660 South Euclid                     |
  46. | Bitnet: david%wubios@wucfua.wustl  Saint Louis, MO 63110                |
  47. | Internet: david%wubios@wucfua.wustl.edu                                 |
  48. *-------------------------------------------------------------------------*
  49.  
  50. */
  51.  
  52. #include <readable.h> /* see below */
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #include <process.h>
  56.  
  57. main (argc, argv)
  58. int argc;
  59. char * argv [];
  60.  
  61. begin
  62. FILE * f;
  63. char buffer [256];
  64. char * var;
  65. int code;
  66.  
  67. fprintf (stderr,"MSC - a CL command invoker, written by David J. Camp\n");
  68. if (argc != 2)
  69.     begin
  70.     fprintf (stderr, "usage: MSC filename\n");
  71.     fprintf (stderr, "where the file contains CL arguments separated ");
  72.     fprintf (stderr, "by whitespace.\n");
  73.     exit (1);
  74.     end
  75. if ((f = fopen (argv [1], "r")) eq NULL)
  76.     begin
  77.     fprintf (stderr, "Cannot open file %s\n", argv [1]);
  78.     exit (2);
  79.     end
  80. fgets (buffer, 256, f);
  81. var = malloc (4);
  82. strcpy (var, "CL=");
  83. while (not feof (f))
  84.     begin
  85.     if (buffer [strlen (buffer) - 1] eq '\n')
  86.         buffer [strlen (buffer) - 1] = ' ';
  87.     fprintf (stdout, "MSC: %s\n", buffer);
  88.     var = realloc (var, strlen (var) + strlen (buffer) + 1);
  89.     strcat (var, buffer);
  90.     fgets (buffer, 256, f);
  91.     end
  92. fclose (f);
  93. fprintf (stdout, "\n");
  94. if (putenv (var) != 0)
  95.     begin
  96.     fprintf (stderr,"Error in putenv(\"%s\")", var);
  97.     exit (3);
  98.     end
  99. if ((code = system ("CL")) != 0)
  100.     begin
  101.     fprintf (stderr, "Return code %d from CL\n");
  102.     exit (code);
  103.     end
  104. exit (0);
  105. end
  106. /* readable.h follows:
  107. #define begin {
  108. #define end }
  109. #define and &&
  110. #define or ||
  111. #define not !
  112. #define eq ==
  113. */
  114.