32 #include <glib/gstdio.h>
37 #define MIN_TOOL_NUMBER 1
38 #define MAX_TOOL_NUMBER 99
40 static int have_tools_file = 0;
41 static double tools[1+MAX_TOOL_NUMBER];
44 ProcessToolLine(
const char *cp,
const char *file_name,
long int file_line)
54 while (isspace((
int) *cp)) {
60 GERB_COMPILE_WARNING(_(
"Ignored strange tool \"%s\" "
61 "at line %ld in file \"%s\""),
62 cp0, file_line, file_name);
65 if ((!isdigit((
int) cp[1])) || (!isdigit((
int) cp[2]))) {
66 GERB_COMPILE_WARNING(_(
"No tool number in \"%s\" "
67 "at line %ld in file \"%s\""),
68 cp0, file_line, file_name);
76 toolNumber = atoi(tnb);
77 if ((toolNumber < MIN_TOOL_NUMBER) || (toolNumber > MAX_TOOL_NUMBER)) {
78 GERB_COMPILE_WARNING(_(
"Can't parse tool number in \"%s\" "
79 "at line %ld in file \"%s\""),
80 cp0, file_line, file_name);
88 while (isspace((
int) *cp)) {
97 GERB_COMPILE_ERROR(_(
"Tool T%02d diameter is impossible "
98 "at line %ld in file \"%s\""),
99 toolNumber, file_line, file_name);
102 if (toolDia < 0.001) {
103 GERB_COMPILE_WARNING(_(
"Tool T%02d diameter is very small "
104 "at line %ld in file \"%s\""),
105 toolNumber, file_line, file_name);
108 if (tools[toolNumber] != 0) {
109 GERB_COMPILE_ERROR(_(
"Tool T%02d is already defined, occurred "
110 "at line %ld in file \"%s\""),
111 toolNumber, file_line, file_name);
112 GERB_FATAL_ERROR(_(
"Exiting because this is a HOLD error "
113 "at any board house."));
118 tools[toolNumber] = toolDia;
123 gerbv_process_tools_file(
const char *tf)
127 long int file_line = 0;
130 memset(tools, 0,
sizeof(tools));
135 f = g_fopen(tf,
"r");
137 GERB_COMPILE_ERROR(_(
"Failed to open \"%s\" for reading"), tf);
141 memset(buf, 0,
sizeof(buf));
142 if (NULL == fgets(buf,
sizeof(buf)-1, f))
146 ProcessToolLine(buf, tf, file_line);
155 gerbv_get_tool_diameter(
int toolNumber)
157 if (!have_tools_file)
159 if ((toolNumber < MIN_TOOL_NUMBER) || (toolNumber > MAX_TOOL_NUMBER))
161 return tools[toolNumber];
The main header file for the libgerbv library.