ctm_ed.c (7894) | ctm_ed.c (8857) |
---|---|
1/* 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 * ---------------------------------------------------------------------------- 8 * | 1/* 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 * ---------------------------------------------------------------------------- 8 * |
9 * $Id: ctm_ed.c,v 1.4 1994/09/22 02:49:17 phk Exp $ | 9 * $Id: ctm_ed.c,v 1.5 1995/04/16 22:40:49 bde Exp $ |
10 * 11 */ 12 13#include "ctm.h" 14 15int 16ctm_edit(u_char *script, int length, char *filein, char *fileout) 17{ 18 u_char *ep, cmd; 19 int ln, ln2, iln, ret=0, c; 20 FILE *fi=0,*fo=0; 21 22 fi = fopen(filein,"r"); | 10 * 11 */ 12 13#include "ctm.h" 14 15int 16ctm_edit(u_char *script, int length, char *filein, char *fileout) 17{ 18 u_char *ep, cmd; 19 int ln, ln2, iln, ret=0, c; 20 FILE *fi=0,*fo=0; 21 22 fi = fopen(filein,"r"); |
23 if(!fi) { | 23 if(!fi) { |
24 perror(filein); | 24 perror(filein); |
25 return 8; | 25 return 8; |
26 } 27 28 fo = fopen(fileout,"w"); 29 if(!fo) { 30 perror(fileout); 31 fclose(fi); 32 return 4; 33 } --- 45 unchanged lines hidden (view full) --- 79 c = *ep++; 80 putc(c,fo); 81 if(c != '\n') 82 continue; 83 ln2--; 84 } 85 continue; 86 } | 26 } 27 28 fo = fopen(fileout,"w"); 29 if(!fo) { 30 perror(fileout); 31 fclose(fi); 32 return 4; 33 } --- 45 unchanged lines hidden (view full) --- 79 c = *ep++; 80 putc(c,fo); 81 if(c != '\n') 82 continue; 83 ln2--; 84 } 85 continue; 86 } |
87 ret = 1; | 87 ret = 1; |
88 goto bye; 89 } 90 while(1) { 91 c = getc(fi); 92 if(c == EOF) break; 93 putc(c,fo); 94 } 95 ret = 0; --- 19 unchanged lines hidden --- | 88 goto bye; 89 } 90 while(1) { 91 c = getc(fi); 92 if(c == EOF) break; 93 putc(c,fo); 94 } 95 ret = 0; --- 19 unchanged lines hidden --- |