home *** CD-ROM | disk | FTP | other *** search
- Date: Tue, 12 Jul 88 17:58:23 cdt
- From: wucs1!wubios!david@uunet.UU.NET (David Camp)
- Subject: MSC.C
-
- Gregory,
- Here is another useful utility.
- -David-
-
- *-------------------------------------------------------------------------*
- | (314) 362-3635 Mr. David J. Camp |
- | Room 1108D ^ Box 8067, Biostatistics |
- | 706 South Euclid < * > Washington University Medical School |
- | v 660 South Euclid |
- | Bitnet: david%wubios@wucfua.wustl Saint Louis, MO 63110 |
- | Internet: david%wubios@wucfua.wustl.edu |
- *-------------------------------------------------------------------------*
-
- /* MSC.C -- A program to pass arguments from a file to CL */
- /* written by David J. Camp */
- /* of the Division of Biostatistics, Box 8067 */
- /* Washington University Medical School */
- /* Saint Louis, MO 63110 */
-
- /*
-
- While attempting to preprocess a file with the Microsoft C 5.0 CL
- command, I wanted to use a command line with many '=' signs. I
- encountered the Dos line limit. I tried to use the CL environment
- variable to extend the line, but the SET command would not allow '=' signs
- in the assigned string. Thus I wrote MSC.C, a program to read command
- line options from a file, and call CL as a child process (using the
- system() function). I tested it on my data, and it seems to work well.
- Just edit a file with one or more lines of CL command line options, and
- type 'msc filename' at the Dos prompt. It is suitable for inclusion in
- MAKE files. I use ECHO options >file, ECHO more-options >>file, msc file.
-
- Good Computing!
-
- -David-
-
- *-------------------------------------------------------------------------*
- | (314) 362-3635 Mr. David J. Camp |
- | Room 1108D ^ Box 8067, Biostatistics |
- | 706 South Euclid < * > Washington University Medical School |
- | v 660 South Euclid |
- | Bitnet: david%wubios@wucfua.wustl Saint Louis, MO 63110 |
- | Internet: david%wubios@wucfua.wustl.edu |
- *-------------------------------------------------------------------------*
-
- */
-
- #include <readable.h> /* see below */
- #include <stdio.h>
- #include <stdlib.h>
- #include <process.h>
-
- main (argc, argv)
- int argc;
- char * argv [];
-
- begin
- FILE * f;
- char buffer [256];
- char * var;
- int code;
-
- fprintf (stderr,"MSC - a CL command invoker, written by David J. Camp\n");
- if (argc != 2)
- begin
- fprintf (stderr, "usage: MSC filename\n");
- fprintf (stderr, "where the file contains CL arguments separated ");
- fprintf (stderr, "by whitespace.\n");
- exit (1);
- end
- if ((f = fopen (argv [1], "r")) eq NULL)
- begin
- fprintf (stderr, "Cannot open file %s\n", argv [1]);
- exit (2);
- end
- fgets (buffer, 256, f);
- var = malloc (4);
- strcpy (var, "CL=");
- while (not feof (f))
- begin
- if (buffer [strlen (buffer) - 1] eq '\n')
- buffer [strlen (buffer) - 1] = ' ';
- fprintf (stdout, "MSC: %s\n", buffer);
- var = realloc (var, strlen (var) + strlen (buffer) + 1);
- strcat (var, buffer);
- fgets (buffer, 256, f);
- end
- fclose (f);
- fprintf (stdout, "\n");
- if (putenv (var) != 0)
- begin
- fprintf (stderr,"Error in putenv(\"%s\")", var);
- exit (3);
- end
- if ((code = system ("CL")) != 0)
- begin
- fprintf (stderr, "Return code %d from CL\n");
- exit (code);
- end
- exit (0);
- end
- /* readable.h follows:
- #define begin {
- #define end }
- #define and &&
- #define or ||
- #define not !
- #define eq ==
- */
-