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;
400 if (bindir != NULL) {
405 if (exec_prefix != NULL) {
410 if (pkgdatadir != NULL) {
415 if (scmdatadir != NULL) {
422 init_paths (
char *argv0)
427 int found_bindir = 0;
441 for (
unsigned int i = 0; i < strlen (argv0) ; i++)
443 if (argv0[i] == GERBV_DIR_SEPARATOR_C)
447 DPRINTF(
"%s (%s): haspath = %d\n", __FUNCTION__, argv0, haspath);
452 bindir = lrealpath (argv0);
457 char *path, *p, *tmps;
461 tmps = getenv (
"PATH");
465 path = strdup (tmps);
468 for (p = strtok (path, GERBV_PATH_DELIMETER); p && *p;
469 p = strtok (NULL, GERBV_PATH_DELIMETER))
471 DPRINTF(
"Looking for %s in %s\n", argv0, p);
472 if ( (tmps = malloc ( (strlen (argv0) + strlen (p) + 2) *
sizeof (
char))) == NULL )
474 fprintf (stderr,
"malloc failed in %s()\n", __FUNCTION__);
477 sprintf (tmps,
"%s%s%s", p, GERBV_DIR_SEPARATOR_S, argv0);
478 r = stat (tmps, &sb);
481 DPRINTF(
"Found it: \"%s\"\n", tmps);
482 bindir = lrealpath (tmps);
492 DPRINTF(
"%s(): bindir = \"%s\"\n", __FUNCTION__, bindir);
499 t1 = strchr (bindir, GERBV_DIR_SEPARATOR_C);
500 while (t1 != NULL && *t1 !=
'\0')
503 t1 = strchr (t2 + 1, GERBV_DIR_SEPARATOR_C);
507 DPRINTF(
"After stripping off the executible name, we found\n");
508 DPRINTF(
"bindir = \"%s\"\n", bindir);
516 bindir = strdup (GERBV_BINDIR);
520 l = strlen (bindir) + 1 + strlen (BINDIR_TO_EXECPREFIX) + 1;
521 if ( (exec_prefix = (
char *) malloc (l *
sizeof (
char) )) == NULL )
523 fprintf (stderr,
"malloc failed in %s()\n", __FUNCTION__);
526 sprintf (exec_prefix,
"%s%s%s", bindir, GERBV_DIR_SEPARATOR_S,
527 BINDIR_TO_EXECPREFIX);
530 l = strlen (bindir) + 1 + strlen (BINDIR_TO_PKGDATADIR) + 1;
531 if ( (pkgdatadir = (
char *) malloc (l *
sizeof (
char) )) == NULL )
533 fprintf (stderr,
"malloc failed in %s()\n", __FUNCTION__);
536 sprintf (pkgdatadir,
"%s%s%s", bindir, GERBV_DIR_SEPARATOR_S,
537 BINDIR_TO_PKGDATADIR);
539 scmdatadir = g_strdup_printf (
"%s%s%s", pkgdatadir, GERBV_DIR_SEPARATOR_S, GERBV_SCMSUBDIR);
541 DPRINTF(
"%s(): bindir = %s\n", __FUNCTION__, bindir);
542 DPRINTF(
"%s(): exec_prefix = %s\n", __FUNCTION__, exec_prefix);
543 DPRINTF(
"%s(): pkgdatadir = %s\n", __FUNCTION__, pkgdatadir);
544 DPRINTF(
"%s(): scmdatadir = %s\n", __FUNCTION__, scmdatadir);
551 get_value_string(scheme *sc, pointer value)
553 if (!sc->vptr->is_string(value))
556 return sc->vptr->string_value(value);
565 if (path == NULL)
return NULL;
567 #if defined (__MINGW32__)
573 while ((hit_in_path = strchr(path,
'\\'))) {
578 while ((hit_in_path = strchr(path,
'/'))) {
590 define_layer(scheme *sc, pointer args)
592 pointer car_el, cdr_el, name, value;
593 project_list_t *plist;
597 DPRINTF(
"--> entering %s: %s\n", __FILE__, __func__);
599 if (!sc->vptr->is_pair(args)) {
600 GERB_MESSAGE(_(
"%s(): too few arguments"), __func__);
605 car_el = sc->vptr->pair_car(args);
606 cdr_el = sc->vptr->pair_cdr(args);
608 if (!sc->vptr->is_integer(car_el) || !sc->vptr->is_number(car_el)) {
609 GERB_MESSAGE(_(
"%s(): layer number missing/incorrect"), __func__);
614 layerno = sc->vptr->ivalue(car_el);
615 DPRINTF(
" layerno = %d\n", layerno);
617 car_el = sc->vptr->pair_car(cdr_el);
618 cdr_el = sc->vptr->pair_cdr(cdr_el);
620 plist = g_new0(project_list_t, 1);
621 plist->next = project_list_top;
622 project_list_top = plist;
623 plist->layerno = layerno;
626 plist->attr_list = NULL;
627 plist->translate_x = plist->translate_y = 0.0;
628 plist->scale_x = plist->scale_y = 1.0;
629 plist->mirror_x = plist->mirror_y = 0;
632 plist->alpha = alpha_def_value;
634 while (sc->vptr->is_pair(car_el)) {
636 name = sc->vptr->pair_car(car_el);
637 value = sc->vptr->pair_cdr(car_el);
639 if (!sc->vptr->is_symbol(name)) {
640 GERB_MESSAGE(_(
"%s(): non-symbol found, ignoring"), __func__);
641 goto end_name_value_parse;
644 str = sc->vptr->symname(name);
645 if (strcmp(str,
"color") == 0) {
646 get_color(sc, value, plist->rgb);
647 }
else if (strcmp(str,
"alpha") == 0) {
648 get_alpha(sc, value, &plist->alpha);
649 }
else if (strcmp(str,
"translate") == 0) {
650 get_double_pair(sc, value,
"translate",
651 &plist->translate_x, &plist->translate_y, 0.0);
652 }
else if (strcmp(str,
"rotation") == 0) {
653 get_double(sc, value,
"rotation", &plist->rotation, 0.0);
654 }
else if (strcmp(str,
"scale") == 0) {
655 get_double_pair(sc, value,
"scale",
656 &plist->scale_x, &plist->scale_y, 1.0);
657 }
else if (strcmp(str,
"mirror") == 0) {
658 get_bool_pair(sc, value,
"mirror",
659 &plist->mirror_x, &plist->mirror_y, 0);
660 }
else if (strcmp(str,
"filename") == 0) {
661 plist->filename = g_strdup(get_value_string(sc, value));
665 }
else if (strcmp(str,
"pick_and_place") == 0) {
666 plist->filename = g_strdup(get_value_string(sc, value));
670 }
else if (strcmp(str,
"inverted") == 0) {
671 if (value == sc->F) {
673 }
else if (value == sc->T) {
676 GERB_MESSAGE(_(
"Argument to inverted must be #t or #f"));
678 }
else if (strcmp(str,
"visible") == 0) {
679 if (value == sc->F) {
681 }
else if (value == sc->T) {
684 GERB_MESSAGE(_(
"Argument to visible must be #t or #f"));
686 }
else if (strcmp(str,
"attribs") == 0) {
687 pointer attr_car_el, attr_cdr_el;
688 pointer attr_name, attr_type, attr_value;
691 DPRINTF(
"Parsing file attributes\n");
693 attr_car_el = sc->vptr->pair_car (value);
694 attr_cdr_el = sc->vptr->pair_cdr (value);
695 while (sc->vptr->is_pair(attr_car_el)) {
696 int p = plist->n_attr;
698 plist->attr_list = (gerbv_HID_Attribute *)
699 realloc (plist->attr_list,
700 plist->n_attr * sizeof (gerbv_HID_Attribute));
701 if (plist->attr_list == NULL ) {
702 fprintf (stderr, _(
"%s(): realloc failed\n"), __FUNCTION__);
707 attr_name = sc->vptr->pair_car(attr_car_el);
710 attr_type = sc->vptr->pair_cdr (attr_car_el);
711 attr_type = sc->vptr->pair_car (attr_type);
714 attr_value = sc->vptr->pair_cdr (attr_car_el);
715 attr_value = sc->vptr->pair_cdr (attr_value);
716 attr_value = sc->vptr->pair_car (attr_value);
718 DPRINTF(
" attribute %s, type is %s, value is ",
719 sc->vptr->symname(attr_name),
720 sc->vptr->symname(attr_type));
722 plist->attr_list[p].name = strdup (sc->vptr->symname (attr_name));
724 type = sc->vptr->symname (attr_type);
726 plist->attr_list[p].default_val.str_value = NULL;
727 if (strcmp (type,
"label") == 0) {
728 DPRINTF(
"%s", sc->vptr->string_value (attr_value));
729 plist->attr_list[p].type = HID_Label;
730 plist->attr_list[p].default_val.str_value =
731 strdup (sc->vptr->string_value (attr_value));
733 }
else if (strcmp (type,
"integer") == 0) {
734 DPRINTF(
"%ld", sc->vptr->ivalue (attr_value));
735 plist->attr_list[p].type = HID_Integer;
736 plist->attr_list[p].default_val.int_value =
737 sc->vptr->ivalue (attr_value);
739 }
else if (strcmp (type,
"real") == 0) {
740 DPRINTF(
"%g", sc->vptr->rvalue (attr_value));
741 plist->attr_list[p].type = HID_Real;
742 plist->attr_list[p].default_val.real_value =
743 sc->vptr->rvalue (attr_value);
745 }
else if (strcmp (type,
"string") == 0) {
746 DPRINTF(
"%s", sc->vptr->string_value (attr_value));
747 plist->attr_list[p].type = HID_String;
748 plist->attr_list[p].default_val.str_value =
749 strdup (sc->vptr->string_value (attr_value));
751 }
else if (strcmp (type,
"boolean") == 0) {
752 DPRINTF(
"%ld", sc->vptr->ivalue (attr_value));
753 plist->attr_list[p].type = HID_Boolean;
754 plist->attr_list[p].default_val.int_value =
755 sc->vptr->ivalue (attr_value);
757 }
else if (strcmp (type,
"enum") == 0) {
758 DPRINTF(
"%ld", sc->vptr->ivalue (attr_value));
759 plist->attr_list[p].type = HID_Enum;
760 plist->attr_list[p].default_val.int_value =
761 sc->vptr->ivalue (attr_value);
763 }
else if (strcmp (type,
"mixed") == 0) {
764 plist->attr_list[p].type = HID_Mixed;
765 plist->attr_list[p].default_val.str_value = NULL;
766 fprintf (stderr, _(
"%s(): WARNING: HID_Mixed is not yet supported\n"),
769 }
else if (strcmp (type,
"path") == 0) {
770 DPRINTF(
"%s", sc->vptr->string_value (attr_value));
771 plist->attr_list[p].type = HID_Path;
772 plist->attr_list[p].default_val.str_value =
773 strdup (sc->vptr->string_value (attr_value));
775 fprintf (stderr, _(
"%s(): Unknown attribute type: \"%s\"\n"),
780 attr_car_el = sc->vptr->pair_car(attr_cdr_el);
781 attr_cdr_el = sc->vptr->pair_cdr(attr_cdr_el);
784 GERB_MESSAGE(_(
"Ignoring \"%s\" in project file"), str);
787 end_name_value_parse:
788 car_el = sc->vptr->pair_car(cdr_el);
789 cdr_el = sc->vptr->pair_cdr(cdr_el);
796 set_render_type(scheme *sc, pointer args)
801 DPRINTF(
"--> entering project.c:%s()\n", __FUNCTION__);
803 if (!sc->vptr->is_pair(args)){
804 GERB_MESSAGE(_(
"set-render-type!: Too few arguments"));
808 car_el = sc->vptr->pair_car(args);
810 r = sc->vptr->ivalue (car_el);
811 DPRINTF(
"%s(): Setting render type to %d\n", __FUNCTION__, r);
812 interface_set_render_type (r);
818 gerbv_file_version(scheme *sc, pointer args)
825 DPRINTF(
"--> entering project.c:%s()\n", __FUNCTION__);
827 if (!sc->vptr->is_pair(args)){
828 GERB_MESSAGE(_(
"gerbv-file-version!: Too few arguments"));
832 car_el = sc->vptr->pair_car(args);
833 vstr = get_value_string(sc, car_el);
836 r = version_str_to_int( vstr );
839 r = version_str_to_int( GERBV_DEFAULT_PROJECT_FILE_VERSION );
840 GERB_MESSAGE(_(
"The project file you are attempting to load has specified that it\n"
841 "uses project file version \"%s\" but this string is not\n"
842 "a valid version. Gerbv will attempt to load the file using\n"
843 "version \"%s\". You may experience unexpected results."),
844 vstr, version_int_to_str( r ));
845 vstr = GERBV_DEFAULT_PROJECT_FILE_VERSION;
848 tmps = version_int_to_str( r );
849 printf (_(
"%s(): Read a project file version of %s (%d)\n"), __FUNCTION__, vstr, r);
850 printf (_(
" Translated back to \"%s\"\n"), tmps);
854 DPRINTF(
"%s(): Read a project file version of %s (%d)\n", __FUNCTION__, vstr, r);
856 if ( r > version_str_to_int( GERBV_PROJECT_FILE_VERSION )) {
858 GERB_MESSAGE(_(
"The project file you are attempting to load is version \"%s\"\n"
859 "but this copy of gerbv is only capable of loading project files\n"
860 "using version \"%s\" or older. You may experience unexpected results."),
861 vstr, GERBV_PROJECT_FILE_VERSION);
866 while( known_versions[i] != NULL ) {
867 if( strcmp( known_versions[i], vstr) == 0 ) {
877 GERB_MESSAGE(_(
"The project file you are attempting to load is version \"%s\"\n"
878 "which is an unknown version.\n"
879 "You may experience unexpected results."),
890 current_file_version = r;
906 const gsize buf_size = 200;
908 fd = g_fopen(filename,
"rb");
910 GERB_MESSAGE(_(
"Failed to open \"%s\" for reading: %s"),
911 filename, strerror(errno));
915 buf = (
char *) g_malloc(buf_size);
917 GERB_FATAL_ERROR(
"malloc buf failed while checking for "
918 "Gerbv project in %s()", __FUNCTION__);
920 if (fgets(buf, buf_size, fd) != NULL)
921 *ret = (g_strrstr(buf,
"gerbv-file-version") != NULL);
941 struct stat stat_info;
951 char *initdirs[] = {
"$GERBV_SCHEMEINIT",
"", GERBV_BACKEND_DIR,
961 initdirs[1] = scmdatadir;
968 while(initdirs[i] != NULL) {
969 printf(
"%s(): initdirs[%d] = \"%s\"\n", __FUNCTION__, i, initdirs[i]);
980 current_file_version =
981 version_str_to_int(GERBV_DEFAULT_PROJECT_FILE_VERSION);
983 if (stat(filename, &stat_info) || !S_ISREG(stat_info.st_mode)) {
984 GERB_MESSAGE(_(
"Failed to read %s"), filename);
989 sc = scheme_init_new();
990 scheme_set_output_port_file(sc, stdout);
993 GERB_FATAL_ERROR(_(
"Couldn't init scheme"));
999 if (initfile == NULL) {
1001 GERB_MESSAGE(_(
"Problem loading init.scm (%s)"), strerror(errno));
1004 DPRINTF(
"%s(): initfile = \"%s\"\n", __FUNCTION__, initfile);
1006 if ((fd = g_fopen(initfile,
"r")) == NULL) {
1008 GERB_MESSAGE(_(
"Couldn't open %s (%s)"), initfile, strerror(errno));
1015 setlocale(LC_NUMERIC,
"C");
1017 sc->vptr->load_file(sc, fd);
1020 sc->vptr->scheme_define(sc, sc->global_env,
1021 sc->vptr->mk_symbol(sc,
"define-layer!"),
1022 sc->vptr->mk_foreign_func(sc, define_layer));
1024 sc->vptr->scheme_define(sc, sc->global_env,
1025 sc->vptr->mk_symbol(sc,
"set-render-type!"),
1026 sc->vptr->mk_foreign_func(sc, set_render_type));
1028 sc->vptr->scheme_define(sc, sc->global_env,
1029 sc->vptr->mk_symbol(sc,
"gerbv-file-version!"),
1030 sc->vptr->mk_foreign_func(sc, gerbv_file_version));
1032 if ((fd = g_fopen(filename,
"r")) == NULL) {
1033 setlocale(LC_NUMERIC,
"");
1035 GERB_MESSAGE(_(
"Couldn't open project file %s (%s)"), filename,
1041 project_list_top = NULL;
1043 scheme_load_file(sc, fd);
1046 setlocale(LC_NUMERIC,
"");
1049 return project_list_top;
1054 project_destroy_project_list (project_list_t *projectList){
1055 project_list_t *tempP,*tempP2;
1057 for (tempP = projectList; tempP != NULL; ){
1058 tempP2 = tempP->next;
1060 g_free (tempP->filename);
1061 gerbv_attribute_destroy_HID_attribute (tempP->attr_list, tempP->n_attr);
1062 tempP->attr_list = NULL;
1073 write_project_file(
gerbv_project_t *gerbvProject,
char const* filename, project_list_t *project)
1076 project_list_t *p = project;
1078 gerbv_HID_Attribute *attr_list = NULL;
1079 const float min_val = GERBV_PRECISION_LINEAR_INCH;
1082 if ((fd = g_fopen(filename,
"w")) == NULL) {
1083 GERB_MESSAGE(_(
"Couldn't save project %s"), filename);
1088 setlocale(LC_NUMERIC,
"C");
1090 fprintf(fd,
"(gerbv-file-version! \"%s\")\n", GERBV_PROJECT_FILE_VERSION);
1093 fprintf(fd,
"(define-layer! %d ", p->layerno);
1095 fprintf(fd,
"(cons 'filename \"%s\")\n",
1099 fprintf(fd,
"\t(cons 'inverted #t)\n");
1101 if (p->layerno >= 0) {
1102 fprintf(fd,
"\t(cons 'visible #%c)\n", p->visible?
't':
'f');
1105 fprintf(fd,
"\t(cons 'color #(%d %d %d))\n",
1106 p->rgb[0], p->rgb[1], p->rgb[2]);
1108 if (p->layerno >= 0) {
1109 if (p->alpha != alpha_def_value)
1110 fprintf(fd,
"\t(cons 'alpha #(%d))\n", p->alpha);
1113 if ((fabs(p->translate_x) > min_val)
1114 || (fabs(p->translate_y) > min_val)) {
1115 fprintf(fd,
"\t(cons 'translate #(%f %f))\n",
1116 p->translate_x, p->translate_y);
1118 if (fabs(p->rotation) > GERBV_PRECISION_ANGLE_RAD) {
1119 fprintf(fd,
"\t(cons 'rotation #(%f))\n", p->rotation);
1121 if ((fabs(p->scale_x - 1.0) > min_val)
1122 || (fabs(p->scale_y - 1.0) > min_val)) {
1123 fprintf(fd,
"\t(cons 'scale #(%f %f))\n",
1124 p->scale_x, p->scale_y);
1126 if (p->mirror_x || p->mirror_y) {
1127 fprintf(fd,
"\t(cons 'mirror #(#%c #%c))\n",
1128 p->mirror_x?
't':
'f', p->mirror_y?
't':
'f');
1134 if (p->layerno < 0) {
1138 attr_list = gerbvProject->
file[p->layerno]->
image->
info->attr_list;
1139 n_attr = gerbvProject->
file[p->layerno]->
image->
info->n_attr;
1143 fprintf(fd,
"\t(cons 'attribs (list\n");
1145 for (i = 0; i < n_attr ; i++) {
1146 switch (attr_list[i].type) {
1148 fprintf(fd,
"\t\t(list '%s 'Label \"%s\")\n", attr_list[i].name,
1149 attr_list[i].default_val.str_value);
1153 fprintf(fd,
"\t\t(list '%s 'Integer %d)\n", attr_list[i].name,
1154 attr_list[i].default_val.int_value);
1158 fprintf(fd,
"\t\t(list '%s 'Real %g)\n", attr_list[i].name,
1159 attr_list[i].default_val.real_value);
1163 fprintf(fd,
"\t\t(list '%s 'String \"%s\")\n", attr_list[i].name,
1164 attr_list[i].default_val.str_value);
1168 fprintf(fd,
"\t\t(list '%s 'Boolean %d)\n", attr_list[i].name,
1169 attr_list[i].default_val.int_value);
1173 fprintf(fd,
"\t\t(list '%s 'Enum %d)\n", attr_list[i].name,
1174 attr_list[i].default_val.int_value);
1178 DPRINTF(
"HID_Mixed\n");
1179 fprintf (stderr, _(
"%s(): WARNING: HID_Mixed is not yet supported.\n"),
1184 fprintf(fd,
"\t\t(list '%s 'Path \"%s\")\n", attr_list[i].name,
1185 attr_list[i].default_val.str_value);
1189 fprintf (stderr, _(
"%s: unknown type of HID attribute (%d)\n"),
1190 __FUNCTION__, attr_list[i].type);
1195 fprintf (fd,
"\t))\n");
1202 fprintf (fd,
"(set-render-type! %d)\n", screenRenderInfo.
renderType);
1204 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.
static void destroy_paths(void)
Free static path strings allocated by init_paths().
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