00001
00034 #ifdef HAVE_CONFIG_H
00035 # include <config.h>
00036 #endif
00037
00038 #include <gtk/gtk.h>
00039 #include <stdlib.h>
00040 #include <math.h>
00041 #include <string.h>
00042
00043 #include "globals.h"
00044 #include "pcb_globals.h"
00045
00046
00047 AttributeTypePtr create_new_attribute (AttributeListTypePtr list, char *name, char *value);
00048
00049 ElementTypePtr current_element;
00050
00051 GList *packages_list;
00052
00063 ElementTypePtr
00064 create_attributes_in_element
00065 (
00066 ElementTypePtr element
00068 )
00069 {
00070 create_new_attribute (&element->Attributes, "author", g_strdup_printf ("%s", footprint_author));
00071 create_new_attribute (&element->Attributes, "dist-license", g_strdup_printf ("%s", footprint_dist_license));
00072 create_new_attribute (&element->Attributes, "use-license", g_strdup_printf ("%s", footprint_use_license));
00073 create_new_attribute (&element->Attributes, "status\" \"%s\")\n", footprint_status);
00074 create_new_attribute (&element->Attributes, "attributes in footprint", g_strdup_printf ("%d", (int) attributes_in_footprint));
00075 create_new_attribute (&element->Attributes, "package body length", g_strdup_printf ("%f", package_body_length));
00076 create_new_attribute (&element->Attributes, "package body width", g_strdup_printf ("%f", package_body_width));
00077 create_new_attribute (&element->Attributes, "package height", g_strdup_printf ("%f", package_body_height));
00078 create_new_attribute (&element->Attributes, "package is radial", g_strdup_printf ("%d", package_is_radial));
00079 create_new_attribute (&element->Attributes, "number of pins", g_strdup_printf ("%d", (int) number_of_pins));
00080 create_new_attribute (&element->Attributes, "number of columns", g_strdup_printf ("%d", (int) number_of_columns));
00081 create_new_attribute (&element->Attributes, "number of rows", g_strdup_printf ("%d", (int) number_of_rows));
00082 create_new_attribute (&element->Attributes, "pitch_x", g_strdup_printf ("%f", pitch_x));
00083 create_new_attribute (&element->Attributes, "pitch_y", g_strdup_printf ("%f", pitch_y));
00084 create_new_attribute (&element->Attributes, "count_x", g_strdup_printf ("%d", (int) count_x));
00085 create_new_attribute (&element->Attributes, "count_x", g_strdup_printf ("%d", (int) count_y));
00086 create_new_attribute (&element->Attributes, "pad_shape", g_strdup_printf ("%s", pad_shape));
00087 create_new_attribute (&element->Attributes, "pin_pad_exceptions", g_strdup_printf ("%s", pin_pad_exceptions_string));
00088 create_new_attribute (&element->Attributes, "pin_1_position", g_strdup_printf ("%s", pin_1_position));
00089 create_new_attribute (&element->Attributes, "pad_diameter", g_strdup_printf ("%f", pad_diameter));
00090 create_new_attribute (&element->Attributes, "pin_drill_diameter", g_strdup_printf ("%f", pin_drill_diameter));
00091 create_new_attribute (&element->Attributes, "pin1_square", g_strdup_printf ("%d", (int) pin1_square));
00092 create_new_attribute (&element->Attributes, "pad_length", g_strdup_printf ("%f", pad_length));
00093 create_new_attribute (&element->Attributes, "pad_width", g_strdup_printf ("%f", pad_width));
00094 create_new_attribute (&element->Attributes, "pad_clearance", g_strdup_printf ("%f", pad_clearance));
00095 create_new_attribute (&element->Attributes, "pad_solder_mask_clearance", g_strdup_printf ("%f", pad_solder_mask_clearance));
00096 create_new_attribute (&element->Attributes, "thermal", g_strdup_printf ("%d", (int) thermal));
00097 create_new_attribute (&element->Attributes, "thermal_nopaste", g_strdup_printf ("%d", (int) thermal_nopaste));
00098 create_new_attribute (&element->Attributes, "thermal_length", g_strdup_printf ("%f", thermal_length));
00099 create_new_attribute (&element->Attributes, "thermal_width", g_strdup_printf ("%f", thermal_width));
00100 create_new_attribute (&element->Attributes, "thermal_clearance", g_strdup_printf ("%f", thermal_clearance));
00101 create_new_attribute (&element->Attributes, "thermal_solder_mask_clearance", g_strdup_printf ("%f", thermal_solder_mask_clearance));
00102 create_new_attribute (&element->Attributes, "silkscreen_package_outline", g_strdup_printf ("%d", (int) silkscreen_package_outline));
00103 create_new_attribute (&element->Attributes, "silkscreen_indicate_1", g_strdup_printf ("%d", (int) silkscreen_indicate_1));
00104 create_new_attribute (&element->Attributes, "silkscreen_line_width", g_strdup_printf ("%f", silkscreen_line_width));
00105 create_new_attribute (&element->Attributes, "courtyard", g_strdup_printf ("%d", (int) courtyard));
00106 create_new_attribute (&element->Attributes, "courtyard_length", g_strdup_printf ("%f", courtyard_length));
00107 create_new_attribute (&element->Attributes, "courtyard_width", g_strdup_printf ("%f", courtyard_width));
00108 create_new_attribute (&element->Attributes, "courtyard_line_width", g_strdup_printf ("%f", courtyard_line_width));
00109 create_new_attribute (&element->Attributes, "courtyard_clearance_with_package", g_strdup_printf ("%f", courtyard_clearance_with_package));
00110 create_new_attribute (&element->Attributes, "c1", g_strdup_printf ("%f", c1));
00111 create_new_attribute (&element->Attributes, "g1", g_strdup_printf ("%f", g1));
00112 create_new_attribute (&element->Attributes, "z1", g_strdup_printf ("%f", z1));
00113 create_new_attribute (&element->Attributes, "c2", g_strdup_printf ("%f", c2));
00114 create_new_attribute (&element->Attributes, "g2", g_strdup_printf ("%f", g2));
00115 create_new_attribute (&element->Attributes, "z2", g_strdup_printf ("%f", z2));
00116 return element;
00117 }
00118
00119
00128 ArcTypePtr
00129 create_new_arc
00130 (
00131 ElementTypePtr element,
00133 LocationType X,
00135 LocationType Y,
00137 BDimension width,
00139 BDimension height,
00141 int angle,
00143 int delta,
00145 BDimension thickness)
00147 {
00148 ArcTypePtr arc = element->Arc;
00149
00150 if (element->ArcN >= element->ArcMax)
00151 {
00152 element->ArcMax += 5;
00153 size_t size = element->ArcMax * sizeof (ArcType);
00154 if (size == 0)
00155 {
00156 size = 1;
00157 }
00158 void *p;
00159 p = arc ? realloc (arc, size) : malloc (size);
00160 if (!p)
00161 g_log ("", G_LOG_LEVEL_WARNING,
00162 _("out of memory during realloc() in create_new_arc()."));
00163 arc = realloc (arc, element->ArcMax * sizeof (ArcType));
00164 element->Arc = arc;
00165 memset ((arc + element->ArcN), 0, (5 * sizeof (ArcType)));
00166 }
00167
00168 if ((delta = delta % 360) == 0)
00169 delta = 360;
00170 if (delta < 0)
00171 {
00172 angle += delta;
00173 delta = -delta;
00174 }
00175 if ((angle = angle % 360) < 0)
00176 angle += 360;
00177
00178 arc = arc + element->ArcN++;
00179 arc->X = X;
00180 arc->Y = Y;
00181 arc->Width = width;
00182 arc->Height = height;
00183 arc->StartAngle = angle;
00184 arc->Delta = delta;
00185 arc->Thickness = thickness;
00186 arc->ID = ID++;
00187 return (arc);
00188 }
00189
00190
00199 AttributeTypePtr
00200 create_new_attribute
00201 (
00202 AttributeListTypePtr list,
00204 char *name,
00206 char *value
00208 )
00209 {
00210 if (list->Number >= list->Max)
00211 {
00212 list->Max += 10;
00213 size_t size = list->Max * sizeof (AttributeType);
00214 if (size == 0)
00215 {
00216 size = 1;
00217 }
00218 void *p;
00219 p = list->List ? realloc (list, size) : malloc (size);
00220 if (!p)
00221 g_log ("", G_LOG_LEVEL_WARNING,
00222 _("out of memory during realloc() in create_new_attribute()."));
00223 }
00224 list->List[list->Number].name = g_strdup (name);
00225 list->List[list->Number].value = g_strdup (value);
00226 list->Number++;
00227 return &list->List[list->Number - 1];
00228 }
00229
00230
00239 LineTypePtr
00240 create_new_line
00241 (
00242 ElementTypePtr element,
00244 LocationType X1,
00246 LocationType Y1,
00248 LocationType X2,
00250 LocationType Y2,
00252 BDimension thickness)
00254 {
00255 LineTypePtr line = element->Line;
00256 if (thickness == 0)
00257 return (NULL);
00258
00259 if (element->LineN >= element->LineMax)
00260 {
00261 element->LineMax += 10;
00262 size_t size = element->LineMax * sizeof (LineType);
00263 if (size == 0)
00264 {
00265 size = 1;
00266 }
00267 void *p;
00268 p = line ? realloc (line, size) : malloc (size);
00269 if (!p)
00270 g_log ("", G_LOG_LEVEL_WARNING,
00271 _("out of memory during realloc() in create_new_line()."));
00272 element->Line = line;
00273 memset ((line + element->LineN), 0, (10 * sizeof (LineType)));
00274 }
00275
00276 line = line + element->LineN++;
00277 line->Point1.X = X1;
00278 line->Point1.Y = Y1;
00279 line->Point2.X = X2;
00280 line->Point2.Y = Y2;
00281 line->Thickness = thickness;
00282
00283 line->ID = ID++;
00284 return (line);
00285 }
00286
00287
00296 PadTypePtr
00297 create_new_pad
00298 (
00299 ElementTypePtr element,
00301 LocationType X1,
00303 LocationType Y1,
00305 LocationType X2,
00307 LocationType Y2,
00309 BDimension thickness,
00311 BDimension clearance,
00313 BDimension mask,
00315 char *name,
00317 char *number,
00319 FlagType flags
00334 )
00335 {
00336 PadTypePtr pad;
00337
00338 if (X1 > X2 || (X1 == X2 && Y1 > Y2))
00339 {
00340 pad->Point1.X = X2;
00341 pad->Point1.Y = Y2;
00342 pad->Point2.X = X1;
00343 pad->Point2.Y = Y1;
00344 }
00345 else
00346 {
00347 pad->Point1.X = X1;
00348 pad->Point1.Y = Y1;
00349 pad->Point2.X = X2;
00350 pad->Point2.Y = Y2;
00351 }
00352 pad->Thickness = thickness;
00353 pad->Clearance = clearance;
00354 pad->Mask = mask;
00355 pad->Name = g_strdup (name);
00356 pad->Number = g_strdup (number);
00357 pad->Flags = flags;
00358 pad->ID = ID++;
00359 pad->Element = element;
00360 return (pad);
00361 }
00362
00363
00372 PinTypePtr
00373 create_new_pin
00374 (
00375 ElementTypePtr element,
00377 LocationType X,
00379 LocationType Y,
00381 BDimension thickness,
00383 BDimension clearance,
00385 BDimension mask,
00387 BDimension drillinghole,
00389 char *name,
00391 char *number,
00393 FlagType flags
00408 )
00409 {
00410 PinTypePtr pin;
00411
00412 pin->X = X;
00413 pin->Y = Y;
00414 pin->Thickness = thickness;
00415 pin->Clearance = clearance;
00416 pin->Mask = mask;
00417 pin->DrillingHole = drillinghole;
00418 pin->Name = g_strdup (name);
00419 pin->Number = g_strdup (number);
00420 pin->Flags = flags;
00421 pin->ID = ID++;
00422 pin->Element = element;
00423 return (pin);
00424 }
00425
00426
00433 int
00434 get_package_type ()
00435 {
00436
00437 if (!footprint_type)
00438 {
00439 package_type = NO_PACKAGE;
00440 g_log ("", G_LOG_LEVEL_CRITICAL,
00441 _("footprint type is not valid."));
00442 return (EXIT_FAILURE);
00443 }
00444 if (!strcmp (footprint_type, ""))
00445 {
00446 package_type = NO_PACKAGE;
00447 g_log ("", G_LOG_LEVEL_CRITICAL,
00448 _("empty footprint type entered."));
00449 return (EXIT_FAILURE);
00450 }
00451 else if (!strcmp (footprint_type, "BGA"))
00452 {
00453 package_type = BGA;
00454 }
00455 else if (!strcmp (footprint_type, "CAPA"))
00456 {
00457 package_type = CAPA;
00458 }
00459 else if (!strcmp (footprint_type, "CAPAE"))
00460 {
00461 package_type = CAPAE;
00462 }
00463 else if (!strcmp (footprint_type, "CAPC"))
00464 {
00465 package_type = CAPC;
00466 }
00467 else if (!strcmp (footprint_type, "CAPM"))
00468 {
00469 package_type = CAPM;
00470 }
00471 else if (!strcmp (footprint_type, "CAPMP"))
00472 {
00473 package_type = CAPMP;
00474 }
00475 else if (!strcmp (footprint_type, "CON_DIL"))
00476 {
00477 package_type = CON_DIL;
00478 }
00479 else if (!strcmp (footprint_type, "CON_DIP"))
00480 {
00481 package_type = CON_DIP;
00482 }
00483 else if (!strcmp (footprint_type, "CON_HDR"))
00484 {
00485 package_type = CON_HDR;
00486 }
00487 else if (!strcmp (footprint_type, "CON_SIL"))
00488 {
00489 package_type = CON_SIL;
00490 }
00491 else if (!strcmp (footprint_type, "DIL"))
00492 {
00493 package_type = DIL;
00494 }
00495 else if (!strcmp (footprint_type, "DIOM"))
00496 {
00497 package_type = DIOM;
00498 }
00499 else if (!strcmp (footprint_type, "DIOMELF"))
00500 {
00501 package_type = DIOMELF;
00502 }
00503 else if (!strcmp (footprint_type, "DIP"))
00504 {
00505 package_type = DIP;
00506 }
00507 else if (!strcmp (footprint_type, "DIPS"))
00508 {
00509 package_type = DIPS;
00510 }
00511 else if (!strcmp (footprint_type, "INDC"))
00512 {
00513 package_type = INDC;
00514 }
00515 else if (!strcmp (footprint_type, "INDP"))
00516 {
00517 package_type = INDP;
00518 }
00519 else if (!strcmp (footprint_type, "INDM"))
00520 {
00521 package_type = INDM;
00522 }
00523 else if (!strcmp (footprint_type, "PGA"))
00524 {
00525 package_type = PGA;
00526 }
00527 else if (!strcmp (footprint_type, "QFN"))
00528 {
00529 package_type = QFN;
00530 g_log ("", G_LOG_LEVEL_CRITICAL,
00531 _("footprint type %s not yet implemented."),
00532 footprint_type);
00533 return (EXIT_FAILURE);
00534 }
00535 else if (!strcmp (footprint_type, "QFP"))
00536 {
00537 package_type = QFP;
00538 g_log ("", G_LOG_LEVEL_CRITICAL,
00539 _("footprint type %s not yet implemented."),
00540 footprint_type);
00541 return (EXIT_FAILURE);
00542 }
00543 else if (!strcmp (footprint_type, "RES"))
00544 {
00545 package_type = RES;
00546 }
00547 else if (!strcmp (footprint_type, "RESC"))
00548 {
00549 package_type = RESC;
00550 }
00551 else if (!strcmp (footprint_type, "SIL"))
00552 {
00553 package_type = SIL;
00554 }
00555 else if (!strcmp (footprint_type, "SIP"))
00556 {
00557 package_type = SIP;
00558 }
00559 else if (!strcmp (footprint_type, "SO"))
00560 {
00561 package_type = SO;
00562 g_log ("", G_LOG_LEVEL_CRITICAL,
00563 _("footprint type %s not yet implemented."),
00564 footprint_type);
00565 return (EXIT_FAILURE);
00566 }
00567 else if (!strcmp (footprint_type, "SOT"))
00568 {
00569 package_type = SOT;
00570 }
00571 else if (!strcmp (footprint_type, "TO92"))
00572 {
00573 package_type = TO92;
00574 }
00575 else if (!strcmp (footprint_type, "TO220"))
00576 {
00577 package_type = TO220;
00578 }
00579 else if (!strcmp (footprint_type, "TO220S"))
00580 {
00581 package_type = TO220S;
00582 }
00583 else if (!strcmp (footprint_type, "TO220SW"))
00584 {
00585 package_type = TO220SW;
00586 }
00587 else if (!strcmp (footprint_type, "TO220W"))
00588 {
00589 package_type = TO220W;
00590 }
00591 else
00592 {
00593 package_type = NO_PACKAGE;
00594 g_log ("", G_LOG_LEVEL_CRITICAL,
00595 _("footprint type %s is not valid."),
00596 footprint_type);
00597 return (EXIT_FAILURE);
00598 }
00599 return (EXIT_SUCCESS);
00600 }
00601
00602
00610 int
00611 get_pin_pad_exception
00612 (
00613 gchar *pin_pad_name
00615 )
00616 {
00617
00618 if (!pin_pad_name)
00619 return EXIT_FAILURE;
00620 if (!pin_pad_exceptions_string)
00621 return EXIT_FAILURE;
00622 if (!strcmp (pin_pad_name, ""))
00623 return EXIT_FAILURE;
00624 if (!strcmp (pin_pad_exceptions_string, ""))
00625 return EXIT_FAILURE;
00626
00627
00628 gchar *delimiters = g_strdup (", ");
00629 gchar *search_string = g_strdup (pin_pad_exceptions_string);
00630
00631 gchar *token = strtok (search_string, delimiters);
00632 if (!strcmp (pin_pad_name, token))
00633 {
00634 return EXIT_SUCCESS;
00635 }
00636 else
00637 {
00638
00639 while (token)
00640 {
00641 token = strtok (NULL, delimiters);
00642 if (!token)
00643 return EXIT_FAILURE;
00644 if (!strcmp (pin_pad_name, token))
00645 {
00646 return EXIT_SUCCESS;
00647 }
00648 }
00649 }
00650
00651 return EXIT_FAILURE;
00652 }
00653
00654
00662 int
00663 get_status_type ()
00664 {
00665
00666 if ((!strcmp (footprint_status, "")) || (!footprint_status))
00667 {
00668 status_type = NO_STATUS;
00669 }
00670 else if (!strcmp (footprint_status, "Experimental"))
00671 {
00672 status_type = EXPERIMENTAL;
00673 }
00674 else if (!strcmp (footprint_status, "Private (not published)"))
00675 {
00676 status_type = PRIVATE;
00677 }
00678 else if (!strcmp (footprint_status, "Public (released)"))
00679 {
00680 status_type = PUBLIC;
00681 }
00682 else if (!strcmp (footprint_status, "Stable (confirmed by peers)"))
00683 {
00684 status_type = STABLE;
00685 }
00686 else
00687 {
00688 g_log ("", G_LOG_LEVEL_INFO,
00689 _("footprint status %s is not valid."),
00690 footprint_status);
00691 return (EXIT_FAILURE);
00692 }
00693 return (EXIT_SUCCESS);
00694 }
00695
00696
00706 int
00707 get_total_number_of_pins ()
00708 {
00709
00710
00711 switch (package_type)
00712 {
00713 case BGA :
00714 number_of_pins = (number_of_columns * number_of_rows) -
00715 number_of_exceptions + (fiducial * 2);
00716 break;
00717 case CAPC :
00718 number_of_pins = 2;
00719 break;
00720 case CAPM :
00721 number_of_pins = 2;
00722 break;
00723 case CAPMP :
00724 number_of_pins = 2;
00725 break;
00726 case CON_DIL :
00727 number_of_pins = number_of_rows * count_x;
00728 break;
00729 case CON_DIP :
00730 number_of_pins = number_of_columns * number_of_rows;
00731 break;
00732 case CON_HDR :
00733 number_of_pins = number_of_rows * count_x;
00734 break;
00735 case CON_SIL :
00736 number_of_pins = number_of_rows;
00737 break;
00738 case DIL :
00739 number_of_pins = number_of_columns * number_of_rows;
00740 break;
00741 case DIOM :
00742 number_of_pins = 2;
00743 break;
00744 case DIOMELF :
00745 number_of_pins = 2;
00746 break;
00747 case DIP :
00748 number_of_pins = number_of_columns * count_y;
00749 break;
00750 case DIPS :
00751 number_of_pins = number_of_columns * count_y;
00752 break;
00753 case INDC :
00754 number_of_pins = 2;
00755 break;
00756 case INDM :
00757 number_of_pins = 2;
00758 break;
00759 case INDP :
00760 number_of_pins = 2;
00761 break;
00762 case PGA :
00763 number_of_pins = (number_of_columns * number_of_rows) - number_of_exceptions;
00764 break;
00765 case PLCC :
00766 number_of_pins = (number_of_columns * count_x +
00767 number_of_rows * count_y) + thermal;
00768 break;
00769 case QFN :
00770 number_of_pins = (number_of_columns * count_x +
00771 number_of_rows * count_y) + thermal;
00772 break;
00773 case QFP :
00774 number_of_pins = (number_of_columns * count_x +
00775 number_of_rows * count_y) + thermal;
00776 break;
00777 case RESC :
00778 number_of_pins = 2;
00779 break;
00780 case RESM :
00781 number_of_pins = 2;
00782 break;
00783 case RESMELF :
00784 number_of_pins = 2;
00785 break;
00786 case SIL :
00787 number_of_pins = number_of_rows;
00788 break;
00789 case SIP :
00790 number_of_pins = number_of_rows;
00791 break;
00792 case SO :
00793 break;
00794 case SOT :
00795 break;
00796 case TO92 :
00797 number_of_pins = 3;
00798 break;
00799 default :
00800 break;
00801 }
00802 return (number_of_pins);
00803 }
00804
00805
00812 int
00813 read_footprintwizard_file
00814 (
00815 gchar *fpw_filename
00817 )
00818 {
00819
00820 FILE *fpw = fopen (fpw_filename, "r");
00821 if (!fpw)
00822 {
00823 if ((verbose) || (!silent))
00824 {
00825 g_log ("", G_LOG_LEVEL_CRITICAL,
00826 _("could not open footprint wizard file: %s for reading.\n"),
00827 fpw_filename);
00828 }
00829 return (EXIT_FAILURE);
00830 }
00831 fscanf (fpw, "%s\n", footprint_filename);
00832 if (ferror (fpw))
00833 {
00834 if ((verbose) || (!silent))
00835 {
00836 g_log ("", G_LOG_LEVEL_CRITICAL,
00837 _("error while reading footprint_filename value in: %s.\n"),
00838 fpw_filename);
00839 }
00840 fclose (fpw);
00841 return (EXIT_FAILURE);
00842 }
00843
00844 if (!footprint_filename || (!strcmp (footprint_filename, "(null)")))
00845 {
00846 if ((verbose) || (!silent))
00847 {
00848 g_log ("", G_LOG_LEVEL_CRITICAL,
00849 _("footprint filename with a null pointer found in: %s.\n"),
00850 fpw_filename);
00851 }
00852 footprint_filename = g_strdup ("");
00853 fclose (fpw);
00854 return (EXIT_FAILURE);
00855 }
00856 fscanf (fpw, "%s\n", dummy);
00857 if (ferror (fpw))
00858 {
00859 if ((verbose) || (!silent))
00860 {
00861 g_log ("", G_LOG_LEVEL_CRITICAL,
00862 _("error while reading a dummy value in: %s.\n"),
00863 fpw_filename);
00864 }
00865 fclose (fpw);
00866 return (EXIT_FAILURE);
00867 }
00868 fscanf (fpw, "%s\n", footprint_type);
00869 if (ferror (fpw))
00870 {
00871 if ((verbose) || (!silent))
00872 {
00873 g_log ("", G_LOG_LEVEL_CRITICAL,
00874 _("error while reading footprint_type value in: %s.\n"),
00875 fpw_filename);
00876 }
00877 fclose (fpw);
00878 return (EXIT_FAILURE);
00879 }
00880
00881 if (!footprint_type || (!strcmp (footprint_type, "(null)")))
00882 {
00883 if ((verbose) || (!silent))
00884 {
00885 g_log ("", G_LOG_LEVEL_CRITICAL,
00886 _("footprint type with a null pointer found in: %s.\n"),
00887 fpw_filename);
00888 }
00889 footprint_type = g_strdup ("");
00890 fclose (fpw);
00891 return (EXIT_FAILURE);
00892 }
00893
00894 if (get_package_type () == EXIT_FAILURE)
00895 {
00896 if ((verbose) || (!silent))
00897 {
00898 g_log ("", G_LOG_LEVEL_CRITICAL,
00899 _("footprint type contains an unknown package type."));
00900 }
00901 footprint_type = g_strdup ("");
00902 fclose (fpw);
00903 return (EXIT_FAILURE);
00904 }
00905 else
00906 {
00907 if (verbose)
00908 {
00909 g_log ("", G_LOG_LEVEL_INFO,
00910 _("determined the package type successful."));
00911 }
00912 }
00913 fscanf (fpw, "%s\n", footprint_units);
00914 if (ferror (fpw))
00915 {
00916 if ((verbose) || (!silent))
00917 {
00918 g_log ("", G_LOG_LEVEL_CRITICAL,
00919 _("error while reading footprint_units value in: %s.\n"),
00920 fpw_filename);
00921 }
00922 fclose (fpw);
00923 return (EXIT_FAILURE);
00924 }
00925
00926 if (!footprint_units || (!strcmp (footprint_units, "(null)")))
00927 {
00928 if ((verbose) || (!silent))
00929 {
00930 g_log ("", G_LOG_LEVEL_CRITICAL,
00931 _("footprint units with null pointer found in: %s.\n"),
00932 fpw_filename);
00933 }
00934 footprint_units = g_strdup ("");
00935 fclose (fpw);
00936 return (EXIT_FAILURE);
00937 }
00938
00939 if (update_units_variables () == EXIT_FAILURE)
00940 {
00941 if ((verbose) || (!silent))
00942 {
00943 g_log ("", G_LOG_LEVEL_CRITICAL,
00944 _("footprint units contains an unknown units type."));
00945 }
00946 footprint_units = g_strdup ("");
00947 fclose (fpw);
00948 return (EXIT_FAILURE);
00949 }
00950 else
00951 {
00952 if (verbose)
00953 {
00954 g_log ("", G_LOG_LEVEL_INFO,
00955 _("footprint units variables updated successful."));
00956 }
00957 }
00958 fscanf (fpw, "%s\n", footprint_refdes);
00959 if (ferror (fpw))
00960 {
00961 if ((verbose) || (!silent))
00962 {
00963 g_log ("", G_LOG_LEVEL_CRITICAL,
00964 _("error while reading footprint_refdes value in: %s.\n"),
00965 fpw_filename);
00966 }
00967 fclose (fpw);
00968 return (EXIT_FAILURE);
00969 }
00970
00971 if (!footprint_refdes || (!strcmp (footprint_refdes, "(null)")))
00972 {
00973 if (verbose)
00974 {
00975 g_log ("", G_LOG_LEVEL_WARNING,
00976 _("footprint refdes with a null pointer found in: %s.\n"),
00977 fpw_filename);
00978 }
00979 footprint_refdes = g_strdup ("");
00980 }
00981 fscanf (fpw, "%s\n", footprint_value);
00982 if (ferror (fpw))
00983 {
00984 if ((verbose) || (!silent))
00985 {
00986 g_log ("", G_LOG_LEVEL_CRITICAL,
00987 _("error while reading footprint_value value in: %s.\n"),
00988 fpw_filename);
00989 }
00990 fclose (fpw);
00991 return (EXIT_FAILURE);
00992 }
00993
00994 if (!footprint_value || (!strcmp (footprint_value, "(null)")))
00995 {
00996 if (verbose)
00997 {
00998 g_log ("", G_LOG_LEVEL_WARNING,
00999 _("footprint value with a null pointer found in: %s.\n"),
01000 fpw_filename);
01001 }
01002 footprint_value = g_strdup ("");
01003 }
01004 fscanf (fpw, "%f\n", package_body_length);
01005 if (ferror (fpw))
01006 {
01007 if ((verbose) || (!silent))
01008 {
01009 g_log ("", G_LOG_LEVEL_CRITICAL,
01010 _("error while reading package_body_length value in: %s.\n"),
01011 fpw_filename);
01012 }
01013 fclose (fpw);
01014 return (EXIT_FAILURE);
01015 }
01016 if ((isnan (package_body_length)) || (isinf (package_body_length)))
01017 {
01018 if (verbose)
01019 {
01020 g_log ("", G_LOG_LEVEL_WARNING,
01021 _("NaN found in package body length, in: %s.\n"),
01022 fpw_filename);
01023 }
01024 package_body_length = 0.0;
01025 }
01026 fscanf (fpw, "%f\n", package_body_width);
01027 if (ferror (fpw))
01028 {
01029 if ((verbose) || (!silent))
01030 {
01031 g_log ("", G_LOG_LEVEL_CRITICAL,
01032 _("error while reading package_body_width value in: %s.\n"),
01033 fpw_filename);
01034 }
01035 fclose (fpw);
01036 return (EXIT_FAILURE);
01037 }
01038 if ((isnan (package_body_width)) || (isinf (package_body_width)))
01039 {
01040 if (verbose)
01041 {
01042 g_log ("", G_LOG_LEVEL_WARNING,
01043 _("NaN found in package body width, in: %s.\n"),
01044 fpw_filename);
01045 }
01046 package_body_width = 0.0;
01047 }
01048 fscanf (fpw, "%f\n", package_body_height);
01049 if (ferror (fpw))
01050 {
01051 if ((verbose) || (!silent))
01052 {
01053 g_log ("", G_LOG_LEVEL_CRITICAL,
01054 _("error while reading package_body_height value in: %s.\n"),
01055 fpw_filename);
01056 }
01057 fclose (fpw);
01058 return (EXIT_FAILURE);
01059 }
01060 if ((isnan (package_body_height)) || (isinf (package_body_height)))
01061 {
01062 if (verbose)
01063 {
01064 g_log ("", G_LOG_LEVEL_WARNING,
01065 _("NaN found in package body heigth, in: %s.\n"),
01066 fpw_filename);
01067 }
01068 package_body_height = 0.0;
01069 }
01070 fscanf (fpw, "%d\n", package_is_radial);
01071 if (ferror (fpw))
01072 {
01073 if ((verbose) || (!silent))
01074 {
01075 g_log ("", G_LOG_LEVEL_CRITICAL,
01076 _("error while reading package_is_radial value in: %s.\n"),
01077 fpw_filename);
01078 }
01079 fclose (fpw);
01080 return (EXIT_FAILURE);
01081 }
01082 fscanf (fpw, "%s\n", footprint_author);
01083 if (ferror (fpw))
01084 {
01085 if ((verbose) || (!silent))
01086 {
01087 g_log ("", G_LOG_LEVEL_CRITICAL,
01088 _("error while reading footprint_author value in: %s.\n"),
01089 fpw_filename);
01090 }
01091 fclose (fpw);
01092 return (EXIT_FAILURE);
01093 }
01094
01095 if (!footprint_author || (!strcmp (footprint_author, "(null)")))
01096 {
01097 if (verbose)
01098 {
01099 g_log ("", G_LOG_LEVEL_WARNING,
01100 _("footprint author with a null pointer found in: %s.\n"),
01101 fpw_filename);
01102 }
01103 footprint_author = g_strdup ("");
01104 }
01105 fscanf (fpw, "%s\n", footprint_dist_license);
01106 if (ferror (fpw))
01107 {
01108 if ((verbose) || (!silent))
01109 {
01110 g_log ("", G_LOG_LEVEL_CRITICAL,
01111 _("error while reading footprint_dist_license value in: %s.\n"),
01112 fpw_filename);
01113 }
01114 fclose (fpw);
01115 return (EXIT_FAILURE);
01116 }
01117
01118 if (!footprint_dist_license
01119 || (!strcmp (footprint_dist_license, "(null)")))
01120 {
01121 if (verbose)
01122 {
01123 g_log ("", G_LOG_LEVEL_WARNING,
01124 _("footprint distribution license with a null pointer found in: %s.\n"),
01125 fpw_filename);
01126 }
01127 footprint_dist_license = g_strdup ("");
01128 }
01129 fscanf (fpw, "%s\n", footprint_use_license);
01130 if (ferror (fpw))
01131 {
01132 if ((verbose) || (!silent))
01133 {
01134 g_log ("", G_LOG_LEVEL_CRITICAL,
01135 _("error while reading footprint_use_license value in: %s.\n"),
01136 fpw_filename);
01137 }
01138 fclose (fpw);
01139 return (EXIT_FAILURE);
01140 }
01141
01142 if (!footprint_use_license
01143 || (!strcmp (footprint_use_license, "(null)")))
01144 {
01145 if (verbose)
01146 {
01147 g_log ("", G_LOG_LEVEL_WARNING,
01148 _("footprint usage license with a null pointer found in: %s.\n"),
01149 fpw_filename);
01150 }
01151 footprint_use_license = g_strdup ("");
01152 }
01153 fscanf (fpw, "%s\n", footprint_status);
01154 if (ferror (fpw))
01155 {
01156 if ((verbose) || (!silent))
01157 {
01158 g_log ("", G_LOG_LEVEL_CRITICAL,
01159 _("error while reading footprint_status value in: %s.\n"),
01160 fpw_filename);
01161 }
01162 fclose (fpw);
01163 return (EXIT_FAILURE);
01164 }
01165
01166 if (!footprint_status || (!strcmp (footprint_status, "(null)")))
01167 {
01168 if (verbose)
01169 {
01170 g_log ("", G_LOG_LEVEL_WARNING,
01171 _("footprint status with a null pointer found in: %s.\n"),
01172 fpw_filename);
01173 }
01174 footprint_status = g_strdup ("");
01175 }
01176 fscanf (fpw, "%d\n", attributes_in_footprint);
01177 if (ferror (fpw))
01178 {
01179 if ((verbose) || (!silent))
01180 {
01181 g_log ("", G_LOG_LEVEL_CRITICAL,
01182 _("error while reading attributes_in_footprint value in: %s.\n"),
01183 fpw_filename);
01184 }
01185 fclose (fpw);
01186 return (EXIT_FAILURE);
01187 }
01188 fscanf (fpw, "%d\n", number_of_pins);
01189 if (ferror (fpw))
01190 {
01191 if ((verbose) || (!silent))
01192 {
01193 g_log ("", G_LOG_LEVEL_CRITICAL,
01194 _("error while reading number_of_pins value in: %s.\n"),
01195 fpw_filename);
01196 }
01197 fclose (fpw);
01198 return (EXIT_FAILURE);
01199 }
01200 fscanf (fpw, "%d\n", number_of_columns);
01201 if (ferror (fpw))
01202 {
01203 if ((verbose) || (!silent))
01204 {
01205 g_log ("", G_LOG_LEVEL_CRITICAL,
01206 _("error while reading number_of_columns value in: %s.\n"),
01207 fpw_filename);
01208 }
01209 fclose (fpw);
01210 return (EXIT_FAILURE);
01211 }
01212 fscanf (fpw, "%d\n", number_of_rows);
01213 if (ferror (fpw))
01214 {
01215 if ((verbose) || (!silent))
01216 {
01217 g_log ("", G_LOG_LEVEL_CRITICAL,
01218 _("error while reading number_of_rows value in: %s.\n"),
01219 fpw_filename);
01220 }
01221 fclose (fpw);
01222 return (EXIT_FAILURE);
01223 }
01224 fscanf (fpw, "%f\n", pitch_x);
01225 if (ferror (fpw))
01226 {
01227 if ((verbose) || (!silent))
01228 {
01229 g_log ("", G_LOG_LEVEL_CRITICAL,
01230 _("error while reading pitch_x value in: %s.\n"),
01231 fpw_filename);
01232 }
01233 fclose (fpw);
01234 return (EXIT_FAILURE);
01235 }
01236 if ((isnan (pitch_x)) || (isinf (pitch_x)))
01237 {
01238 if (verbose)
01239 {
01240 g_log ("", G_LOG_LEVEL_WARNING,
01241 _("NaN number of pitch in X-direction found in: %s.\n"),
01242 fpw_filename);
01243 }
01244 pitch_x = 0.0;
01245 }
01246 fscanf (fpw, "%f\n", pitch_y);
01247 if (ferror (fpw))
01248 {
01249 if ((verbose) || (!silent))
01250 {
01251 g_log ("", G_LOG_LEVEL_CRITICAL,
01252 _("error while reading pitch_y value in: %s.\n"),
01253 fpw_filename);
01254 }
01255 fclose (fpw);
01256 return (EXIT_FAILURE);
01257 }
01258 if ((isnan (pitch_y)) || (isinf (pitch_y)))
01259 {
01260 if (verbose)
01261 g_log ("", G_LOG_LEVEL_WARNING,
01262 _("NaN number of pitch in Y-direction found in: %s.\n"),
01263 fpw_filename);
01264 pitch_y = 0.0;
01265 }
01266 fscanf (fpw, "%d\n", count_x);
01267 if (ferror (fpw))
01268 {
01269 if ((verbose) || (!silent))
01270 {
01271 g_log ("", G_LOG_LEVEL_CRITICAL,
01272 _("error while reading count_x value in: %s.\n"),
01273 fpw_filename);
01274 }
01275 fclose (fpw);
01276 return (EXIT_FAILURE);
01277 }
01278 fscanf (fpw, "%d\n", count_y);
01279 if (ferror (fpw))
01280 {
01281 if ((verbose) || (!silent))
01282 {
01283 g_log ("", G_LOG_LEVEL_CRITICAL,
01284 _("error while reading count_y value in: %s.\n"),
01285 fpw_filename);
01286 }
01287 fclose (fpw);
01288 return (EXIT_FAILURE);
01289 }
01290 fscanf (fpw, "%s\n", pad_shape);
01291 if (ferror (fpw))
01292 {
01293 if ((verbose) || (!silent))
01294 {
01295 g_log ("", G_LOG_LEVEL_CRITICAL,
01296 _("error while reading pad_shape value in: %s.\n"),
01297 fpw_filename);
01298 }
01299 fclose (fpw);
01300 return (EXIT_FAILURE);
01301 }
01302
01303 if (!pad_shape || (!strcmp (pad_shape, "(null)")))
01304 {
01305 if ((verbose) || (!silent))
01306 {
01307 g_log ("", G_LOG_LEVEL_CRITICAL,
01308 _("pad shape with a null pointer found in: %s.\n"),
01309 fpw_filename);
01310 }
01311 pad_shape = g_strdup ("");
01312 return (EXIT_FAILURE);
01313 }
01314
01315 if (update_pad_shapes_variables () == EXIT_FAILURE)
01316 {
01317 if ((verbose) || (!silent))
01318 {
01319 g_log ("", G_LOG_LEVEL_CRITICAL,
01320 _("pad shape contains an unknown pad shape type."));
01321 }
01322 return (EXIT_FAILURE);
01323 }
01324 else
01325 {
01326 if (verbose)
01327 {
01328 g_log ("", G_LOG_LEVEL_INFO,
01329 _("pad shape variables updated successful."));
01330 }
01331 }
01332 fscanf (fpw, "%s\n", pin_pad_exceptions_string);
01333 if (ferror (fpw))
01334 {
01335 if ((verbose) || (!silent))
01336 {
01337 g_log ("", G_LOG_LEVEL_CRITICAL,
01338 _("error while reading pin_pad_exceptions_string value in: %s.\n"),
01339 fpw_filename);
01340 }
01341 fclose (fpw);
01342 return (EXIT_FAILURE);
01343 }
01344
01345 if (!pin_pad_exceptions_string || (!strcmp (pin_pad_exceptions_string, "(null)")))
01346 {
01347 if ((verbose) || (!silent))
01348 {
01349 g_log ("", G_LOG_LEVEL_CRITICAL,
01350 _("pin/pad exceptions with a null pointer found in: %s.\n"),
01351 fpw_filename);
01352 }
01353 pin_pad_exceptions_string = g_strdup ("");
01354 return (EXIT_FAILURE);
01355 }
01356 fscanf (fpw, "%s\n", pin_1_position);
01357 if (ferror (fpw))
01358 {
01359 if ((verbose) || (!silent))
01360 {
01361 g_log ("", G_LOG_LEVEL_CRITICAL,
01362 _("error while reading pin_1_position value in: %s.\n"),
01363 fpw_filename);
01364 }
01365 fclose (fpw);
01366 return (EXIT_FAILURE);
01367 }
01368
01369 if (!pin_1_position || (!strcmp (pin_1_position, "(null)")))
01370 {
01371 if (verbose)
01372 {
01373 g_log ("", G_LOG_LEVEL_WARNING,
01374 _("pin #1 position with a null pointer found in: %s.\n"),
01375 fpw_filename);
01376 }
01377 pin_1_position = g_strdup ("");
01378 }
01379 fscanf (fpw, "%f\n", pad_length);
01380 if (ferror (fpw))
01381 {
01382 if ((verbose) || (!silent))
01383 {
01384 g_log ("", G_LOG_LEVEL_CRITICAL,
01385 _("error while reading pad_length value in: %s.\n"),
01386 fpw_filename);
01387 }
01388 fclose (fpw);
01389 return (EXIT_FAILURE);
01390 }
01391 if ((isnan (pad_length)) || (isinf (pad_length)))
01392 {
01393 if (verbose)
01394 {
01395 g_log ("", G_LOG_LEVEL_WARNING,
01396 _("NaN number in pad length found in: %s.\n"),
01397 fpw_filename);
01398 }
01399 pad_length = 0.0;
01400 }
01401 fscanf (fpw, "%f\n", pad_width);
01402 if (ferror (fpw))
01403 {
01404 if ((verbose) || (!silent))
01405 {
01406 g_log ("", G_LOG_LEVEL_CRITICAL,
01407 _("error while reading pad_width value in: %s.\n"),
01408 fpw_filename);
01409 }
01410 fclose (fpw);
01411 return (EXIT_FAILURE);
01412 }
01413 if ((isnan (pad_width)) || (isinf (pad_width)))
01414 {
01415 if (verbose)
01416 {
01417 g_log ("", G_LOG_LEVEL_WARNING,
01418 _("NaN number in pad width found in: %s.\n"),
01419 fpw_filename);
01420 }
01421 pad_width = 0.0;
01422 }
01423 fscanf (fpw, "%f\n", pad_diameter);
01424 if (ferror (fpw))
01425 {
01426 if ((verbose) || (!silent))
01427 {
01428 g_log ("", G_LOG_LEVEL_CRITICAL,
01429 _("error while reading pad_diameter value in: %s.\n"),
01430 fpw_filename);
01431 }
01432 fclose (fpw);
01433 return (EXIT_FAILURE);
01434 }
01435 if ((isnan (pad_diameter)) || (isinf (pad_diameter)))
01436 {
01437 if (verbose)
01438 {
01439 g_log ("", G_LOG_LEVEL_WARNING,
01440 _("NaN number in pad diameter found in: %s.\n"),
01441 fpw_filename);
01442 }
01443 pad_diameter = 0.0;
01444 }
01445 fscanf (fpw, "%f\n", pin_drill_diameter);
01446 if (ferror (fpw))
01447 {
01448 if ((verbose) || (!silent))
01449 {
01450 g_log ("", G_LOG_LEVEL_CRITICAL,
01451 _("error while reading pin_drill_diameter value in: %s.\n"),
01452 fpw_filename);
01453 }
01454 fclose (fpw);
01455 return (EXIT_FAILURE);
01456 }
01457 if ((isnan (pin_drill_diameter)) || (isinf (pin_drill_diameter)))
01458 {
01459 if (verbose)
01460 {
01461 g_log ("", G_LOG_LEVEL_WARNING,
01462 _("NaN number in pin drill diameter found in: %s.\n"),
01463 fpw_filename);
01464 }
01465 pin_drill_diameter = 0.0;
01466 }
01467 fscanf (fpw, "%d\n", pin1_square);
01468 if (ferror (fpw))
01469 {
01470 if ((verbose) || (!silent))
01471 {
01472 g_log ("", G_LOG_LEVEL_CRITICAL,
01473 _("error while reading pin1_square value in: %s.\n"),
01474 fpw_filename);
01475 }
01476 return (EXIT_FAILURE);
01477 }
01478 fscanf (fpw, "%f\n", pad_clearance);
01479 if (ferror (fpw))
01480 {
01481 if ((verbose) || (!silent))
01482 {
01483 g_log ("", G_LOG_LEVEL_CRITICAL,
01484 _("error while reading pad_clearance value in: %s.\n"),
01485 fpw_filename);
01486 }
01487 fclose (fpw);
01488 return (EXIT_FAILURE);
01489 }
01490 if ((isnan (pad_clearance)) || (isinf (pad_clearance)))
01491 {
01492 if (verbose)
01493 {
01494 g_log ("", G_LOG_LEVEL_WARNING,
01495 _("NaN number in pad clearance found in: %s.\n"),
01496 fpw_filename);
01497 }
01498 pad_clearance = 0.0;
01499 }
01500 fscanf (fpw, "%f\n", pad_solder_mask_clearance);
01501 if (ferror (fpw))
01502 {
01503 if ((verbose) || (!silent))
01504 {
01505 g_log ("", G_LOG_LEVEL_CRITICAL,
01506 _("error while reading pad_solder_mask_clearance value in: %s.\n"),
01507 fpw_filename);
01508 }
01509 fclose (fpw);
01510 return (EXIT_FAILURE);
01511 }
01512 if ((isnan (pad_solder_mask_clearance)) ||
01513 (isinf (pad_solder_mask_clearance)))
01514 {
01515 if (verbose)
01516 {
01517 g_log ("", G_LOG_LEVEL_WARNING,
01518 _("NaN number in pad solder mask clearance found in: %s.\n"),
01519 fpw_filename);
01520 }
01521 pad_solder_mask_clearance = 0.0;
01522 }
01523 fscanf (fpw, "%d\n", thermal);
01524 if (ferror (fpw))
01525 {
01526 if ((verbose) || (!silent))
01527 {
01528 g_log ("", G_LOG_LEVEL_CRITICAL,
01529 _("error while reading thermal value in: %s.\n"),
01530 fpw_filename);
01531 }
01532 return (EXIT_FAILURE);
01533 }
01534 fscanf (fpw, "%d\n", thermal_nopaste);
01535 if (ferror (fpw))
01536 {
01537 if ((verbose) || (!silent))
01538 {
01539 g_log ("", G_LOG_LEVEL_CRITICAL,
01540 _("error while reading thermal_nopaste value in: %s.\n"),
01541 fpw_filename);
01542 }
01543 return (EXIT_FAILURE);
01544 }
01545 fscanf (fpw, "%f\n", thermal_length);
01546 if (ferror (fpw))
01547 {
01548 if ((verbose) || (!silent))
01549 {
01550 g_log ("", G_LOG_LEVEL_CRITICAL,
01551 _("error while reading thermal_length value in: %s.\n"),
01552 fpw_filename);
01553 }
01554 fclose (fpw);
01555 return (EXIT_FAILURE);
01556 }
01557 if ((isnan (thermal_length)) || (isinf (thermal_length)))
01558 {
01559 if (verbose)
01560 {
01561 g_log ("", G_LOG_LEVEL_WARNING,
01562 _("NaN number in thermal length found in: %s.\n"),
01563 fpw_filename);
01564 }
01565 thermal_length = 0.0;
01566 }
01567 fscanf (fpw, "%f\n", thermal_width);
01568 if (ferror (fpw))
01569 {
01570 if ((verbose) || (!silent))
01571 {
01572 g_log ("", G_LOG_LEVEL_CRITICAL,
01573 _("error while reading thermal_width value in: %s.\n"),
01574 fpw_filename);
01575 }
01576 fclose (fpw);
01577 return (EXIT_FAILURE);
01578 }
01579 if ((isnan (thermal_width)) || (isinf (thermal_width)))
01580 {
01581 if (verbose)
01582 {
01583 g_log ("", G_LOG_LEVEL_WARNING,
01584 _("NaN number in thermal width found in: %s.\n"),
01585 fpw_filename);
01586 }
01587 thermal_width = 0.0;
01588 }
01589 fscanf (fpw, "%f\n", thermal_clearance);
01590 if (ferror (fpw))
01591 {
01592 if ((verbose) || (!silent))
01593 {
01594 g_log ("", G_LOG_LEVEL_CRITICAL,
01595 _("error while reading thermal_clearance value in: %s.\n"),
01596 fpw_filename);
01597 }
01598 fclose (fpw);
01599 return (EXIT_FAILURE);
01600 }
01601 if ((isnan (thermal_clearance)) || (isinf (thermal_clearance)))
01602 {
01603 if (verbose)
01604 {
01605 g_log ("", G_LOG_LEVEL_WARNING,
01606 _("NaN number in thermal clearance found in: %s.\n"),
01607 fpw_filename);
01608 }
01609 thermal_clearance = 0.0;
01610 }
01611 fscanf (fpw, "%f\n", thermal_solder_mask_clearance);
01612 if (ferror (fpw))
01613 {
01614 if ((verbose) || (!silent))
01615 {
01616 g_log ("", G_LOG_LEVEL_CRITICAL,
01617 _("error while reading thermal_solder_mask value in: %s.\n"),
01618 fpw_filename);
01619 }
01620 fclose (fpw);
01621 return (EXIT_FAILURE);
01622 }
01623 if ((isnan (thermal_solder_mask_clearance)) ||
01624 (isinf (thermal_solder_mask_clearance)))
01625 {
01626 if (verbose)
01627 {
01628 g_log ("", G_LOG_LEVEL_WARNING,
01629 _("NaN number in thermal solder mask clearance found in: %s.\n"),
01630 fpw_filename);
01631 }
01632 thermal_solder_mask_clearance = 0.0;
01633 }
01634 fscanf (fpw, "%d\n", fiducial);
01635 if (ferror (fpw))
01636 {
01637 if ((verbose) || (!silent))
01638 {
01639 g_log ("", G_LOG_LEVEL_CRITICAL,
01640 _("error while reading fiducial value in: %s.\n"),
01641 fpw_filename);
01642 }
01643 return (EXIT_FAILURE);
01644 }
01645 fscanf (fpw, "%f\n", fiducial_pad_diameter);
01646 if (ferror (fpw))
01647 {
01648 if ((verbose) || (!silent))
01649 {
01650 g_log ("", G_LOG_LEVEL_CRITICAL,
01651 _("error while reading fiducial_pad_diameter value in: %s.\n"),
01652 fpw_filename);
01653 }
01654 fclose (fpw);
01655 return (EXIT_FAILURE);
01656 }
01657 if ((isnan (fiducial_pad_diameter)) || (isinf (fiducial_pad_diameter)))
01658 {
01659 if (verbose)
01660 {
01661 g_log ("", G_LOG_LEVEL_WARNING,
01662 _("NaN number in fiducial pad diameter found in: %s.\n"),
01663 fpw_filename);
01664 }
01665 fiducial_pad_diameter = 0.0;
01666 }
01667 fscanf (fpw, "%f\n", fiducial_pad_solder_mask_clearance);
01668 if (ferror (fpw))
01669 {
01670 if ((verbose) || (!silent))
01671 {
01672 g_log ("", G_LOG_LEVEL_CRITICAL,
01673 _("error while reading fiducial_pad_solder_mask value in: %s.\n"),
01674 fpw_filename);
01675 }
01676 fclose (fpw);
01677 return (EXIT_FAILURE);
01678 }
01679 if ((isnan (fiducial_pad_solder_mask_clearance)) ||
01680 (isinf (fiducial_pad_solder_mask_clearance)))
01681 {
01682 if (verbose)
01683 {
01684 g_log ("", G_LOG_LEVEL_WARNING,
01685 _("NaN number in fiducial pad solder mask clearance found in: %s.\n"),
01686 fpw_filename);
01687 }
01688 fiducial_pad_solder_mask_clearance = 0.0;
01689 }
01690 fscanf (fpw, "%d\n", silkscreen_package_outline);
01691 if (ferror (fpw))
01692 {
01693 if ((verbose) || (!silent))
01694 {
01695 g_log ("", G_LOG_LEVEL_CRITICAL,
01696 _("error while reading silkscreen_package_outline value in: %s.\n"),
01697 fpw_filename);
01698 }
01699 return (EXIT_FAILURE);
01700 }
01701 fscanf (fpw, "%d\n", silkscreen_indicate_1);
01702 if (ferror (fpw))
01703 {
01704 if ((verbose) || (!silent))
01705 {
01706 g_log ("", G_LOG_LEVEL_CRITICAL,
01707 _("error while reading silkscreen_indicate_1 value in: %s.\n"),
01708 fpw_filename);
01709 }
01710 return (EXIT_FAILURE);
01711 }
01712 fscanf (fpw, "%f\n", silkscreen_line_width);
01713 if ((isnan (silkscreen_line_width)) || (isinf (silkscreen_line_width)))
01714 {
01715 if (verbose)
01716 {
01717 g_log ("", G_LOG_LEVEL_WARNING,
01718 _("NaN number in silkscreen line width found in: %s.\n"),
01719 fpw_filename);
01720 }
01721 silkscreen_line_width = 0.0;
01722 }
01723 fscanf (fpw, "%d\n", courtyard);
01724 if (ferror (fpw))
01725 {
01726 if ((verbose) || (!silent))
01727 {
01728 g_log ("", G_LOG_LEVEL_CRITICAL,
01729 _("error while reading courtyard value in: %s.\n"),
01730 fpw_filename);
01731 }
01732 return (EXIT_FAILURE);
01733 }
01734 fscanf (fpw, "%f\n", courtyard_length);
01735 if (ferror (fpw))
01736 {
01737 if ((verbose) || (!silent))
01738 {
01739 g_log ("", G_LOG_LEVEL_CRITICAL,
01740 _("error while reading courtyard_length value in: %s.\n"),
01741 fpw_filename);
01742 }
01743 fclose (fpw);
01744 return (EXIT_FAILURE);
01745 }
01746 if ((isnan (courtyard_length)) || (isinf (courtyard_length)))
01747 {
01748 if (verbose)
01749 {
01750 g_log ("", G_LOG_LEVEL_WARNING,
01751 _("NaN number in courtyard length found in: %s.\n"),
01752 fpw_filename);
01753 }
01754 courtyard_length = 0.0;
01755 }
01756 fscanf (fpw, "%f\n", courtyard_width);
01757 if (ferror (fpw))
01758 {
01759 if ((verbose) || (!silent))
01760 {
01761 g_log ("", G_LOG_LEVEL_CRITICAL,
01762 _("error while reading courtyard_width value in: %s.\n"),
01763 fpw_filename);
01764 }
01765 fclose (fpw);
01766 return (EXIT_FAILURE);
01767 }
01768 if ((isnan (courtyard_width)) || (isinf (courtyard_width)))
01769 {
01770 if (verbose)
01771 {
01772 g_log ("", G_LOG_LEVEL_WARNING,
01773 _("NaN number in courtyard width found in: %s.\n"),
01774 fpw_filename);
01775 }
01776 courtyard_width = 0.0;
01777 }
01778 fscanf (fpw, "%f\n", courtyard_line_width);
01779 if (ferror (fpw))
01780 {
01781 if ((verbose) || (!silent))
01782 {
01783 g_log ("", G_LOG_LEVEL_CRITICAL,
01784 _("error while reading courtyard_line_width value in: %s.\n"),
01785 fpw_filename);
01786 }
01787 fclose (fpw);
01788 return (EXIT_FAILURE);
01789 }
01790 if ((isnan (courtyard_line_width)) || (isinf (courtyard_line_width)))
01791 {
01792 if (verbose)
01793 {
01794 g_log ("", G_LOG_LEVEL_WARNING,
01795 _("NaN number in courtyard line width found in: %s.\n"),
01796 fpw_filename);
01797 }
01798 courtyard_line_width = 0.0;
01799 }
01800 fscanf (fpw, "%f\n", courtyard_clearance_with_package);
01801 if (ferror (fpw))
01802 {
01803 if ((verbose) || (!silent))
01804 {
01805 g_log ("", G_LOG_LEVEL_CRITICAL,
01806 _("error while reading courtyard_clearance_with_package value in: %s.\n"),
01807 fpw_filename);
01808 }
01809 fclose (fpw);
01810 return (EXIT_FAILURE);
01811 }
01812 if ((isnan (courtyard_clearance_with_package)) ||
01813 (isinf (courtyard_clearance_with_package)))
01814 {
01815 if (verbose)
01816 {
01817 g_log ("", G_LOG_LEVEL_WARNING,
01818 _("NaN number in courtyard clearance with package found in: %s.\n"),
01819 fpw_filename);
01820 }
01821 courtyard_clearance_with_package = 0.0;
01822 }
01823
01824 fscanf (fpw, "%f\n", c1);
01825 if (ferror (fpw))
01826 {
01827 if ((verbose) || (!silent))
01828 {
01829 g_log ("", G_LOG_LEVEL_CRITICAL,
01830 _("error while reading c1 value in: %s.\n"),
01831 fpw_filename);
01832 }
01833 fclose (fpw);
01834 return (EXIT_FAILURE);
01835 }
01836 if ((isnan (c1)) || (isinf (c1)))
01837 {
01838 if (verbose)
01839 {
01840 g_log ("", G_LOG_LEVEL_WARNING,
01841 _("NaN number in top to bottom center-center distance found in: %s.\n"),
01842 fpw_filename);
01843 }
01844 c1 = 0.0;
01845 }
01846 fscanf (fpw, "%f\n", g1);
01847 if (ferror (fpw))
01848 {
01849 if ((verbose) || (!silent))
01850 {
01851 g_log ("", G_LOG_LEVEL_CRITICAL,
01852 _("error while reading g1 value in: %s.\n"),
01853 fpw_filename);
01854 }
01855 fclose (fpw);
01856 return (EXIT_FAILURE);
01857 }
01858 if ((isnan (g1)) || (isinf (g1)))
01859 {
01860 if (verbose)
01861 {
01862 g_log ("", G_LOG_LEVEL_WARNING,
01863 _("NaN number in top to bottom inner-inner distance found in: %s.\n"),
01864 fpw_filename);
01865 }
01866 g1 = 0.0;
01867 }
01868 fscanf (fpw, "%f\n", z1);
01869 if (ferror (fpw))
01870 {
01871 if ((verbose) || (!silent))
01872 {
01873 g_log ("", G_LOG_LEVEL_CRITICAL,
01874 _("error while reading z1 value in: %s.\n"),
01875 fpw_filename);
01876 }
01877 fclose (fpw);
01878 return (EXIT_FAILURE);
01879 }
01880 if ((isnan (z1)) || (isinf (z1)))
01881 {
01882 if (verbose)
01883 {
01884 g_log ("", G_LOG_LEVEL_WARNING,
01885 _("NaN number in top to bottom outer-outer distance found in: %s.\n"),
01886 fpw_filename);
01887 }
01888 z1 = 0.0;
01889 }
01890 fscanf (fpw, "%f\n", c2);
01891 if (ferror (fpw))
01892 {
01893 if ((verbose) || (!silent))
01894 {
01895 g_log ("", G_LOG_LEVEL_CRITICAL,
01896 _("error while reading c2 value in: %s.\n"),
01897 fpw_filename);
01898 }
01899 fclose (fpw);
01900 return (EXIT_FAILURE);
01901 }
01902 if ((isnan (c2)) || (isinf (c2)))
01903 {
01904 if (verbose)
01905 {
01906 g_log ("", G_LOG_LEVEL_WARNING,
01907 _("NaN number in left to right center-center distance found in: %s.\n"),
01908 fpw_filename);
01909 }
01910 c2 = 0.0;
01911 }
01912 fscanf (fpw, "%f\n", g2);
01913 if (ferror (fpw))
01914 {
01915 if ((verbose) || (!silent))
01916 {
01917 g_log ("", G_LOG_LEVEL_CRITICAL,
01918 _("error while reading g2 value in: %s.\n"),
01919 fpw_filename);
01920 }
01921 fclose (fpw);
01922 return (EXIT_FAILURE);
01923 }
01924 if ((isnan (g2)) || (isinf (g2)))
01925 {
01926 if (verbose)
01927 {
01928 g_log ("", G_LOG_LEVEL_WARNING,
01929 _("NaN number in left to right inner-inner distance found in: %s.\n"),
01930 fpw_filename);
01931 }
01932 g2 = 0.0;
01933 }
01934 fscanf (fpw, "%f\n", z2);
01935 if (ferror (fpw))
01936 {
01937 if ((verbose) || (!silent))
01938 {
01939 g_log ("", G_LOG_LEVEL_CRITICAL,
01940 _("error while reading z2 value in: %s.\n"),
01941 fpw_filename);
01942 }
01943 fclose (fpw);
01944 return (EXIT_FAILURE);
01945 }
01946 if ((isnan (z2)) || (isinf (z2)))
01947 {
01948 if (verbose)
01949 {
01950 g_log ("", G_LOG_LEVEL_WARNING,
01951 _("NaN number in left to right outer-outer distance found in: %s.\n"),
01952 fpw_filename);
01953 }
01954 z2 = 0.0;
01955 }
01956 if (feof (fpw))
01957 {
01958 fclose (fpw);
01959 if (verbose)
01960 {
01961 g_log ("", G_LOG_LEVEL_INFO,
01962 "read footprint wizard file: %s.\n",
01963 fpw_filename);
01964 }
01965 }
01966 return (EXIT_SUCCESS);
01967 }
01968
01969
01976 int
01977 update_location_variables ()
01978 {
01979 if (!strcmp (pin_1_position, "Upper left"))
01980 {
01981 pin1_location = UPPER_LEFT;
01982 return (EXIT_SUCCESS);
01983 }
01984 else if (!strcmp (pin_1_position, "Middle left"))
01985 {
01986 pin1_location = MIDDLE_LEFT;
01987 return (EXIT_SUCCESS);
01988 }
01989 else if (!strcmp (pin_1_position, "Lower left"))
01990 {
01991 pin1_location = LOWER_LEFT;
01992 return (EXIT_SUCCESS);
01993 }
01994 else if (!strcmp (pin_1_position, "Upper middle"))
01995 {
01996 pin1_location = UPPER_MIDDLE;
01997 return (EXIT_SUCCESS);
01998 }
01999 else if (!strcmp (pin_1_position, "Middle middle"))
02000 {
02001 pin1_location = MIDDLE_MIDDLE;
02002 return (EXIT_SUCCESS);
02003 }
02004 else if (!strcmp (pin_1_position, "Lower middle"))
02005 {
02006 pin1_location = LOWER_MIDDLE;
02007 return (EXIT_SUCCESS);
02008 }
02009 else if (!strcmp (pin_1_position, "Upper right"))
02010 {
02011 pin1_location = UPPER_RIGHT;
02012 return (EXIT_SUCCESS);
02013 }
02014 else if (!strcmp (pin_1_position, "Middle right"))
02015 {
02016 pin1_location = MIDDLE_RIGHT;
02017 return (EXIT_SUCCESS);
02018 }
02019 else if (!strcmp (pin_1_position, "Lower right"))
02020 {
02021 pin1_location = LOWER_RIGHT;
02022 return (EXIT_SUCCESS);
02023 }
02024 else if (!strcmp (pin_1_position, "Left topside"))
02025 {
02026 pin1_location = LEFT_TOP;
02027 return (EXIT_SUCCESS);
02028 }
02029 else if (!strcmp (pin_1_position, "Right topside"))
02030 {
02031 pin1_location = RIGHT_TOP;
02032 return (EXIT_SUCCESS);
02033 }
02034 else if (!strcmp (pin_1_position, "Left bottomside"))
02035 {
02036 pin1_location = LEFT_BOTTOM;
02037 return (EXIT_SUCCESS);
02038 }
02039 else if (!strcmp (pin_1_position, "Right bottomside"))
02040 {
02041 pin1_location = RIGHT_BOTTOM;
02042 return (EXIT_SUCCESS);
02043 }
02044 return (EXIT_FAILURE);
02045 }
02046
02047
02054 int
02055 update_pad_shapes_variables ()
02056 {
02057 if (!strcmp (pad_shape, "circular pad"))
02058 {
02059 pad_shapes_type = ROUND;
02060 if (verbose)
02061 {
02062 g_log ("", G_LOG_LEVEL_INFO,
02063 _("pad shape is %s, setting pad_shapes_type to ROUND."),
02064 pad_shape);
02065 }
02066 return (EXIT_SUCCESS);
02067 }
02068 else if (!strcmp (pad_shape, "rectangular pad"))
02069 {
02070 pad_shapes_type = SQUARE;
02071 if (verbose)
02072 {
02073 g_log ("", G_LOG_LEVEL_INFO,
02074 _("pad shape is %s, setting pad_shapes_type to SQUARE."),
02075 pad_shape);
02076 }
02077 return (EXIT_SUCCESS);
02078 }
02079 else if (!strcmp (pad_shape, "octagonal pad"))
02080 {
02081 pad_shapes_type = OCTAGONAL;
02082 if (verbose)
02083 {
02084 g_log ("", G_LOG_LEVEL_INFO,
02085 _("pad shape is %s, setting pad_shapes_type to OCTOGONAL."),
02086 pad_shape);
02087 }
02088 return (EXIT_SUCCESS);
02089 }
02090 else if (!strcmp (pad_shape, "rounded pad, elongated"))
02091 {
02092 pad_shapes_type = ROUND_ELONGATED;
02093 if (verbose)
02094 {
02095 g_log ("", G_LOG_LEVEL_INFO,
02096 _("pad shape is %s, setting pad_shapes_type to ROUND_ELONGATED."),
02097 pad_shape);
02098 }
02099 return (EXIT_SUCCESS);
02100 }
02101 else
02102 {
02103 pad_shapes_type = NO_SHAPE;
02104 if (verbose)
02105 {
02106 g_log ("", G_LOG_LEVEL_WARNING,
02107 _("encountered a %s pad shape, resetting pad_shapes_type to NO_SHAPE."),
02108 pad_shape);
02109 }
02110 return (EXIT_FAILURE);
02111 }
02112 }
02113
02120 int
02121 update_units_variables ()
02122 {
02123 if (!strcmp (footprint_units, "mil"))
02124 {
02125 multiplier = 100.0;
02126 units_type = MIL;
02127 if (verbose)
02128 {
02129 g_log ("", G_LOG_LEVEL_INFO,
02130 _("footprint units_type set to MIL, multiplier set to 100.0"));
02131 }
02132 return (EXIT_SUCCESS);
02133 }
02134 if (!strcmp (footprint_units, "mil/100"))
02135 {
02136 multiplier = 1.0;
02137 units_type = MIL_100;
02138 if (verbose)
02139 {
02140 g_log ("", G_LOG_LEVEL_INFO,
02141 _("footprint units_type set to MIL/100, multiplier set to 1.0"));
02142 }
02143 return (EXIT_SUCCESS);
02144 }
02145 if (!strcmp (footprint_units, "mm"))
02146 {
02147 multiplier = (1000 / 25.4) * 100;
02148 units_type = MM;
02149 if (verbose)
02150 {
02151 g_log ("", G_LOG_LEVEL_INFO,
02152 _("footprint units_type set to MM, multiplier set to 3937.00..."));
02153 }
02154 return (EXIT_SUCCESS);
02155 }
02156 return (EXIT_FAILURE);
02157 }
02158
02159
02165 int
02166 write_attributes ()
02167 {
02168
02169 fprintf (fp, "# Write attributes\n");
02170 fprintf (fp, "\tAttribute(\"author\" \"%s\")\n", footprint_author);
02171 fprintf (fp, "\tAttribute(\"dist-license\" \"%s\")\n", footprint_dist_license);
02172 fprintf (fp, "\tAttribute(\"use-license\" \"%s\")\n", footprint_use_license);
02173 fprintf (fp, "\tAttribute(\"status\" \"%s\")\n", footprint_status);
02174 fprintf (fp, "\tAttribute(\"attributes in footprint\" \"%d\")\n", (int) attributes_in_footprint);
02175 fprintf (fp, "\tAttribute(\"footprint type\" \"%s\")\n", footprint_type);
02176 fprintf (fp, "\tAttribute(\"footprint name\" \"%s\")\n", footprint_name);
02177 fprintf (fp, "\tAttribute(\"footprint units\" \"%s\")\n", footprint_units);
02178 fprintf (fp, "\tAttribute(\"footprint refdes\" \"%s\")\n", footprint_refdes);
02179 fprintf (fp, "\tAttribute(\"footprint value\" \"%s\")\n", footprint_value);
02180 fprintf (fp, "\tAttribute(\"package body length\" \"%f\")\n", package_body_length);
02181 fprintf (fp, "\tAttribute(\"package body width\" \"%f\")\n", package_body_width);
02182 fprintf (fp, "\tAttribute(\"package height\" \"%f\")\n", package_body_height);
02183 fprintf (fp, "\tAttribute(\"package is radial\" \"%d\")\n", package_is_radial);
02184 fprintf (fp, "\tAttribute(\"number of pins\" \"%d\")\n", (int) number_of_pins);
02185 fprintf (fp, "\tAttribute(\"number of columns\" \"%d\")\n", (int) number_of_columns);
02186 fprintf (fp, "\tAttribute(\"number of rows\" \"%d\")\n", (int) number_of_rows);
02187 fprintf (fp, "\tAttribute(\"pitch_x\" \"%f\")\n", pitch_x);
02188 fprintf (fp, "\tAttribute(\"pitch_y\" \"%f\")\n", pitch_y);
02189 fprintf (fp, "\tAttribute(\"count_x\" \"%d\")\n", (int) count_x);
02190 fprintf (fp, "\tAttribute(\"count_x\" \"%d\")\n", (int) count_y);
02191 fprintf (fp, "\tAttribute(\"pad_shape\" \"%s\")\n", pad_shape);
02192 fprintf (fp, "\tAttribute(\"pin_pad_exceptions\" \"%s\")\n", pin_pad_exceptions_string);
02193 fprintf (fp, "\tAttribute(\"pin_1_position\" \"%s\")\n", pin_1_position);
02194 fprintf (fp, "\tAttribute(\"pad_diameter\" \"%f\")\n", pad_diameter);
02195 fprintf (fp, "\tAttribute(\"pin_drill_diameter\" \"%f\")\n", pin_drill_diameter);
02196 fprintf (fp, "\tAttribute(\"pin1_square\" \"%d\")\n", (int) pin1_square);
02197 fprintf (fp, "\tAttribute(\"pad_length\" \"%f\")\n", pad_length);
02198 fprintf (fp, "\tAttribute(\"pad_width\" \"%f\")\n", pad_width);
02199 fprintf (fp, "\tAttribute(\"pad_clearance\" \"%f\")\n", pad_clearance);
02200 fprintf (fp, "\tAttribute(\"pad_solder_mask_clearance\" \"%f\")\n", pad_solder_mask_clearance);
02201 fprintf (fp, "\tAttribute(\"thermal\" \"%d\")\n", (int) thermal);
02202 fprintf (fp, "\tAttribute(\"thermal_nopaste\" \"%d\")\n", (int) thermal_nopaste);
02203 fprintf (fp, "\tAttribute(\"thermal_length\" \"%f\")\n", thermal_length);
02204 fprintf (fp, "\tAttribute(\"thermal_width\" \"%f\")\n", thermal_width);
02205 fprintf (fp, "\tAttribute(\"thermal_clearance\" \"%f\")\n", thermal_clearance);
02206 fprintf (fp, "\tAttribute(\"thermal_solder_mask_clearance\" \"%f\")\n", thermal_solder_mask_clearance);
02207 fprintf (fp, "\tAttribute(\"silkscreen_package_outline\" \"%d\")\n", (int) silkscreen_package_outline);
02208 fprintf (fp, "\tAttribute(\"silkscreen_indicate_1\" \"%d\")\n", (int) silkscreen_indicate_1);
02209 fprintf (fp, "\tAttribute(\"silkscreen_line_width\" \"%f\")\n", silkscreen_line_width);
02210 fprintf (fp, "\tAttribute(\"courtyard\" \"%d\")\n", (int) courtyard);
02211 fprintf (fp, "\tAttribute(\"courtyard_length\" \"%f\")\n", courtyard_length);
02212 fprintf (fp, "\tAttribute(\"courtyard_width\" \"%f\")\n", courtyard_width);
02213 fprintf (fp, "\tAttribute(\"courtyard_line_width\" \"%f\")\n", courtyard_line_width);
02214 fprintf (fp, "\tAttribute(\"courtyard_clearance_with_package\" \"%f\")\n", courtyard_clearance_with_package);
02215 fprintf (fp, "\tAttribute(\"c1\" \"%f\")\n", c1);
02216 fprintf (fp, "\tAttribute(\"g1\" \"%f\")\n", g1);
02217 fprintf (fp, "\tAttribute(\"z1\" \"%f\")\n", z1);
02218 fprintf (fp, "\tAttribute(\"c2\" \"%f\")\n", c2);
02219 fprintf (fp, "\tAttribute(\"g2\" \"%f\")\n", g2);
02220 fprintf (fp, "\tAttribute(\"z2\" \"%f\")\n", z2);
02221 return (EXIT_SUCCESS);
02222 }
02223
02224
02233 int
02234 write_element_arc
02235 (
02236 gdouble x,
02238 gdouble y,
02240 gdouble width,
02242 gdouble height,
02244 gdouble start_angle,
02247 gdouble delta_angle,
02250 gdouble line_width
02252 )
02253 {
02254 fprintf
02255 (
02256 fp,
02257 "\tElementArc[%d %d %d %d %d %d %d]\n",
02258 (int) x,
02259 (int) y,
02260 (int) width,
02261 (int) height,
02262 (int) start_angle,
02263 (int) delta_angle,
02264 (int) line_width
02265 );
02266 return (EXIT_SUCCESS);
02267 }
02268
02269
02275 int
02276 write_element_header
02277 (
02278 gdouble x_text,
02280 gdouble y_text
02282 )
02283 {
02284
02285 fprintf
02286 (
02287 fp,
02288 "Element[\"\" \"%s\" \"%s?\" \"%s\" 0 0 %d %d 0 100 \"\"]\n(\n",
02289 footprint_name,
02290 footprint_refdes,
02291 footprint_value,
02292 (int) (x_text),
02293 (int) (y_text)
02294 );
02295 return (EXIT_SUCCESS);
02296 }
02297
02298
02307 int
02308 write_element_line
02309 (
02310 gdouble x0,
02314 gdouble y0,
02318 gdouble x1,
02322 gdouble y1,
02326 gdouble line_width
02328 )
02329 {
02330 fprintf
02331 (
02332 fp,
02333 "\tElementLine[%d %d %d %d %d]\n",
02334 (int) x0,
02335 (int) y0,
02336 (int) x1,
02337 (int) y1,
02338 (int) line_width
02339 );
02340 return (EXIT_SUCCESS);
02341 }
02342
02343
02445 int
02446 write_license
02447 (
02448 )
02449 {
02450
02451 fprintf (fp, "# This footprint is free software; you may redistribute it and/or modify\n");
02452 fprintf (fp, "# it under the terms of the GNU General Public License as published by the\n");
02453 fprintf (fp, "# Free Software Foundation; either version 2 of the License, or (at your\n");
02454 fprintf (fp, "# option) any later version.\n");
02455 fprintf (fp, "# As a special exception, if you create a design which uses this\n");
02456 fprintf (fp, "# footprint, and embed this footprint or unaltered portions of this\n");
02457 fprintf (fp, "# footprint into the design, this footprint does not by itself cause\n");
02458 fprintf (fp, "# the resulting design to be covered by the GNU General Public\n");
02459 fprintf (fp, "# License.\n");
02460 fprintf (fp, "# This exception does not however invalidate any other reasons why\n");
02461 fprintf (fp, "# the design itself might be covered by the GNU General Public\n");
02462 fprintf (fp, "# License.\n");
02463 fprintf (fp, "# If you modify this footprint, you may extend this exception to your\n");
02464 fprintf (fp, "# version of the footprint, but you are not obligated to do so.\n");
02465 fprintf (fp, "# If you do not wish to do so, delete this exception statement from\n");
02466 fprintf (fp, "# your version.\n");
02467 fprintf (fp, "#\n");
02468 return (EXIT_SUCCESS);
02469 }
02470
02471
02480 int
02481 write_pad
02482 (
02483 gint pad_number,
02485 gchar *pad_name,
02487 gdouble x0,
02489 gdouble y0,
02491 gdouble x1,
02493 gdouble y1,
02495 gdouble width,
02497 gdouble clearance,
02499 gdouble pad_solder_mask_clearance,
02501 gchar *flags
02516 )
02517 {
02518 fprintf
02519 (
02520 fp,
02521 "\tPad[%d %d %d %d %d %d %d \"%s\" \"%d\" \"%s\"]\n",
02522 (int) x0,
02523 (int) y0,
02524 (int) x1,
02525 (int) y1,
02526 (int) width,
02527 (int) clearance,
02528 (int) pad_solder_mask_clearance,
02529 pad_name,
02530 pad_number,
02531 flags
02532 );
02533 return (EXIT_SUCCESS);
02534 }
02535
02536
02545 int
02546 write_pin
02547 (
02548 gint pin_number,
02550 gchar *pin_name,
02552 gdouble x0,
02554 gdouble y0,
02556 gdouble width,
02558 gdouble clearance,
02560 gdouble pad_solder_mask_clearance,
02562 gdouble drill,
02564 gchar *flags
02579 )
02580 {
02581 fprintf
02582 (
02583 fp,
02584 "\tPin[%d %d %d %d %d %d \"%s\" \"%d\" \"%s\"]\n",
02585 (int) x0,
02586 (int) y0,
02587 (int) width,
02588 (int) clearance,
02589 (int) pad_solder_mask_clearance,
02590 (int) drill,
02591 pin_name,
02592 pin_number,
02593 flags
02594 );
02595 return (EXIT_SUCCESS);
02596 }
02597
02608 int
02609 write_rectangle
02610 (
02611 gdouble xmin,
02613 gdouble ymin,
02615 gdouble xmax,
02617 gdouble ymax,
02619 gdouble line_width
02621 )
02622 {
02623
02624 if (line_width == 0.0)
02625 {
02626 return;
02627 }
02628
02629
02630
02631 if (line_width < 0.0)
02632 {
02633 line_width = THIN_DRAW;
02634 }
02635
02636 fprintf
02637 (
02638 fp,
02639 "\tElementLine[%d %d %d %d %d]\n",
02640 (int) xmin,
02641 (int) ymin,
02642 (int) xmin,
02643 (int) ymax,
02644 (int) line_width
02645 );
02646 fprintf
02647 (
02648 fp,
02649 "\tElementLine[%d %d %d %d %d]\n",
02650 (int) xmax,
02651 (int) ymin,
02652 (int) xmax,
02653 (int) ymax,
02654 (int) line_width
02655 );
02656
02657 fprintf
02658 (
02659 fp,
02660 "\tElementLine[%d %d %d %d %d]\n",
02661 (int) xmin,
02662 (int) ymin,
02663 (int) xmax,
02664 (int) ymin,
02665 (int) line_width
02666 );
02667 fprintf
02668 (
02669 fp,
02670 "\tElementLine[%d %d %d %d %d]\n",
02671 (int) xmax,
02672 (int) ymax,
02673 (int) xmin,
02674 (int) ymax,
02675 (int) line_width
02676 );
02677 return (EXIT_SUCCESS);
02678 }
02679
02680
02687 int
02688 write_footprintwizard_file
02689 (
02690 gchar *fpw_filename
02692 )
02693 {
02694
02695 FILE *fpw = fopen (fpw_filename, "w");
02696 if (!fpw)
02697 {
02698 g_log ("", G_LOG_LEVEL_WARNING,
02699 _("could not open footprint wizard file: %s for writing."),
02700 fpw_filename);
02701 return (EXIT_FAILURE);
02702 }
02703
02704 if (!footprint_filename || (!strcmp (footprint_filename, "")))
02705 {
02706 g_log ("", G_LOG_LEVEL_WARNING,
02707 _("could not write footprint wizard file (null or empty footprint filename string)."));
02708 return (EXIT_FAILURE);
02709 }
02710
02711 if (!footprint_name || (!strcmp (footprint_name, "")))
02712 {
02713 g_log ("", G_LOG_LEVEL_WARNING,
02714 _("could not write footprint wizard file (null or empty footprint name string)."));
02715 return (EXIT_FAILURE);
02716 }
02717
02718 if (!footprint_type || (!strcmp (footprint_type, "")))
02719 {
02720 g_log ("", G_LOG_LEVEL_WARNING,
02721 _("could not write footprint wizard file (null or empty footprint type string)."));
02722 return (EXIT_FAILURE);
02723 }
02724
02725 if (!footprint_units || (!strcmp (footprint_units, "")))
02726 {
02727 g_log ("", G_LOG_LEVEL_WARNING,
02728 _("could not write footprint wizard file (null or empty footprint units string)."));
02729 return (EXIT_FAILURE);
02730 }
02731
02732 if (!pad_shape)
02733 {
02734 g_log ("", G_LOG_LEVEL_WARNING,
02735 _("could not write footprint wizard file (null or empty pad shape string)."));
02736 return (EXIT_FAILURE);
02737 }
02738 if (!pin_pad_exceptions_string)
02739 {
02740 g_log ("", G_LOG_LEVEL_WARNING,
02741 _("could not write footprint wizard file (null or empty pin/pad exception string)."));
02742 return (EXIT_FAILURE);
02743 }
02744
02745 fprintf (fpw, "%s\n", footprint_filename);
02746 fprintf (fpw, "%s\n", footprint_name);
02747 fprintf (fpw, "%s\n", footprint_type);
02748 fprintf (fpw, "%s\n", footprint_units);
02749
02750
02751
02752
02753
02754
02755 (!footprint_refdes) ? fprintf (fpw, "\n") :
02756 fprintf (fpw, "%s\n", footprint_refdes);
02757 (!footprint_value) ? fprintf (fpw, "\n") :
02758 fprintf (fpw, "%s\n", footprint_value);
02759 fprintf (fpw, "%f\n", package_body_length);
02760 fprintf (fpw, "%f\n", package_body_width);
02761 fprintf (fpw, "%f\n", package_body_height);
02762 fprintf (fpw, "%d\n", package_is_radial);
02763 (!footprint_author) ? fprintf (fpw, "\n") :
02764 fprintf (fpw, "%s\n", footprint_author);
02765 (!footprint_dist_license) ? fprintf (fpw, "\n") :
02766 fprintf (fpw, "%s\n", footprint_dist_license);
02767 (!footprint_use_license) ? fprintf (fpw, "\n") :
02768 fprintf (fpw, "%s\n", footprint_use_license);
02769 (!footprint_status) ? fprintf (fpw, "\n") :
02770 fprintf (fpw, "%s\n", footprint_status);
02771 fprintf (fpw, "%d\n", attributes_in_footprint);
02772 fprintf (fpw, "%d\n", number_of_pins);
02773 fprintf (fpw, "%d\n", number_of_columns);
02774 fprintf (fpw, "%d\n", number_of_rows);
02775 fprintf (fpw, "%f\n", pitch_x);
02776 fprintf (fpw, "%f\n", pitch_y);
02777 fprintf (fpw, "%f\n", count_x);
02778 fprintf (fpw, "%f\n", count_y);
02779 fprintf (fpw, "%s\n", pad_shape);
02780 fprintf (fpw, "%s\n", pin_pad_exceptions_string);
02781 (!pin_1_position) ? fprintf (fpw, "\n") :
02782 fprintf (fpw, "%s\n", pin_1_position);
02783 fprintf (fpw, "%f\n", pad_diameter);
02784 fprintf (fpw, "%f\n", pin_drill_diameter);
02785 fprintf (fpw, "%d\n", pin1_square);
02786 fprintf (fpw, "%f\n", pad_length);
02787 fprintf (fpw, "%f\n", pad_width);
02788 fprintf (fpw, "%f\n", pad_clearance);
02789 fprintf (fpw, "%f\n", pad_solder_mask_clearance);
02790 fprintf (fpw, "%d\n", thermal);
02791 fprintf (fpw, "%d\n", thermal_nopaste);
02792 fprintf (fpw, "%f\n", thermal_length);
02793 fprintf (fpw, "%f\n", thermal_width);
02794 fprintf (fpw, "%f\n", thermal_clearance);
02795 fprintf (fpw, "%f\n", thermal_solder_mask_clearance);
02796 fprintf (fpw, "%d\n", fiducial);
02797 fprintf (fpw, "%f\n", fiducial_pad_diameter);
02798 fprintf (fpw, "%f\n", fiducial_pad_solder_mask_clearance);
02799 fprintf (fpw, "%d\n", silkscreen_package_outline);
02800 fprintf (fpw, "%d\n", silkscreen_indicate_1);
02801 fprintf (fpw, "%f\n", silkscreen_line_width);
02802 fprintf (fpw, "%d\n", courtyard);
02803 fprintf (fpw, "%f\n", courtyard_length);
02804 fprintf (fpw, "%f\n", courtyard_width);
02805 fprintf (fpw, "%f\n", courtyard_line_width);
02806 fprintf (fpw, "%f\n", courtyard_clearance_with_package);
02807 fprintf (fpw, "%f\n", c1);
02808 fprintf (fpw, "%f\n", g1);
02809 fprintf (fpw, "%f\n", z1);
02810 fprintf (fpw, "%f\n", c2);
02811 fprintf (fpw, "%f\n", g2);
02812 fprintf (fpw, "%f\n", z2);
02813 fclose (fpw);
02814 fprintf (stderr, "SUCCESS: wrote Footprintwizard file %s.\n",
02815 fpw_filename);
02816 return (EXIT_SUCCESS);
02817 }
02818
02819
02829 int
02830 write_footprint()
02831 {
02832 int error_found;
02833 error_found = FALSE;
02834
02835 switch (package_type)
02836 {
02837 case BGA:
02838 if (bga_drc() == EXIT_SUCCESS)
02839 {
02840 bga_write_footprint ();
02841 }
02842 else
02843 {
02844 error_found = TRUE;
02845 }
02846 break;
02847 case CAPA:
02848 if (capa_drc () == EXIT_SUCCESS)
02849 {
02850 capa_write_footprint ();
02851 }
02852 else
02853 {
02854 error_found = TRUE;
02855 }
02856 break;
02857 case CAPC:
02858 if (capc_drc () == EXIT_SUCCESS)
02859 {
02860 capc_write_footprint ();
02861 }
02862 else
02863 {
02864 error_found = TRUE;
02865 }
02866 break;
02867 case CAPM:
02868 if (capm_drc () == EXIT_SUCCESS)
02869 {
02870 capm_write_footprint ();
02871 }
02872 else
02873 {
02874 error_found = TRUE;
02875 }
02876 break;
02877 case CAPMP:
02878 if (capmp_drc () == EXIT_SUCCESS)
02879 {
02880 capmp_write_footprint ();
02881 }
02882 else
02883 {
02884 error_found = TRUE;
02885 }
02886 break;
02887 case CAPPR:
02888 if (cappr_drc () == EXIT_SUCCESS)
02889 {
02890 cappr_write_footprint ();
02891 }
02892 else
02893 {
02894 error_found = TRUE;
02895 }
02896 break;
02897 case CON_DIL:
02898 if (con_dil_drc() == EXIT_SUCCESS)
02899 {
02900 con_dil_write_footprint ();
02901 }
02902 else
02903 {
02904 error_found = TRUE;
02905 }
02906 break;
02907 case CON_DIP:
02908 if (con_dip_drc() == EXIT_SUCCESS)
02909 {
02910 con_dip_write_footprint ();
02911 }
02912 else
02913 {
02914 error_found = TRUE;
02915 }
02916 break;
02917 case CON_HDR:
02918 if (con_hdr_drc () == EXIT_SUCCESS)
02919 {
02920 con_hdr_write_footprint ();
02921 }
02922 else
02923 {
02924 error_found = TRUE;
02925 }
02926 break;
02927 case CON_SIL:
02928 if (con_sil_drc () == EXIT_SUCCESS)
02929 {
02930 con_sil_write_footprint ();
02931 }
02932 else
02933 {
02934 error_found = TRUE;
02935 }
02936 break;
02937 case DIL:
02938 return (EXIT_FAILURE);
02939 break;
02940 case DIOM:
02941 if (diom_drc () == EXIT_SUCCESS)
02942 {
02943 diom_write_footprint (); break;
02944 }
02945 else
02946 {
02947 error_found = TRUE;
02948 }
02949 break;
02950 case DIOMELF:
02951 if (diomelf_drc () == EXIT_SUCCESS)
02952 {
02953 diomelf_write_footprint ();
02954 }
02955 else
02956 {
02957 error_found = TRUE;
02958 }
02959 break;
02960 case DIP:
02961 if (dip_drc () == EXIT_SUCCESS)
02962 {
02963 dip_write_footprint ();
02964 }
02965 else
02966 {
02967 error_found = TRUE;
02968 }
02969 break;
02970 case DIPS:
02971 if (dips_drc () == EXIT_SUCCESS)
02972 {
02973 dips_write_footprint ();
02974 }
02975 else
02976 {
02977 error_found = TRUE;
02978 }
02979 break;
02980 case INDC:
02981 if (indc_drc () == EXIT_SUCCESS)
02982 {
02983 indc_write_footprint ();
02984 }
02985 else
02986 {
02987 error_found = TRUE;
02988 }
02989 break;
02990 case INDM:
02991 if (indm_drc () == EXIT_SUCCESS)
02992 {
02993 indm_write_footprint ();
02994 }
02995 else
02996 {
02997 error_found = TRUE;
02998 }
02999 break;
03000 case INDP:
03001 if (indp_drc () == EXIT_SUCCESS)
03002 {
03003 indp_write_footprint ();
03004 }
03005 else
03006 {
03007 error_found = TRUE;
03008 }
03009 break;
03010 case PGA:
03011 if (pga_drc () == EXIT_SUCCESS)
03012 {
03013 pga_write_footprint ();
03014 }
03015 else
03016 {
03017 error_found = TRUE;
03018 }
03019 break;
03020 case PLCC:
03021 if (plcc_drc () == EXIT_SUCCESS)
03022 {
03023 plcc_write_footprint ();
03024 }
03025 else
03026 {
03027 error_found = TRUE;
03028 }
03029 break;
03030 case QFN:
03031 return (EXIT_FAILURE);
03032 break;
03033 case QFP:
03034 return (EXIT_FAILURE);
03035 break;
03036 case RES:
03037 if (res_drc () == EXIT_SUCCESS)
03038 {
03039 res_write_footprint ();
03040 }
03041 else
03042 {
03043 error_found = TRUE;
03044 }
03045 break;
03046 case RESC:
03047 if (resc_drc () == EXIT_SUCCESS)
03048 {
03049 resc_write_footprint ();
03050 }
03051 else
03052 {
03053 error_found = TRUE;
03054 }
03055 break;
03056 case RESM:
03057 if (resm_drc () == EXIT_SUCCESS)
03058 {
03059 resm_write_footprint ();
03060 }
03061 else
03062 {
03063 error_found = TRUE;
03064 }
03065 break;
03066 case RESMELF:
03067 if (resmelf_drc () == EXIT_SUCCESS)
03068 {
03069 resmelf_write_footprint ();
03070 }
03071 else
03072 {
03073 error_found = TRUE;
03074 }
03075 break;
03076 case SIL:
03077 if (sil_drc () == EXIT_SUCCESS)
03078 {
03079 sil_write_footprint ();
03080 }
03081 else
03082 {
03083 error_found = TRUE;
03084 }
03085 break;
03086 case SIP:
03087 if (sip_drc () == EXIT_SUCCESS)
03088 {
03089 sip_write_footprint ();
03090 }
03091 else
03092 {
03093 error_found = TRUE;
03094 }
03095 break;
03096 case SO:
03097 return (EXIT_FAILURE);
03098 break;
03099 case SOT:
03100 if (sot_drc () == EXIT_SUCCESS)
03101 {
03102 sot_write_footprint ();
03103 }
03104 else
03105 {
03106 error_found = TRUE;
03107 }
03108 break;
03109 case TO92:
03110 if (to_drc () == EXIT_SUCCESS)
03111 {
03112 to_write_footprint_to92 ();
03113 }
03114 else
03115 {
03116 error_found = TRUE;
03117 }
03118 break;
03119 case TO220:
03120 if (to_drc () == EXIT_SUCCESS)
03121 {
03122 to_write_footprint_to220 ();
03123 }
03124 else
03125 {
03126 error_found = TRUE;
03127 }
03128 break;
03129 case TO220S:
03130 if (to_drc () == EXIT_SUCCESS)
03131 {
03132 to_write_footprint_to220_staggered ();
03133 }
03134 else
03135 {
03136 error_found = TRUE;
03137 }
03138 break;
03139 case TO220SW:
03140 if (to_drc () == EXIT_SUCCESS)
03141 {
03142 to_write_footprint_to220_standing_staggered ();
03143 }
03144 else
03145 {
03146 error_found = TRUE;
03147 }
03148 break;
03149 case TO220W:
03150 if (to_drc () == EXIT_SUCCESS)
03151 {
03152 to_write_footprint_to220_standing ();
03153 }
03154 else
03155 {
03156 error_found = TRUE;
03157 }
03158 break;
03159 default:
03160 if ((verbose) || (!silent))
03161 {
03162 g_log ("", G_LOG_LEVEL_WARNING,
03163 _("unknown or not yet implemented footprint type entered.\n"));
03164 }
03165 return (EXIT_FAILURE);
03166 break;
03167 }
03168 if (error_found)
03169 {
03170 g_log ("", G_LOG_LEVEL_WARNING,
03171 (_("no [%s] footprint written: found DRC errors while checking package %s.")),
03172 footprint_type, footprint_name);
03173 }
03174 return (EXIT_SUCCESS);
03175 }
03176
03177