diff --git a/CMakeLists.txt b/CMakeLists.txt
index cbf9341494..b8476f7116 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -233,11 +233,23 @@ if(NOT LIBREDWG_DISABLE_JSON)
src/in_json.c)
endif()
+if(NOT LIBREDWG_DISABLE_DXF)
+ set(outdxf_SOURCES
+ src/out_dxf.c
+ src/out_dxfb.c)
+ set(indxf_SOURCES
+ src/in_dxf.c)
+ if(LIBREDWG_DISABLE_WRITE)
+ set(indxf_SOURCES
+ src/encode.c) # in_dxf depends on some functions
+ endif
+endif()
+
if(NOT LIBREDWG_DISABLE_WRITE)
set(write_SOURCES
src/encode.c
- src/in_dxf.c
- ${injson_SOURCES}
+ ${outjson_SOURCES}
+ ${outdxf_SOURCES}
src/reedsolomon.c)
endif()
@@ -257,9 +269,8 @@ set(libredwg_SOURCES
src/dxfclasses.c
src/free.c
src/geom.c
- src/out_dxf.c
- ${outjson_SOURCES}
- src/out_dxfb.c
+ ${indxf_SOURCES}
+ ${injson_SOURCES}
${write_SOURCES}
src/print.c)
@@ -287,14 +298,21 @@ if(NOT LIBREDWG_LIBONLY)
if(NOT HAVE_GETOPT_H)
set(getopt_c programs/getopt.c)
endif(NOT HAVE_GETOPT_H)
- set(executables_TARGETS dwgread dwg2dxf dwggrep dwglayers dwgbmp dwg2SVG)
+ set(executables_TARGETS dwgread dwggrep dwglayers dwgbmp dwg2SVG)
add_executable(dwgread programs/dwgread.c ${getopt_c})
- add_executable(dwg2dxf programs/dwg2dxf.c ${getopt_c})
+ if(NOT LIBREDWG_DISABLE_DXF)
+ add_executable(dxfread programs/dxfread.c ${getopt_c})
+ set(executables_TARGETS ${executables_TARGETS} dxfread)
+ if(NOT LIBREDWG_DISABLE_WRITE)
+ add_executable(dwg2dxf programs/dwg2dxf.c ${getopt_c})
+ add_executable(dxf2dwg programs/dxf2dwg.c ${getopt_c})
+ set(executables_TARGETS ${executables_TARGETS} dxf2dwg dwg2dxf)
+ endif(NOT LIBREDWG_DISABLE_WRITE)
+ endif(NOT LIBREDWG_DISABLE_DXF)
if(NOT LIBREDWG_DISABLE_WRITE)
add_executable(dwgrewrite programs/dwgrewrite.c ${getopt_c})
add_executable(dwgwrite programs/dwgwrite.c ${getopt_c})
- add_executable(dxf2dwg programs/dxf2dwg.c ${getopt_c})
- set(executables_TARGETS ${executables_TARGETS} dwgrewrite dwgwrite dxf2dwg)
+ set(executables_TARGETS ${executables_TARGETS} dwgrewrite dwgwrite)
endif(NOT LIBREDWG_DISABLE_WRITE)
add_executable(dwggrep programs/dwggrep.c ${getopt_c})
add_executable(dwglayers programs/dwglayers.c ${getopt_c})
diff --git a/libredwg.spec b/libredwg.spec
index b950acdae5..537bd391b7 100644
--- a/libredwg.spec
+++ b/libredwg.spec
@@ -135,6 +135,7 @@ fi
%{_bindir}/dwgread
%{_bindir}/dwgrewrite
%{_bindir}/dwgwrite
+%{_bindir}/dxfread
%{_bindir}/dxf2dwg
%{_bindir}/dxfwrite
%{_libdir}/libredwg.so.0
@@ -151,6 +152,7 @@ fi
%{_mandir}/man1/dwgread.1.gz
%{_mandir}/man1/dwgrewrite.1.gz
%{_mandir}/man1/dwgwrite.1.gz
+%{_mandir}/man1/dxfread.1.gz
%{_mandir}/man1/dxf2dwg.1.gz
%{_mandir}/man1/dxfwrite.1.gz
%{_mandir}/man5/dwg*
diff --git a/programs/Makefile.am b/programs/Makefile.am
index 0348f32402..0122b7d7e9 100644
--- a/programs/Makefile.am
+++ b/programs/Makefile.am
@@ -22,45 +22,40 @@ AM_CFLAGS = -I. -I$(top_srcdir)/include -I$(top_srcdir)/src $(WARN_CFLAGS)
LDADD = $(top_builddir)/src/libredwg.la
CPPCHECK = @CPPCHECK@
-bin_PROGRAMS = dwgread
-noinst_PROGRAMS =
-dist_man1_MANS = $(srcdir)/dwgread.1
-if !DISABLE_DXF
-bin_PROGRAMS += dwgbmp dwg2dxf dwg2SVG dwglayers dwggrep
-dist_bin_SCRIPTS = dwgfilter
-dist_man1_MANS += $(srcdir)/dwgbmp.1 $(srcdir)/dwg2dxf.1 \
- $(srcdir)/dwg2SVG.1 $(srcdir)/dwglayers.1 \
+bin_PROGRAMS = dwglayers dwggrep
+noinst_PROGRAMS =
+dist_bin_SCRIPTS = dwgfilter
+dist_man1_MANS = $(srcdir)/dwglayers.1 \
$(srcdir)/dwggrep.1 $(srcdir)/dwgfilter.1
-endif
-
-if !DISABLE_DXF
-if HAVE_LIBPS
-bin_PROGRAMS += dwg2ps
-dist_man1_MANS += $(srcdir)/dwg2ps.1
-dwg2ps_SOURCES = dwg2ps.c
-dwg2ps_LDADD = $(LDADD) -lps
-endif
-endif
-dwgread_SOURCES = dwgread.c
-dwgbmp_SOURCES = dwgbmp.c
-dwg2dxf_SOURCES = dwg2dxf.c
dwglayers_SOURCES = dwglayers.c
-dwg2SVG_SOURCES = dwg2SVG.c escape.c
dwggrep_SOURCES = dwggrep.c
dwggrep_CFLAGS = $(AM_CFLAGS) $(CFLAGS) $(PCRE2_CFLAGS)
dwggrep_LDADD = $(LDADD) $(PCRE2_LIBS)
if USE_WRITE
-bin_PROGRAMS += dwgrewrite
-dist_man1_MANS += $(srcdir)/dwgrewrite.1
+bin_PROGRAMS += dwgread dwgrewrite dwgwrite dwgbmp dwg2SVG
+dist_man1_MANS += $(srcdir)/dwgread.1 $(srcdir)/dwgrewrite.1 \
+ $(srcdir)/dwgwrite.1 $(srcdir)/dwgbmp.1 $(srcdir)/dwg2SVG.1
dwgrewrite_SOURCES = dwgrewrite.c
+dwgwrite_SOURCES = dwgwrite.c
+dwgread_SOURCES = dwgread.c
+dwgbmp_SOURCES = dwgbmp.c
+dwg2SVG_SOURCES = dwg2SVG.c escape.c
if !DISABLE_DXF
-bin_PROGRAMS += dxf2dwg dwgwrite dxfwrite
-dist_man1_MANS += $(srcdir)/dxf2dwg.1 $(srcdir)/dwgwrite.1 $(srcdir)/dxfwrite.1
+bin_PROGRAMS += dxf2dwg dwg2dxf dxfwrite dxfread
+dist_man1_MANS += $(srcdir)/dxf2dwg.1 $(srcdir)/dwg2dxf.1 \
+ $(srcdir)/dxfwrite.1 $(srcdir)/dxfread.1
dxf2dwg_SOURCES = dxf2dwg.c
-dwgwrite_SOURCES = dwgwrite.c
+dxfread_SOURCES = dxfread.c
dxfwrite_SOURCES = dxfwrite.c
+dwg2dxf_SOURCES = dwg2dxf.c
+endif
+if HAVE_LIBPS
+bin_PROGRAMS += dwg2ps
+dist_man1_MANS += $(srcdir)/dwg2ps.1
+dwg2ps_SOURCES = dwg2ps.c
+dwg2ps_LDADD = $(LDADD) -lps
endif
endif
diff --git a/programs/alive.test.in b/programs/alive.test.in
index 8374551224..b1018f1a3c 100755
--- a/programs/alive.test.in
+++ b/programs/alive.test.in
@@ -107,6 +107,24 @@ run ()
fi
fi
;;
+ dxfread) if [ -z "$DISABLE_JSON" ]; then
+ if [ -n "$addarg" ]; then
+ arg="-y -v2 $addarg -o $bdwg-$out.json $bdwg.dxf"
+ else
+ arg="-y -v2 $bdwg.dxf"
+ fi
+ else
+ if [ -n "$addarg" ]; then
+ arg="-y -v2 $addarg -o $bdwg-$out.dwg $bdwg.dxf"
+ else
+ arg="-y -v2 $dwg.dxf"
+ fi
+ fi
+ # no pre-r2 dxf yet (not sure this actually applies to reading)
+ if [ "$ddwg" = "r1.4" ]; then
+ return
+ fi
+ ;;
dxfwrite) if [ -z "$DISABLE_JSON" ]; then
if [ -n "$addarg" ]; then
arg="-y -v2 $addarg -o $bdwg-$out.dxf $bdwg.json"
diff --git a/programs/dxfread.1 b/programs/dxfread.1
new file mode 100644
index 0000000000..364adf0ee1
--- /dev/null
+++ b/programs/dxfread.1
@@ -0,0 +1,42 @@
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5.
+.TH DXFREAD "1" "November 2023" "dxfread 0.13.0" "User Commands"
+.SH NAME
+dxfread \- manual page for dxfread 0.13.0
+.SH SYNOPSIS
+.B dxfread
+[\fI\,OPTION\/\fR]... \fI\,DXFFILE\/\fR
+.SH DESCRIPTION
+Reads the DXF into some optional output format to stdout or some file,
+and prints error, success or verbose internal progress to stderr.
+.TP
+\fB\-v[0\-9]\fR, \fB\-\-verbose\fR [0\-9]
+verbosity
+.TP
+\fB\-O\fR fmt, \fB\-\-format\fR fmt
+fmt: DXF, DXFB, JSON, GeoJSON
+.TP
+Planned output formats:
+YAML, XML/OGR, GPX, SVG, PS
+.TP
+\fB\-o\fR outfile
+also defines the output fmt. Default: stdout
+.TP
+\fB\-\-help\fR
+display this help and exit
+.TP
+\fB\-\-version\fR
+output version information and exit
+.PP
+GNU LibreDWG online manual:
+.SH "SEE ALSO"
+The full documentation for
+.B dxfread
+is maintained as a Texinfo manual. If the
+.B info
+and
+.B dxfread
+programs are properly installed at your site, the command
+.IP
+.B info LibreDWG
+.PP
+should give you access to the complete manual.
diff --git a/programs/dxfread.c b/programs/dxfread.c
new file mode 100644
index 0000000000..c68a84f1c9
--- /dev/null
+++ b/programs/dxfread.c
@@ -0,0 +1,362 @@
+/*****************************************************************************/
+/* LibreDWG - free implementation of the DWG file format */
+/* */
+/* Copyright (C) 2009-2023 Free Software Foundation, Inc. */
+/* Copyright (C) 2010 Thien-Thi Nguyen */
+/* */
+/* This library is free software, licensed under the terms of the GNU */
+/* General Public License as published by the Free Software Foundation, */
+/* either version 3 of the License, or (at your option) any later version. */
+/* You should have received a copy of the GNU General Public License */
+/* along with this program. If not, see . */
+/*****************************************************************************/
+
+/*
+ * dxfread.c: read a DXF file, print verbose logging, and output to
+ * various formats.
+ * written by Felipe Castro
+ * modified by Felipe CorrĂȘa da Silva Sances
+ * modified by Rodrigo Rodrigues da Silva
+ * modified by Thien-Thi Nguyen
+ * modified by Reini Urban
+ */
+
+#include "../src/config.h"
+#include
+#include
+#include
+// strings.h or string.h
+#ifdef AX_STRCASECMP_HEADER
+# include AX_STRCASECMP_HEADER
+#endif
+#include "my_getopt.h"
+#ifdef HAVE_VALGRIND_VALGRIND_H
+# include
+#endif
+
+#include "dwg.h"
+#include "common.h"
+#include "bits.h"
+#ifndef DISABLE_DXF
+# include "out_dxf.h"
+# ifndef DISABLE_JSON
+# include "out_json.h"
+# endif
+#endif
+
+#if !defined HAVE_STRCASECMP
+int strcasecmp (const char *a, const char *b);
+#endif
+
+static int opts = 1;
+
+static int
+usage (void)
+{
+#ifndef DISABLE_DXF
+ printf ("\nUsage: dxfread [-v[0-9]] [-O FMT] [-o OUTFILE] [DXFFILE|-]\n");
+#else
+ printf ("\nUsage: dxfread [-v[0-9]] [DXFFILE|-]\n");
+#endif
+ return 1;
+}
+static int
+opt_version (void)
+{
+ printf ("dxfread %s\n", PACKAGE_VERSION);
+ return 0;
+}
+static int
+help (void)
+{
+ printf ("\nUsage: dxfread [OPTION]... DXFFILE\n");
+ printf ("Reads the DXF into some optional output format to stdout or some "
+ "file,\n"
+ "and prints error, success or verbose internal progress to stderr.\n"
+ "\n");
+#ifdef HAVE_GETOPT_LONG
+ printf (" -v[0-9], --verbose [0-9] verbosity\n");
+# ifndef DISABLE_DXF
+# ifndef DISABLE_JSON
+ printf (" -O fmt, --format fmt fmt: DXF, DXFB, JSON, GeoJSON\n");
+# else
+ printf (" -O fmt, --format fmt fmt: DXF, DXFB\n");
+# endif
+ printf (" Planned output formats: YAML, XML/OGR, GPX, SVG, PS\n");
+ printf (" -o outfile also defines the output fmt. Default: "
+ "stdout\n");
+# endif
+ printf (" --help display this help and exit\n");
+ printf (" --version output version information and exit\n"
+ "\n");
+#else
+ printf (" -v[0-9] verbosity\n");
+# ifndef DISABLE_DXF
+# ifndef DISABLE_JSON
+ printf (" -O fmt fmt: DXF, DXFB, JSON, GeoJSON\n");
+# else
+ printf (" -O fmt fmt: DXF, DXFB\n");
+# endif
+ printf (
+ " Planned output formats: YAML, XML/OGR, GPX, SVG, PS\n");
+ printf (" -o outfile also defines the output fmt. Default: stdout\n");
+# endif
+ printf (" -h display this help and exit\n");
+ printf (" -i output version information and exit\n"
+ "\n");
+#endif
+ printf ("GNU LibreDWG online manual: "
+ "\n");
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ int i = 1;
+ int error;
+ Dwg_Data dwg;
+ const char *fmt = NULL;
+ const char *outfile = NULL;
+ int has_v = 0;
+ int force_free = 0;
+ int c;
+#ifdef HAVE_GETOPT_LONG
+ int option_index = 0;
+ static struct option long_options[]
+ = { { "verbose", 1, &opts, 1 }, // optional
+ { "format", 1, NULL, 'O' }, { "file", 1, NULL, 'o' },
+ { "help", 0, NULL, 0 }, { "version", 0, NULL, 0 },
+ { "force-free", 0, NULL, 0 }, { NULL, 0, NULL, 0 } };
+#endif
+
+ if (argc < 2)
+ return usage ();
+
+ while (1)
+ {
+#ifdef HAVE_GETOPT_LONG
+ c = getopt_long (argc, argv, "v::O:o:h", long_options, &option_index);
+#else
+ c = getopt (argc, argv, "v::O:o:hi");
+#endif
+ if (c == -1)
+ break;
+ switch (c)
+ {
+ case ':': // missing arg
+ if (optarg && !strcmp (optarg, "v"))
+ {
+ opts = 1;
+ has_v = 1;
+ break;
+ }
+ fprintf (stderr, "%s: option '-%c' requires an argument\n", argv[0],
+ optopt);
+ break;
+#ifdef HAVE_GETOPT_LONG
+ case 0:
+ /* This option sets a flag */
+ if (!strcmp (long_options[option_index].name, "verbose"))
+ {
+ if (opts < 0 || opts > 9)
+ return usage ();
+# if defined(USE_TRACING) && defined(HAVE_SETENV)
+ {
+ char v[2];
+ *v = opts + '0';
+ *(v + 1) = 0;
+ setenv ("LIBREDWG_TRACE", v, 1);
+ }
+# endif
+ has_v = 1;
+ break;
+ }
+ if (!strcmp (long_options[option_index].name, "version"))
+ return opt_version ();
+ if (!strcmp (long_options[option_index].name, "help"))
+ return help ();
+ if (!strcmp (long_options[option_index].name, "force-free"))
+ force_free = 1;
+ break;
+#else
+ case 'i':
+ return opt_version ();
+#endif
+ case 'O':
+ fmt = strdup (optarg);
+ break;
+ case 'o':
+ outfile = strdup (optarg);
+ if (!fmt && outfile != NULL)
+ {
+#ifndef DISABLE_DXF
+ if (strstr (outfile, ".dxf") || strstr (outfile, ".DXF"))
+ fmt = strdup ("dxf");
+ else if (strstr (outfile, ".dxfb") || strstr (outfile, ".DXFB"))
+ fmt = strdup ("dxfb");
+ else
+#endif
+#ifndef DISABLE_JSON
+ if (strstr (outfile, ".json") || strstr (outfile, ".JSON"))
+ fmt = strdup ("json");
+ else if (strstr (outfile, ".geojson")
+ || strstr (outfile, ".GeoJSON"))
+ fmt = strdup ("geojson");
+ else
+#endif
+ fprintf (stderr, "Unknown output format for %s\n", outfile);
+ }
+ break;
+ case 'v': // support -v3 and -v
+ i = (optind > 0 && optind < argc) ? optind - 1 : 1;
+ if (!memcmp (argv[i], "-v", 2))
+ {
+ opts = argv[i][2] ? argv[i][2] - '0' : 1;
+ }
+ if (opts < 0 || opts > 9)
+ return usage ();
+#if defined(USE_TRACING) && defined(HAVE_SETENV)
+ {
+ char v[2];
+ *v = opts + '0';
+ *(v + 1) = 0;
+ setenv ("LIBREDWG_TRACE", v, 1);
+ }
+#endif
+ has_v = 1;
+ break;
+ case 'h':
+ return help ();
+ case '?':
+ fprintf (stderr, "%s: invalid option '-%c' ignored\n", argv[0],
+ optopt);
+ break;
+ default:
+ return usage ();
+ }
+ }
+ i = optind;
+
+ memset (&dwg, 0, sizeof (Dwg_Data));
+ if (has_v || !fmt)
+ dwg.opts = opts;
+#if defined(USE_TRACING) && defined(HAVE_SETENV)
+ if (!has_v)
+ setenv ("LIBREDWG_TRACE", "1", 0);
+#endif
+
+#ifndef DISABLE_DXF
+ if (optind != argc)
+ {
+ if (opts > 1)
+ fprintf (stderr, "Reading DXF file %s\n", argv[i]);
+ error = dxf_read_file (argv[i], &dwg);
+ }
+ else
+ {
+ if (opts > 1)
+ fprintf (stderr, "Reading DXF from stdin\n");
+ error = dxf_read_file ("-", &dwg); // i.e. from stdin
+ }
+#endif
+
+ if (error >= DWG_ERR_CRITICAL)
+ goto done;
+
+ if (fmt)
+ {
+ Bit_Chain dat = { 0 };
+ if (outfile)
+ dat.fh = fopen (outfile, "w");
+ else
+ dat.fh = stdout;
+ fprintf (stderr, "\n");
+ dat.version = dat.from_version = dwg.header.version;
+ dat.codepage = dwg.header.codepage;
+ // TODO --as-rNNNN version? for now not.
+ // we want the native dump, converters are separate.
+#ifndef DISABLE_DXF
+# ifndef DISABLE_JSON
+ if (!strcasecmp (fmt, "json"))
+ {
+ if (opts > 1 && outfile)
+ fprintf (stderr, "Writing JSON file %s\n", outfile);
+ error = dwg_write_json (&dat, &dwg);
+ }
+ else
+# endif
+ if (!strcasecmp (fmt, "dxfb"))
+ {
+ if (opts > 1 && outfile)
+ fprintf (stderr, "Writing Binary DXF file %s\n", outfile);
+ error = dwg_write_dxfb (&dat, &dwg);
+ }
+ else if (!strcasecmp (fmt, "dxf"))
+ {
+ if (opts > 1 && outfile)
+ fprintf (stderr, "Writing Binary DXF file %s\n", outfile);
+ error = dwg_write_dxf (&dat, &dwg);
+ }
+# ifndef DISABLE_JSON
+ else if (!strcasecmp (fmt, "geojson"))
+ {
+ if (opts > 1 && outfile)
+ fprintf (stderr, "Writing GeoJSON file %s\n", outfile);
+ error = dwg_write_geojson (&dat, &dwg);
+ }
+ else
+# endif
+#endif
+ fprintf (stderr, "Invalid output format '%s'\n", fmt);
+
+ if (outfile)
+ fclose (dat.fh);
+ }
+
+done:
+#if defined __SANITIZE_ADDRESS__ || __has_feature(address_sanitizer)
+ {
+ char *asanenv = getenv ("ASAN_OPTIONS");
+ if (!asanenv)
+ force_free = 1;
+ // detect_leaks is enabled by default. see if it's turned off
+ else if (strstr (asanenv, "detect_leaks=0") == NULL) /* not found */
+ force_free = 1;
+ }
+#endif
+
+ // forget about valgrind. really huge DWG's need endlessly here.
+ if ((dwg.header.version && dwg.num_objects < 1000) || force_free
+#ifdef HAVE_VALGRIND_VALGRIND_H
+ || (RUNNING_ON_VALGRIND)
+#endif
+ )
+ {
+ if (fmt)
+ free ((char *)fmt);
+ if (outfile)
+ free ((char *)outfile);
+ dwg_free (&dwg);
+ }
+
+ if (error >= DWG_ERR_CRITICAL)
+ {
+ fprintf (stderr, "ERROR 0x%x\n", error);
+ if (error && opts > 2)
+ dwg_errstrings (error);
+ }
+ else
+ {
+ if (opts > 1)
+ {
+ fprintf (stderr, "SUCCESS 0x%x\n", error);
+ if (error && opts > 2)
+ dwg_errstrings (error);
+ }
+ else
+ fprintf (stderr, "SUCCESS\n");
+ }
+
+ return error >= DWG_ERR_CRITICAL ? 1 : 0;
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f308e355b..0be58c9d69 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,54 +30,58 @@ endif
CPPCHECK = @CPPCHECK@
libredwg_la_SOURCES = \
- dwg.c \
- common.c \
- codepages.c \
- bits.c \
- decode.c \
+ dwg.c \
+ common.c \
+ codepages.c \
+ bits.c \
+ decode.c \
decode_r11.c \
decode_r2007.c \
- reedsolomon.c \
+ reedsolomon.c \
print.c \
free.c \
hash.c \
- dynapi.c \
- classes.c \
- dwg_api.c \
- objects.c \
- geom.c \
- $(EXTRA_HEADERS)
+ dynapi.c \
+ classes.c \
+ dwg_api.c \
+ objects.c \
+ geom.c \
+ $(EXTRA_HEADERS)
if !DISABLE_DXF
libredwg_la_SOURCES += \
- out_dxf.c \
- out_dxfb.c
-# out_xml.c \
-# out_yaml.c
+ in_dxf.c
+if !USE_WRITE
+libredwg_la_SOURCES += \
+ encode.c # in_dxf.c depends on some functions
+endif
if !DISABLE_JSON
libredwg_la_SOURCES += \
- out_json.c \
- out_geojson.c
+ in_json.c
endif
endif
if USE_WRITE
libredwg_la_SOURCES += \
- encode.c \
- dxfclasses.c
+ encode.c \
+ dxfclasses.c
# encode_r2007.c
# in_xml.c
# in_yaml.c
if !DISABLE_DXF
libredwg_la_SOURCES += \
- in_dxf.c
+ out_dxf.c \
+ out_dxfb.c
+# out_xml.c
+# out_yaml.c
endif
if !DISABLE_JSON
libredwg_la_SOURCES += \
- in_json.c
+ out_json.c \
+ out_geojson.c
endif
endif
EXTRA_HEADERS = \
- dwg.spec \
+ dwg.spec \
header_variables.spec \
header_variables_r11.spec \
header_variables_dxf.spec \
@@ -87,7 +91,7 @@ EXTRA_HEADERS = \
header.spec \
auxheader.spec \
2ndheader.spec \
- r2004_file_header.spec \
+ r2004_file_header.spec \
summaryinfo.spec \
acds.spec \
appinfo.spec \
@@ -97,53 +101,56 @@ EXTRA_HEADERS = \
template.spec \
objfreespace.spec \
revhistory.spec \
- classes.inc \
- objects.inc \
- spec.h \
- common.h \
- importer.h \
- classes.h \
- codepages.h \
- bits.h \
- myalloca.h \
- decode.h \
- decode_r11.h \
- dec_macros.h \
- free.h \
+ classes.inc \
+ objects.inc \
+ spec.h \
+ common.h \
+ importer.h \
+ classes.h \
+ codepages.h \
+ bits.h \
+ myalloca.h \
+ decode.h \
+ decode_r11.h \
+ dec_macros.h \
+ free.h \
print.h \
- logging.h \
- reedsolomon.h \
+ logging.h \
+ reedsolomon.h \
hash.h \
- dynapi.h \
- out_json.h \
- geom.h
+ dynapi.h \
+ geom.h
+if !DISABLE_JSON
+EXTRA_HEADERS += \
+ in_json.h
+# in_xml.h
+# in_yaml.h
+endif
if !DISABLE_DXF
EXTRA_HEADERS += \
- out_dxf.h
-# out_xml.h
-# out_yaml.h
+ in_dxf.h
endif
if USE_WRITE
EXTRA_HEADERS += \
- encode.h
+ encode.h
if !DISABLE_DXF
EXTRA_HEADERS += \
- in_dxf.h
-# in_xml.h
-# in_yaml.h
+ out_dxf.h
+# out_xml.h
+# out_yaml.h
if !DISABLE_JSON
EXTRA_HEADERS += \
- in_json.h
+ out_json.h
endif
endif
endif
EXTRA_DIST = \
- $(include_HEADERS) \
- $(EXTRA_HEADERS) \
- gen-dynapi.pl \
- dxfclasses.in \
- objects.in
+ $(include_HEADERS) \
+ $(EXTRA_HEADERS) \
+ gen-dynapi.pl \
+ dxfclasses.in \
+ objects.in
# maintainer only:
$(srcdir)/dynapi.c: $(srcdir)/gen-dynapi.pl $(top_srcdir)/include/dwg.h
diff --git a/src/dwg.c b/src/dwg.c
index 8aec6b2236..1324df56d4 100644
--- a/src/dwg.c
+++ b/src/dwg.c
@@ -284,7 +284,7 @@ dwg_read_file (const char *restrict filename, Dwg_Data *restrict dwg)
return error;
}
-#if !defined(DISABLE_DXF) && defined(USE_WRITE)
+#if !defined(DISABLE_DXF)
/** dxf_read_file
* returns 0 on success.
*