home *** CD-ROM | disk | FTP | other *** search
- #include <io.h>
- #include <string.h>
- #include <fcntl.h>
- #include <sys\stat.h>
-
- main(int argc, char *argv[])
- {
- int i,handle;
- char buffer[256];
- char *bpoint=buffer;
-
- if (argc<3)
- {
- cprintf("\n\rSyntax: ADD2FILE <filename> <text> [<prompt> [<moretext>]].\n\r");
- exit(1);
- }
-
- bpoint += sprintf(bpoint,"%s",argv[2]);
-
- if (argc>3)
- {
- cprintf(argv[3]);
- bpoint += (int) strlen(gets(bpoint));
- }
-
- if (argc>4) bpoint += sprintf(bpoint,"%s",argv[4]);
-
- bpoint += sprintf(bpoint,"\n");
-
- for (i=0;i<bpoint-buffer;i++)
- if (buffer[i]=='\'') buffer[i]='"';
-
- if ((handle=open(argv[1],O_CREAT|O_WRONLY|O_TEXT|O_APPEND|O_DENYALL
- ,S_IWRITE))==-1)
- {
- cprintf("\n\rCan't open file %s\n\r",argv[1]);
- exit(2);
- }
-
- if (write(handle,buffer,bpoint-buffer)==-1)
- {
- cprintf("\n\rCan't write to file %s\n\r",argv[1]);
- exit(2);
- }
-
- close(handle);
- }