[go: up one dir, main page]

File: prune.c

package info (click to toggle)
circlepack 5.1-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 2,828 kB
  • ctags: 1,683
  • sloc: ansic: 43,152; makefile: 46
file content (44 lines) | stat: -rw-r--r-- 927 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/resource.h>

int main(int argc,char *argv[])
{
  int count=0;
  char filein[256],fileout[256];
  char inlin[2048],hold1[2048],hold2[2048];
  FILE *fp, *fpout;

  strcpy(filein,argv[1]);
  strcpy(fileout,argv[1]);
  strcat(fileout,"p");

  hold1[0]=hold2[0]='\0';
  if (!(fp=fopen(filein,"r")) || !(fpout=fopen(fileout,"w")))
    exit(0);
  while (fgets(inlin,2000,fp))
    {
      if (inlin[0]=='s')
	count++;
      if (strlen(inlin)!=2 || inlin[0]!='s'
	  || !fgets(hold1,2000,fp) || strncmp(hold1," 0 sg",5)
	  || !fgets(hold2,2000,fp) || hold2[strlen(hold2)-2]!='m')
	{
	  fprintf(fpout,"%s",inlin);
	  if (strlen(hold1)>0) 
	    fprintf(fpout,"%s",hold1);
	  if (strlen(hold2)>0) 
	    fprintf(fpout,"%s",hold2);
	}
      hold1[0]='\0';
      hold2[0]='\0';
    }
  fclose(fp);
  fclose(fpout);
  exit(1);
}