46 #ifdef HAVE_SYS_TYPES_H
47 #include <sys/types.h>
50 #ifdef HAVE_SYS_STAT_H
61 #include <glib/gstdio.h>
66 #include "lrealpath.h"
68 #include "scheme-private.h"
89 #define GERBV_PROJECT_FILE_VERSION "2.0A"
94 #define GERBV_DEFAULT_PROJECT_FILE_VERSION "1.9A"
100 static const char * known_versions[] = {
108 #define DPRINTF(...) do { if (DEBUG) printf(__VA_ARGS__); } while (0)
110 static project_list_t *project_list_top = NULL;
112 static const int alpha_def_value = 177*257;
118 static int current_file_version = 0;
126 version_str_to_int(
const char * str)
129 gchar *dup, *tmps, *ptr;
134 DPRINTF(
"%s(\"%s\")\n", __FUNCTION__, str);
141 tmps = g_strdup(str);
143 while(*ptr !=
'\0' && *ptr !=
'.') { ptr++; }
150 r = 10000 * atoi(tmps);
151 DPRINTF(
"%s(): Converted \"%s\" to r = %d\n", __FUNCTION__, tmps, r);
163 while(*ptr !=
'\0' && *ptr !=
'.') { ptr++; }
171 while(*ptr !=
'\0' && isdigit( (
int) *ptr)) { ptr++; }
178 r += 100 * atoi(tmps);
179 DPRINTF(
"%s(): Converted \"%s\" to r = %d\n", __FUNCTION__, tmps, r);
192 while(*ptr !=
'\0' && (isdigit( (
int) *ptr) || *ptr ==
'.') ) { ptr++; }
199 DPRINTF(
"%s(): Processing \"%s\"\n", __FUNCTION__, tmps);
201 if( strlen(tmps) == 1) {
202 r += *tmps -
'A' + 1;
203 DPRINTF(
"%s(): Converted \"%s\" to r = %d\n", __FUNCTION__, tmps, r);
204 }
else if( strlen(tmps) == 2 ) {
208 r += *tmps -
'A' + 1;
230 version_int_to_str(
int ver )
232 int major, minor, teeny;
241 minor = (ver - 10000*major) / 100;
242 teeny = (ver - 10000*major - 100*minor);
243 if(teeny >= 1 && teeny <= 26) {
244 l[0] =
'A' + teeny - 1;
245 }
else if(teeny > 26 && teeny <= 52) {
247 l[1] =
'A' + teeny - 26 - 1;
250 str = g_strdup_printf(
"%d.%d%s", major, minor, l);
255 check_vector_and_length(scheme *sc, pointer value,
256 unsigned int length,
const char *item)
258 if (!sc->vptr->is_vector(value)) {
259 GERB_MESSAGE(_(
"'%s' parameter not a vector"), item);
264 if (sc->vptr->vector_length(value) != length) {
265 GERB_MESSAGE(_(
"'%s' vector of incorrect length"), item);
274 get_color(scheme *sc, pointer value,
int *color)
279 if (check_vector_and_length(sc, value, 3,
"color"))
282 for (i = 0; i < 3; i++) {
283 elem = sc->vptr->vector_elem(value, i);
284 if (sc->vptr->is_integer(elem) && sc->vptr->is_number(elem))
285 color[i] = sc->vptr->ivalue(elem);
288 GERB_MESSAGE(_(
"Illegal color in projectfile"));
296 get_alpha(scheme *sc, pointer value,
int *alpha)
300 if (check_vector_and_length(sc, value, 1,
"alpha"))
303 elem = sc->vptr->vector_elem(value, 0);
304 if (sc->vptr->is_integer(elem) && sc->vptr->is_number(elem)) {
305 *alpha = sc->vptr->ivalue(elem);
309 GERB_MESSAGE(_(
"Illegal alpha value in projectfile"));
313 get_double(scheme *sc, pointer value,
char *item,
double *x,
double def)
317 if (check_vector_and_length(sc, value, 1, item))
320 elem = sc->vptr->vector_elem(value, 0);
321 if (sc->vptr->is_real(elem) && sc->vptr->is_number(elem)) {
322 *x = sc->vptr->rvalue(elem);
325 GERB_MESSAGE(_(
"Illegal %s in projectfile"), item);
330 get_double_pair(scheme *sc, pointer value,
char *item,
331 double *x,
double *y,
double def)
335 if (check_vector_and_length(sc, value, 2, item))
338 elem = sc->vptr->vector_elem(value, 0);
339 if (sc->vptr->is_real(elem) && sc->vptr->is_number(elem)) {
340 *x = sc->vptr->rvalue(elem);
343 GERB_MESSAGE(_(
"Illegal %s in projectfile"), item);
346 elem = sc->vptr->vector_elem(value, 1);
347 if (sc->vptr->is_real(elem) && sc->vptr->is_number(elem)) {
348 *y = sc->vptr->rvalue(elem);
351 GERB_MESSAGE(_(
"Illegal %s in projectfile"), item);
356 get_bool_pair(scheme *sc, pointer value,
char *item,
357 char *x,
char *y,
char def)
361 if (check_vector_and_length(sc, value, 2, item))
364 elem = sc->vptr->vector_elem(value, 0);
367 }
else if (elem == sc->T) {
371 GERB_MESSAGE(_(
"Illegal %s in projectfile"), item);
374 elem = sc->vptr->vector_elem(value, 1);
377 }
else if (elem == sc->T) {
381 GERB_MESSAGE(_(
"Illegal %s in projectfile"), item);
390 static char *bindir = NULL;
391 static char *exec_prefix = NULL;
392 static char *pkgdatadir = NULL;
393 static gchar *scmdatadir = NULL;
405 if (bindir != NULL) {
410 if (exec_prefix != NULL) {
415 if (pkgdatadir != NULL) {
420 if (scmdatadir != NULL) {
430 init_paths (
char *argv0)
435 int found_bindir = 0;
449 for (
unsigned int i = 0; i < strlen (argv0) ; i++)
451 if (argv0[i] == GERBV_DIR_SEPARATOR_C)
455 DPRINTF(
"%s (%s): haspath = %d\n", __FUNCTION__, argv0, haspath);
458 bindir = strdup (lrealpath (argv0));
463 char *path, *p, *tmps;
467 tmps = getenv (
"PATH");
471 path = strdup (tmps);
474 for (p = strtok (path, GERBV_PATH_DELIMETER); p && *p;
475 p = strtok (NULL, GERBV_PATH_DELIMETER))
477 DPRINTF(
"Looking for %s in %s\n", argv0, p);
478 if ( (tmps = malloc ( (strlen (argv0) + strlen (p) + 2) *
sizeof (
char))) == NULL )
480 fprintf (stderr,
"malloc failed in %s()\n", __FUNCTION__);
483 sprintf (tmps,
"%s%s%s", p, GERBV_DIR_SEPARATOR_S, argv0);
484 r = stat (tmps, &sb);
487 DPRINTF(
"Found it: \"%s\"\n", tmps);
488 bindir = lrealpath (tmps);
498 DPRINTF(
"%s(): bindir = \"%s\"\n", __FUNCTION__, bindir);
505 t1 = strchr (bindir, GERBV_DIR_SEPARATOR_C);
506 while (t1 != NULL && *t1 !=
'\0')
509 t1 = strchr (t2 + 1, GERBV_DIR_SEPARATOR_C);
513 DPRINTF(
"After stripping off the executible name, we found\n");
514 DPRINTF(
"bindir = \"%s\"\n", bindir);
522 bindir = strdup (GERBV_BINDIR);
526 l = strlen (bindir) + 1 + strlen (BINDIR_TO_EXECPREFIX) + 1;
527 if ( (exec_prefix = (
char *) malloc (l *
sizeof (
char) )) == NULL )
529 fprintf (stderr,
"malloc failed in %s()\n", __FUNCTION__);
532 sprintf (exec_prefix,
"%s%s%s", bindir, GERBV_DIR_SEPARATOR_S,
533 BINDIR_TO_EXECPREFIX);
536 l = strlen (bindir) + 1 + strlen (BINDIR_TO_PKGDATADIR) + 1;
537 if ( (pkgdatadir = (
char *) malloc (l *
sizeof (
char) )) == NULL )
539 fprintf (stderr,
"malloc failed in %s()\n", __FUNCTION__);
542 sprintf (pkgdatadir,
"%s%s%s", bindir, GERBV_DIR_SEPARATOR_S,
543 BINDIR_TO_PKGDATADIR);
545 scmdatadir = g_strdup_printf (
"%s%s%s", pkgdatadir, GERBV_DIR_SEPARATOR_S, GERBV_SCMSUBDIR);
547 DPRINTF(
"%s(): bindir = %s\n", __FUNCTION__, bindir);
548 DPRINTF(
"%s(): exec_prefix = %s\n", __FUNCTION__, exec_prefix);
549 DPRINTF(
"%s(): pkgdatadir = %s\n", __FUNCTION__, pkgdatadir);
550 DPRINTF(
"%s(): scmdatadir = %s\n", __FUNCTION__, scmdatadir);
556 get_value_string(scheme *sc, pointer value)
558 if (!sc->vptr->is_string(value))
561 return sc->vptr->string_value(value);
570 if (path == NULL)
return NULL;
572 #if defined (__MINGW32__)
578 while ((hit_in_path = strchr(path,
'\\'))) {
583 while ((hit_in_path = strchr(path,
'/'))) {
595 define_layer(scheme *sc, pointer args)
597 pointer car_el, cdr_el, name, value;
598 project_list_t *plist;
602 DPRINTF(
"--> entering %s: %s\n", __FILE__, __func__);
604 if (!sc->vptr->is_pair(args)) {
605 GERB_MESSAGE(_(
"%s(): too few arguments"), __func__);
610 car_el = sc->vptr->pair_car(args);
611 cdr_el = sc->vptr->pair_cdr(args);
613 if (!sc->vptr->is_integer(car_el) || !sc->vptr->is_number(car_el)) {
614 GERB_MESSAGE(_(
"%s(): layer number missing/incorrect"), __func__);
619 layerno = sc->vptr->ivalue(car_el);
620 DPRINTF(
" layerno = %d\n", layerno);
622 car_el = sc->vptr->pair_car(cdr_el);
623 cdr_el = sc->vptr->pair_cdr(cdr_el);
625 plist = g_new0(project_list_t, 1);
626 plist->next = project_list_top;
627 project_list_top = plist;
628 plist->layerno = layerno;
631 plist->attr_list = NULL;
632 plist->translate_x = plist->translate_y = 0.0;
633 plist->scale_x = plist->scale_y = 1.0;
634 plist->mirror_x = plist->mirror_y = 0;
637 plist->alpha = alpha_def_value;
639 while (sc->vptr->is_pair(car_el)) {
641 name = sc->vptr->pair_car(car_el);
642 value = sc->vptr->pair_cdr(car_el);
644 if (!sc->vptr->is_symbol(name)) {
645 GERB_MESSAGE(_(
"%s(): non-symbol found, ignoring"), __func__);
646 goto end_name_value_parse;
649 str = sc->vptr->symname(name);
650 if (strcmp(str,
"color") == 0) {
651 get_color(sc, value, plist->rgb);
652 }
else if (strcmp(str,
"alpha") == 0) {
653 get_alpha(sc, value, &plist->alpha);
654 }
else if (strcmp(str,
"translate") == 0) {
655 get_double_pair(sc, value,
"translate",
656 &plist->translate_x, &plist->translate_y, 0.0);
657 }
else if (strcmp(str,
"rotation") == 0) {
658 get_double(sc, value,
"rotation", &plist->rotation, 0.0);
659 }
else if (strcmp(str,
"scale") == 0) {
660 get_double_pair(sc, value,
"scale",
661 &plist->scale_x, &plist->scale_y, 1.0);
662 }
else if (strcmp(str,
"mirror") == 0) {
663 get_bool_pair(sc, value,
"mirror",
664 &plist->mirror_x, &plist->mirror_y, 0);
665 }
else if (strcmp(str,
"filename") == 0) {
666 plist->filename = g_strdup(get_value_string(sc, value));
670 }
else if (strcmp(str,
"pick_and_place") == 0) {
671 plist->filename = g_strdup(get_value_string(sc, value));
675 }
else if (strcmp(str,
"inverted") == 0) {
676 if (value == sc->F) {
678 }
else if (value == sc->T) {
681 GERB_MESSAGE(_(
"Argument to inverted must be #t or #f"));
683 }
else if (strcmp(str,
"visible") == 0) {
684 if (value == sc->F) {
686 }
else if (value == sc->T) {
689 GERB_MESSAGE(_(
"Argument to visible must be #t or #f"));
691 }
else if (strcmp(str,
"attribs") == 0) {
692 pointer attr_car_el, attr_cdr_el;
693 pointer attr_name, attr_type, attr_value;
696 DPRINTF(
"Parsing file attributes\n");
698 attr_car_el = sc->vptr->pair_car (value);
699 attr_cdr_el = sc->vptr->pair_cdr (value);
700 while (sc->vptr->is_pair(attr_car_el)) {
701 int p = plist->n_attr;
703 plist->attr_list = (gerbv_HID_Attribute *)
704 realloc (plist->attr_list,
705 plist->n_attr * sizeof (gerbv_HID_Attribute));
706 if (plist->attr_list == NULL ) {
707 fprintf (stderr, _(
"%s(): realloc failed\n"), __FUNCTION__);
712 attr_name = sc->vptr->pair_car(attr_car_el);
715 attr_type = sc->vptr->pair_cdr (attr_car_el);
716 attr_type = sc->vptr->pair_car (attr_type);
719 attr_value = sc->vptr->pair_cdr (attr_car_el);
720 attr_value = sc->vptr->pair_cdr (attr_value);
721 attr_value = sc->vptr->pair_car (attr_value);
723 DPRINTF(
" attribute %s, type is %s, value is ",
724 sc->vptr->symname(attr_name),
725 sc->vptr->symname(attr_type));
727 plist->attr_list[p].name = strdup (sc->vptr->symname (attr_name));
729 type = sc->vptr->symname (attr_type);
731 plist->attr_list[p].default_val.str_value = NULL;
732 if (strcmp (type,
"label") == 0) {
733 DPRINTF(
"%s", sc->vptr->string_value (attr_value));
734 plist->attr_list[p].type = HID_Label;
735 plist->attr_list[p].default_val.str_value =
736 strdup (sc->vptr->string_value (attr_value));
738 }
else if (strcmp (type,
"integer") == 0) {
739 DPRINTF(
"%ld", sc->vptr->ivalue (attr_value));
740 plist->attr_list[p].type = HID_Integer;
741 plist->attr_list[p].default_val.int_value =
742 sc->vptr->ivalue (attr_value);
744 }
else if (strcmp (type,
"real") == 0) {
745 DPRINTF(
"%g", sc->vptr->rvalue (attr_value));
746 plist->attr_list[p].type = HID_Real;
747 plist->attr_list[p].default_val.real_value =
748 sc->vptr->rvalue (attr_value);
750 }
else if (strcmp (type,
"string") == 0) {
751 DPRINTF(
"%s", sc->vptr->string_value (attr_value));
752 plist->attr_list[p].type = HID_String;
753 plist->attr_list[p].default_val.str_value =
754 strdup (sc->vptr->string_value (attr_value));
756 }
else if (strcmp (type,
"boolean") == 0) {
757 DPRINTF(
"%ld", sc->vptr->ivalue (attr_value));
758 plist->attr_list[p].type = HID_Boolean;
759 plist->attr_list[p].default_val.int_value =
760 sc->vptr->ivalue (attr_value);
762 }
else if (strcmp (type,
"enum") == 0) {
763 DPRINTF(
"%ld", sc->vptr->ivalue (attr_value));
764 plist->attr_list[p].type = HID_Enum;
765 plist->attr_list[p].default_val.int_value =
766 sc->vptr->ivalue (attr_value);
768 }
else if (strcmp (type,
"mixed") == 0) {
769 plist->attr_list[p].type = HID_Mixed;
770 plist->attr_list[p].default_val.str_value = NULL;
771 fprintf (stderr, _(
"%s(): WARNING: HID_Mixed is not yet supported\n"),
774 }
else if (strcmp (type,
"path") == 0) {
775 DPRINTF(
"%s", sc->vptr->string_value (attr_value));
776 plist->attr_list[p].type = HID_Path;
777 plist->attr_list[p].default_val.str_value =
778 strdup (sc->vptr->string_value (attr_value));
780 fprintf (stderr, _(
"%s(): Unknown attribute type: \"%s\"\n"),
785 attr_car_el = sc->vptr->pair_car(attr_cdr_el);
786 attr_cdr_el = sc->vptr->pair_cdr(attr_cdr_el);
789 GERB_MESSAGE(_(
"Ignoring \"%s\" in project file"), str);
792 end_name_value_parse:
793 car_el = sc->vptr->pair_car(cdr_el);
794 cdr_el = sc->vptr->pair_cdr(cdr_el);
801 set_render_type(scheme *sc, pointer args)
806 DPRINTF(
"--> entering project.c:%s()\n", __FUNCTION__);
808 if (!sc->vptr->is_pair(args)){
809 GERB_MESSAGE(_(
"set-render-type!: Too few arguments"));
813 car_el = sc->vptr->pair_car(args);
815 r = sc->vptr->ivalue (car_el);
816 DPRINTF(
"%s(): Setting render type to %d\n", __FUNCTION__, r);
817 interface_set_render_type (r);
823 gerbv_file_version(scheme *sc, pointer args)
830 DPRINTF(
"--> entering project.c:%s()\n", __FUNCTION__);
832 if (!sc->vptr->is_pair(args)){
833 GERB_MESSAGE(_(
"gerbv-file-version!: Too few arguments"));
837 car_el = sc->vptr->pair_car(args);
838 vstr = get_value_string(sc, car_el);
841 r = version_str_to_int( vstr );
844 r = version_str_to_int( GERBV_DEFAULT_PROJECT_FILE_VERSION );
845 GERB_MESSAGE(_(
"The project file you are attempting to load has specified that it\n"
846 "uses project file version \"%s\" but this string is not\n"
847 "a valid version. Gerbv will attempt to load the file using\n"
848 "version \"%s\". You may experience unexpected results."),
849 vstr, version_int_to_str( r ));
850 vstr = GERBV_DEFAULT_PROJECT_FILE_VERSION;
853 tmps = version_int_to_str( r );
854 printf (_(
"%s(): Read a project file version of %s (%d)\n"), __FUNCTION__, vstr, r);
855 printf (_(
" Translated back to \"%s\"\n"), tmps);
859 DPRINTF(
"%s(): Read a project file version of %s (%d)\n", __FUNCTION__, vstr, r);
861 if ( r > version_str_to_int( GERBV_PROJECT_FILE_VERSION )) {
863 GERB_MESSAGE(_(
"The project file you are attempting to load is version \"%s\"\n"
864 "but this copy of gerbv is only capable of loading project files\n"
865 "using version \"%s\" or older. You may experience unexpected results."),
866 vstr, GERBV_PROJECT_FILE_VERSION);
871 while( known_versions[i] != NULL ) {
872 if( strcmp( known_versions[i], vstr) == 0 ) {
882 GERB_MESSAGE(_(
"The project file you are attempting to load is version \"%s\"\n"
883 "which is an unknown version.\n"
884 "You may experience unexpected results."),
895 current_file_version = r;
911 const gsize buf_size = 200;
913 fd = g_fopen(filename,
"rb");
915 GERB_MESSAGE(_(
"Failed to open \"%s\" for reading: %s"),
916 filename, strerror(errno));
920 buf = (
char *) g_malloc(buf_size);
922 GERB_FATAL_ERROR(
"malloc buf failed while checking for "
923 "Gerbv project in %s()", __FUNCTION__);
925 if (fgets(buf, buf_size, fd) != NULL)
926 *ret = (g_strrstr(buf,
"gerbv-file-version") != NULL);
946 struct stat stat_info;
956 char *initdirs[] = {
"$GERBV_SCHEMEINIT",
"", GERBV_BACKEND_DIR,
966 initdirs[1] = scmdatadir;
973 while(initdirs[i] != NULL) {
974 printf(
"%s(): initdirs[%d] = \"%s\"\n", __FUNCTION__, i, initdirs[i]);
985 current_file_version =
986 version_str_to_int(GERBV_DEFAULT_PROJECT_FILE_VERSION);
988 if (stat(filename, &stat_info) || !S_ISREG(stat_info.st_mode)) {
989 GERB_MESSAGE(_(
"Failed to read %s"), filename);
994 sc = scheme_init_new();
995 scheme_set_output_port_file(sc, stdout);
998 GERB_FATAL_ERROR(_(
"Couldn't init scheme"));
1004 if (initfile == NULL) {
1006 GERB_MESSAGE(_(
"Problem loading init.scm (%s)"), strerror(errno));
1009 DPRINTF(
"%s(): initfile = \"%s\"\n", __FUNCTION__, initfile);
1011 if ((fd = g_fopen(initfile,
"r")) == NULL) {
1013 GERB_MESSAGE(_(
"Couldn't open %s (%s)"), initfile, strerror(errno));
1020 setlocale(LC_NUMERIC,
"C");
1022 sc->vptr->load_file(sc, fd);
1025 sc->vptr->scheme_define(sc, sc->global_env,
1026 sc->vptr->mk_symbol(sc,
"define-layer!"),
1027 sc->vptr->mk_foreign_func(sc, define_layer));
1029 sc->vptr->scheme_define(sc, sc->global_env,
1030 sc->vptr->mk_symbol(sc,
"set-render-type!"),
1031 sc->vptr->mk_foreign_func(sc, set_render_type));
1033 sc->vptr->scheme_define(sc, sc->global_env,
1034 sc->vptr->mk_symbol(sc,
"gerbv-file-version!"),
1035 sc->vptr->mk_foreign_func(sc, gerbv_file_version));
1037 if ((fd = g_fopen(filename,
"r")) == NULL) {
1038 setlocale(LC_NUMERIC,
"");
1040 GERB_MESSAGE(_(
"Couldn't open project file %s (%s)"), filename,
1046 project_list_top = NULL;
1048 scheme_load_file(sc, fd);
1051 setlocale(LC_NUMERIC,
"");
1054 return project_list_top;
1059 project_destroy_project_list (project_list_t *projectList){
1060 project_list_t *tempP,*tempP2;
1062 for (tempP = projectList; tempP != NULL; ){
1063 tempP2 = tempP->next;
1065 g_free (tempP->filename);
1066 gerbv_attribute_destroy_HID_attribute (tempP->attr_list, tempP->n_attr);
1067 tempP->attr_list = NULL;
1078 write_project_file(
gerbv_project_t *gerbvProject,
char const* filename, project_list_t *project)
1081 project_list_t *p = project;
1083 gerbv_HID_Attribute *attr_list = NULL;
1084 const float min_val = GERBV_PRECISION_LINEAR_INCH;
1087 if ((fd = g_fopen(filename,
"w")) == NULL) {
1088 GERB_MESSAGE(_(
"Couldn't save project %s"), filename);
1093 setlocale(LC_NUMERIC,
"C");
1095 fprintf(fd,
"(gerbv-file-version! \"%s\")\n", GERBV_PROJECT_FILE_VERSION);
1098 fprintf(fd,
"(define-layer! %d ", p->layerno);
1100 fprintf(fd,
"(cons 'filename \"%s\")\n",
1104 fprintf(fd,
"\t(cons 'inverted #t)\n");
1106 if (p->layerno >= 0) {
1107 fprintf(fd,
"\t(cons 'visible #%c)\n", p->visible?
't':
'f');
1110 fprintf(fd,
"\t(cons 'color #(%d %d %d))\n",
1111 p->rgb[0], p->rgb[1], p->rgb[2]);
1113 if (p->layerno >= 0) {
1114 if (p->alpha != alpha_def_value)
1115 fprintf(fd,
"\t(cons 'alpha #(%d))\n", p->alpha);
1118 if ((fabs(p->translate_x) > min_val)
1119 || (fabs(p->translate_y) > min_val)) {
1120 fprintf(fd,
"\t(cons 'translate #(%f %f))\n",
1121 p->translate_x, p->translate_y);
1123 if (fabs(p->rotation) > GERBV_PRECISION_ANGLE_RAD) {
1124 fprintf(fd,
"\t(cons 'rotation #(%f))\n", p->rotation);
1126 if ((fabs(p->scale_x - 1.0) > min_val)
1127 || (fabs(p->scale_y - 1.0) > min_val)) {
1128 fprintf(fd,
"\t(cons 'scale #(%f %f))\n",
1129 p->scale_x, p->scale_y);
1131 if (p->mirror_x || p->mirror_y) {
1132 fprintf(fd,
"\t(cons 'mirror #(#%c #%c))\n",
1133 p->mirror_x?
't':
'f', p->mirror_y?
't':
'f');
1139 if (p->layerno < 0) {
1143 attr_list = gerbvProject->
file[p->layerno]->
image->
info->attr_list;
1144 n_attr = gerbvProject->
file[p->layerno]->
image->
info->n_attr;
1148 fprintf(fd,
"\t(cons 'attribs (list\n");
1150 for (i = 0; i < n_attr ; i++) {
1151 switch (attr_list[i].type) {
1153 fprintf(fd,
"\t\t(list '%s 'Label \"%s\")\n", attr_list[i].name,
1154 attr_list[i].default_val.str_value);
1158 fprintf(fd,
"\t\t(list '%s 'Integer %d)\n", attr_list[i].name,
1159 attr_list[i].default_val.int_value);
1163 fprintf(fd,
"\t\t(list '%s 'Real %g)\n", attr_list[i].name,
1164 attr_list[i].default_val.real_value);
1168 fprintf(fd,
"\t\t(list '%s 'String \"%s\")\n", attr_list[i].name,
1169 attr_list[i].default_val.str_value);
1173 fprintf(fd,
"\t\t(list '%s 'Boolean %d)\n", attr_list[i].name,
1174 attr_list[i].default_val.int_value);
1178 fprintf(fd,
"\t\t(list '%s 'Enum %d)\n", attr_list[i].name,
1179 attr_list[i].default_val.int_value);
1183 DPRINTF(
"HID_Mixed\n");
1184 fprintf (stderr, _(
"%s(): WARNING: HID_Mixed is not yet supported.\n"),
1189 fprintf(fd,
"\t\t(list '%s 'Path \"%s\")\n", attr_list[i].name,
1190 attr_list[i].default_val.str_value);
1194 fprintf (stderr, _(
"%s: unknown type of HID attribute (%d)\n"),
1195 __FUNCTION__, attr_list[i].type);
1200 fprintf (fd,
"\t))\n");
1207 fprintf (fd,
"(set-render-type! %d)\n", screenRenderInfo.
renderType);
1209 setlocale(LC_NUMERIC,
"");
char * gerb_find_file(char const *filename, char **paths)
Search for files in directories pointed out by paths, a NULL terminated list of directories to search...
Header info for the file parsing support functions.
The main header file for the libgerbv library.
Header info for the GUI building functions for Gerber Viewer.
gerbv_project_t * mainProject
Global state variable to keep track of what's happening on the screen.
Header info for common structs and functions used for the GUI application.
static char * convert_path_separators(char *path, int conv_flag)
Conversion of '\' into '/' and vice versa for compatibility under WIN32 platforms.
project_list_t * read_project_file(char const *filename)
Reads the content of a project file.
int project_is_gerbv_project(const char *filename, gboolean *ret)
Checks whether the supplied file look like a gerbv project by reading the first line and checking if ...
Header info for loading and saving project files.
Header info for the rendering support functions for gerbv.
gerbv_image_info_t * info
gerbv_render_types_t renderType