view pads2gpcb/main.c @ 44:bf1be6c97c28

pads2gpcb: fixed conversion of elongated pads
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sat, 30 Jan 2016 05:48:04 +0000
parents 43ba91b137e2
children 8fa304e2b7e1
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include "globals.h"

static
parse_header_line()
{
	char *cp;

	if (strncmp(input_line_buf, "!PADS-POWERPCB-", 15))
		return(-1);
	cp = input_line_buf + 15;
	while (isalnum(*cp) || *cp == '.')
		cp++;
	if (*cp++ != '-')
		return(-1);
	if (!strncmp(cp, "BASIC", 5))
		input_units_global = 'B';
	else if (!strncmp(cp, "MILS", 4))
		input_units_global = 'I';
	else if (!strncmp(cp, "METRIC", 6))
		input_units_global = 'M';
	else
		return(-1);
	return(0);
}

main(argc, argv)
	char **argv;
{
	if (argc != 2) {
		fprintf(stderr, "usage: %s pads-file.asc\n", argv[0]);
		exit(1);
	}
	input_filename = argv[1];
	open_input_file();

	/* parse the header line with the units specification */
	if (!get_input_line()) {
invheader:	fprintf(stderr,
		"error: %s does not begin with a recognized header line\n",
			input_filename);
		exit(1);
	}
	if (parse_header_line() < 0)
		goto invheader;

	/* process the body of the monster! */
	while (get_input_line()) {
		if (input_line_buf[0] != '*')
			continue;
		parse_starline();
loop:		if (!strcmp(input_line_starkw, "PARTDECAL")) {
			process_partdecal_section();
			goto loop;
		}
#if 0
		if (!strcmp(input_line_starkw, "PARTTYPE")) {
			process_parttype_section();
			goto loop;
		}
		if (!strcmp(input_line_starkw, "PART")) {
			process_part_section();
			goto loop;
		}
#endif
	}
	exit(0);
}