2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
9 * $FreeBSD: src/usr.sbin/ctm/ctm/ctm_ed.c,v 1.10 1999/08/28 01:15:59 peter Exp $
10 * $DragonFly: src/usr.sbin/ctm/ctm/Attic/ctm_ed.c,v 1.2 2003/06/17 04:29:53 dillon Exp $
17 ctm_edit(u_char *script, int length, char *filein, char *fileout)
20 int ln, ln2, iln, ret=0, c;
23 fi = fopen(filein,"r");
29 fo = fopen(fileout,"w");
36 for(ep=script;ep < script+length;) {
38 if(cmd != 'a' && cmd != 'd') { ret = 1; goto bye; }
44 if(*ep++ != ' ') { ret = 1; goto bye; }
50 if(*ep++ != '\n') { ret = 1; goto bye; }
56 if(c == EOF) { ret = 1; goto bye; }
63 if(c == EOF) { ret = 1; goto bye; }
74 if(c == EOF) { ret = 1; goto bye; }
105 if(fflush(fo) != 0) {
109 if(fclose(fo) != 0) {