LibreDWG API  0.13.3
LibreDWG API - The DWG Library
decode.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#include <limits.h>
#include "common.h"
#include "bits.h"
#include "dwg.h"
#include "hash.h"
#include "decode.h"
#include "print.h"
#include "free.h"
#include "dynapi.h"
#include "logging.h"
#include "dec_macros.h"
#include "template.spec"
#include "header.spec"
#include "auxheader.spec"
#include "summaryinfo.spec"
#include "2ndheader.spec"
#include "objfreespace.spec"
#include "appinfo.spec"
#include "filedeplist.spec"
#include "security.spec"
#include "revhistory.spec"
#include "acds.spec"
#include "r2004_file_header.spec"
#include "common_entity_data.spec"
#include "common_object_handle_data.spec"
#include "header_variables.spec"
#include "common_entity_handle_data.spec"
#include "dwg.spec"
#include "classes.inc"

Data Structures

union  _encrypted_section_header
 

Macros

#define _DEFAULT_SOURCE   1
 
#define _BSD_SOURCE   1
 
#define _GNU_SOURCE   1 /* for memmem on linux */
 
#define _USE_BSD   1
 
#define IS_DECODER
 
#define DWG_LOGLEVEL   loglevel
 
#define MAX_HEADER_SIZE   2048
 
#define LOG_POS   LOG_RPOS
 
#define CMP(f, type)
 
#define DECODE_PRER13_SENTINEL(ID)    error |= decode_preR13_sentinel (ID, #ID, dat, dwg)
 

Typedefs

typedef union _encrypted_section_header encrypted_section_header
 

Functions

int dwg_decode (Bit_Chain *restrict dat, Dwg_Data *restrict dwg)
 
Dwg_Object_Refdwg_find_objectref (const Dwg_Data *restrict dwg, const Dwg_Object *restrict obj)
 
void dwg_resolve_objectrefs_silent (Dwg_Data *restrict dwg)
 
void bfr_read (void *restrict dst, BITCODE_RC *restrict *restrict src, size_t size)
 
void bfr_read_32 (void *restrict dst, BITCODE_RC *restrict *restrict src, size_t size)
 
void bfr_read_64 (void *restrict dst, BITCODE_RC *restrict *restrict src, size_t size)
 
uint32_t dwg_section_page_checksum (const uint32_t seed, Bit_Chain *restrict dat, int32_t size)
 
unsigned int section_max_decomp_size (const Dwg_Data *dwg, const Dwg_Section_Type id)
 
void decrypt_R2004_header (BITCODE_RC *restrict dest, const BITCODE_RC *restrict src, size_t size)
 
int dwg_decode_eed (Bit_Chain *restrict dat, Dwg_Object_Object *restrict obj)
 
int obj_handle_stream (Bit_Chain *restrict dat, Dwg_Object *restrict obj, Bit_Chain *restrict hdl_dat)
 
Dwg_Object_Refdwg_new_ref (Dwg_Data *restrict dwg)
 
Dwg_Object_Refdwg_decode_handleref (Bit_Chain *restrict dat, Dwg_Object *restrict obj, Dwg_Data *restrict dwg)
 
Dwg_Object_Refdwg_decode_handleref_with_code (Bit_Chain *restrict dat, Dwg_Object *restrict obj, Dwg_Data *restrict dwg, unsigned int code)
 
int dwg_decode_header_variables (Bit_Chain *dat, Bit_Chain *hdl_dat, Bit_Chain *str_dat, Dwg_Data *restrict dwg)
 
void dwg_free_xdata_resbuf (Dwg_Resbuf *rbuf)
 
int dwg_add_object (Dwg_Data *restrict dwg)
 
int dwg_decode_add_object (Dwg_Data *restrict dwg, Bit_Chain *dat, Bit_Chain *hdl_dat, size_t address)
 
int dwg_decode_unknown_bits (Bit_Chain *restrict dat, Dwg_Object *restrict obj)
 
int dwg_decode_unknown_rest (Bit_Chain *restrict dat, Dwg_Object *restrict obj)
 
char * dwg_dim_blockname (Dwg_Data *restrict dwg, const Dwg_Object *restrict obj)
 
int dwg_validate_INSERT (Dwg_Object *restrict obj)
 
int dwg_validate_POLYLINE (Dwg_Object *restrict obj)
 
int dwg_fixup_BLOCKS_entities (Dwg_Data *restrict dwg)
 
void dxf_3dsolid_revisionguid (Dwg_Entity__3DSOLID *_obj)
 
int decode_preR13_DIMENSION (Bit_Chain *restrict dat, Dwg_Object *restrict obj)
 
int decode_preR13_sentinel (const Dwg_Sentinel sentinel, const char *restrict sentinel_name, Bit_Chain *restrict dat, Dwg_Data *restrict dwg)
 
int decode_r11_auxheader (Bit_Chain *restrict dat, Dwg_Data *restrict dwg)
 
int decode_preR13_entities (BITCODE_RL start, BITCODE_RL end, unsigned num_entities, BITCODE_RL size, Bit_Chain *restrict dat, Dwg_Data *restrict dwg, const EntitySectionIndexR11 entity_section)
 

Macro Definition Documentation

◆ _BSD_SOURCE

#define _BSD_SOURCE   1

◆ _DEFAULT_SOURCE

#define _DEFAULT_SOURCE   1

◆ _GNU_SOURCE

#define _GNU_SOURCE   1 /* for memmem on linux */

◆ _USE_BSD

#define _USE_BSD   1

◆ CMP

#define CMP (   f,
  type 
)
Value:
if (tbl->f != f) \
LOG_ERROR ("decode_preR13_section_chk %s %s", tbl->name, #f)

◆ DECODE_PRER13_SENTINEL

#define DECODE_PRER13_SENTINEL (   ID)     error |= decode_preR13_sentinel (ID, #ID, dat, dwg)

◆ DWG_LOGLEVEL

#define DWG_LOGLEVEL   loglevel

◆ IS_DECODER

#define IS_DECODER

◆ LOG_POS

#define LOG_POS   LOG_RPOS

◆ MAX_HEADER_SIZE

#define MAX_HEADER_SIZE   2048

Typedef Documentation

◆ encrypted_section_header

Function Documentation

◆ bfr_read()

void bfr_read ( void *restrict  dst,
BITCODE_RC *restrict *restrict  src,
size_t  size 
)

◆ bfr_read_32()

void bfr_read_32 ( void *restrict  dst,
BITCODE_RC *restrict *restrict  src,
size_t  size 
)

◆ bfr_read_64()

void bfr_read_64 ( void *restrict  dst,
BITCODE_RC *restrict *restrict  src,
size_t  size 
)

◆ decode_preR13_DIMENSION()

int decode_preR13_DIMENSION ( Bit_Chain *restrict  dat,
Dwg_Object *restrict  obj 
)

◆ decode_preR13_entities()

int decode_preR13_entities ( BITCODE_RL  start,
BITCODE_RL  end,
unsigned  num_entities,
BITCODE_RL  size,
Bit_Chain *restrict  dat,
Dwg_Data *restrict  dwg,
const EntitySectionIndexR11  entity_section 
)

◆ decode_preR13_sentinel()

int decode_preR13_sentinel ( const Dwg_Sentinel  sentinel,
const char *restrict  sentinel_name,
Bit_Chain *restrict  dat,
Dwg_Data *restrict  dwg 
)

◆ decode_r11_auxheader()

int decode_r11_auxheader ( Bit_Chain *restrict  dat,
Dwg_Data *restrict  dwg 
)

◆ decrypt_R2004_header()

void decrypt_R2004_header ( BITCODE_RC *restrict  dest,
const BITCODE_RC *restrict  src,
size_t  size 
)

◆ dwg_add_object()

int dwg_add_object ( Dwg_Data *restrict  dwg)

Adds a new empty obj to the dwg->object[] array. The new object is at &dwg->object[dwg->num_objects-1].

Returns 0 or some error codes on success. Returns -1 if the dwg->object pool was re-alloced, i.e. pointers within are invalidated. Returns DWG_ERR_OUTOFMEM otherwise.

◆ dwg_decode()

int dwg_decode ( Bit_Chain *restrict  dat,
Dwg_Data *restrict  dwg 
)

dwg_decode returns 0 on success.

everything in dwg is cleared and then either read from dat, or set to a default.

◆ dwg_decode_add_object()

int dwg_decode_add_object ( Dwg_Data *restrict  dwg,
Bit_Chain dat,
Bit_Chain hdl_dat,
size_t  address 
)

Adds an object to the DWG (i.e. dwg->object[dwg->num_objects]) Returns 0 or some error codes on success. Returns -1 if the dwg->object pool was re-alloced. Returns some DWG_ERR_* otherwise.

◆ dwg_decode_eed()

int dwg_decode_eed ( Bit_Chain *restrict  dat,
Dwg_Object_Object *restrict  obj 
)

◆ dwg_decode_handleref()

Dwg_Object_Ref* dwg_decode_handleref ( Bit_Chain *restrict  dat,
Dwg_Object *restrict  obj,
Dwg_Data *restrict  dwg 
)

◆ dwg_decode_handleref_with_code()

Dwg_Object_Ref* dwg_decode_handleref_with_code ( Bit_Chain *restrict  dat,
Dwg_Object *restrict  obj,
Dwg_Data *restrict  dwg,
unsigned int  code 
)

code: TYPEDOBJHANDLE: 2 Soft owner 3 Hard owner 4 Soft pointer 5 Hard pointer OFFSETOBJHANDLE for soft owners or pointers: 6 ref + 1 8 ref - 1 a ref + offset c ref - offset e ??

◆ dwg_decode_header_variables()

int dwg_decode_header_variables ( Bit_Chain dat,
Bit_Chain hdl_dat,
Bit_Chain str_dat,
Dwg_Data *restrict  dwg 
)

◆ dwg_decode_unknown_bits()

int dwg_decode_unknown_bits ( Bit_Chain *restrict  dat,
Dwg_Object *restrict  obj 
)

dwg_decode_unknown Container to hold a unknown class entity, see classes.inc Every DEBUGGING class holds a bits array, a bitsize, and the handle and string stream offsets. It starts after the common_entity|object_data until and goes until the end of final padding, to the CRC. (obj->common_size/8 .. obj->size)

◆ dwg_decode_unknown_rest()

int dwg_decode_unknown_rest ( Bit_Chain *restrict  dat,
Dwg_Object *restrict  obj 
)

◆ dwg_dim_blockname()

char* dwg_dim_blockname ( Dwg_Data *restrict  dwg,
const Dwg_Object *restrict  obj 
)

◆ dwg_find_objectref()

Dwg_Object_Ref* dwg_find_objectref ( const Dwg_Data *restrict  dwg,
const Dwg_Object *restrict  obj 
)

◆ dwg_fixup_BLOCKS_entities()

int dwg_fixup_BLOCKS_entities ( Dwg_Data *restrict  dwg)

◆ dwg_free_xdata_resbuf()

void dwg_free_xdata_resbuf ( Dwg_Resbuf rbuf)

◆ dwg_new_ref()

Dwg_Object_Ref* dwg_new_ref ( Dwg_Data *restrict  dwg)

Add the empty ref to the DWG (freshly malloc'ed), or NULL.

◆ dwg_resolve_objectrefs_silent()

void dwg_resolve_objectrefs_silent ( Dwg_Data *restrict  dwg)

◆ dwg_section_page_checksum()

uint32_t dwg_section_page_checksum ( const uint32_t  seed,
Bit_Chain *restrict  dat,
int32_t  size 
)

◆ dwg_validate_INSERT()

int dwg_validate_INSERT ( Dwg_Object *restrict  obj)

◆ dwg_validate_POLYLINE()

int dwg_validate_POLYLINE ( Dwg_Object *restrict  obj)

◆ dxf_3dsolid_revisionguid()

void dxf_3dsolid_revisionguid ( Dwg_Entity__3DSOLID _obj)

◆ obj_handle_stream()

int obj_handle_stream ( Bit_Chain *restrict  dat,
Dwg_Object *restrict  obj,
Bit_Chain *restrict  hdl_dat 
)

◆ section_max_decomp_size()

unsigned int section_max_decomp_size ( const Dwg_Data dwg,
const Dwg_Section_Type  id 
)