diff ifctf-part-lib/geda-symbols/fixpinseq.c @ 0:cd92449fdb51

initial import of ueda and ifctf-part-lib from ifctfvax CVS
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 20 Jul 2015 00:24:37 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ifctf-part-lib/geda-symbols/fixpinseq.c	Mon Jul 20 00:24:37 2015 +0000
@@ -0,0 +1,40 @@
+#include <sys/param.h>
+#include <stdio.h>
+
+main(argc, argv)
+	char **argv;
+{
+	char *infile, outfile[MAXPATHLEN];
+	FILE *inf, *of;
+	char line[1024];
+	int pinnum;
+
+	if (argc != 2) {
+		fprintf(stderr, "usage: %s symfile\n", argv[0]);
+		exit(1);
+	}
+	infile = argv[1];
+	inf = fopen(infile, "r");
+	if (!inf) {
+		perror(infile);
+		exit(1);
+	}
+	strcpy(outfile, infile);
+	strcat(outfile, ".fix");
+	of = fopen(outfile, "w");
+	if (!of) {
+		perror(outfile);
+		exit(1);
+	}
+
+	while (fgets(line, sizeof line, inf)) {
+		if (!strncmp(line, "pinnumber=", 10))
+			pinnum = atoi(line + 10);
+		else if (!strncmp(line, "pinseq=", 7))
+			sprintf(line, "pinseq=%d\n", pinnum);
+		fputs(line, of);
+	}
+	fclose(inf);
+	fclose(of);
+	exit(0);
+}