Update Pier_v1 project

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
CopilotandCopilot committed 2026-11-03 12:04:58 +09:00
1 parent f25e36c050
commit ad73ddec2b
2476 files changed
+3423 -4902

No files matched your search

@@ -0,0 +1,244 @@
LibreDWG - free implementation of the DWG file format
LibreDWG is a free C library to read and write DWG files. This program is
part of the GNU project, released under the aegis of GNU. It is licensed
under the terms of the GNU General Public License version 3 (or at you option
any later version).
DWG is a file format created in the 70's for the emerging CAD applications.
Currently it is the native file format of AutoCAD, a proprietary CAD program
developed by AutoDesk.
LibreDWG is a fork from LibDWG due to its usage of Esperanto, which we
think is not the best strategy for a free software project which aims
to get lots of contributors. LibreDWG is written in English. At the
moment our decoder (i.e. reader) is done, it can read all DWG
versions, just some very advanced R2010+ objects fail to read and are
skipped over. The writer is good enough for everything but R2007.
R2010-R2018 writing leads to CRC errors still. Among the
example applications we wrote using LibreDWG is a reader, a writer, a
rewriter (i.e. saveas), an initial SVG and Postscript conversion, dxf
and json converters, dwggrep to search for text, and dwglayer to print
the list of layers. More are in the pipeline. Please contact us if you
want to help.
The strings API is UTF-8 (WTF8 really, Windows UCS-2 has no surrogate
pairs), and encodes to the internal 8-bit or UCS-2 strings, depending
on the DWG version. Older DWG's are encoded in ~30 codepages, which we
convert to unicode/UTF-8.
We also maintain a diff document for our internal fixed ODA-5.4.1 spec
at doc/ODA-5.4.2-libredwg-diff.pdf
For security contact file a ticket or email the package maintainers:
Reini Urban <rurban AT cpan.org>
The now inactive founders and previous maintainers were:
Felipe Corrêa da Silva Sanches <juca AT members.fsf.org>
Rodrigo Rodrigues da Silva <pitanga AT members.fsf.org>
Hardeep Singh Rai <hardeep.rai AT gmail DOT com>
If you are looking for general information about the project, check our website:
http://www.gnu.org/software/libredwg/
== Building and installing the library ==
You need the following dependencies:
- Basic development tools (a C99 compiler like gcc/clang, make, autoconf, automake
and libtool)
Optionally:
- libiconv: optional codepage conversion. without it's just a bit slower.
- libmimalloc: faster memory allocation, but usually not worth the hassle.
- pslib for dwg2ps: http://pslib.sourceforge.net/doc/pslib.html
- pcre2 with 8bit and 16bit libraries for dwggrep regexp support.
- gperf to update static hashes for several API's
Only needed when you added objects or changed the dwg.spec significantly
- cmake, ninja
- ODAFileConverter from https://www.opendesign.com/guestfiles/oda_file_converter
for doing cross-checks.
- xvfb-run from xvfb/xorg-x11-server-Xvfb for silencing ODAFileConverter popups.
- TeXinfo for building the docs
- SWIG 1.7+
- Python 2.7 or 3.x development headers (debian: python-dev; yum: python-devel)
and the libxml2 python bindings.
- Perl 5 for the perl bindings
- doxygen to generate the reference manual
- jq to check json validity, and as dwgfilter backend
- shellcheck to check shell scripts
- rpmlint to check the spec validity
- jinq with some svg11 relaxng to check SVG validity.
LaTeXML used to have a broken svg11-basic.rng. If so
the zip from http://yupotan.sppd.ne.jp/relax-ng/svg11/ is correct.
Needs to be installed into /usr/local/share/relaxng/svg11/
sudo unzip ~/Downloads/svg11-relaxng-20060604.zip -d /usr/local/share/relaxng/
On Ubuntu I needed:
apt install jing libjaxp1.3-java libbatik-java libavalon-framework-java
- mapbox/geojsonhint as geojson linter
npm install -g @mapbox/geojsonhint
- geojson-validation as 2nd geojson fallback linter
npm install -g geojson-validation
- shfmt to format shell scripts
- clang-format to format the C source code
- clang-tidy to check source code
- valgrind to find leaks and memory bugs
- timeout to help tests with large or hanging DWG's
- GNU parallel to speed up special tests (not the moreutils parallel!)
- picat to find unknown fields, a better prolog. http://picat-lang.org/
See INSTALL for generic instructions. Basically, you do:
$ sh ./autogen.sh (if you checked out the source code from git)
$ ./configure [--disable-bindings] [--disable-docs] [--disable-shared]
$ make
$ make check
$ sudo make install
This builds and installs various files in the "installation dirs":
$libdir ($exec_prefix/lib) -- library files (libredwg.*)
$includedir ($prefix/include) -- dwg.h dwg_api.h
$libdir/pkgconfig -- libredwg.pc
$infodir ($datarootdir/info) -- LibreDWG.info
Use "./configure --help" to see a full list of options you can use to
customize the installation dirs. Other options recognized by configure are:
--enable-release
Recommended for packagers and fuzzers. Disables all features
which will not be enabled in official tarball releases. Like skipping
unstable DWG features or objects, unknown DWG versions and objects.
--enable-trace
Enable runtime tracing via LIBREDWG_TRACE (default: no). When
enabled, the environment variable LIBREDWG_TRACE is consulted on
the first decode/encode attempt. Its value is an integer: 0 (no
output) through 9 (full verbosity). Most tools do support a
--verbosity|-v flag instead.
--with-dxf-precision=rfc
How many after-comma places in DXF doubles. 6 is the recommended
value (e.g. use rfc), max and the default is 16.
--with-geojson-precision=rfc
How many after-comma places in GeoJSON doubles. 6 is the
recommended value by RFC 7946, max and the default is 16.
--disable-write
Disable DWG write support (default: no).
Write support only works for earlier versions until r2004.
Rewriting most DWG's <= r2004 usually works fine.
--disable-bindings
Disable SWIG bindings for python and perl5.
--disable-dxf
Disables all in and out modules: DXF, DXFB, JSON, GeoJSON.
--disable-json
Disables the json in and out modules: JSON, GeoJSON.
--disable-python
Disable python bindings and tests.
Related: --enable-python=python3.6
to enforce a specific version.
--enable-debug
Activates support for unstable classes. For testing only.
--enable-gcov
Activates support for GNU gcov, test coverage reporting.
--with-perl-install=vendor
Where to install the perl bindings: vendor,arch,yes,no,site.
Default is perl-install=site
== Windows ==
See the following scripts how we build on Windows:
* .github/workflows/main.yml: via msys/autotools, or cmake. gcc, clang-cl or VS2019.
* build-aux/smoke.sh: cross-compilation recipes
* build-aux/msys2.bat: msys2 deps
* .appveyor.yml: windows smoker
We do support mingw, clang-cl and Visual Studio >= 2019 via cmake.
stdint.h and inttypes.h must be available.
Pre-compiled Windows binaries are here: https://github.com/LibreDWG/libredwg/releases
== Example usage of the library ==
The programs and examples directories contains some application code
that uses our lib:
* dwgread -- A DWG reader supporting various output formats, such as
JSON, DXF, DXFB, GeoJSON.
* dwgwrite -- A DWG writer supporting various input formats, such as DXF, DXFB, JSON.
* dxfwrite -- A DXF writer supporting various input formats, such as DWG, DXF, DXFB, JSON.
* dwg2dxf -- Converts a DWG to a DXF (ascii or binary, minimal or full), optionally
under a different version. About 90% coverage.
* dxf2dwg -- Converts a ascii or binary DXF to a DWG (r2000 only so far).
About 80% coverage.
* dwglayers -- Prints the list of layers in a DWG. Optionally with --extnames
* dwggrep -- Searches DWG files for a text string, via regular expressions.
* dwg2ps -- Opens a DWG file and outputs an PostScript file. This code
depends on the PSlib library. On Debian-based systems this is usually
available as a package named pslib-dev. This is very limited so far.
* dwgfilter -- Applies JSON filters via JQ. Either as structured grep,
or to mass change certain values.
* dwg2SVG -- Opens a DWG file and outputs an SVG (Scalable Vector Graphics)
file. SVG is a W3C standard for 2d vector graphics. You can open these
files on several free software tools. We recommend Inkscape, a free software
vector graphics editor. The dwg2SVG program will not handle 3d content
from DWG since SVG only supports 2-dimensional images. Handles only some
entities.
* dwgbmp -- Extracts the bmp thumbnail of a dwg file when it is available.
* dwgadd -- the easiest way to create DWG's (or DXF, JSON) from scratch or
add entities to an existing DWG. It accepts a very simple file with commands
to create entities or objects and set its properties.
* dwgrewrite -- Reads a DWG, writes it back under a different name and optionally
under a different version (default r2000), and re-reads it back for confirmation.
* load_dwg -- This is a skeleton code, reading the DWG and adding an entity.
Look there if you want to have a quickly glance on how to use the library.
* dwg2svg2 -- Another example how to use the DWG API, bypassing direct access to
the DWG struct.
* xmlsuite -- an extensive example library to use XML to compare against prepared
features is in the test/xmlsuite directory. It also features code to output entities
in XML, but does not use the python bindings.
Copyright (C) 2009, 2010, 2015, 2018-2026 Free Software Foundation, Inc.
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 <http://www.gnu.org/licenses/>.
@@ -0,0 +1,84 @@
#!/bin/sh
# options: --help, --version, --debug, -i
version() {
echo "dwgfilter 0.14"
exit
}
help() {
echo "dwgfilter [OPTIONS...] dwgfile"
echo ""
echo "Allow custom jq queries on a temporary JSON dump."
echo ""
echo "OPTIONS: --help,--version"
echo " --debug keep the tmp json"
echo " -i write back in-place, with an updating JQ query"
echo " ... all other options are passed to jq. See 'man jq'"
exit
}
opts=
# get last arg
for dwg; do true; done
for arg in "$@"
do
case $arg in
--help) help ;;
--version) version ;;
--debug) debug=1 ;;
"$dwg") if [ ! -f "$dwg" ]; then echo DWG "$dwg" not found; exit 1; fi ;;
-i) writemode=1 ;;
*) opts="$opts $arg" ;;
esac
done
if [ ! -f "$dwg" ]
then
echo Wrong input DWG "$dwg"
exit 1
fi
if [ -z "$opts" ]
then
echo Input JQ query arguments missing
exit 1
fi
prefix=""
exec_prefix="${prefix}"
jq=""
jq="${jq:-jq}"
json="$(mktemp "${TMPDIR:-/tmp}/dwgfilter.XXXXXX.json")" || exit 1
if [ -z "$debug" ]; then
trap 'rm -f "$json"' EXIT
trap 'exit 2' INT TERM
fi
selfpath="$(realpath "$0")"
if [ "$selfpath" = "${exec_prefix}/bin/dwgfilter" ]; then
dwgread="${exec_prefix}/bin/dwgread"
dwgwrite="${exec_prefix}/bin/dwgwrite"
else
dwgread="$(dirname "$selfpath")/dwgread"
dwgwrite="$(dirname "$selfpath")/dwgwrite"
fi
if [ -n "$debug" ]; then
dwgread="$dwgread -v3"
dwgwrite="$dwgwrite -v3"
fi
echo "$dwgread -O json -o $json $dwg"
$dwgread -O json -o "$json" "$dwg"
echo "$jq $opts $json"
$jq "$opts" "$json"
fail=$?
if [ $fail = 0 ] && [ -n "$writemode" ]; then
mv "$dwg" "$dwg.bak"
echo "$dwgwrite -o $dwg $json"
if $dwgwrite -o "$dwg" "$json"; then
:
else
mv "$dwg.bak" "$dwg"
fail=1
fi
fi
if [ -n "$debug" ]; then
echo "Keeping JSON dump: $json"
fi
exit $fail
@@ -0,0 +1,152 @@
/*****************************************************************************/
/* LibreDWG - free implementation of the DWG file format */
/* */
/* Copyright (C) 2018-2019 Free Software Foundation, Inc. */
/* */
/* 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 <http://www.gnu.org/licenses/>. */
/*****************************************************************************/
/*
* bd.c: print double of bits
* written by Reini Urban
*
*/
#include "../src/config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dwg.h"
#include "../src/bits.h"
int
main (int argc, char *argv[])
{
char *input;
int hex = 0;
int size, bits;
unsigned long pos;
Bit_Chain dat = EMPTY_CHAIN (0);
if (argc < 2)
{
printf ("usage: examples/bd "
"001100000000000000000000000000011000000000000000100000001010010"
"00\n");
printf ("or examples/bd -x '8055 40f9 3284 d222 3e40 7436 e0d9 23fd'\n");
return 1;
}
if (argc > 2 && !strcmp (argv[1], "-x"))
{
hex = 1;
input = argv[2];
size = strlen (input);
}
else
{
input = argv[1];
bits = strlen (input);
size = (bits / 8);
}
dat.chain = malloc (size + 1);
dat.size = size;
dat.version = R_2004;
if (hex)
{
dat.size = bit_write_hexbits (&dat, input);
bits = dat.size / 8;
}
else
bit_write_bits1 (&dat, input);
pos = bit_position (&dat);
bit_set_position (&dat, 0);
// accept more types, like CMC, BS, BL, HANDLE and print all possible
// variants
if (pos == 64)
{
double d = bit_read_RD (&dat);
printf ("%.15f RD @%lu\n", d, bit_position (&dat));
}
else if (pos == 2 || pos > 64)
{
double d = bit_read_BD (&dat);
printf ("%.15f BD @%lu (%ld)\n", d, bit_position (&dat), pos);
if (pos == 2)
{
int i;
bit_set_position (&dat, 0);
i = bit_read_BB (&dat);
printf ("%d BB @%lu\n", i, bit_position (&dat));
if (i == 2)
printf ("%d BS/BL @%lu\n", 0, bit_position (&dat));
else if (i == 3)
printf ("%d BS @%lu\n", 256, bit_position (&dat));
}
}
else if (pos == 34)
{
long l = bit_read_BL (&dat);
printf ("%ld BL @%lu\n", l, bit_position (&dat));
}
else if (pos == 32)
{
long l = bit_read_RL (&dat);
printf ("%ld RL @%lu\n", l, bit_position (&dat));
}
else if (pos == 16)
{
int l = (int)bit_read_RS (&dat);
printf ("%d RS @%lu\n", l, bit_position (&dat));
}
else if (pos == 10)
{
long l = bit_read_BS (&dat);
Dwg_Handle h;
printf ("%ld BS @%lu\n", l, bit_position (&dat));
bit_set_position (&dat, 0);
if (!bit_read_H (&dat, &h) && h.size == 1)
printf (FORMAT_H " H @%lu (%ld)\n", ARGS_H (h), bit_position (&dat),
pos);
}
else if (pos == 8)
{
int l = (int)bit_read_RC (&dat);
Dwg_Handle h;
printf ("%d RC @%lu\n", l, bit_position (&dat));
bit_set_position (&dat, 0);
if (!bit_read_H (&dat, &h) && h.size == 1)
printf (FORMAT_H " H @%lu (%ld)\n", ARGS_H (h), bit_position (&dat),
pos);
}
else
{
Dwg_Handle h;
Dwg_Color c;
double d = bit_read_BD (&dat);
if (pos >= bit_position (&dat))
{
printf ("%.15f BD? @%lu (%ld)\n", d, bit_position (&dat), pos);
}
else
{ // divide into chunks of 34,32,18,16,10,8,2
printf ("? (%ld)\n", pos);
}
bit_set_position (&dat, 0);
if (!bit_read_H (&dat, &h))
printf (FORMAT_H " H? @%lu (%ld)\n", ARGS_H (h), bit_position (&dat),
pos);
bit_set_position (&dat, 0);
bit_read_CMC (&dat, &dat, &c);
if (c.index < 257)
printf ("%d 0x%06X 0x%x CMC? @%lu (%ld)\n", c.index, c.rgb, c.flag,
bit_position (&dat), pos);
}
free (dat.chain);
return 0;
}
@@ -0,0 +1,237 @@
/*****************************************************************************/
/* LibreDWG - free implementation of the DWG file format */
/* */
/* Copyright (C) 2018-2019 Free Software Foundation, Inc. */
/* */
/* 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 <http://www.gnu.org/licenses/>. */
/*****************************************************************************/
/*
* bits.c: print all possible type/values of given bits
* written by Reini Urban
*/
#include "../src/config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "dwg.h"
#include "../src/bits.h"
static int maxoff = 0;
static int
decode (Bit_Chain *dat, int off, const int size)
{
int pos = 0;
BITCODE_BS bs = 0;
printf ("decode offset:%d, size:%d\n", off, size);
if (off >= size)
return 0;
bit_set_position (dat, off);
if (size - off >= 66)
{
double d = bit_read_BD (dat);
int p = (int)bit_position (dat);
if (d != bit_nan ())
{
printf ("%.15f BD @%d @%u.%u (%d)\n", d, p, p / 8, p % 8, size);
pos = p;
}
bit_set_position (dat, off);
}
if (size - off >= 64)
{
double d = bit_read_RD (dat);
int p = (int)bit_position (dat);
if (d != bit_nan ())
{
printf ("%.15f RD @%d @%u.%u (%d)\n", d, p, p / 8, p % 8, size);
pos = p;
}
bit_set_position (dat, off);
}
if (size - off >= 34)
{
BITCODE_BL l = (long)bit_read_BL (dat);
int p = (int)bit_position (dat);
if (p <= size - off)
{
printf ("%u BL @%d @%u.%u (%d)\n", l, p, p / 8, p % 8, size);
pos = p;
}
bit_set_position (dat, off);
}
if (size - off >= 32)
{
BITCODE_BL l = (long)bit_read_RL (dat);
pos = (int)bit_position (dat);
printf ("%u RL @%d @%u.%u (%d)\n", l, pos, pos / 8, pos % 8, size);
bit_set_position (dat, off);
}
if (size - off >= 16)
{
BITCODE_RS l = (int)bit_read_RS (dat);
pos = (int)bit_position (dat);
printf ("%d RS @%d (%d)\n", l, pos, size);
bit_set_position (dat, off);
}
if (size - off >= 10)
{
int p;
bs = bit_read_BS (dat);
p = (int)bit_position (dat);
if (p <= size - off)
{
printf ("%d BS @%d (%d)\n", bs, p, size);
pos = p;
}
bit_set_position (dat, off);
}
if (size - off >= 8)
{
int l = bit_read_RC (dat);
pos = (int)bit_position (dat);
printf ("%d RC @%d (%d)\n", l, pos, size);
bit_set_position (dat, off);
}
if (size - off >= 8)
{
Dwg_Handle h;
int err, p;
err = bit_read_H (dat, &h);
p = (int)bit_position (dat);
if (!err && h.size == 1 && p <= size - off)
{
printf ("%x.%d.%lX H @%d (%d)\n", h.code, h.size, h.value, p, size);
pos = p;
}
bit_set_position (dat, off);
}
if (size - off >= 4)
{
Dwg_Color c;
int p;
bit_read_CMC (dat, dat, &c);
p = (int)bit_position (dat);
if (c.index < 257 && p <= size - off)
{
printf ("%d 0x%06X 0x%x CMC @%d (%d)\n", c.index, c.rgb, c.flag, p,
size);
pos = p;
}
free (c.name);
free (c.book_name);
bit_set_position (dat, off);
}
if (size - off >= 2)
{
int i = bit_read_BB (dat);
pos = (int)bit_position (dat);
printf ("%d BB @%d (%d)\n", i, pos, size);
if (i == 2)
printf ("%d BS/BL @%d (%d)\n", 0, pos, size);
else if (i == 3)
printf ("%d BS @%d (%d)\n", 256, pos, size);
bit_set_position (dat, off);
}
// if BS is a valid length try TV also
if (bs > 0 && bs < size - off - pos)
{
int i;
char *s = bit_read_TV (dat);
int p = (int)bit_position (dat);
if (s)
{
for (i = 0; i < bs; i++)
if (!isprint (s[i]))
break;
if (i == bs)
{
printf ("%s TV @%d (%d)\n", s, pos, size);
pos = p;
}
free (s);
}
}
while (pos < size)
{
if (pos <= off)
pos++;
if (maxoff < pos)
maxoff = pos;
// printf ("offset %d\n", pos);
return decode (dat, off + 1, size);
}
return 0;
}
int
main (int argc, char *argv[])
{
int hex = 0;
int print_bits = 0;
int i;
int pos;
Bit_Chain dat = EMPTY_CHAIN (0);
if (argc < 2)
{
printf ("usage: examples/bits "
"001100000000000000000000000000011000000000000000100000001010010"
"00\n");
printf (
"or examples/bits -x '8055 40f9 3284 d222 3e40 7436 e0d9 23fd'\n");
return 1;
}
i = 1;
if (argc > 2 && !strcmp (argv[i], "-x"))
{
hex = 1;
i++;
}
if (argc > 2 && !strcmp (argv[i], "-b"))
{
print_bits = 1;
i++;
}
// dat.chain = malloc (size + 1);
// dat.size = size;
dat.version = R_2004;
do
{
char *input = argv[i];
int bits = strlen (input);
if (hex)
dat.size += bits;
else
dat.size += bits / 8;
dat.chain = realloc (dat.chain, dat.size + 1);
if (hex)
{
int size = bit_write_hexbits (&dat, input);
dat.size -= dat.size - size;
}
else
bit_write_bits1 (&dat, input);
i++;
}
while (i < argc);
pos = (int)bit_position (&dat);
if (print_bits)
bit_print_bits (&dat.chain[0], pos);
// accept all types, like CMC, BS, BL, HANDLE and print all possible variants
pos = decode (&dat, 0, (int)pos);
free (dat.chain);
return 0;
}
@@ -0,0 +1,531 @@
/*****************************************************************************/
/* LibreDWG - free implementation of the DWG file format */
/* */
/* Copyright (C) 2013-2020,2023 Free Software Foundation, Inc. */
/* */
/* 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 <http://www.gnu.org/licenses/>. */
/*****************************************************************************/
/*
* dwg2svg2.c: convert a DWG to SVG via the API.
if there are paperspace entities, only output them. else all modelspace
entities.
* written by Gaganjyot Singh
* modified by Reini Urban
*/
#include "../src/config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <getopt.h>
#ifdef ENABLE_MIMALLOC
# include <mimalloc-override.h>
#endif
#include <dwg.h>
#include <dwg_api.h>
#include "geom.h"
static int opts = 0;
static dwg_data g_dwg;
static double model_xmin, model_ymin;
static double page_width, page_height, scale;
static int
usage (void)
{
printf ("\nUsage: dwg2svg2 [-v[0-9]] DWGFILE\n");
return 1;
}
static int
opt_version (void)
{
printf ("dwg2svg2 %s\n", PACKAGE_VERSION);
return 0;
}
static int
help (void)
{
printf ("\nUsage: dwg2svg2 [OPTION]... DWGFILE >file.svg\n");
printf ("Example to use the DWG api\n"
"\n");
#ifdef HAVE_GETOPT_LONG
printf (" -v[0-9], --verbose [0-9] verbosity\n");
printf (" --help display this help and exit\n");
printf (" --version output version information and exit\n"
"\n");
#else
printf (" -v[0-9] verbosity\n");
printf (" -h display this help and exit\n");
printf (" -i output version information and exit\n"
"\n");
#endif
printf ("GNU LibreDWG online manual: "
"<https://www.gnu.org/software/libredwg/>\n");
return 0;
}
#define log_if_error(msg) \
if (error) \
{ \
fprintf (stderr, "ERROR: %s\n", msg); \
exit (1); \
}
#define log_error(msg) \
{ \
fprintf (stderr, "ERROR: %s\n", msg); \
exit (1); \
}
#define dynget(obj, name, field, var) \
if (!dwg_dynapi_entity_value (obj, "" name, "" field, var, NULL)) \
{ \
fprintf (stderr, "ERROR: %s.%s\n", name, field); \
exit (1); \
}
#define dynget_utf8(obj, name, field, var) \
if (!dwg_dynapi_entity_utf8text (obj, "" name, "" field, var, &isnew, \
NULL)) \
{ \
fprintf (stderr, "ERROR: %s.%s\n", name, field); \
exit (1); \
}
static double
transform_X (double x)
{
return x - model_xmin;
}
static double
transform_Y (double y)
{
return page_height - (y - model_ymin);
}
static void output_SVG (dwg_data *dwg);
static int
test_SVG (char *filename)
{
int error;
memset (&g_dwg, 0, sizeof (dwg_data));
g_dwg.opts = opts;
error = dwg_read_file (filename, &g_dwg);
if (error < DWG_ERR_CRITICAL)
output_SVG (&g_dwg);
dwg_free (&g_dwg);
/* This value is the return value for `main',
so clamp it to either 0 or 1. */
return error < DWG_ERR_CRITICAL ? 0 : 1;
}
static void
output_TEXT (dwg_object *obj)
{
int error, index;
dwg_point_2d ins_pt;
Dwg_Entity_TEXT *text;
char *text_value;
double fontsize;
const Dwg_Version_Type dwg_version = obj->parent->header.version;
int isnew = 0;
index = dwg_object_get_index (obj, &error);
log_if_error ("object_get_index");
text = dwg_object_to_TEXT (obj);
if (!text)
log_error ("dwg_object_to_TEXT");
dynget_utf8 (text, "TEXT", "text_value", &text_value);
dynget (text, "TEXT", "ins_pt", &ins_pt);
dynget (text, "TEXT", "height", &fontsize);
printf ("\t<text id=\"dwg-object-%d\" x=\"%f\" y=\"%f\" "
"font-family=\"Verdana\" font-size=\"%f\" fill=\"blue\">%s</text>\n",
index, transform_X (ins_pt.x), transform_Y (ins_pt.y), fontsize,
text_value);
if (text_value && isnew)
free (text_value);
}
static void
output_LINE (dwg_object *obj)
{
int error, index;
Dwg_Entity_LINE *line;
dwg_point_3d start, end;
index = dwg_object_get_index (obj, &error);
log_if_error ("object_get_index");
line = dwg_object_to_LINE (obj);
if (!line)
log_error ("dwg_object_to_LINE");
if (!dwg_get_LINE (line, "start", &start))
log_error ("LINE.start");
if (!dwg_get_LINE (line, "end", &end))
log_error ("LINE.end");
printf ("\t<path id=\"dwg-object-%d\" d=\"M %f,%f %f,%f\" "
"style=\"fill:none;stroke:blue;stroke-width:0.1px\" />\n",
index, transform_X (start.x), transform_Y (start.y),
transform_X (end.x), transform_Y (end.y));
}
static void
output_CIRCLE (dwg_object *obj)
{
Dwg_Entity_CIRCLE *circle;
int error, index;
double radius;
dwg_point_3d center;
index = dwg_object_get_index (obj, &error);
log_if_error ("object_get_index");
circle = dwg_object_to_CIRCLE (obj);
if (!circle)
log_error ("dwg_object_to_CIRCLE");
if (!dwg_get_CIRCLE (circle, "center", &center))
log_error ("CIRCLE.center");
if (!dwg_get_CIRCLE (circle, "radius", &radius))
log_error ("CIRCLE.radius");
printf ("\t<circle id=\"dwg-object-%d\" cx=\"%f\" cy=\"%f\" r=\"%f\" "
"fill=\"none\" stroke=\"blue\" stroke-width=\"0.1px\" />\n",
index, transform_X (center.x), transform_Y (center.y), radius);
}
static void
output_ARC (dwg_object *obj)
{
Dwg_Entity_ARC *arc;
int error, index;
double radius, start_angle, end_angle;
dwg_point_3d center;
double x_start, y_start, x_end, y_end;
int large_arc;
index = dwg_object_get_index (obj, &error);
log_if_error ("object_get_index");
arc = dwg_object_to_ARC (obj);
if (!arc)
log_error ("dwg_object_to_ARC");
dynget (arc, "ARC", "radius", &radius);
dynget (arc, "ARC", "center", &center);
dynget (arc, "ARC", "start_angle", &start_angle);
dynget (arc, "ARC", "end_angle", &end_angle);
x_start = center.x + radius * cos (start_angle);
y_start = center.y + radius * sin (start_angle);
x_end = center.x + radius * cos (end_angle);
y_end = center.y + radius * sin (end_angle);
// Assuming clockwise arcs.
large_arc = (end_angle - start_angle < M_PI) ? 0 : 1;
printf ("\t<path id=\"dwg-object-%d\" d=\"M %f,%f A %f,%f 0 %d 0 %f,%f\" "
"fill=\"none\" stroke=\"blue\" stroke-width=\"%f\" />\n",
index, transform_X (x_start), transform_Y (y_start), radius, radius,
large_arc, transform_X (x_end), transform_Y (y_end), 0.1);
}
static void
output_INSERT (dwg_object *obj)
{
int index, error;
BITCODE_RL abs_ref;
double rotation;
dwg_ent_insert *insert;
dwg_point_3d ins_pt, _scale;
dwg_handle *obj_handle, *ins_handle;
Dwg_Data *dwg;
insert = dwg_object_to_INSERT (obj);
if (!insert)
log_error ("dwg_object_to_INSERT");
dwg = obj->parent;
index = dwg_object_get_index (obj, &error);
log_if_error ("object_get_index");
dynget (insert, "INSERT", "rotation", &rotation);
dynget (insert, "INSERT", "ins_pt", &ins_pt);
dynget (insert, "INSERT", "scale", &_scale);
obj_handle = dwg_object_get_handle (obj, &error);
log_if_error ("get_handle");
if (!insert->block_header)
log_error ("insert->block_header");
abs_ref = insert->block_header->absolute_ref;
if (insert->block_header->handleref.code == 5 || dwg->header.version < R_13)
{
printf ("\t<use id=\"dwg-object-%d\" transform=\"translate(%f %f) "
"rotate(%f) scale(%f %f)\" xlink:href=\"#symbol-%X\" /><!-- "
"block_header->handleref: " FORMAT_H " -->\n",
index, transform_X (ins_pt.x), transform_Y (ins_pt.y),
(180.0 / M_PI) * rotation, _scale.x, _scale.y, abs_ref,
ARGS_H (*obj_handle));
}
else
{
printf ("\n\n<!-- WRONG INSERT(" FORMAT_H ") -->\n",
ARGS_H (*obj_handle));
}
}
static int
output_object (dwg_object *obj)
{
int i = 0;
if (!obj)
{
fprintf (stderr, "object is NULL\n");
return 0;
}
if (dwg_object_get_fixedtype (obj) == DWG_TYPE_INSERT)
{
i++;
output_INSERT (obj);
}
else if (dwg_object_get_fixedtype (obj) == DWG_TYPE_LINE)
{
i++;
output_LINE (obj);
}
else if (dwg_object_get_fixedtype (obj) == DWG_TYPE_CIRCLE)
{
i++;
output_CIRCLE (obj);
}
else if (dwg_object_get_fixedtype (obj) == DWG_TYPE_TEXT)
{
i++;
output_TEXT (obj);
}
else if (dwg_object_get_fixedtype (obj) == DWG_TYPE_ARC)
{
i++;
output_ARC (obj);
}
return i;
}
static int
output_BLOCK_HEADER (dwg_object_ref *ref)
{
dwg_object *hdr, *obj;
dwg_obj_block_header *_hdr;
int error;
BITCODE_RL abs_ref;
char *name;
int i = 0;
if (!ref)
{
fprintf (stderr,
"Empty BLOCK."
" Could not output an SVG symbol for this BLOCK_HEADER\n");
return 0;
}
hdr = dwg_ref_get_object (ref, &error);
if (!hdr || error)
{
abs_ref = dwg_ref_get_absref (ref, &error);
fprintf (stderr, "Failed to resolve BLOCK handle %X.\n",
(unsigned)abs_ref);
return 0;
}
abs_ref = dwg_ref_get_absref (ref, &error);
_hdr = dwg_object_to_BLOCK_HEADER (hdr);
if (_hdr)
{
i++;
dynget (_hdr, "BLOCK_HEADER", "name", &name);
// name = dwg_obj_block_header_get_name (_hdr, &error);
printf ("\t<g id=\"symbol-%X\" >\n\t\t<!-- %s -->\n",
abs_ref ? abs_ref : 0, name ? name : "");
if (name != NULL && name != _hdr->name
&& hdr->parent->header.version >= R_2007)
free (name);
}
else
printf ("\t<g id=\"symbol-%X\" >\n\t\t<!-- ? -->\n",
abs_ref ? abs_ref : 0);
obj = get_first_owned_entity (hdr);
while (obj)
{
i += output_object (obj);
obj = get_next_owned_entity (hdr, obj);
}
printf ("\t</g>\n");
return i;
}
static void
output_SVG (dwg_data *dwg)
{
unsigned int i, num_hdr_objs;
int error;
dwg_obj_block_control *_ctrl;
dwg_object_ref *hdr;
dwg_object_ref **hdr_refs;
dwg_object_ref *ms = dwg_model_space_ref (dwg);
dwg_object_ref *ps = dwg_paper_space_ref (dwg);
double dx = dwg_model_x_max (dwg) - dwg_model_x_min (dwg);
double dy = dwg_model_y_max (dwg) - dwg_model_y_min (dwg);
double pdx = dwg->header_vars.PLIMMAX.x - dwg->header_vars.PLIMMIN.x;
double pdy = dwg->header_vars.PLIMMAX.y - dwg->header_vars.PLIMMIN.y;
double scale_x = dx / (pdx == 0.0 ? 1.0 : pdx);
double scale_y = dy / (pdy == 0.0 ? 1.0 : pdy);
scale = 25.4 / 72.0; // pt:mm TODO
model_xmin = dwg_model_x_min (dwg);
model_ymin = dwg_model_y_min (dwg);
page_width = dx;
page_height = dy;
scale *= (scale_x > scale_y ? scale_x : scale_y);
_ctrl = dwg_block_control (dwg);
hdr_refs = dwg_obj_block_control_get_block_headers (_ctrl, &error);
log_if_error ("block_control_get_block_headers");
num_hdr_objs = dwg_obj_block_control_get_num_entries (_ctrl, &error);
log_if_error ("block_control_get_num_entries");
printf ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
"<svg\n"
" xmlns:svg=\"http://www.w3.org/2000/svg\"\n"
" xmlns=\"http://www.w3.org/2000/svg\"\n"
" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
" version=\"1.1\"\n"
" width=\"%f\"\n"
" height=\"%f\"\n"
">\n",
page_width, page_height);
printf ("\t<defs>\n");
for (i = 0; i < num_hdr_objs; i++)
{
hdr = hdr_refs[i];
if (hdr == ms || hdr == ps)
continue;
output_BLOCK_HEADER (hdr_refs[i]);
}
printf ("\t</defs>\n");
if (ps)
i = output_BLOCK_HEADER (ps);
if (!ps || !i)
output_BLOCK_HEADER (ms);
free (hdr_refs);
printf ("</svg>\n");
}
int
main (int argc, char *argv[])
{
int i = 1;
int c;
#ifdef HAVE_GETOPT_LONG
int option_index = 0;
static struct option long_options[]
= { { "verbose", 1, &opts, 1 }, // optional
{ "help", 0, 0, 0 },
{ "version", 0, 0, 0 },
{ NULL, 0, NULL, 0 } };
#endif
if (argc < 2)
return usage ();
while
#ifdef HAVE_GETOPT_LONG
((c = getopt_long (argc, argv, ":v::h", long_options, &option_index))
!= -1)
#else
((c = getopt (argc, argv, ":v::hi")) != -1)
#endif
{
if (c == -1)
break;
switch (c)
{
case ':': // missing arg
if (optarg && !strcmp (optarg, "v"))
{
opts = 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
break;
}
if (!strcmp (long_options[option_index].name, "version"))
return opt_version ();
if (!strcmp (long_options[option_index].name, "help"))
return help ();
break;
#else
case 'i':
return opt_version ();
#endif
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
break;
case 'h':
return help ();
case '?':
fprintf (stderr, "%s: invalid option '-%c' ignored\n", argv[0],
optopt);
break;
default:
return usage ();
}
}
i = optind;
if (i >= argc)
return usage ();
return test_SVG (argv[i]);
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,834 @@
/*****************************************************************************/
/* LibreDWG - free implementation of the DWG file format */
/* */
/* Copyright (C) 2020 Free Software Foundation, Inc. */
/* */
/* 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 <http://www.gnu.org/licenses/>. */
/*****************************************************************************/
/*
* dwgfuzz.c: afl++/honggfuzz fuzzing for all in- and exporters. Just not the
separate ones.
*
* Also usable like:
../configure --disable-shared --disable-bindings CC=hfuzz-clang CFLAGS='-O2
-g -fsanitize=address,undefined -fno-omit-frame-pointer -I/usr/local/include'
&& make -C src && make -C examples dwgfuzz honggfuzz -i ../.fuzz-in-dxf --
examples/dwgfuzz -indxf ___FILE___
* Also useful for debugging the fuzzers.
AFL_DONT_OPTIMIZE=1 AFL_LLVM_INSTRIM=1 AFL_USE_ASAN=1 make -C examples
dwgfuzz V=1 AFL_DEBUG=15 AFL_DEBUG_CHILD_OUTPUT=1 gdb --args afl-fuzz -m none
-i ../.fuzz-in-dxf/ -o .fuzz-out/ examples/dwgfuzz (gdb) set follow-fork-mode
child
* written by Reini Urban
*/
#include "../src/config.h"
#ifdef HAVE_SSCANF_S
# define __STDC_WANT_LIB_EXT1__ 1
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <getopt.h>
#include <dwg.h>
#include <dwg_api.h>
#include "common.h"
#include "decode.h"
#include "encode.h"
#include "bits.h"
#ifndef DISABLE_DXF
# include "out_dxf.h"
# ifndef DISABLE_JSON
# include "in_json.h"
# include "out_json.h"
# endif
# include "in_dxf.h"
#endif
#define FUZZ_INMEM 0
#define FUZZ_STDIN 1
#define FUZZ_FILE 2
// defined by ./make-afl-clang-fast.sh for INMEM. defaults to FILE for
// debugging
#ifndef FUZZ_MODE
# define FUZZ_MODE FUZZ_INMEM
// #define FUZZ_MODE FUZZ_STDIN
// #define FUZZ_MODE FUZZ_FILE
#endif
int dwg_fuzz_dat (Dwg_Data **restrict dwgp, Bit_Chain *restrict dat);
static int
version (void)
{
#if FUZZ_MODE == FUZZ_INMEM
printf ("dwgfuzz %s INMEM\n", PACKAGE_VERSION);
#elif FUZZ_MODE == FUZZ_FILE
printf ("dwgfuzz %s FILE\n", PACKAGE_VERSION);
#elif FUZZ_MODE == FUZZ_STDIN
printf ("dwgfuzz %s STDIN\n", PACKAGE_VERSION);
#else
error unknown FUZZ_MODE
#endif
#ifndef __AFL_COMPILER
printf ("not instrumented\n");
#else
# ifdef __AFL_FUZZ_TESTCASE_BUF
printf ("shared-memory instrumented\n");
# else
printf ("instrumented\n");
# endif
#endif
return 0;
}
#ifndef __AFL_COMPILER
# define __AFL_FUZZ_INIT()
# if FUZZ_MODE == FUZZ_INMEM
unsigned char *__AFL_FUZZ_TESTCASE_BUF;
unsigned long __AFL_FUZZ_TESTCASE_LEN;
# define __AFL_INIT() \
fp = fopen (argv[2], "rb"); \
if (!fp) \
return 0; \
__AFL_FUZZ_TESTCASE_LEN = dat.size; \
dat_read_file (&dat, fp, argv[2]); \
__AFL_FUZZ_TESTCASE_BUF = dat.chain;
# else
# define __AFL_INIT()
# endif
# define __AFL_FUZZ_TESTCASE_LEN dat.size
# define __AFL_LOOP(i) 1
#endif
__AFL_FUZZ_INIT ();
static int
help (void)
{
#if FUZZ_MODE == FUZZ_FILE
printf ("\nUsage: dwgfuzz MODE @@\n");
#elif !defined __AFL_COMPILER
printf ("\nUsage: dwgfuzz MODE ../.fuzz-in/INFILE\n");
#else
printf ("\nUsage: dwgfuzz MODE\n");
#endif
printf ("afl++ clang-fast shared-memory backend, using many importers and "
"exporters.\n"
"\n");
printf ("MODE:\n");
#ifdef USE_WRITE
# ifndef DISABLE_DXF
printf (" -indxf: import from DXF, export as DWG\n");
# endif
# ifndef DISABLE_JSON
printf (" -injson: import from JSON, export as DWG\n");
# endif
printf (" -rw: import from DWG, export as DWG, re-import from "
"this DWG (rewrite)\n");
printf (" -add: import from special add file, export as DWG and DXF, "
"re-import from this\n");
#endif
printf (" -dwg: import from DWG only\n");
#ifndef DISABLE_DXF
printf (" -dxf: import from DWG, export as DXF\n");
printf (" -dxfb: import from DWG, export as binary DXF\n");
#endif
#ifndef DISABLE_JSON
printf (" -json: import from DWG, export as JSON\n");
printf (" -geojson: import from DWG, export as GeoJSON\n");
#endif
printf ("\n"
" --version display the version and exit\n");
printf (" --help display this help and exit\n");
return 0;
}
// for LLVMFuzzerTestOneInput see llvmfuzz.c
int
main (int argc, char *argv[])
{
int i = 0;
Dwg_Data dwg;
Bit_Chain dat = { 0 };
Bit_Chain out_dat = { 0 };
FILE *fp;
struct stat attrib;
enum
{
INVALID,
DWG,
#if defined(USE_WRITE) && !defined(DISABLE_DXF)
INDXF,
#endif
#if defined(USE_WRITE) && !defined(DISABLE_JSON)
INJSON,
#endif
#if defined(USE_WRITE)
RW,
ADD,
#endif
#if !defined(DISABLE_DXF)
DXF,
DXFB,
#endif
#if !defined(DISABLE_JSON)
JSON,
GEOJSON,
#endif
} mode
= INVALID;
if (argc <= 1 || !*argv[1])
return 1;
if (strEQc (argv[1], "--version"))
return version ();
if (strEQc (argv[1], "--help"))
return help ();
__AFL_INIT ();
if (strEQc (argv[1], "-dwg"))
mode = DWG;
#ifdef USE_WRITE
# ifndef DISABLE_DXF
else if (strEQc (argv[1], "-indxf"))
mode = INDXF;
# endif
# ifndef DISABLE_JSON
else if (strEQc (argv[1], "-injson"))
mode = INJSON;
# endif
else if (strEQc (argv[1], "-rw"))
mode = RW;
else if (strEQc (argv[1], "-add"))
mode = ADD;
#endif /* USE_WRITE */
#ifndef DISABLE_DXF
else if (strEQc (argv[1], "-dxf"))
mode = DXF;
else if (strEQc (argv[1], "-dxfb"))
mode = DXFB;
#endif
#ifndef DISABLE_JSON
else if (strEQc (argv[1], "-json"))
mode = JSON;
else if (strEQc (argv[1], "-geojson"))
mode = GEOJSON;
#endif
else
return 1;
if (mode == INVALID)
return 1;
#if FUZZ_MODE == FUZZ_FILE
if (argc <= 2 || !*argv[2])
return 1;
#endif
#if FUZZ_MODE == FUZZ_INMEM && !defined(__AFL_COMPILER)
if (argc <= 2 || !*argv[2])
return 1;
#endif
memset (&dwg, 0, sizeof (dwg));
dat.chain = NULL;
// dat.opts = 3;;
#if FUZZ_MODE == FUZZ_INMEM
dat.chain = __AFL_FUZZ_TESTCASE_BUF;
#endif
while (__AFL_LOOP (10000))
{ // llvm_mode persistent, non-forking mode
i++;
#ifndef __AFL_COMPILER
# ifdef USE_WRITE
if (mode == ADD && i > 1)
break;
# endif
if (i > 3)
break;
#endif
#if FUZZ_MODE == FUZZ_INMEM
// fastest mode via shared mem
if (!dat.chain)
dat.chain = __AFL_FUZZ_TESTCASE_BUF;
dat.size = __AFL_FUZZ_TESTCASE_LEN;
printf ("Fuzzing from shared memory (%" PRIuSIZE ")\n", dat.size);
#elif FUZZ_MODE == FUZZ_STDIN
// still 10x faster than the old file-forking fuzzer.
dat.size = 0;
// dat.chain = NULL;
dat_read_stream (&dat, stdin);
printf ("Fuzzing from stdin (%" PRIuSIZE ")\n", dat.size);
#elif FUZZ_MODE == FUZZ_FILE
dat.size = 0;
fp = fopen (argv[2], "rb");
if (!fp)
return 0;
dat_read_file (&dat, fp, argv[2]);
fclose (fp);
printf ("Fuzzing from file (%" PRIuSIZE ")\n", dat.size);
#else
# error Missing FUZZ_MODE
#endif
if (dat.size == 0)
exit (1);
if (dat.size < 100)
continue; // useful minimum input length
memset (&out_dat, 0, sizeof (out_dat));
bit_chain_set_version (&out_dat, &dat);
#ifdef _WIN32
out_dat.fh = fopen ("NUL", "w");
#else
out_dat.fh = fopen ("/dev/null", "w");
#endif
switch (mode)
{
case DWG:
if (dwg_decode (&dat, &dwg) >= DWG_ERR_CRITICAL)
exit (0);
break;
#if defined(USE_WRITE) && !defined(DISABLE_DXF)
case INDXF:
if (dwg_read_dxf (&dat, &dwg) < DWG_ERR_CRITICAL)
{
if (dat.version == R_2007)
out_dat.version = R_2010;
if (dwg_encode (&dwg, &out_dat) >= DWG_ERR_CRITICAL)
exit (0);
free (out_dat.chain);
out_dat.chain = NULL;
}
break;
#endif
#if defined(USE_WRITE)
case RW:
if (dwg_decode (&dat, &dwg) < DWG_ERR_CRITICAL)
{
if (dat.version == R_2007)
out_dat.version = R_2010;
if (dwg_encode (&dwg, &out_dat) >= DWG_ERR_CRITICAL)
exit (0);
if (dwg_decode (&out_dat, &dwg) >= DWG_ERR_CRITICAL)
exit (0);
free (out_dat.chain);
out_dat.chain = NULL;
}
break;
case ADD:
{
Dwg_Data *dwgp = &dwg;
if (dwg_fuzz_dat (&dwgp, &dat) == 0)
{
int error;
out_dat.byte = 0;
out_dat.bit = 0;
out_dat.from_version = dwg.header.from_version;
out_dat.version = dwg.header.version;
out_dat.opts = dwg.opts;
error = dwg_encode (&dwg, &out_dat); // dwg -> out_dat
if (error >= DWG_ERR_CRITICAL)
exit (0);
out_dat.byte = 0;
out_dat.bit = 0;
memset (&dwg, 0, sizeof (Dwg_Data));
error = dwg_decode (&out_dat, &dwg); // out_dat -> dwg
if (error >= DWG_ERR_CRITICAL)
exit (0);
}
}
break;
#endif
#if defined(USE_WRITE) && !defined(DISABLE_JSON)
case INJSON:
if (dwg_read_json (&dat, &dwg) < DWG_ERR_CRITICAL)
{
if (dat.version == R_2007)
out_dat.version = R_2010;
if (dwg_encode (&dwg, &out_dat) >= DWG_ERR_CRITICAL)
exit (0);
}
break;
#endif
#ifndef DISABLE_DXF
case DXF:
if (dwg_decode (&dat, &dwg) < DWG_ERR_CRITICAL)
{
if (dwg_write_dxf (&out_dat, &dwg) >= DWG_ERR_CRITICAL)
exit (0);
}
break;
case DXFB:
if (dwg_decode (&dat, &dwg) < DWG_ERR_CRITICAL)
{
if (dwg_write_dxfb (&out_dat, &dwg) >= DWG_ERR_CRITICAL)
exit (0);
}
break;
#endif
#ifndef DISABLE_JSON
case JSON:
if (dwg_decode (&dat, &dwg) < DWG_ERR_CRITICAL)
{
if (dwg_write_json (&out_dat, &dwg) >= DWG_ERR_CRITICAL)
exit (0);
}
break;
case GEOJSON:
if (dwg_decode (&dat, &dwg) < DWG_ERR_CRITICAL)
{
if (dwg_write_geojson (&out_dat, &dwg) >= DWG_ERR_CRITICAL)
exit (0);
}
break;
#endif
case INVALID:
default:
exit (1);
}
free (out_dat.chain);
fclose (out_dat.fh);
}
dwg_free (&dwg);
return 0;
}
#if defined(USE_WRITE)
static dwg_point_2d *
scan_pts2d (unsigned num_pts, char **pp)
{
char *p = *pp;
dwg_point_2d *pts;
p = strchr (p, '(');
if (!p)
return NULL;
p++;
if (num_pts > 5000)
exit (0);
pts = calloc (num_pts, 16);
if (!pts)
exit (0);
for (unsigned i = 0; i < num_pts; i++)
{
if (sscanf (p, "(%lf %lf)", &pts[i].x, &pts[i].y))
{
p = strchr (p, ')');
if (!p)
break;
p++;
}
else
{
*pp = p;
p = NULL;
break;
}
}
if (p)
{
*pp = p;
return pts;
}
else
{
free (pts);
return NULL;
}
}
static dwg_point_3d *
scan_pts3d (unsigned num_pts, char **pp)
{
char *p = *pp;
dwg_point_3d *pts;
p = strchr (p, '(');
if (!p)
return NULL;
p++;
if (num_pts > 5000)
exit (0);
pts = calloc (num_pts, 24);
if (!pts)
exit (0);
for (unsigned i = 0; i < num_pts; i++)
{
if (sscanf (p, "(%lf %lf %lf)", &pts[i].x, &pts[i].y, &pts[i].z))
{
p = strchr (p, ')');
if (!p)
break;
p++;
}
else
{
*pp = p;
p = NULL;
break;
}
}
if (p && num_pts)
{
*pp = p;
return pts;
}
else
{
free (pts);
return NULL;
}
}
static char *
next_line (char *restrict p, const char *restrict end)
{
while (p < end && *p != '\n')
p++;
if (p < end)
p++;
return p;
}
int
dwg_fuzz_dat (Dwg_Data **restrict dwgp, Bit_Chain *restrict dat)
{
Dwg_Data *dwg;
Dwg_Object *mspace;
Dwg_Object_Ref *mspace_ref;
Dwg_Object_BLOCK_HEADER *hdr;
const char *end;
char *p;
Dwg_Version_Type version = R_INVALID;
int i = 0;
int imperial = 0;
BITCODE_BL orig_num;
if (!dat->chain)
abort ();
end = (char *)&dat->chain[dat->size - 1];
if ((p = strstr ((char *)dat->chain, "\nimperial\n")))
{
imperial = 1;
p += strlen ("\nimperial\n");
}
if ((p = strstr ((char *)dat->chain, "version")))
{
int i_ver;
char s_ver[16];
i = sscanf (p, "version %d", &i_ver);
if (i)
{
snprintf (s_ver, 16, "r%d", i_ver);
s_ver[15] = '\0';
version = dwg_version_as (s_ver);
p += strlen ("version ");
}
else
p += strlen ("version ");
p = next_line (p, end);
}
if (!i || version >= R_AFTER)
version = R_2000;
dwg = dwg_new_Document (version, imperial, 0);
*dwgp = dwg;
mspace = dwg_model_space_object (dwg);
mspace_ref = dwg_model_space_ref (dwg);
hdr = mspace->tio.object->tio.BLOCK_HEADER;
orig_num = dwg->num_objects;
// read dat line by line and call the matching add API
while (p && p < end)
{
char text[120], s1[120];
dwg_point_2d p2, p3, p4;
dwg_point_3d pt1, pt2, pt3, pt4, scale;
double height, rot, len, f1, f2;
int i1, i2;
unsigned u;
Dwg_Entity_VIEWPORT *viewport = NULL;
Dwg_Entity_MTEXT *mtext = NULL;
Dwg_Object_DICTIONARY *dictionary = NULL;
Dwg_Object_XRECORD *xrecord = NULL;
Dwg_Object_MLINESTYLE *mlinestyle = NULL;
Dwg_Object_DIMSTYLE *dimstyle = NULL;
Dwg_Object_UCS *ucs = NULL;
Dwg_Object_LAYOUT *layout = NULL;
// accepts only ASCII strings, for fuzzing only
# ifdef HAVE_SSCANF_S
# define SSCANF_S sscanf_s
# define SZ , 119
# define FMT_NAME "%[a-zA-Z0-9_]"
# define FMT_TBL "\"%[a-zA-Z0-9._ -]\""
# define FMT_PATH "\"%[a-zA-Z0-9_. \\-]\""
# define FMT_ANY "\"%s\""
# else
# define SSCANF_S sscanf
# define SZ
# define FMT_NAME "%119[a-zA-Z0-9_]"
# define FMT_TBL "\"%119[a-zA-Z0-9._ -]\""
# define FMT_PATH "\"%119[a-zA-Z0-9_. \\-]\""
# define FMT_ANY "\"%119s\""
# endif
# define SET_ENT(var, name) \
if (!var) \
; \
else if (SSCANF_S (p, #var "." FMT_NAME " = %d", &s1[0] SZ, &i1)) \
dwg_dynapi_entity_set_value (var, #name, s1, &i1, 0); \
else if (SSCANF_S (p, #var "." FMT_NAME " = %lf", &s1[0] SZ, &f1)) \
dwg_dynapi_entity_set_value (var, #name, s1, &f1, 0); \
else if (SSCANF_S (p, #var "." FMT_NAME " = " FMT_ANY, &s1[0] SZ, \
&text[0] SZ)) \
dwg_dynapi_entity_set_value (var, #name, s1, text, 1)
if (SSCANF_S (p, "line (%lf %lf %lf) (%lf %lf %lf)", &pt1.x, &pt1.y,
&pt1.z, &pt2.x, &pt2.y, &pt2.z))
dwg_add_LINE (hdr, &pt1, &pt2);
else if (SSCANF_S (p, "ray (%lf %lf %lf) (%lf %lf %lf)", &pt1.x, &pt1.y,
&pt1.z, &pt2.x, &pt2.y, &pt2.z))
dwg_add_RAY (hdr, &pt1, &pt2);
else if (SSCANF_S (p, "xline (%lf %lf %lf) (%lf %lf %lf)", &pt1.x,
&pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z))
dwg_add_XLINE (hdr, &pt1, &pt2);
else if (SSCANF_S (p, "text " FMT_ANY " (%lf %lf %lf) %lf", &text[0] SZ,
&pt1.x, &pt1.y, &pt1.z, &height))
dwg_add_TEXT (hdr, text, &pt1, height);
else if (SSCANF_S (p, "mtext (%lf %lf %lf) %lf " FMT_ANY, &pt1.x, &pt1.y,
&pt1.z, &height, &text[0] SZ))
mtext = dwg_add_MTEXT (hdr, &pt1, height, text);
else
SET_ENT (mtext, MTEXT);
else if (SSCANF_S (p, "block " FMT_TBL, &text[0] SZ))
dwg_add_BLOCK (hdr, text);
else if (memBEGINc (p, "endblk\n")) dwg_add_ENDBLK (hdr);
else if (SSCANF_S (p, "insert (%lf %lf %lf) " FMT_TBL " %lf %lf %lf %lf",
&pt1.x, &pt1.y, &pt1.z, &text[0] SZ, &scale.x,
&scale.y, &scale.z, &rot))
dwg_add_INSERT (hdr, &pt1, text, scale.x, scale.y, scale.z,
deg2rad (rot));
else if (SSCANF_S (p,
"minsert (%lf %lf %lf) " FMT_TBL
" %lf %lf %lf %lf %d %d "
"%lf %lf",
&pt1.x, &pt1.y, &pt1.z, &text[0] SZ, &scale.x,
&scale.y, &scale.z, &rot, &i1, &i2, &f1, &f2))
dwg_add_MINSERT (hdr, &pt1, text, scale.x, scale.y, scale.z,
deg2rad (rot), i1, i2, f1, f2);
else if (SSCANF_S (p, "point (%lf %lf %lf)", &pt1.x, &pt1.y, &pt1.z))
dwg_add_POINT (hdr, &pt1);
else if (SSCANF_S (p, "circle (%lf %lf %lf) %lf", &pt1.x, &pt1.y, &pt1.z,
&f1)) dwg_add_CIRCLE (hdr, &pt1, f1);
else if (SSCANF_S (p, "arc (%lf %lf %lf) %lf %lf %lf", &pt1.x, &pt1.y,
&pt1.z, &f1, &f2, &height))
dwg_add_ARC (hdr, &pt1, f1, f2, height);
else if (SSCANF_S (p,
"dimension_aligned (%lf %lf %lf) (%lf %lf %lf) (%lf "
"%lf %lf)",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z,
&pt3.x, &pt3.y, &pt3.z))
dwg_add_DIMENSION_ALIGNED (hdr, &pt1, &pt2, &pt3);
else if (SSCANF_S (
p,
"dimension_linear (%lf %lf %lf) (%lf %lf %lf) (%lf %lf "
"%lf) %lf",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &pt3.x,
&pt3.y, &pt3.z, &rot))
dwg_add_DIMENSION_LINEAR (hdr, &pt1, &pt2, &pt3, deg2rad (rot));
else if (SSCANF_S (
p,
"dimension_ang2ln (%lf %lf %lf) (%lf %lf %lf) (%lf %lf "
"%lf) (%lf %lf %lf)",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &pt3.x,
&pt3.y, &pt3.z, &pt4.x, &pt4.y, &pt4.z))
dwg_add_DIMENSION_ANG2LN (hdr, &pt1, &pt2, &pt3, &pt4);
else if (SSCANF_S (
p,
"dimension_ang3pt (%lf %lf %lf) (%lf %lf %lf) (%lf %lf "
"%lf) (%lf %lf %lf)",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &pt3.x,
&pt3.y, &pt3.z, &pt4.x, &pt4.y, &pt4.z))
dwg_add_DIMENSION_ANG3PT (hdr, &pt1, &pt2, &pt3, &pt4);
else if (SSCANF_S (p,
"dimension_diameter (%lf %lf %lf) (%lf %lf %lf) %lf",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &len))
dwg_add_DIMENSION_DIAMETER (hdr, &pt1, &pt2, len);
else if (SSCANF_S (p,
"dimension_ordinate (%lf %lf %lf) (%lf %lf %lf) %d",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &i1))
dwg_add_DIMENSION_ORDINATE (hdr, &pt1, &pt2, i1 ? true : false);
else if (SSCANF_S (p, "dimension_radius (%lf %lf %lf) (%lf %lf %lf) %lf",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &len))
dwg_add_DIMENSION_RADIUS (hdr, &pt1, &pt2, len);
else if (SSCANF_S (p,
"3dface (%lf %lf %lf) (%lf %lf %lf) (%lf %lf "
"%lf) (%lf %lf %lf)",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z,
&pt3.x, &pt3.y, &pt3.z, &pt4.x, &pt4.y, &pt4.z))
dwg_add_3DFACE (hdr, &pt1, &pt2, &pt3, &pt4);
else if (SSCANF_S (p,
"3dface (%lf %lf %lf) (%lf %lf %lf) (%lf %lf "
"%lf)",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z,
&pt3.x, &pt3.y, &pt3.z))
dwg_add_3DFACE (hdr, &pt1, &pt2, &pt3, NULL);
else if (SSCANF_S (
p, "solid (%lf %lf %lf) (%lf %lf) (%lf %lf) (%lf %lf)",
&pt1.x, &pt1.y, &pt1.z, &p2.x, &p2.y, &p3.x, &p3.y, &p4.x,
&p4.y)) dwg_add_SOLID (hdr, &pt1, &p2, &p3, &p4);
else if (SSCANF_S (
p, "trace (%lf %lf %lf) (%lf %lf) (%lf %lf) (%lf %lf)",
&pt1.x, &pt1.y, &pt1.z, &p2.x, &p2.y, &p3.x, &p3.y, &p4.x,
&p4.y)) dwg_add_TRACE (hdr, &pt1, &p2, &p3, &p4);
else if (SSCANF_S (p, "polyline_2d %d ((%lf %lf)", &i1, &pt1.x, &pt1.y))
{
dwg_point_2d *pts = scan_pts2d (i1, &p);
if (i1 && pts)
{
dwg_add_POLYLINE_2D (hdr, i1, pts);
free (pts);
}
}
else if (SSCANF_S (p, "polyline_3d %d ((%lf %lf %lf)", &i1, &pt1.x,
&pt1.y, &pt1.z))
{
dwg_point_3d *pts = scan_pts3d (i1, &p);
if (i1 && pts)
{
dwg_add_POLYLINE_3D (hdr, i1, pts);
free (pts);
}
}
else if (SSCANF_S (p, "polyline_mesh %d %d ((%lf %lf %lf)", &i1, &i2,
&pt1.x, &pt1.y, &pt1.z))
{
dwg_point_3d *pts = scan_pts3d (i1 * i2, &p);
if (i1 && i2 && pts)
{
dwg_add_POLYLINE_MESH (hdr, i1, i2, pts);
free (pts);
}
}
else if (SSCANF_S (p, "dictionary " FMT_TBL " " FMT_TBL " %u",
&text[0] SZ, &s1[0] SZ, &u)) dictionary
= dwg_add_DICTIONARY (dwg, text, s1, (unsigned long)u);
else if (dictionary
&& SSCANF_S (p, "xrecord dictionary " FMT_TBL, &text[0] SZ))
xrecord
= dwg_add_XRECORD (dictionary, text);
else if (SSCANF_S (p, "shape " FMT_PATH " (%lf %lf %lf) %lf %lf",
&text[0] SZ, &pt1.x, &pt1.y, &pt1.z, &scale.x, &rot))
dwg_add_SHAPE (hdr, text, &pt1, scale.x, deg2rad (rot));
else if (SSCANF_S (p, "viewport " FMT_TBL, &text[0] SZ)) viewport
= dwg_add_VIEWPORT (hdr, text);
else SET_ENT (viewport, VIEWPORT);
else if (SSCANF_S (p, "ellipse (%lf %lf %lf) %lf %lf", &pt1.x, &pt1.y,
&pt1.z, &f1, &f2))
dwg_add_ELLIPSE (hdr, &pt1, f1, f2);
else if (SSCANF_S (p, "spline %d ((%lf %lf %lf)", &i1, &pt1.x, &pt1.y,
&pt1.z))
{
dwg_point_3d *fitpts = scan_pts3d (i1, &p);
if (i1 && fitpts
&& sscanf (p, ") (%lf %lf %lf) (%lf %lf %lf)", &pt2.x, &pt2.y,
&pt2.z, &pt3.x, &pt3.y, &pt3.z))
{
dwg_add_SPLINE (hdr, i1, fitpts, &pt2, &pt3);
}
free (fitpts);
}
else if (mtext
&& sscanf (p, "leader %d ((%lf %lf %lf)", &i1, &pt1.x, &pt1.y,
&pt1.z))
{
dwg_point_3d *pts = scan_pts3d (i1, &p);
if (i1 && pts && sscanf (p, ") mtext %d", &i2))
{
dwg_add_LEADER (hdr, i1, pts, mtext, i2);
}
free (pts);
}
else if (SSCANF_S (p,
"tolerance " FMT_TBL " (%lf %lf %lf) (%lf %lf %lf)",
&text[0] SZ, &pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y,
&pt2.z)) dwg_add_TOLERANCE (hdr, text, &pt1, &pt2);
else if (SSCANF_S (p, "mlinestyle " FMT_TBL, &text[0] SZ)) mlinestyle
= dwg_add_MLINESTYLE (dwg, text);
else if (SSCANF_S (p, "dimstyle " FMT_TBL, &text[0] SZ)) dimstyle
= dwg_add_DIMSTYLE (dwg, text);
else SET_ENT (mlinestyle, MLINESTYLE);
else SET_ENT (dimstyle, DIMSTYLE);
else if (SSCANF_S (
p, "ucs (%lf %lf %lf) (%lf %lf %lf) (%lf %lf %lf) " FMT_TBL,
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &pt3.x,
&pt3.y, &pt3.z, &text[0] SZ)) ucs
= dwg_add_UCS (dwg, &pt1, &pt2, &pt3, text);
else SET_ENT (ucs, UCS);
else if (viewport
&& SSCANF_S (p, "layout viewport " FMT_TBL " " FMT_ANY,
&text[0] SZ, &s1[0] SZ))
{
int error;
Dwg_Object *obj = dwg_ent_generic_to_object (viewport, &error);
if (!error)
layout = dwg_add_LAYOUT (obj, text, s1);
}
else if (SSCANF_S (p, "torus (%lf %lf %lf) (%lf %lf %lf) %lf %lf",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &f1,
&f2)) dwg_add_TORUS (hdr, &pt1, &pt2, f1, f2);
else if (SSCANF_S (p, "sphere (%lf %lf %lf) (%lf %lf %lf) %lf", &pt1.x,
&pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &f1))
dwg_add_SPHERE (hdr, &pt1, &pt2, f1);
else if (SSCANF_S (
p, "cylinder (%lf %lf %lf) (%lf %lf %lf) %lf %lf %lf %lf",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &height,
&f1, &f2, &len))
dwg_add_CYLINDER (hdr, &pt1, &pt2, height, f1, f2, len);
else if (SSCANF_S (p, "cone (%lf %lf %lf) (%lf %lf %lf) %lf %lf %lf %lf",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z,
&height, &f1, &f2, &len))
dwg_add_CONE (hdr, &pt1, &pt2, height, f1, f2, len);
else if (SSCANF_S (p, "wedge (%lf %lf %lf) (%lf %lf %lf) %lf %lf %lf",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &len,
&f1, &height))
dwg_add_WEDGE (hdr, &pt1, &pt2, len, f1, height);
else if (SSCANF_S (p, "box (%lf %lf %lf) (%lf %lf %lf) %lf %lf %lf",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z, &len,
&f1, &height))
dwg_add_BOX (hdr, &pt1, &pt2, len, f1, height);
else if (SSCANF_S (p,
"pyramid (%lf %lf %lf) (%lf %lf %lf) %lf %d %lf %lf",
&pt1.x, &pt1.y, &pt1.z, &pt2.x, &pt2.y, &pt2.z,
&height, &i1, &f1, &f2))
dwg_add_PYRAMID (hdr, &pt1, &pt2, height, i1, f1, f2);
else if (SSCANF_S (p, "HEADER." FMT_NAME " = %d", &s1[0] SZ, &i1))
dwg_dynapi_header_set_value (dwg, s1, &i1, 0);
else if (SSCANF_S (p, "HEADER." FMT_NAME " = %lf", &s1[0] SZ, &f1))
dwg_dynapi_header_set_value (dwg, s1, &f1, 0);
else if (SSCANF_S (p, "HEADER." FMT_NAME " = " FMT_ANY, &s1[0] SZ,
&text[0] SZ))
dwg_dynapi_header_set_value (dwg, s1, text, 1);
p = next_line (p, end);
}
// dwg_resolve_objectrefs_silent (orig_dwg);
// start fuzzing if at least 2 entities were added.
return (dwg->num_objects - orig_num > 2 ? 0 : 1);
}
#endif // USE_WRITE
@@ -0,0 +1,356 @@
/*****************************************************************************/
/* LibreDWG - free implementation of the DWG file format */
/* */
/* Copyright (C) 2021, 2023 Free Software Foundation, Inc. */
/* */
/* 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 <http://www.gnu.org/licenses/>. */
/*****************************************************************************/
/*
* llvmfuzz.c: libfuzzer testing, esp. for oss-fuzz. with libfuzzer or
* standalone written by Reini Urban
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// #include <unistd.h>
#include <sys/stat.h>
#include "common.h"
#include <dwg.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#include "decode.h"
#include "encode.h"
#include "bits.h"
#ifndef DISABLE_DXF
# include "out_dxf.h"
# ifndef DISABLE_JSON
# include "in_json.h"
# include "out_json.h"
# endif
# include "in_dxf.h"
#endif
// Number of output converters selectable via out: 0 encode, 1 dxf, 2 dxfb, 3
// json, 4 geojson
#ifdef DISABLE_DXF
# define LLVMFUZZ_NUM_OUTPUTS 1
#else
# ifdef DISABLE_JSON
# define LLVMFUZZ_NUM_OUTPUTS 3
# else
# define LLVMFUZZ_NUM_OUTPUTS 5
# endif
#endif
int out;
int ver;
extern int LLVMFuzzerTestOneInput (const unsigned char *data, size_t size);
// libfuzzer limitation:
// Enforce NULL-termination of the input buffer, to avoid bogus reports. copy
// it. Problematic is mostly strtol(3) which also works with \n termination.
static int
enforce_null_termination (Bit_Chain *dat, bool enforce)
{
unsigned char *copy;
unsigned char c;
if (!dat->size)
return 0;
c = dat->chain[dat->size - 1];
// Allow \n termination without \0 in DXF? No, still crashes
if (!enforce && ((c == '\n' && c + 1 == '\0') || c == '\0'))
return 0;
#ifdef STANDALONE
fprintf (stderr,
"llvmfuzz_standalone: enforce libfuzzer buffer NULL termination\n");
#endif
copy = malloc (dat->size + 1);
memcpy (copy, dat->chain, dat->size);
copy[dat->size] = '\0';
dat->chain = copy;
return 1;
}
int
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
{
Dwg_Data dwg;
Bit_Chain dat = { NULL, 0, 0, 0, 0, 0, 0, NULL, 0 };
Bit_Chain out_dat = { NULL, 0, 0, 0, 0, 0, 0, NULL, 0 };
int copied = 0;
struct ly_ctx *ctx = NULL;
static char tmp_file[256];
#ifndef STANDALONE
/* The libfuzzer path otherwise leaves out/ver at 0, so only dwg_encode runs.
Derive them from the input (without consuming it, so the existing corpus
keeps decoding) to also drive the out_dxf/out_dxfb/out_json encoders. */
out = 0;
ver = 0;
if (size)
{
unsigned int h = 2166136261u;
const size_t n = size > 4096 ? 4096 : size;
for (size_t i = 0; i < n; i++)
h = (h ^ data[i]) * 16777619u;
out = (int)(h % LLVMFUZZ_NUM_OUTPUTS);
ver = (int)((h >> 8) % 20);
}
#endif
dat.chain = (unsigned char *)data;
dat.size = size;
memset (&dwg, 0, sizeof (dwg));
// Detect the input format: DWG, DXF or JSON
if (dat.size > 2 && dat.chain[0] == 'A' && dat.chain[1] == 'C')
{
if (dwg_decode (&dat, &dwg) >= DWG_ERR_CRITICAL)
{
dwg_free (&dwg);
return 0;
}
}
#ifndef DISABLE_JSON
else if (dat.size > 1 && dat.chain[0] == '{')
{
copied = enforce_null_termination (&dat, true);
if (dwg_read_json (&dat, &dwg) >= DWG_ERR_CRITICAL)
{
if (copied)
bit_chain_free (&dat);
dwg_free (&dwg);
return 0;
}
dat.opts |= DWG_OPTS_INJSON;
dwg.opts |= DWG_OPTS_INJSON;
}
#endif
#ifndef DISABLE_DXF
else
{
copied = enforce_null_termination (&dat, false);
if (dwg_read_dxf (&dat, &dwg) >= DWG_ERR_CRITICAL)
{
if (copied)
bit_chain_free (&dat);
dwg_free (&dwg);
return 0;
}
}
#else
else
return 0;
#endif
memset (&out_dat, 0, sizeof (out_dat));
bit_chain_set_version (&out_dat, &dat);
if (copied)
bit_chain_free (&dat);
#if 0
snprintf (tmp_file, 255, "/tmp/llvmfuzzer%d.out", getpid());
tmp_file[255] = '\0';
#elif defined _WIN32
strcpy (tmp_file, "NUL");
#else
strcpy (tmp_file, "/dev/null");
#endif
out_dat.fh = fopen (tmp_file, "w");
switch (out)
{
case 0:
{
switch (ver)
{
// TODO support preR13, many downconverters still missing
case 0:
out_dat.version = dwg.header.version = R_1_4;
break;
case 1:
out_dat.version = dwg.header.version = R_2_0;
break;
case 2:
out_dat.version = dwg.header.version = R_2_10;
break;
case 3:
out_dat.version = dwg.header.version = R_2_21;
break;
case 4:
out_dat.version = dwg.header.version = R_2_4;
break;
case 5:
out_dat.version = dwg.header.version = R_2_6;
break;
case 6:
out_dat.version = dwg.header.version = R_9;
break;
case 7:
out_dat.version = dwg.header.version = R_10;
break;
case 8:
out_dat.version = dwg.header.version = R_11;
break;
case 9:
out_dat.version = dwg.header.version = R_12;
break;
case 10:
out_dat.version = dwg.header.version = R_13;
break;
case 11:
out_dat.version = dwg.header.version = R_13c3;
break;
case 12:
out_dat.version = dwg.header.version = R_14;
break;
case 13:
out_dat.version = dwg.header.version = R_2004;
break;
default: // favor this one
out_dat.version = dwg.header.version = R_2000;
break;
}
dwg_encode (&dwg, &out_dat);
break;
}
#ifndef DISABLE_DXF
case 1:
dwg_write_dxf (&out_dat, &dwg);
break;
case 2: // experimental
dwg_write_dxfb (&out_dat, &dwg);
break;
# ifndef DISABLE_JSON
case 3:
dwg_write_json (&out_dat, &dwg);
break;
case 4:
dwg_write_geojson (&out_dat, &dwg);
break;
# endif
#endif
default:
break;
}
dwg_free (&dwg);
free (out_dat.chain);
fclose (out_dat.fh);
// unlink (tmp_file);
return 0;
}
#ifdef STANDALONE
/*
# ifdef __GNUC__
__attribute__((weak))
# endif
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
*/
static int
usage (void)
{
printf ("\nUsage: OUT=0 VER=3 llvmfuzz_standalone INPUT...");
return 1;
}
// llvmfuzz_standalone reproducer, see OUT and VER env vars
int
main (int argc, char *argv[])
{
unsigned seed;
const unsigned int possible_outputformats = LLVMFUZZ_NUM_OUTPUTS;
if (argc <= 1 || !*argv[1])
return usage ();
if (getenv ("SEED"))
seed = (unsigned)strtol (getenv ("SEED"), NULL, 10) % 9999;
else
{
# ifdef HAVE_GETTIMEOFDAY
struct timeval tval;
gettimeofday (&tval, NULL);
seed = (unsigned)(tval.tv_sec * 1000 + tval.tv_usec) % 9999;
# else
seed = (unsigned)time (NULL) % 9999;
# endif
}
srand (seed);
/* works only on linux
if (LLVMFuzzerInitialize)
LLVMFuzzerInitialize (&argc, &argv);
*/
for (int i = 1; i < argc; i++)
{
unsigned char *buf;
FILE *f = fopen (argv[i], "rb");
struct stat attrib;
long len;
size_t n_read;
int fd;
if (!f)
{
fprintf (stderr, "Illegal file argument %s\n", argv[i]);
continue;
}
fd = fileno (f);
if (fd < 0 || fstat (fd, &attrib)
|| !(S_ISREG (attrib.st_mode)
# ifndef _WIN32
|| S_ISLNK (attrib.st_mode)
# endif
))
{
fprintf (stderr, "Illegal input file \"%s\"\n", argv[i]);
continue;
}
// libFuzzer design bug, not zero-terminating its text buffer
fseek (f, 0, SEEK_END);
len = ftell (f);
fseek (f, 0, SEEK_SET);
if (len <= 0)
continue;
buf = (unsigned char *)malloc (len);
n_read = fread (buf, 1, len, f);
fclose (f);
assert ((long)n_read == len);
out = rand () % possible_outputformats;
# ifdef STANDALONE
if (getenv ("OUT"))
out = strtol (getenv ("OUT"), NULL, 10);
// print SEED onlyu when needed (no env vars given)
if (!(out || getenv ("VER")))
fprintf (stderr, "SEED=%04u ", seed);
fprintf (stderr, "OUT=%d ", out);
# endif
if (out == 0)
{
ver = rand () % 20;
# ifdef STANDALONE
if (getenv ("VER"))
ver = strtol (getenv ("VER"), NULL, 10);
fprintf (stderr, "VER=%d ", ver);
# endif
}
fprintf (stderr, "examples/llvmfuzz_standalone %s [%" PRIuSIZE "]\n",
argv[i], len);
LLVMFuzzerTestOneInput (buf, len);
free (buf);
// Bit_Chain dat = { 0 };
// dat_read_file (&dat, fp, argv[i]);
// LLVMFuzzerTestOneInput (dat.chain, dat.size);
// bit_free_chain (&dat);
}
}
#endif
@@ -0,0 +1,230 @@
/*****************************************************************************/
/* 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 <http://www.gnu.org/licenses/>. */
/*****************************************************************************/
/*
* load_dwg.c: load a DWG, get lines, text and circles
* written by Felipe Castro
* modified by Felipe Corrêa da Silva Sances
* modified by Thien-Thi Nguyen
* modified by Reini Urban
*/
#include "config.h"
#ifdef __STDC_ALLOC_LIB__ /* for strdup */
# define __STDC_WANT_LIB_EXT2__ 1 /* for strdup */
#else
# define _USE_BSD 1
#endif
#ifndef _XOPEN_SOURCE /* for strdup, snprintf */
# define _XOPEN_SOURCE 700
#endif
#include <stdio.h>
#include <time.h>
#ifndef DISABLE_WRITE
# include <sys/stat.h>
# include <unistd.h>
#endif
#include "dwg.h"
#include "dwg_api.h"
#include "../src/bits.h"
#include "../programs/suffix.inc"
static int help (void);
int verbosity (int argc, char **argv, int i, unsigned int *opts);
#include "../programs/common.inc"
static int
usage (void)
{
printf ("\nUsage: load_dwg [-v[0-9]] DWGFILE\n");
return 1;
}
static int
opt_version (void)
{
printf ("load_dwg %s\n", PACKAGE_VERSION);
return 0;
}
static int
help (void)
{
printf ("\nUsage: load_dwg [OPTION]... DWGFILE\n");
printf ("Example to add fingerprint elements to a DWG.\n"
"\n");
printf (" -v[0-9], --verbose [0-9] verbosity\n");
printf (" --help display this help and exit\n");
printf (" --version output version information and exit\n"
"\n");
printf ("GNU LibreDWG online manual: "
"<https://www.gnu.org/software/libredwg/>\n");
return 0;
}
static int
add_fingerprint (Dwg_Data *dwg, dwg_point_3d *pt)
{
int error = 0;
char text[128];
double height = dwg->header_vars.TEXTSIZE;
time_t t = time (NULL);
Dwg_Object_BLOCK_HEADER *hdr = dwg_get_block_header (dwg, &error);
Dwg_Entity_TEXT *ent;
if (error)
return 1;
#ifdef HAVE_WFORMAT_Y2K
GCC46_DIAG_IGNORE (-Wformat-y2k)
#endif
strftime (text, sizeof (text), "Last updated: %c", localtime (&t));
#ifdef HAVE_WFORMAT_Y2K
GCC46_DIAG_RESTORE
#endif
#ifdef USE_WRITE
if ((ent = dwg_add_TEXT (hdr, text, pt, height)))
{
ent->horiz_alignment = HORIZ_ALIGNMENT_RIGHT;
return 0;
}
else
#endif
return 1;
}
static int
change_fingerprint (Dwg_Data *dwg, Dwg_Entity_TEXT *_obj)
{
char text[128];
double height = dwg->header_vars.TEXTSIZE;
time_t t = time (NULL);
#ifdef HAVE_WFORMAT_Y2K
GCC46_DIAG_IGNORE (-Wformat-y2k)
#endif
strftime (text, sizeof (text), "Last updated: %c", localtime (&t));
#ifdef HAVE_WFORMAT_Y2K
GCC46_DIAG_RESTORE
#endif
if (dwg->header.version < R_2007)
{
if (strlen (text) < strlen (_obj->text_value))
strcpy (_obj->text_value, text);
else
{
free (_obj->text_value);
_obj->text_value = strdup (text);
}
}
else
{
free (_obj->text_value);
_obj->text_value = (BITCODE_TV)bit_utf8_to_TU (text, 0);
}
return 0;
}
static int
load_dwg (char *filename, unsigned int opts)
{
BITCODE_BL i;
int success, found = 0;
Dwg_Data dwg;
dwg_point_3d pt;
#ifdef USE_WRITE
char *new_filename = (char *)malloc (strlen (filename) + 4);
char *fn = strdup (filename);
char *base = basename (fn);
char *p;
struct stat st;
if ((p = strrchr (base, '.')))
*p = '\0';
sprintf (new_filename, "%s_new.dwg", base);
free (fn);
#endif
memset (&dwg, 0, sizeof (Dwg_Data));
dwg.opts = opts;
success = dwg_read_file (filename, &dwg);
// get the insertion point for our fingerprint
pt.x = dwg.header_vars.LIMMAX.x;
pt.y = dwg.header_vars.LIMMAX.y;
pt.z = 0.0;
// check if a fingerprint already exists there.
// if so update it. if not add it
for (i = 0; i < dwg.num_objects; i++)
{
if (dwg.object[i].fixedtype == DWG_TYPE_TEXT)
{
Dwg_Entity_TEXT *_obj = dwg.object[i].tio.entity->tio.TEXT;
if (pt.x == _obj->ins_pt.x && pt.y == _obj->ins_pt.y
&& _obj->horiz_alignment == HORIZ_ALIGNMENT_RIGHT)
{
found++;
change_fingerprint (&dwg, _obj);
fprintf (stderr, "fingerprint updated at (%f, %f)\n", pt.x,
pt.y);
}
}
}
if (!found)
{
add_fingerprint (&dwg, &pt);
fprintf (stderr, "fingerprint added at (%f, %f)\n", pt.x, pt.y);
}
#ifdef USE_WRITE
if (0 == stat (new_filename, &st))
unlink (new_filename);
if (dwg.header.version > R_2000)
dwg.header.version = R_2000;
success = dwg_write_file (new_filename, &dwg);
free (new_filename);
#endif
dwg_free (&dwg);
return success;
}
int
main (int argc, char *argv[])
{
int i = 1;
unsigned int opts = 0;
if (argc < 2)
return usage ();
#if defined(USE_TRACING) && defined(HAVE_SETENV)
setenv ("LIBREDWG_TRACE", "1", 0);
#endif
if (argc > 2
&& (!strcmp (argv[i], "--verbose") || !strncmp (argv[i], "-v", 2)))
{
int num_args = verbosity (argc, argv, i, &opts);
argc -= num_args;
i += num_args;
}
if (argc > 1 && !strcmp (argv[i], "--help"))
return help ();
if (argc > 1 && !strcmp (argv[i], "--version"))
return opt_version ();
REQUIRE_INPUT_FILE_ARG (argc);
load_dwg (argv[i], opts);
return 0;
}
@@ -0,0 +1,76 @@
/*****************************************************************************/
/* LibreDWG - free implementation of the DWG file format */
/* */
/* Copyright (C) 2023 Free Software Foundation, Inc. */
/* */
/* 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 <http://www.gnu.org/licenses/>. */
/*****************************************************************************/
/*
* odaversion.c: prints the ODA compatible DWG version
* modified by Reini Urban
oda understands those versions:
"ACAD9","ACAD10","ACAD12",
"ACAD13","ACAD14",
"ACAD2000","ACAD2004",
"ACAD2007","ACAD2010",
"ACAD2013","ACAD2018"
*/
#include <stdio.h>
int
main (int argc, char *argv[])
{
FILE *f;
char buf[7];
size_t size;
if (argc != 2)
return 1;
f = fopen (argv[1], "rb");
if (!f)
return 1;
size = fread (buf, 1, 6, f);
if (size != 6)
return 1;
buf[6] = '\0';
if (buf[0] == 'A' && buf[1] == 'C')
{
int v;
if (1 != sscanf (buf, "AC%4d", &v))
return 1;
if (v < 1004) // <r9
printf ("\n");
else if (v <= 1005)
printf ("9\n");
else if (v <= 1006)
printf ("10\n");
else if (v <= 1009)
printf ("11\n");
else if (v <= 1012)
printf ("13\n");
else if (v <= 1014)
printf ("14\n");
else if (v <= 1016)
printf ("2000\n");
else if (v <= 1018)
printf ("2004\n");
else if (v <= 1021)
printf ("2007\n");
else if (v <= 1024)
printf ("2010\n");
else if (v < 1028)
printf ("2013\n");
else if (v < 1033)
printf ("2018\n");
else
printf ("\n");
}
fclose (f);
return 0;
}
@@ -0,0 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
unsigned char block[255];
main ()
{
int len, err;
while (!feof (stdin))
{
len = fread (block, 1, 255, stdin);
err = rs_decode_block (block, 1);
fwrite (block, 1, 239, stdout);
}
}
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
unsigned char data[239];
unsigned char parity[16];
main ()
{
int len, i;
while (!feof (stdin))
{
len = fread (data, 1, 239, stdin);
rs_encode_block (parity, data, len);
for (i = 0; i < 16; i++)
{
if (i != 0)
fputc ('-', stderr);
}
fwrite (data, 1, len, stdout);
while (len++ < 239)
fputc (0, stdout); /* Pad data with 0s */
fwrite (parity, 16, 1, stdout);
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,41 @@
# libredwg.la - a libtool library file
# Generated by libtool (GNU libtool) 2.5.4
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='../bin/libredwg-0.dll'
# Names of this library.
library_names='libredwg.dll.a'
# The name of the static archive.
old_library=''
# Linker flags that cannot go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=''
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libredwg.
current=0
age=0
revision=14
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/lib'
@@ -0,0 +1,12 @@
# libredwg.pc. Generated from libredwg.pc.in by configure.
prefix=
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libredwg
Description: Free implementation of the DWG file format
Version: 0.14
URL: https://savannah.gnu.org/projects/libredwg/
Libs: -L${libdir} -lredwg -lm
Cflags: -I${includedir}
@@ -0,0 +1,41 @@
# _LibreDWG.la - a libtool library file
# Generated by libtool (GNU libtool) 2.5.4
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='_LibreDWG.dll'
# Names of this library.
library_names='_LibreDWG.dll.a'
# The name of the static archive.
old_library=''
# Linker flags that cannot go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=' /lib/libredwg.la -L=C:/msys64/MINGW64/lib -lpython3.12 -lversion -lshlwapi -lpathcch -lbcrypt'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for _LibreDWG.
current=0
age=0
revision=0
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=yes
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/lib/python3.12/site-packages'
@@ -0,0 +1,561 @@
This is LibreDWG.info, produced by makeinfo version 7.2 from
LibreDWG.texi.
This manual is for GNU LibreDWG (version 0.14, 27 June 2026).
Copyright © 2010-2026 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, with no Front-Cover Texts,
and with no Back-Cover Texts. A copy of the license is included in
the section entitled "GNU Free Documentation License".
All other trademarks, trade names or company names referenced herein
are used for identification purposes only and are the property of their
respective owners.
DWG is the native and proprietary file format for AutoCAD® and a
trademark of Autodesk, Inc. LibreDWG is neither associated with
Autodesk, nor with the Open Design Alliance.
INFO-DIR-SECTION Libraries
START-INFO-DIR-ENTRY
* LibreDWG: (LibreDWG). Free implementation of the DWG file format.
END-INFO-DIR-ENTRY

Indirect:
LibreDWG.info-1: 1095
LibreDWG.info-2: 303901

Tag Table:
(Indirect)
Node: Top1095
Node: Overview2721
Node: Usage10452
Node: Types11183
Node: Objects13909
Node: HEADER14200
Node: ENTITIES30247
Ref: 3DFACE30440
Ref: 3DLINE30786
Ref: 3DSOLID31018
Ref: ALIGNMENTPARAMETERENTITY32363
Ref: ARC32429
Ref: ARCALIGNEDTEXT32756
Ref: ARC_DIMENSION34036
Ref: ATTDEF35421
Ref: ATTRIB36733
Ref: BASEPOINTPARAMETERENTITY38032
Ref: BLOCK38100
Ref: BODY38286
Ref: CAMERA38321
Ref: CIRCLE38418
Ref: DGNUNDERLAY38656
Ref: UNDERLAY38656
Ref: DIMENSION_ALIGNED39243
Ref: DIMENSION_ANG2LN40375
Ref: DIMENSION_ANG3PT41563
Ref: DIMENSION_DIAMETER42732
Ref: DIMENSION_LINEAR43821
Ref: DIMENSION_ORDINATE45000
Ref: DIMENSION_RADIUS46129
Ref: DWFUNDERLAY47213
Ref: ELLIPSE47250
Ref: ENDBLK47572
Ref: ENDREP47641
Ref: EXTRUDEDSURFACE47885
Ref: FLIPGRIPENTITY50489
Ref: FLIPPARAMETERENTITY50571
Ref: GEOPOSITIONMARKER50651
Ref: HATCH51401
Ref: HELIX52654
Ref: IMAGE53951
Ref: INSERT54708
Ref: JUMP55444
Ref: LARGE_RADIAL_DIMENSION55668
Ref: LAYOUTPRINTCONFIG56837
Ref: LEADER56981
Ref: LIGHT58131
Ref: LINE60261
Ref: LINEARGRIPENTITY60572
Ref: LINEARPARAMETERENTITY60656
Ref: LOAD60723
Ref: LOFTEDSURFACE60840
Ref: LWPOLYLINE63218
Ref: MESH63818
Ref: MINSERT64479
Ref: MLINE65174
Ref: MPOLYGON65626
Ref: MTEXT66784
Ref: MULTILEADER68234
Ref: NAVISWORKSMODEL70082
Ref: NURBSURFACE70325
Ref: OLE2FRAME71987
Ref: OLEFRAME72414
Ref: PDFUNDERLAY72634
Ref: PLANESURFACE72676
Ref: POINT74181
Ref: POINTCLOUD74479
Ref: POINTCLOUDEX75499
Ref: POINTPARAMETERENTITY77032
Ref: POLARGRIPENTITY77110
Ref: POLYLINE_2D77184
Ref: POLYLINE_3D77917
Ref: POLYLINE_MESH78410
Ref: POLYLINE_PFACE78947
Ref: PROXY_ENTITY79349
Ref: RAY79942
Ref: REGION80090
Ref: REPEAT80125
Ref: REVOLVEDSURFACE80203
Ref: ROTATIONGRIPENTITY82280
Ref: ROTATIONPARAMETERENTITY82366
Ref: RTEXT82434
Ref: SECTIONOBJECT82784
Ref: SEQEND83409
Ref: SHAPE83516
Ref: SOLID83955
Ref: SPLINE84315
Ref: SWEPTSURFACE85173
Ref: TABLE87891
Ref: TEXT94167
Ref: TOLERANCE94880
Ref: TRACE95247
Ref: UNKNOWN_ENT95612
Ref: VERTEX_2D95684
Ref: VERTEX_3D96035
Ref: VERTEX_MESH96185
Ref: VERTEX_PFACE96228
Ref: VERTEX_PFACE_FACE96276
Ref: VIEWPORT96425
Ref: VISIBILITYGRIPENTITY98425
Ref: VISIBILITYPARAMETERENTITY98513
Ref: WIPEOUT98583
Ref: XLINE99339
Ref: XYGRIPENTITY99376
Ref: XYPARAMETERENTITY99456
Node: OBJECTS99514
Ref: ACMECOMMANDHISTORY99706
Ref: ACMESCOPE99816
Ref: ACMESTATEMGR99929
Ref: ACSH_BOOLEAN_CLASS100048
Ref: ACSH_BOX_CLASS100425
Ref: ACSH_BREP_CLASS100793
Ref: ACSH_CHAMFER_CLASS102306
Ref: ACSH_CONE_CLASS102798
Ref: ACSH_CYLINDER_CLASS103224
Ref: ACSH_EXTRUSION_CLASS103651
Ref: ACSH_FILLET_CLASS104981
Ref: ACSH_HISTORY_CLASS105631
Ref: ACSH_LOFT_CLASS105956
Ref: ACSH_PYRAMID_CLASS106367
Ref: ACSH_REVOLVE_CLASS106780
Ref: ACSH_SPHERE_CLASS107492
Ref: ACSH_SWEEP_CLASS107784
Ref: ACSH_TORUS_CLASS109113
Ref: ACSH_WEDGE_CLASS109456
Ref: ALDIMOBJECTCONTEXTDATA109831
Ref: ANGDIMOBJECTCONTEXTDATA110137
Ref: ANNOTSCALEOBJECTCONTEXTDATA110443
Ref: APPID110638
Ref: APPID_CONTROL111010
Ref: ASSOC2DCONSTRAINTGROUP111250
Ref: ASSOC3POINTANGULARDIMACTIONBODY112193
Ref: ASSOCACTION112661
Ref: ASSOCACTIONPARAM113266
Ref: ASSOCALIGNEDDIMACTIONBODY113474
Ref: ASSOCARRAYACTIONBODY113910
Ref: ASSOCARRAYMODIFYACTIONBODY114229
Ref: ASSOCASMBODYACTIONPARAM114675
Ref: ASSOCBLENDSURFACEACTIONBODY116237
Ref: ASSOCCOMPOUNDACTIONPARAM116823
Ref: ASSOCDEPENDENCY117469
Ref: ASSOCDIMDEPENDENCYBODY118160
Ref: ASSOCEDGEACTIONPARAM118416
Ref: ASSOCEDGECHAMFERACTIONBODY118914
Ref: ASSOCEDGEFILLETACTIONBODY119198
Ref: ASSOCEXTENDSURFACEACTIONBODY119485
Ref: ASSOCEXTRUDEDSURFACEACTIONBODY119860
Ref: ASSOCFACEACTIONPARAM120185
Ref: ASSOCFILLETSURFACEACTIONBODY120568
Ref: ASSOCGEOMDEPENDENCY121005
Ref: ASSOCLOFTEDSURFACEACTIONBODY121340
Ref: ASSOCMLEADERACTIONBODY121667
Ref: ASSOCNETWORK122118
Ref: ASSOCNETWORKSURFACEACTIONBODY123029
Ref: ASSOCOBJECTACTIONPARAM123356
Ref: ASSOCOFFSETSURFACEACTIONBODY123701
Ref: ASSOCORDINATEDIMACTIONBODY124067
Ref: ASSOCOSNAPPOINTREFACTIONPARAM124512
Ref: ASSOCPATCHSURFACEACTIONBODY125290
Ref: ASSOCPATHACTIONPARAM125615
Ref: ASSOCPERSSUBENTMANAGER126308
Ref: ASSOCPLANESURFACEACTIONBODY128253
Ref: ASSOCPOINTREFACTIONPARAM128582
Ref: ASSOCRESTOREENTITYSTATEACTIONBODY129246
Ref: ASSOCREVOLVEDSURFACEACTIONBODY129468
Ref: ASSOCROTATEDDIMACTIONBODY129798
Ref: ASSOCSWEPTSURFACEACTIONBODY130241
Ref: ASSOCTRIMSURFACEACTIONBODY130572
Ref: ASSOCVALUEDEPENDENCY131008
Ref: ASSOCVARIABLE131141
Ref: ASSOCVERTEXACTIONPARAM132099
Ref: BLKREFOBJECTCONTEXTDATA132475
Ref: BLOCKALIGNEDCONSTRAINTPARAMETER132825
Ref: BLOCKALIGNMENTGRIP133978
Ref: BLOCKALIGNMENTPARAMETER134551
Ref: BLOCKANGULARCONSTRAINTPARAMETER135542
Ref: BLOCKARRAYACTION136838
Ref: BLOCKBASEPOINTPARAMETER137495
Ref: BLOCKDIAMETRICCONSTRAINTPARAMETER138168
Ref: BLOCKFLIPACTION139370
Ref: BLOCKFLIPGRIP140043
Ref: BLOCKFLIPPARAMETER140722
Ref: BLOCKGRIPLOCATIONCOMPONENT141973
Ref: BLOCKHORIZONTALCONSTRAINTPARAMETER142197
Ref: BLOCKLINEARCONSTRAINTPARAMETER143362
Ref: BLOCKLINEARGRIP144512
Ref: BLOCKLINEARPARAMETER145082
Ref: BLOCKLOOKUPACTION146195
Ref: BLOCKLOOKUPGRIP146935
Ref: BLOCKLOOKUPPARAMETER147457
Ref: BLOCKMOVEACTION148190
Ref: BLOCKPARAMDEPENDENCYBODY148892
Ref: BLOCKPOINTPARAMETER149147
Ref: BLOCKPOLARGRIP149860
Ref: BLOCKPOLARPARAMETER150381
Ref: BLOCKPOLARSTRETCHACTION151653
Ref: BLOCKPROPERTIESTABLE152494
Ref: BLOCKPROPERTIESTABLEGRIP152581
Ref: BLOCKRADIALCONSTRAINTPARAMETER153113
Ref: BLOCKREPRESENTATION154270
Ref: BLOCKROTATEACTION154425
Ref: BLOCKROTATIONGRIP155112
Ref: BLOCKROTATIONPARAMETER155636
Ref: BLOCKSCALEACTION156798
Ref: BLOCKSTRETCHACTION157486
Ref: BLOCKUSERPARAMETER158460
Ref: BLOCKVERTICALCONSTRAINTPARAMETER159252
Ref: BLOCKVISIBILITYGRIP160406
Ref: BLOCKVISIBILITYPARAMETER160932
Ref: BLOCKXYGRIP161877
Ref: BLOCKXYPARAMETER162395
Ref: BLOCK_CONTROL163680
Ref: BLOCK_HEADER163980
Ref: BREAKDATA165294
Ref: BREAKPOINTREF165498
Ref: CELLSTYLEMAP165573
Ref: CONTEXTDATAMANAGER165749
Ref: CSACDOCUMENTOPTIONS165957
Ref: CURVEPATH166067
Ref: DATALINK166223
Ref: DATATABLE167177
Ref: DBCOLOR167456
Ref: DETAILVIEWSTYLE167573
Ref: DICTIONARY169292
Ref: DICTIONARYVAR169570
Ref: DICTIONARYWDFLT169727
Ref: DIMASSOC170042
Ref: DIMSTYLE170378
Ref: DIMSTYLE_CONTROL174070
Ref: DMDIMOBJECTCONTEXTDATA174406
Ref: DUMMY174736
Ref: DYNAMICBLOCKPROXYNODE174820
Ref: DYNAMICBLOCKPURGEPREVENTER174952
Ref: EVALUATION_GRAPH175097
Ref: FCFOBJECTCONTEXTDATA175522
Ref: FIELD175802
Ref: FIELDLIST176682
Ref: GEODATA176866
Ref: GEOMAPIMAGE178721
Ref: GRADIENT_BACKGROUND179768
Ref: GROUND_PLANE_BACKGROUND180158
Ref: GROUP180578
Ref: IBL_BACKGROUND180850
Ref: IDBUFFER181181
Ref: IMAGEDEF181361
Ref: IMAGEDEF_REACTOR181698
Ref: IMAGE_BACKGROUND181823
Ref: INDEX182206
Ref: LAYER182324
Ref: LAYERFILTER183090
Ref: LAYER_CONTROL183238
Ref: LAYER_INDEX183467
Ref: LAYOUT183668
Ref: LEADEROBJECTCONTEXTDATA184636
Ref: LIGHTLIST185106
Ref: LONG_TRANSACTION185323
Ref: LTYPE185391
Ref: LTYPE_CONTROL186093
Ref: MATERIAL186381
Ref: MENTALRAYRENDERSETTINGS188206
Ref: MLEADEROBJECTCONTEXTDATA191009
Ref: MLEADERSTYLE191211
Ref: MLINESTYLE193258
Ref: MOTIONPATH193665
Ref: MTEXTATTRIBUTEOBJECTCONTEXTDATA194062
Ref: MTEXTOBJECTCONTEXTDATA194542
Ref: NAVISWORKSMODELDEF195372
Ref: OBJECT_PTR195701
Ref: ORDDIMOBJECTCONTEXTDATA195787
Ref: PARTIAL_VIEWING_INDEX196146
Ref: PERSUBENTMGR196354
Ref: PLACEHOLDER196818
Ref: PLOTSETTINGS196893
Ref: POINTCLOUDCOLORMAP198272
Ref: POINTCLOUDDEF198813
Ref: POINTCLOUDDEFEX199159
Ref: POINTCLOUDDEF_REACTOR199511
Ref: POINTCLOUDDEF_REACTOR_EX199644
Ref: POINTPATH199762
Ref: PROXY_OBJECT199922
Ref: RADIMLGOBJECTCONTEXTDATA200428
Ref: RADIMOBJECTCONTEXTDATA200776
Ref: RAPIDRTRENDERSETTINGS201082
Ref: RASTERVARIABLES201997
Ref: RENDERENTRY202245
Ref: RENDERENVIRONMENT203123
Ref: RENDERGLOBAL203781
Ref: RENDERSETTINGS204268
Ref: SCALE204808
Ref: SECTIONVIEWSTYLE205099
Ref: SECTION_MANAGER207330
Ref: SECTION_SETTINGS207535
Ref: SKYLIGHT_BACKGROUND207754
Ref: SOLID_BACKGROUND207917
Ref: SORTENTSTABLE208078
Ref: SPATIAL_FILTER208302
Ref: SPATIAL_INDEX208879
Ref: STYLE209199
Ref: STYLE_CONTROL209901
Ref: SUN210122
Ref: SUNSTUDY210661
Ref: TABLECONTENT211932
Ref: TABLEGEOMETRY212190
Ref: TABLESTYLE212436
Ref: TEXTOBJECTCONTEXTDATA213298
Ref: TVDEVICEPROPERTIES213681
Ref: UCS214082
Ref: UCS_CONTROL214783
Ref: UNKNOWN_OBJ215010
Ref: VBA_PROJECT215084
Ref: VIEW215231
Ref: VIEW_CONTROL217000
Ref: VISUALSTYLE217228
Ref: VPORT223233
Ref: VPORT_CONTROL225472
Ref: VX_CONTROL225700
Ref: VX_TABLE_RECORD225930
Ref: WIPEOUTVARIABLES226532
Ref: XRECORD226648
Ref: PDFDEFINITION226962
Ref: UNDERLAYDEFINITION226962
Ref: DGNDEFINITION227112
Ref: DWFDEFINITION227165
Ref: ASSOCARRAYMODIFYPARAMETERS227231
Ref: ASSOCARRAYPARAMETERS227231
Ref: ASSOCARRAYPATHPARAMETERS227568
Ref: ASSOCARRAYPOLARPARAMETERS227635
Ref: ASSOCARRAYRECTANGULARPARAMETERS227708
Ref: Dwg_3DSOLID_material227770
Ref: Dwg_3DSOLID_silhouette227966
Ref: Dwg_3DSOLID_wire228340
Ref: Dwg_ACSH_HistoryNode228941
Ref: Dwg_ACSH_SubentColor229163
Ref: Dwg_ACSH_SubentMaterial229360
Ref: Dwg_ACTIONBODY229515
Ref: Dwg_ARRAYITEMLOCATOR229703
Ref: Dwg_ASSOCACTIONBODY_action229844
Ref: Dwg_ASSOCACTION_Deps230009
Ref: Dwg_ASSOCARRAYITEM230154
Ref: Dwg_ASSOCPARAMBASEDACTIONBODY230615
Ref: Dwg_ASSOCSURFACEACTIONBODY231001
Ref: Dwg_AcDbMTextObjectEmbedded231290
Ref: Dwg_AcDs233055
Ref: Dwg_AcDs_Data234002
Ref: Dwg_AcDs_DataBlob234136
Ref: Dwg_AcDs_DataBlob01234418
Ref: Dwg_AcDs_DataBlobRef234685
Ref: Dwg_AcDs_DataBlobRef_Page234985
Ref: Dwg_AcDs_DataIndex235071
Ref: Dwg_AcDs_DataIndex_Entry235229
Ref: Dwg_AcDs_Data_Record235350
Ref: Dwg_AcDs_Data_RecordHdr235445
Ref: Dwg_AcDs_Schema235598
Ref: Dwg_AcDs_SchemaData235774
Ref: Dwg_AcDs_SchemaData_UProp236052
Ref: Dwg_AcDs_SchemaIndex236139
Ref: Dwg_AcDs_SchemaIndex_Prop236468
Ref: Dwg_AcDs_Schema_Prop236588
Ref: Dwg_AcDs_Search236870
Ref: Dwg_AcDs_Search_Data236983
Ref: Dwg_AcDs_Search_IdIdx237244
Ref: Dwg_AcDs_Search_IdIdxs237372
Ref: Dwg_AcDs_Segment237480
Ref: Dwg_AcDs_SegmentIndex237924
Ref: Dwg_BLOCKACTION_connectionpts238022
Ref: Dwg_BLOCKLOOKUPACTION_lut238113
Ref: Dwg_BLOCKPARAMETER_PropInfo238348
Ref: Dwg_BLOCKPARAMETER_connection238489
Ref: Dwg_BLOCKPARAMVALUESET238576
Ref: Dwg_BLOCKSTRETCHACTION_codes238842
Ref: Dwg_BLOCKSTRETCHACTION_handles239069
Ref: Dwg_BLOCKVISIBILITYPARAMETER_state239299
Ref: Dwg_COMPOUNDOBJECTID239603
Ref: Dwg_CONSTRAINTGROUPNODE239781
Ref: Dwg_CONTEXTDATA_dict240019
Ref: Dwg_CONTEXTDATA_submgr240187
Ref: Dwg_CellContentGeometry240410
Ref: Dwg_CellStyle240854
Ref: Dwg_ColorRamp241760
Ref: Dwg_ContentFormat241977
Ref: Dwg_DATALINK_customdata242518
Ref: Dwg_DATATABLE_column242670
Ref: Dwg_DATATABLE_row242870
Ref: Dwg_DIMASSOC_Ref242995
Ref: Dwg_DIMENSION_common243829
Ref: Dwg_EVAL_Edge244826
Ref: Dwg_EVAL_Node245129
Ref: Dwg_EvalExpr245440
Ref: Dwg_EvalVariant245881
Ref: Dwg_FIELD_ChildValue246117
Ref: Dwg_FileDepList_Files246278
Ref: Dwg_FormattedTableData246625
Ref: Dwg_FormattedTableMerged246872
Ref: Dwg_GEODATA_meshface247126
Ref: Dwg_GEODATA_meshpt247242
Ref: Dwg_GridFormat247332
Ref: Dwg_HATCH_Color247750
Ref: Dwg_HATCH_ControlPoint247918
Ref: Dwg_HATCH_DefLine248076
Ref: Dwg_HATCH_Path248350
Ref: Dwg_HATCH_PathSeg248808
Ref: Dwg_HATCH_PolylinePath249802
Ref: Dwg_LAYER_entry249954
Ref: Dwg_LEADER_ArrowHead250158
Ref: Dwg_LEADER_BlockLabel250331
Ref: Dwg_LEADER_Break250578
Ref: Dwg_LEADER_Line250730
Ref: Dwg_LEADER_Node251284
Ref: Dwg_LIGHTLIST_light251864
Ref: Dwg_LTYPE_dash252016
Ref: Dwg_LWPOLYLINE_width252464
Ref: Dwg_LinkedData252560
Ref: Dwg_LinkedTableData252666
Ref: Dwg_MATERIAL_color252935
Ref: Dwg_MATERIAL_gentexture253109
Ref: Dwg_MATERIAL_mapper253287
Ref: Dwg_MESH_edge253733
Ref: Dwg_MLEADER_AnnotContext253896
Ref: Dwg_MLEADER_Content_Block254862
Ref: Dwg_MLEADER_Content_MText255155
Ref: Dwg_MLINESTYLE_line256154
Ref: Dwg_MLINE_line256393
Ref: Dwg_MLINE_vertex256639
Ref: Dwg_OCD_Dimension256934
Ref: Dwg_PARTIAL_VIEWING_INDEX_Entry257557
Ref: Dwg_POINTCLOUDCOLORMAP_Ramp257766
Ref: Dwg_POINTCLOUDEX_Croppings257997
Ref: Dwg_POINTCLOUD_Clippings258418
Ref: Dwg_POINTCLOUD_IntensityStyle258710
Ref: Dwg_PROXY_LWPOLYLINE258968
Ref: Dwg_R2004_Header259577
Ref: Dwg_SECTION_geometrysettings260693
Ref: Dwg_SECTION_typesettings261465
Ref: Dwg_SPLINE_control_point261905
Ref: Dwg_SUNSTUDY_Dates262098
Ref: Dwg_SummaryInfo_Property262211
Ref: Dwg_TABLEGEOMETRY_Cell262301
Ref: Dwg_TABLESTYLE_CellStyle262677
Ref: Dwg_TABLESTYLE_border263878
Ref: Dwg_TABLESTYLE_rowstyles264004
Ref: Dwg_TABLE_AttrDef264548
Ref: Dwg_TABLE_BreakHeight264744
Ref: Dwg_TABLE_BreakRow264918
Ref: Dwg_TABLE_Cell265086
Ref: Dwg_TABLE_CustomDataItem266797
Ref: Dwg_TABLE_value267010
Ref: Dwg_TableCell267603
Ref: Dwg_TableCellContent268562
Ref: Dwg_TableCellContent_Attr268968
Ref: Dwg_TableDataColumn269169
Ref: Dwg_TableRow269439
Ref: Dwg_UCS_orthopts269850
Ref: Dwg_VALUEPARAM269997
Ref: Dwg_VALUEPARAM_vars270300
Ref: Dwg_MLEADER_Content270400
Ref: Common Entity fields270530
Ref: Common Object fields272376
Node: Sections272806
Node: HEADER_275138
Node: OBJECTS_275272
Node: CLASSES275603
Node: HANDLES277004
Node: R2004_Header277389
Node: UNKNOWN277681
Node: SummaryInfo277903
Node: Preview278707
Node: VBAProject279072
Node: AppInfo279192
Node: AppInfoHistory279368
Node: FileDepList279506
Node: AcDS279709
Node: RevHistory279910
Node: Security280048
Node: ObjFreeSpace280187
Node: Template280341
Node: AuxHeader280507
Node: Signature280669
Node: INFO280787
Node: SYSTEM_MAP280928
Node: Tables281099
Node: EXTRAS282602
Node: Structures285278
Node: EED285475
Node: XDATA287871
Node: Functions288217
Node: Decoding289677
Node: Encoding292452
Node: add api295016
Node: dynapi299155
Node: strings303901
Node: Other Formats305975
Node: DXF306315
Node: DXFB306997
Node: JSON307299
Node: GeoJSON308336
Node: Errors309362
Node: Programs310702
Ref: dwgread310889
Ref: dwgwrite311461
Ref: dxfwrite311679
Ref: dwg2dxf311908
Ref: dxf2dwg312409
Ref: dwgrewrite312836
Ref: dwglayers313009
Ref: dwggrep313642
Ref: dwgfilter314143
Ref: dwg2SVG314431
Ref: dwg2ps314976
Ref: dwgplot315456
Ref: load_dwg315719
Ref: dwg2svg2315776
Ref: unknown316094
Ref: dwgfuzz316357
Ref: dwgadd317154
Node: Bindings317420
Node: Reference API318052
Node: Reporting bugs318583
Node: GNU Free Documentation License320363
Node: Index345517
Node: General Index345753
Node: Object and Field Index377436

End Tag Table

Local Variables:
coding: utf-8
End:
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,18 @@
This is the file .../info/dir, which contains the
topmost node of the Info hierarchy, called (dir)Top.
The first time you invoke Info you start off looking at this node.

File: dir, Node: Top This is the top of the INFO tree
This (the Directory node) gives a menu of major topics.
Typing "q" exits, "H" lists all Info commands, "d" returns here,
"h" gives a primer for first-timers,
"mEmacs<Return>" visits the Emacs manual, etc.
In Emacs, you can click mouse button 2 on a menu item or cross reference
to select it.
* Menu:
Libraries
* LibreDWG: (LibreDWG). Free implementation of the DWG file format.
@@ -0,0 +1,65 @@
# example dwgadd file. strings are utf8 and must not exceed length 255
#readdwg "example_2000.dwg"
#readdxf "example_2000.dxf"
#readjson "example_2000.json"
#version 2000
HEADER.VIEWSIZE = 1.2345
HEADER.ANGBASE = 90
HEADER.LUPREC = 3
HEADER.MENU = "other"
HEADER.INSBASE = (1 0 0)
HEADER.LIMMIN = (12 9)
point (2 0 0)
text "test" (0.0 1.0 0.0) 8
block "bloko"
attdef 8 0 "prompt" (0.0 1.0 0.0) TAG "default_text"
line (0 1 0) (1 1 0)
endblk
insert (0 1 0) "bloko" 1 1 1 0
attrib 8 0 (0.0 2.0 0.0) TAG "text1"
minsert (0 1 0) "bloko" 1 1 1 0 1 2 1 1
minsert.rotation = 90
polyline_2d 2 ((0 1) (1 1))
polyline_3d 2 ((0 1 0.5) (1 1 -0.5))
lwpolyline 2 ((0 1) (1 1))
arc (0.0 1.0 0.0) 0.5 0.0 3.0
circle (0.0 1.0 0.0) 0.5
polyline_pface 5 3 ((0 0 1) (2 0 1) (2 2 0) (1 2 0.5) (1 1 -0.5)) ((0 1 2 3) (1 2 -3 4) (2 -3 4))
polyline_mesh 3 2 ((0 0 1) (2 0 2) (2 2 1) (1 2 0.5) (1 1 -1) (0 1 0))
dimension_aligned (0 0 0) (2 0 0) (2 2 0)
dimension_ang2ln (0 0 0) (2 0 0) (2 2 0) (2 2 0)
dimension_ang3pt (0 0 0) (2 0 0) (2 1 0) (2 2 0)
dimension_diameter (0 0 0) (2 0 0) 2
dimension_ordinate (0 0 0) (2 0 0) 1
dimension_radius (0 0 0) (2 0 0) 1
dimension_linear (2 0 0) (2 1 0) (0 0 0) 90
3dface (0 0 0) (2 0 0) (2 1 0) (0 2 0)
solid (0 0 0) (2 0) (2 1) (0 2)
trace (0 0 0) (2 0) (2 1) (0 2)
shape "roman.shx" (0 0 0) 2 45
ellipse (0 0 0) 2.0 0.75
spline 3 ((0 0 0) (2 0 0) (2 1 0)) (0 2 0) (0 3 0)
ray (0 0 0) (2 0 0)
xline (0 0 0) (2 0 0)
dictionary "ACAD_MATERIAL" "Global" 0
xrecord dictionary "REFRACTIONTILE"
mtext (0 1 0) 10 "test\ntext"
leader 2 ((0 0 0) (0 1 0)) mtext 15
tolerance "testtekst" (0 0 0) (0 0 1)
mlinestyle "Double"
mlinestyle.start_angle = 45
mline 4 ((3.9 1.5 0) (3.2 1.8 0) (4.6 1.0 0) (3.8 1.7 0))
dimstyle "Dim1"
dimstyle.DIMSCALE = 2.0
dimstyle.DIMUPT = 1
ucs (0 1 0) (1 0 0) (0 0 1) "Ucs1"
ucs.ucs_elevation = 1.0
viewport "Viewport1"
layout viewport "Model" "ANSI_A_(8.50_x_11.00_Inches)"
torus (10 5 0) (0 0 1) 19 2.78
sphere (10 5 0) (0 0 1) 15
cylinder (10 5 0) (0 0 1) 15 5 5 5
cone (10 5 0) (0 0 1) 15 5 5 0
wedge (10 5 0) (0 0 1) 3.3 2.4 4.8
box (10 5 0) (0 0 1) 3.3 2.0 2.5
pyramid (10 5 0) (0 0 1) 4.5 4 2.0 2.5
@@ -0,0 +1,32 @@
# example dwgadd file for r10. strings are utf8 and must not exceed length 255
HEADER.VIEWSIZE = 1.2345
HEADER.ANGBASE = 90
HEADER.LUPREC = 3
HEADER.MENU = "other"
HEADER.INSBASE = (1 0 0)
HEADER.LIMMIN = (12 9)
point (2 0 0)
text "test" (0.0 1.0 0.0) 8
block "BLOKO"
attdef 8 0 "prompt" (0.0 1.0 0.0) TAG "default_text"
line (0 1 0) (1 1 0)
endblk
insert (0 1 0) "BLOKO" 1 1 1 0
attrib 8 0 (0.0 2.0 0.0) TAG "text1"
polyline_2d 2 ((0 1) (1 1))
polyline_3d 2 ((0 1 0) (1 1 0))
arc (0.0 1.0 0.0) 0.5 0.0 3.0
circle (0.0 1.0 0.0) 0.5
polyline_pface 5 3 ((0 0 0) (2 0 0) (2 2 0) (1 2 0) (1 1 0)) ((0 1 2 3) (1 2 3 4) (2 3 4 5))
polyline_mesh 3 2 ((0 0 0) (2 0 0) (2 2 0) (1 2 0) (1 1 0) (0 1 0))
dimension_aligned (0 0 0) (2 0 0) (2 2 0)
dimension_ang2ln (0 0 0) (2 0 0) (2 2 0) (2 2 0)
dimension_ang3pt (0 0 0) (2 0 0) (2 1 0) (2 2 0)
dimension_diameter (0 0 0) (2 0 0) 2
dimension_ordinate (0 0 0) (2 0 0) 1
dimension_radius (0 0 0) (2 0 0) 1
dimension_linear (2 0 0) (2 1 0) (0 0 0) 90
3dface (0 0 0) (2 0 0) (2 1 0) (0 2 0)
solid (0 0 0) (2 0) (2 1) (0 2)
trace (0 0 0) (2 0) (2 1) (0 2)
shape "ROMAN.SHX" (0 0 0) 2 45
@@ -0,0 +1,40 @@
# example dwgadd file for r11. strings are utf8 and must not exceed length 255
HEADER.VIEWSIZE = 1.2345
HEADER.ANGBASE = 90
HEADER.LUPREC = 3
HEADER.MENU = "other"
HEADER.INSBASE = (1 0 0)
HEADER.LIMMIN = (12 9)
point (2 0 0)
text "test" (0.0 1.0 0.0) 8
block "BLOKO"
attdef 8 0 "prompt" (0.0 1.0 0.0) TAG "default_text"
line (0 1 0) (1 1 0)
endblk
insert (0 1 0) "BLOKO" 1 1 1 0
attrib 8 0 (0.0 2.0 0.0) TAG "text1"
polyline_2d 2 ((0 1) (1 1))
polyline_3d 2 ((0 1 0.5) (1 1 -0.5))
arc (0.0 1.0 0.0) 0.5 0.0 3.0
circle (0.0 1.0 0.0) 0.5
polyline_pface 5 3 ((0 0 1) (2 0 1) (2 2 0) (1 2 0.5) (1 1 -0.5)) ((0 1 2 3) (1 2 -3 4) (2 -3 4))
polyline_mesh 3 2 ((0 0 1) (2 0 2) (2 2 1) (1 2 0.5) (1 1 -1) (0 1 0))
dimension_aligned (0 0 0) (2 0 0) (2 2 0)
dimension_ang2ln (0 0 0) (2 0 0) (2 2 0) (2 2 0)
dimension_ang3pt (0 0 0) (2 0 0) (2 1 0) (2 2 0)
dimension_diameter (0 0 0) (2 0 0) 2
dimension_ordinate (0 0 0) (2 0 0) 1
dimension_radius (0 0 0) (2 0 0) 1
dimension_linear (2 0 0) (2 1 0) (0 0 0) 90
3dface (0 0 0) (2 0 0) (2 1 0) (0 2 0)
solid (0 0 0) (2 0) (2 1) (0 2)
trace (0 0 0) (2 0) (2 1) (0 2)
shape "ROMAN.SHX" (0 0 0) 2 45
dimstyle "DIM1"
dimstyle.DIMSCALE = 2.0
dimstyle.DIMUPT = 1
ucs (0 1 0) (1 0 0) (0 0 1) "UCS1"
ucs.ucs_elevation = 1.0
layer "FOO"
line (0 0 0) (100 0 100)
line.layer = "FOO"
@@ -0,0 +1,16 @@
# example dwgadd file for r1.4. strings are utf8 and must not exceed length 255
HEADER.TEXTSIZE = 1.2345
HEADER.LUPREC = 3
HEADER.INSBASE = (1 0)
HEADER.LIMMIN = (12 9)
point (2 0 0)
text "test" (0.0 1.0 0.0) 8
block "BLOKO"
line (0 1 0) (1 1 0)
endblk
insert (0 1 0) "BLOKO" 1 1 1 0
arc (0.0 1.0 0.0) 0.5 0.0 3.0
circle (0.0 1.0 0.0) 0.5
solid (0 0 0) (2 0) (2 1) (0 2)
trace (0 0 0) (2 0) (2 1) (0 2)
shape "ROMAN.SHX" (0 0 0) 2 45
@@ -0,0 +1,23 @@
# example dwgadd file for r2.10. strings are utf8 and must not exceed length 255
HEADER.VIEWSIZE = 1.2345
HEADER.LUPREC = 3
HEADER.MENU = "other"
HEADER.INSBASE = (1 0 0)
HEADER.LIMMIN = (12 9)
point (2 0 0)
text "test" (0.0 1.0 0.0) 8
block "BLOKO"
attdef 8 0 "prompt" (0.0 1.0 0.0) TAG "default_text"
line (0 1 0) (1 1 0)
endblk
insert (0 1 0) "BLOKO" 1 1 1 0
attrib 8 0 (0.0 2.0 0.0) TAG "text1"
polyline_2d 2 ((0 1) (2 3))
polyline_3d 2 ((0 1 2) (3 4 5))
arc (0.0 1.0 0.0) 0.5 0.0 3.0
circle (0.0 1.0 0.0) 0.5
polyline_pface 5 3 ((0 0 0) (2 0 0) (2 2 0) (1 2 0) (1 1 0)) ((0 1 2 3) (1 2 3 4) (2 3 4 5))
polyline_mesh 3 2 ((0 0 0) (2 0 0) (2 2 0) (1 2 0) (1 1 0) (0 1 0))
solid (0 0 0) (2 0) (2 1) (0 2)
trace (0 0 0) (2 0) (2 1) (0 2)
shape "ROMAN.SHX" (0 0 0) 2 45
@@ -0,0 +1,36 @@
#! /usr/bin/env python3
from libredwg import (
Dwg_Data,
dwg_read_file,
new_Dwg_Object_Array,
Dwg_Object_Array_getitem,
)
import sys
if len(sys.argv) != 2:
print("Usage: load_dwg.py <filename>")
exit()
filename = sys.argv[1]
a = Dwg_Data()
a.object = new_Dwg_Object_Array(1000)
error = dwg_read_file(filename, a)
if error > 0: # critical errors
print("Error: ", error)
if error > 127:
exit()
print(".dwg version: %s" % a.header.version)
print("Num objects: %d " % a.num_objects)
# XXX TODO Error: Dwg_Object_LAYER_CONTROL object has no attribute 'tio'
# print "Num layers: %d" % a.layer_control.tio.object.tio.LAYER_CONTROL.num_entries
# XXX ugly, but works
for i in range(0, a.num_objects):
obj = Dwg_Object_Array_getitem(a.object, i)
print(" Supertype: ", obj.supertype)
print(" Type: ", obj.type)
@@ -0,0 +1,38 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWG2SVG "1" "June 2026" "dwg2SVG 0.14" "User Commands"
.SH NAME
dwg2SVG \- manual page for dwg2SVG 0.14
.SH SYNOPSIS
.B dwg2SVG
[\fI\,OPTION\/\fR]... \fI\,DWGFILE >SVGFILE\/\fR
.SH DESCRIPTION
Converts some 2D elements of the DWG to a SVG.
.TP
\fB\-v[0\-9]\fR, \fB\-\-verbose\fR [0\-9]
verbosity
.TP
\fB\-\-mspace\fR
only model\-space, no paper\-space
.TP
\fB\-\-force\-free\fR
force free
.TP
\fB\-\-help\fR
display this help and exit
.TP
\fB\-\-version\fR
output version information and exit
.PP
GNU LibreDWG online manual: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dwg2SVG
is maintained as a Texinfo manual. If the
.B info
and
.B dwg2SVG
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,57 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWG2DXF "1" "June 2026" "dwg2dxf 0.14" "User Commands"
.SH NAME
dwg2dxf \- manual page for dwg2dxf 0.14
.SH SYNOPSIS
.B dwg2dxf
[\fI\,OPTION\/\fR]... \fI\,DWGFILES\/\fR...
.SH DESCRIPTION
Converts DWG files to DXF.
Default DXFFILE: DWGFILE with .dxf extension (.dxb with \fB\-b\fR) in the current directory.
Existing files are not overwritten, unless \fB\-y\fR is given.
.TP
\fB\-v[0\-9]\fR, \fB\-\-verbose\fR [0\-9]
verbosity
.TP
\fB\-\-as\fR rNNNN
save as version
.IP
Valid versions:
.IP
r12, r14, r2000, r2004, r2007, r2010, r2013, r2018
.IP
Experimental versions:
.IP
r9, r10, r11
.TP
\fB\-m\fR, \fB\-\-minimal\fR
only $ACADVER, HANDSEED and ENTITIES
.TP
\fB\-b\fR, \fB\-\-binary\fR
save as binary DXB
.TP
\fB\-y\fR, \fB\-\-overwrite\fR
overwrite existing files
.TP
\fB\-o\fR outfile, \fB\-\-file\fR
optional, only valid with one single DWGFILE
.TP
\fB\-\-help\fR
display this help and exit
.TP
\fB\-\-version\fR
output version information and exit
.PP
GNU LibreDWG online manual: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dwg2dxf
is maintained as a Texinfo manual. If the
.B info
and
.B dwg2dxf
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,52 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWGADD "1" "June 2026" "dwgadd 0.14" "User Commands"
.SH NAME
dwgadd \- manual page for dwgadd 0.14
.SH SYNOPSIS
.B dwgadd
[\fI\,OPTIONS\/\fR] \fI\,-o outfile addfile\/\fR
.SH DESCRIPTION
Create a DWG (or DXF, JSON) by adding entities with instructions from a special dwgadd file.
See `man 5 dwgadd`
.TP
\fB\-\-dxf\fR:
write DXF, not DWG
.HP
\fB\-\-binary\fR: write binary DXF, not DWG
.TP
\fB\-\-json\fR:
write JSON, not DWG
.TP
\fB\-v[0\-9]\fR, \fB\-\-verbose\fR [0\-9]
verbosity
.TP
\fB\-\-as\fR rNNNN
save as version
.IP
Valid versions:
.IP
r1.1, r1.2, r1.4, r2.6, r2.10, r9, r10, r11, r13, r14, r2000 (default), r2004
.IP
Planned versions:
.IP
r2007, r2010, r2013, r2018
.HP
\fB\-o\fR outfile, \fB\-\-file\fR outfile (default: stdout)
.TP
\fB\-\-version\fR
display the version and exit
.TP
\fB\-\-help\fR
display this help and exit
.SH "SEE ALSO"
The full documentation for
.B dwgadd
is maintained as a Texinfo manual. If the
.B info
and
.B dwgadd
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,33 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWGBMP "1" "June 2026" "dwgbmp 0.14" "User Commands"
.SH NAME
dwgbmp \- manual page for dwgbmp 0.14
.SH SYNOPSIS
.B dwgbmp
[\fI\,OPTION\/\fR]... \fI\,DWGFILE \/\fR[\fI\,thumbnailfile\/\fR]
.SH DESCRIPTION
Extract the DWG thumbnail image as BMP, WMF or PNG.
Default thumbnailfile: DWGFILE with the proper extension.
.TP
\fB\-v[0\-9]\fR, \fB\-\-verbose\fR [0\-9]
verbosity
.TP
\fB\-\-help\fR
display this help and exit
.TP
\fB\-\-version\fR
output version information and exit
.PP
GNU LibreDWG online manual: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dwgbmp
is maintained as a Texinfo manual. If the
.B info
and
.B dwgbmp
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,31 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWGFILTER "1" "June 2026" "dwgfilter 0.14" "User Commands"
.SH NAME
dwgfilter \- manual page for dwgfilter 0.14
.SH DESCRIPTION
dwgfilter [OPTIONS...] dwgfile
.PP
Allow custom jq queries on a temporary JSON dump.
.PP
OPTIONS: \fB\-\-help\fR,\-\-version
.TP
\fB\-\-debug\fR
keep the tmp json
.TP
\fB\-i\fR
write back in\-place, with an updating JQ query
.TP
\&...
all other options are passed to jq. See 'man jq'
.SH "SEE ALSO"
The full documentation for
.B dwgfilter
is maintained as a Texinfo manual. If the
.B info
and
.B dwgfilter
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,56 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWGGREP "1" "June 2026" "dwggrep 0.14" "User Commands"
.SH NAME
dwggrep \- manual page for dwggrep 0.14
.SH SYNOPSIS
.B dwggrep
[\fI\,OPTIONS\/\fR]... \fI\,pattern files\/\fR
.SH DESCRIPTION
Search regex pattern in a list of DWGs.
.TP
\fB\-i\fR
Case\-insensitive pattern
.TP
\fB\-x\fR
Extended regex pattern
.TP
\fB\-c\fR, \fB\-\-count\fR
Print only the count of matched elements.
.TP
\fB\-h\fR, \fB\-\-no\-filename\fR
Print no filename.
.TP
\fB\-y\fR, \fB\-\-type\fR NAME
Search only NAME entities or objects.
.TP
\fB\-d\fR, \fB\-\-dxf\fR NUM
Search only DXF group NUM fields.
.TP
\fB\-t\fR, \fB\-\-text\fR
Search only in TEXT\-like entities.
.TP
\fB\-b\fR, \fB\-\-blocks\fR
Search also in all block definitions.
.TP
\fB\-n\fR, \fB\-\-tables\fR
Search only in table names.
.TP
\fB\-\-help\fR
Display this help and exit
.TP
\fB\-\-version\fR
Output version information and exit
.PP
GNU LibreDWG online manual: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dwggrep
is maintained as a Texinfo manual. If the
.B info
and
.B dwggrep
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,42 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWGLAYERS "1" "June 2026" "dwglayers 0.14" "User Commands"
.SH NAME
dwglayers \- manual page for dwglayers 0.14
.SH SYNOPSIS
.B dwglayers
[\fI\,OPTION\/\fR]... \fI\,DWGFILE\/\fR
.SH DESCRIPTION
Print list of layers.
.TP
\fB\-x\fR, \fB\-\-extnames\fR
prints EXTNAMES (r13\-r14 only)
.IP
i.e. space instead of _
.TP
\fB\-f\fR, \fB\-\-flags\fR
prints also flags:
.IP
3 chars for: f for frozen, + or \- for ON or OFF, l for locked
.TP
\fB\-o\fR, \fB\-\-on\fR
prints only ON layers
.TP
\fB\-h\fR, \fB\-\-help\fR
display this help and exit
.TP
\fB\-\-version\fR
output version information and exit
.PP
GNU LibreDWG online manual: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dwglayers
is maintained as a Texinfo manual. If the
.B info
and
.B dwglayers
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,39 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWGREAD "1" "June 2026" "dwgread 0.14" "User Commands"
.SH NAME
dwgread \- manual page for dwgread 0.14
.SH SYNOPSIS
.B dwgread
[\fI\,OPTION\/\fR]... \fI\,DWGFILE\/\fR
.SH DESCRIPTION
Reads the DWG 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, minJSON, GeoJSON
.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: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dwgread
is maintained as a Texinfo manual. If the
.B info
and
.B dwgread
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,46 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWGREWRITE "1" "June 2026" "dwgrewrite 0.14" "User Commands"
.SH NAME
dwgrewrite \- manual page for dwgrewrite 0.14
.SH SYNOPSIS
.B dwgrewrite
[\fI\,OPTION\/\fR]... \fI\,INFILE \/\fR[\fI\,OUTFILE\/\fR]
.SH DESCRIPTION
Rewrites the DWG as another DWG.
Default OUTFILE: INFILE with <\-rewrite.dwg> appended.
.TP
\fB\-v[0\-9]\fR, \fB\-\-verbose\fR [0\-9]
verbosity
.TP
\fB\-\-as\fR rNNNN
save as version
.IP
Valid versions:
.IP
r1.4, r2.6, r2.10, r9, r10, r11, r13, r14, r2000 (default), r2004
.IP
Planned versions:
.IP
r2007, r2010, r2013, r2018
.HP
\fB\-o\fR dwgfile, \fB\-\-file\fR
.TP
\fB\-\-help\fR
display this help and exit
.TP
\fB\-\-version\fR
output version information and exit
.PP
GNU LibreDWG online manual: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dwgrewrite
is maintained as a Texinfo manual. If the
.B info
and
.B dwgrewrite
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,55 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DWGWRITE "1" "June 2026" "dwgwrite 0.14" "User Commands"
.SH NAME
dwgwrite \- manual page for dwgwrite 0.14
.SH SYNOPSIS
.B dwgwrite
[\fI\,OPTION\/\fR]... [\fI\,-o DWGFILE\/\fR] \fI\,INFILE\/\fR
.SH DESCRIPTION
Writes a DWG file from various input formats. Only r2000 for now.
.TP
\fB\-v[0\-9]\fR, \fB\-\-verbose\fR [0\-9]
verbosity
.TP
\fB\-\-as\fR rNNNN
save as version
.IP
Valid versions:
.IP
r1.1, r1.2, r1.3, r1.4, r2.0, r2.10, r2.21, r2.22, r2.4,
r2.5, r2.6, r9, r10, r11, r13, r14, r2000, r2004,
r2010, r2013, r2018
.IP
Planned versions:
.IP
r2007
.TP
\fB\-I\fR fmt, \fB\-\-format\fR fmt
DXF, DXFB, JSON
.IP
Planned input formats: GeoJSON, YAML, XML/OGR, GPX
.HP
\fB\-o\fR dwgfile, \fB\-\-file\fR
.TP
\fB\-y\fR, \fB\-\-overwrite\fR
overwrite existing files
.TP
\fB\-\-help\fR
display this help and exit
.TP
\fB\-\-version\fR
output version information and exit
.PP
GNU LibreDWG online manual: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dwgwrite
is maintained as a Texinfo manual. If the
.B info
and
.B dwgwrite
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,49 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DXF2DWG "1" "June 2026" "dxf2dwg 0.14" "User Commands"
.SH NAME
dxf2dwg \- manual page for dxf2dwg 0.14
.SH SYNOPSIS
.B dxf2dwg
[\fI\,OPTION\/\fR]... \fI\,DXFFILES \/\fR...
.SH DESCRIPTION
Converts the DXF to a DWG. Accepts ascii and binary DXF.
Default DWGFILE: DXFFILE with .dwg extension in the current directory.
Existing files are not overwritten, unless \fB\-y\fR is given.
Encoding currently does not work for r2007.
.TP
\fB\-v[0\-9]\fR, \fB\-\-verbose\fR [0\-9]
verbosity
.TP
\fB\-\-as\fR rNNNN
save as version
.IP
Valid versions:
.IP
r12, r14, r2000 (default), r2004
.IP
Planned versions:
.IP
r9, r10, r11, r2007, r2010, r2013, r2018
.TP
\fB\-o\fR outfile, \fB\-\-file\fR
optional, only valid with one single DXFFILE
.TP
\fB\-\-help\fR
display this help and exit
.TP
\fB\-\-version\fR
output version information and exit
.PP
GNU LibreDWG online manual: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dxf2dwg
is maintained as a Texinfo manual. If the
.B info
and
.B dxf2dwg
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,54 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH DXFWRITE "1" "June 2026" "dxfwrite 0.14" "User Commands"
.SH NAME
dxfwrite \- manual page for dxfwrite 0.14
.SH SYNOPSIS
.B dxfwrite
[\fI\,OPTION\/\fR]... [\fI\,-o DXFFILE\/\fR] \fI\,INFILE\/\fR
.SH DESCRIPTION
Writes a DXF file from various input formats.
.TP
\fB\-v[0\-9]\fR, \fB\-\-verbose\fR [0\-9]
verbosity
.TP
\fB\-\-as\fR rNNNN
save as version
.IP
Valid versions:
.TP
r9, r10, r11, r12, r13, r14, r2000, r2004, r2007,
r2010, r2013, r2018
.TP
\fB\-I\fR fmt, \fB\-\-format\fR fmt
DWG, DXF, DXFB, JSON
.HP
\fB\-o\fR dxffile, \fB\-\-file\fR
.TP
\fB\-m\fR, \fB\-\-minimal\fR
only $ACADVER, HANDSEED and ENTITIES
.TP
\fB\-b\fR, \fB\-\-binary\fR
create a binary DXF
.TP
\fB\-y\fR, \fB\-\-overwrite\fR
overwrite existing files
.TP
\fB\-\-help\fR
display this help and exit
.TP
\fB\-\-version\fR
output version information and exit
.PP
GNU LibreDWG online manual: <https://www.gnu.org/software/libredwg/>
.SH "SEE ALSO"
The full documentation for
.B dxfwrite
is maintained as a Texinfo manual. If the
.B info
and
.B dxfwrite
programs are properly installed at your site, the command
.IP
.B info LibreDWG
.PP
should give you access to the complete manual.
@@ -0,0 +1,264 @@
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "DWGADD 5"
.TH DWGADD 5 2025-03-25 0.14 "User Commands"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
dwgadd.5 \- Format of the LibreDWG dwgadd example input\-file
.SH DESCRIPTION
.IX Header "DESCRIPTION"
The dwgadd program accepts this input format to add entities and objects
to a DWG file.
.SH COMMANDS
.IX Header "COMMANDS"
commands start at each new line and must begin with a keyword and has optional arguments.
.PP
comments start with # and are ignored.
.PP
entities are created with the arguments as in the VBA object model AddEntity or AddObject methods.
.PP
entities are added to the model space by default, objects to the DWG or to parents objects, as e.g.
with \f(CW\*(C`xrecord dictionary\*(C'\fR.
.IP "\fBreaddwg\fR ""file.dwg""" 4
.IX Item "readdwg ""file.dwg"""
This must be the very first command. Otherwise a new, empty DWG Document is created.
.IP "\fBreaddxf\fR ""file.dxf""" 4
.IX Item "readdxf ""file.dxf"""
This must be the very first command. Otherwise a new, empty DWG Document is created.
.IP "\fBreadjson\fR ""file.json""" 4
.IX Item "readjson ""file.json"""
This must be the very first command. Otherwise a new, empty DWG Document is created.
.IP \fBimperial\fR 4
.IX Item "imperial"
By default a new DWG is created as metric.
There must be maximal one imperial line.
.IP "\fBversion\fR number" 4
.IX Item "version number"
Writes the output file in this version. It accepts numbers only \f(CW\*(C`[0\-9.]+\*(C'\fR,
prefixes it with an "r", and converts this string via \f(CWdwg_version_as("r"version)\fR
to a \f(CW\*(C`Dwg_Version_Type\*(C'\fR. It accepts only valid DWG versions.
There must be maximal one version line.
.IP \fBpspace\fR 4
.IX Item "pspace"
Add further entities to the paper space.
.IP \fBmspace\fR 4
.IX Item "mspace"
Add further entities to the model space again. This is only needed
when a previous \f(CW\*(C`pspace\*(C'\fR command was used. mspace is the default.
.IP "\fBHEADER\fR.\fIfield\fR = value" 4
.IX Item "HEADER.field = value"
Assign "VALUES" to a HEADER field. See the full documentation of valid HEADER fields.
.IP "\fBpoint\fR (3dpoint)" 4
.IX Item "point (3dpoint)"
.PD 0
.IP "\fBline\fR (3dpoint) (3dpoint)" 4
.IX Item "line (3dpoint) (3dpoint)"
.PD
Create a line variable and entity. You may set all other fields via the
\&\f(CW\*(C`line.field = value\*(C'\fR syntax. E.g. \f(CW\*(C`line.layer = "0"\*(C'\fR
.IP "\fBray\fR (3dpoint) (3dpoint)" 4
.IX Item "ray (3dpoint) (3dpoint)"
.PD 0
.IP "\fBxline\fR (3dpoint) (3dpoint)" 4
.IX Item "xline (3dpoint) (3dpoint)"
.IP "\fBtext\fR ""text_value"" (ins_pt) height" 4
.IX Item "text ""text_value"" (ins_pt) height"
.IP "\fBmtext\fR (ins_pt) height ""text_value""" 4
.IX Item "mtext (ins_pt) height ""text_value"""
.IP "\fBleader\fR num_points ((points)...) mtext type" 4
.IX Item "leader num_points ((points)...) mtext type"
.PD
mtext must be the immediate previous command.
.IP "\fBattribute\fR 8 0 ""prompt"" (0.0 1.0 0.0) ""tag"" ""text""" 4
.IX Item "attribute 8 0 ""prompt"" (0.0 1.0 0.0) ""tag"" ""text"""
.PD 0
.IP "\fBattdef\fR 8 0 ""prompt"" (0.0 1.0 0.0) ""tag"" ""default_text""" 4
.IX Item "attdef 8 0 ""prompt"" (0.0 1.0 0.0) ""tag"" ""default_text"""
.IP "\fBblock\fR ""name""" 4
.IX Item "block ""name"""
.PD
Starts a new block.
.IP \fBendblk\fR 4
.IX Item "endblk"
Ends the current block.
.IP "\fBinsert\fR (ins_pt) ""name"" xscale yscale zscale rotation" 4
.IX Item "insert (ins_pt) ""name"" xscale yscale zscale rotation"
.PD 0
.IP "\fBminsert\fR (ins_pt) ""name"" xscale yscale zscale rotation numrows numcols rowspacing colspacing" 4
.IX Item "minsert (ins_pt) ""name"" xscale yscale zscale rotation numrows numcols rowspacing colspacing"
.IP "\fBpolyline\fR_2d numpts ((2dpoints) ...)" 4
.IX Item "polyline_2d numpts ((2dpoints) ...)"
.IP "\fBlwpolyline\fR numpts ((2dpoints) ...)" 4
.IX Item "lwpolyline numpts ((2dpoints) ...)"
.IP "\fBpolyline\fR_3d numpts ((3dpoints) ...)" 4
.IX Item "polyline_3d numpts ((3dpoints) ...)"
.IP "\fBarc\fR (center) radius startangle endangle" 4
.IX Item "arc (center) radius startangle endangle"
.IP "\fBcircle\fR (center) radius" 4
.IX Item "circle (center) radius"
.IP "\fBpolyline\fR_pface 5 3 ((3dpoints)...) ((faces_4ints)...)" 4
.IX Item "polyline_pface 5 3 ((3dpoints)...) ((faces_4ints)...)"
.IP "\fBpolyline\fR_mesh num_m_verts num_n_verts ((3dpoints)...)" 4
.IX Item "polyline_mesh num_m_verts num_n_verts ((3dpoints)...)"
.IP "\fBdimension\fR_aligned (xline1_pt) (xline2_pt) (text_midpt)" 4
.IX Item "dimension_aligned (xline1_pt) (xline2_pt) (text_midpt)"
.IP "\fBdimension\fR_ang2ln (center_pt) (xline1end_pt) (xline2end_pt) (text_midpt)" 4
.IX Item "dimension_ang2ln (center_pt) (xline1end_pt) (xline2end_pt) (text_midpt)"
.IP "\fBdimension\fR_ang3pt (center_pt) (xline1_pt) (xline2_pt) (text_midpt)" 4
.IX Item "dimension_ang3pt (center_pt) (xline1_pt) (xline2_pt) (text_midpt)"
.IP "\fBdimension\fR_diameter (chord_pt) (far_chord_pt) leader_len" 4
.IX Item "dimension_diameter (chord_pt) (far_chord_pt) leader_len"
.IP "\fBdimension\fR_ordinate (feature_location_pt) (leader_endpt) number" 4
.IX Item "dimension_ordinate (feature_location_pt) (leader_endpt) number"
.IP "\fBdimension\fR_radius (center_pt) (chord_pt) leader_len" 4
.IX Item "dimension_radius (center_pt) (chord_pt) leader_len"
.IP "\fBdimension\fR_linear (xline1_pt) (xline2_pt) (def_pt) angle" 4
.IX Item "dimension_linear (xline1_pt) (xline2_pt) (def_pt) angle"
.IP "\fB3dface\fR (pt1) (pt2) (pt3) [(pt4)]" 4
.IX Item "3dface (pt1) (pt2) (pt3) [(pt4)]"
.IP "\fBsolid\fR (pt1) (pt2\-2d) (pt3\-2d) (pt4\-2d)" 4
.IX Item "solid (pt1) (pt2-2d) (pt3-2d) (pt4-2d)"
.IP "\fBtrace\fR (pt1) (pt2\-2d) (pt3\-2d) (pt4\-2d)" 4
.IX Item "trace (pt1) (pt2-2d) (pt3-2d) (pt4-2d)"
.IP "\fBshape\fR ""name"" (3dpoint) scale angle" 4
.IX Item "shape ""name"" (3dpoint) scale angle"
.IP "\fBviewport\fR ""name""" 4
.IX Item "viewport ""name"""
.IP "\fBellipse\fR (center_pt) major_axis axis_ratio" 4
.IX Item "ellipse (center_pt) major_axis axis_ratio"
.IP "\fBspline\fR num_fitpts ((fitpts)...) (begin_tan_vector) (end_tan_vector)" 4
.IX Item "spline num_fitpts ((fitpts)...) (begin_tan_vector) (end_tan_vector)"
.IP "\fBdictionary\fR ""name"" ""key"" handle_ref" 4
.IX Item "dictionary ""name"" ""key"" handle_ref"
.IP "\fBxrecord\fR dictionary ""name""" 4
.IX Item "xrecord dictionary ""name"""
.IP "\fBtolerance\fR ""testtekst"" (0 0 0) (0 0 1)" 4
.IX Item "tolerance ""testtekst"" (0 0 0) (0 0 1)"
.IP "\fBmlinestyle\fR ""name""" 4
.IX Item "mlinestyle ""name"""
.IP "\fBmline\fR num_points ((points)...)" 4
.IX Item "mline num_points ((points)...)"
.IP "\fBlayout\fR viewport ""name"" ""canonical_media_name""" 4
.IX Item "layout viewport ""name"" ""canonical_media_name"""
.IP "\fBtorus\fR (center_pt) (normal) major_radius minor_radius" 4
.IX Item "torus (center_pt) (normal) major_radius minor_radius"
.IP "\fBsphere\fR (center_pt) (normal) radius" 4
.IX Item "sphere (center_pt) (normal) radius"
.IP "\fBcylinder\fR (center_pt) (normal) height major_radius minor_radius x_radius" 4
.IX Item "cylinder (center_pt) (normal) height major_radius minor_radius x_radius"
.IP "\fBcone\fR (center_pt) (normal) height major_radius minor_radius x_radius" 4
.IX Item "cone (center_pt) (normal) height major_radius minor_radius x_radius"
.IP "\fBwedge\fR (center_pt) (normal) length width height" 4
.IX Item "wedge (center_pt) (normal) length width height"
.IP "\fBbox\fR (center_pt) (normal) length width height" 4
.IX Item "box (center_pt) (normal) length width height"
.IP "\fBpyramid\fR (center_pt) (normal) height sides radius topradius" 4
.IX Item "pyramid (center_pt) (normal) height sides radius topradius"
.IP "\fBlayer\fR ""name""" 4
.IX Item "layer ""name"""
.IP "\fBstyle\fR ""name""" 4
.IX Item "style ""name"""
.IP "\fBltype\fR ""name""" 4
.IX Item "ltype ""name"""
.IP "\fBvport\fR ""name""" 4
.IX Item "vport ""name"""
.IP "\fBview\fR ""name""" 4
.IX Item "view ""name"""
.IP "\fBvport\fR ""name""" 4
.IX Item "vport ""name"""
.IP "\fBlayout\fR ""name""" 4
.IX Item "layout ""name"""
.IP "\fBgroup\fR ""name""" 4
.IX Item "group ""name"""
.IP "\fIentity\fR.\fIfield\fR = value" 4
.IX Item "entity.field = value"
.PD
Every field of the just created entity or object can be set. See "VALUES"
and the full documentation of the available entity fields.
.SH VALUES
.IX Header "VALUES"
Acceptable values must be formatted as:
.IP \fBinteger\fR 4
.IX Item "integer"
negative integers are allowed.
\&\f(CW\*(C`0xXXX\*(C'\fR hex numbers are not accepted.
.IP \fBfloat\fR 4
.IX Item "float"
floats may omit the dot.
.IP "\fBangle\fR as float in degrees, not radians." 4
.IX Item "angle as float in degrees, not radians."
.PD 0
.IP "\fBstring\fR in double-quotes" 4
.IX Item "string in double-quotes"
.PD
E.g "string" or "" for the empty string.
.IP "\fBpoint\fR as (float, float, [float])" 4
.IX Item "point as (float, float, [float])"
esp. (float float) for 2dpoint
.Sp
(float float float) for 3dpoint. (0 0 0) is a valid 3dpoint.
.ie n .IP "\fBhandle\fR as ""D.D.XXX""" 4
.el .IP "\fBhandle\fR as \f(CWD.D.XXX\fR" 4
.IX Item "handle as D.D.XXX"
<C[0\-12]> as type "." decimal digits as size "." hexadecimal absolute ref.
For relative handle codes, like 6,8,10,12 do not take the 3rd handle part asis,
but use the absolute ref.
.Sp
E.g. \f(CW5.1.15\fR for HEADER.LTYPE_BYLAYER.