35 #define MIN_TOOL_NUMBER 1
36 #define MAX_TOOL_NUMBER 99
38 static int have_tools_file = 0;
39 static double tools[1 + MAX_TOOL_NUMBER];
42 ProcessToolLine(
const char* cp,
const char* file_name,
long int file_line) {
51 while (isspace((
int)*cp)) {
58 _(
"Ignored strange tool \"%s\" "
59 "at line %ld in file \"%s\""),
60 cp0, file_line, file_name
64 if ((!isdigit((
int)cp[1])) || (!isdigit((
int)cp[2]))) {
66 _(
"No tool number in \"%s\" "
67 "at line %ld in file \"%s\""),
68 cp0, file_line, file_name
77 toolNumber = atoi(tnb);
78 if ((toolNumber < MIN_TOOL_NUMBER) || (toolNumber > MAX_TOOL_NUMBER)) {
80 _(
"Can't parse tool number in \"%s\" "
81 "at line %ld in file \"%s\""),
82 cp0, file_line, file_name
91 while (isspace((
int)*cp)) {
101 _(
"Tool T%02d diameter is impossible "
102 "at line %ld in file \"%s\""),
103 toolNumber, file_line, file_name
107 if (toolDia < 0.001) {
108 GERB_COMPILE_WARNING(
109 _(
"Tool T%02d diameter is very small "
110 "at line %ld in file \"%s\""),
111 toolNumber, file_line, file_name
115 if (tools[toolNumber] != 0) {
117 _(
"Tool T%02d is already defined, occurred "
118 "at line %ld in file \"%s\""),
119 toolNumber, file_line, file_name
122 _(
"Exiting because this is a HOLD error "
123 "at any board house.")
129 tools[toolNumber] = toolDia;
133 gerbv_process_tools_file(
const char* tf) {
136 long int file_line = 0;
139 memset(tools, 0,
sizeof(tools));
146 GERB_COMPILE_ERROR(_(
"Failed to open \"%s\" for reading"), tf);
150 memset(buf, 0,
sizeof(buf));
151 if (NULL == fgets(buf,
sizeof(buf) - 1, f))
155 ProcessToolLine(buf, tf, file_line);
163 gerbv_get_tool_diameter(
int toolNumber) {
164 if (!have_tools_file)
166 if ((toolNumber < MIN_TOOL_NUMBER) || (toolNumber > MAX_TOOL_NUMBER))
168 return tools[toolNumber];
The main header file for the libgerbv library.