home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / cmplngmg / cl_jun89.arc / BLAKE < prev    next >
Text File  |  1989-05-24  |  2KB  |  78 lines

  1.  1:  // Make a batch file, one line at a time
  2.  2:  // An empty command line will truncate the file "bat.bat"
  3.  3:  // Command lines are appended to the file "bat.bat"
  4.  4:  #include <stdio.h>
  5.  5:  #include <string.h>
  6.  6:  main(int argc, char** argv)
  7.  7:  {
  8.  8:    int i;
  9.  9:    FILE* file;
  10. 10:    static const char bf[] = "bat.bat";// The target filename
  11. 11:    static const char c = ' ';  // A token separator
  12. 12:    static const char n = '\n';  // A line terminator
  13. 13:    if (argc <= 1)      // If the command line is empty...
  14. 14:    {
  15. 15:    if (fopen(bf, "w") == NULL) return 1;// Truncate the file
  16. 16:    }
  17. 17:    else                  // Otherwise...
  18. 18:    {
  19. 19:      if ((file = fopen(bf, "at")) == NULL) return 2;// Open the file
  20. 20:      for (i=1; i<argc; ++i)// Write out the command line elements
  21. 21:      {
  22. 22:        if (i != 1 && fwrite(&c, 1, 1, file) != 1) return 3;// Space
  23. 23:        if (fwrite(argv[i], 1, strlen(argv[i]), file) != strlen(argv[i]))
  24. 24:          return 4;
  25. 25:      }
  26. 26:      if (fwrite(&n, 1, 1, file) != 1) return 5;// Terminate the line
  27. 27:    }
  28. 28:    return 0;
  29. 29:  }
  30.  
  31.  
  32. 1:  bf
  33. 2:  make makefile
  34. 3:  bat
  35.  
  36.  
  37.  1:; Program to return a return code of 1
  38.  2:   ExitBad     equ     4c01h
  39.  3:   DosCall     equ     21h
  40.  4:   code        segment byte public 'CODE'
  41.  5:   assume      cs:code
  42.  6: start:        mov     ax, ExitBad  ; DOS exit command returning 1
  43.  7:   int         DosCall              ; Invoke DOS
  44.  8:   jmp         start                ; Safety jump
  45.  9:   code        ends
  46. 10: end           start
  47.  
  48.  
  49.  1:MODEL=L
  50.  2:CDEBUG=-Zi
  51.  3:LDEBUG=/CO
  52.  4:CPRE_DEFINE=-Dc_plusplus -DM_I86$(MODEL)M -DNO_EXT_KEYS
  53.  5:CPRE_INCLUDE=-Ic:\include\cpp\include -Ic:\include
  54.  6:CPRE_FLAGS=$(CPRE_INCLUDE) $(CPRE_DEFINE)
  55.  7:CPP_FLAGS=+x$(MODEL) +L
  56.  8:CFLAGS=-c -A$(MODEL) $(CDEBUG)
  57.  9:LFLAGS=/M $(LDEBUG)
  58. 10:LINKLIST=$**
  59. 11:LIBS=cplus$(MODEL);
  60. 12:.cpp.obj:
  61. 13:  bf cpre $(CPRE_FLAGS) $*.cpp $*.ci
  62. 14:  bf if errorlevel 1 goto err
  63. 15:  bf cfront $(CPP_FLAGS) +f$*.cpp +F$*.ci
  64. 16:  bf if errorlevel 1 goto err
  65. 17:  bf del $*.ci
  66. 18:  bf cl $(CFLAGS) -Tc$*.cc
  67. 19:  bf if errorlevel 1 goto err
  68. 20:  bf del $*.cc
  69. 21:  bf demake
  70. 22:  bf :err
  71. 23:  fail
  72. 24:.obj.exe:
  73. 25:  link $(LFLAGS) $(LINKLIST),,,$(LIBS)
  74. 26:proga.obj : proga.cpp
  75. 27:progb.obj : progb.cpp
  76. 28:progc.obj : progc.cpp
  77. 29:prog.exe  : proga.obj progb.obj progc.obj
  78.