home *** CD-ROM | disk | FTP | other *** search
- 1: // Make a batch file, one line at a time
- 2: // An empty command line will truncate the file "bat.bat"
- 3: // Command lines are appended to the file "bat.bat"
- 4: #include <stdio.h>
- 5: #include <string.h>
- 6: main(int argc, char** argv)
- 7: {
- 8: int i;
- 9: FILE* file;
- 10: static const char bf[] = "bat.bat";// The target filename
- 11: static const char c = ' '; // A token separator
- 12: static const char n = '\n'; // A line terminator
- 13: if (argc <= 1) // If the command line is empty...
- 14: {
- 15: if (fopen(bf, "w") == NULL) return 1;// Truncate the file
- 16: }
- 17: else // Otherwise...
- 18: {
- 19: if ((file = fopen(bf, "at")) == NULL) return 2;// Open the file
- 20: for (i=1; i<argc; ++i)// Write out the command line elements
- 21: {
- 22: if (i != 1 && fwrite(&c, 1, 1, file) != 1) return 3;// Space
- 23: if (fwrite(argv[i], 1, strlen(argv[i]), file) != strlen(argv[i]))
- 24: return 4;
- 25: }
- 26: if (fwrite(&n, 1, 1, file) != 1) return 5;// Terminate the line
- 27: }
- 28: return 0;
- 29: }
-
-
- 1: bf
- 2: make makefile
- 3: bat
-
-
- 1:; Program to return a return code of 1
- 2: ExitBad equ 4c01h
- 3: DosCall equ 21h
- 4: code segment byte public 'CODE'
- 5: assume cs:code
- 6: start: mov ax, ExitBad ; DOS exit command returning 1
- 7: int DosCall ; Invoke DOS
- 8: jmp start ; Safety jump
- 9: code ends
- 10: end start
-
-
- 1:MODEL=L
- 2:CDEBUG=-Zi
- 3:LDEBUG=/CO
- 4:CPRE_DEFINE=-Dc_plusplus -DM_I86$(MODEL)M -DNO_EXT_KEYS
- 5:CPRE_INCLUDE=-Ic:\include\cpp\include -Ic:\include
- 6:CPRE_FLAGS=$(CPRE_INCLUDE) $(CPRE_DEFINE)
- 7:CPP_FLAGS=+x$(MODEL) +L
- 8:CFLAGS=-c -A$(MODEL) $(CDEBUG)
- 9:LFLAGS=/M $(LDEBUG)
- 10:LINKLIST=$**
- 11:LIBS=cplus$(MODEL);
- 12:.cpp.obj:
- 13: bf cpre $(CPRE_FLAGS) $*.cpp $*.ci
- 14: bf if errorlevel 1 goto err
- 15: bf cfront $(CPP_FLAGS) +f$*.cpp +F$*.ci
- 16: bf if errorlevel 1 goto err
- 17: bf del $*.ci
- 18: bf cl $(CFLAGS) -Tc$*.cc
- 19: bf if errorlevel 1 goto err
- 20: bf del $*.cc
- 21: bf demake
- 22: bf :err
- 23: fail
- 24:.obj.exe:
- 25: link $(LFLAGS) $(LINKLIST),,,$(LIBS)
- 26:proga.obj : proga.cpp
- 27:progb.obj : progb.cpp
- 28:progc.obj : progc.cpp
- 29:prog.exe : proga.obj progb.obj progc.obj