2 * SPDX-License-Identifier: Beerware
4 * ----------------------------------------------------------------------------
5 * "THE BEER-WARE LICENSE" (Revision 42):
6 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
7 * can do whatever you want with this stuff. If we meet some day, and you think
8 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
9 * ----------------------------------------------------------------------------
18 ctm_edit(u_char *script, int length, char *filein, char *fileout)
21 int ln, ln2, iln, ret=0, c;
24 fi = fopen(filein,"r");
30 fo = fopen(fileout,"w");
37 for(ep=script;ep < script+length;) {
39 if(cmd != 'a' && cmd != 'd') { ret = 1; goto bye; }
45 if(*ep++ != ' ') { ret = 1; goto bye; }
51 if(*ep++ != '\n') { ret = 1; goto bye; }
57 if(c == EOF) { ret = 1; goto bye; }
64 if(c == EOF) { ret = 1; goto bye; }
75 if(c == EOF) { ret = 1; goto bye; }
100 if(fclose(fi) != 0) {
106 if(fflush(fo) != 0) {
110 if(fclose(fo) != 0) {