LibreDWG API 0.13.4
LibreDWG API - The DWG Library
Loading...
Searching...
No Matches
bits.h File Reference
#include "config.h"
#include <wchar.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
#include "common.h"
#include "dwg.h"

Go to the source code of this file.

Data Structures

struct  _bit_chain

Macros

#define MAX_MEM_ALLOC   0x10000000000
#define EMPTY_CHAIN(size)
#define IS_FROM_TU(dat)
#define IS_FROM_TU_DWG(dwg)
#define TU_to_int(b)
#define bit_read_RLLd(dat)
#define bit_write_RLLd(dat, value)
#define bit_read_BLd(dat)
#define bit_chain_set_version(to, from)

Typedefs

typedef struct _bit_chain Bit_Chain

Functions

void bit_advance_position (Bit_Chain *dat, long advance)
size_t bit_position (Bit_Chain *dat)
void bit_set_position (Bit_Chain *dat, size_t bitpos)
void bit_reset_chain (Bit_Chain *dat)
BITCODE_B bit_read_B (Bit_Chain *dat)
void bit_write_B (Bit_Chain *dat, unsigned char value)
BITCODE_BB bit_read_BB (Bit_Chain *dat)
void bit_write_BB (Bit_Chain *dat, unsigned char value)
BITCODE_4BITS bit_read_4BITS (Bit_Chain *dat)
void bit_write_4BITS (Bit_Chain *dat, unsigned char value)
BITCODE_RC bit_read_RC (Bit_Chain *dat)
void bit_write_RC (Bit_Chain *dat, unsigned char value)
BITCODE_RS bit_read_RS (Bit_Chain *dat)
void bit_write_RS (Bit_Chain *dat, BITCODE_RS value)
BITCODE_BS bit_read_RS_BE (Bit_Chain *dat)
void bit_write_RS_BE (Bit_Chain *dat, BITCODE_BS value)
BITCODE_RL bit_read_RL (Bit_Chain *dat)
BITCODE_RL bit_read_RL_BE (Bit_Chain *dat)
void bit_write_RL (Bit_Chain *dat, BITCODE_RL value)
void bit_write_RL_BE (Bit_Chain *dat, BITCODE_RL value)
BITCODE_RLL bit_read_RLL (Bit_Chain *dat)
BITCODE_RLL bit_read_RLL_BE (Bit_Chain *dat)
void bit_write_RLL (Bit_Chain *dat, BITCODE_RLL value)
void bit_write_RLL_BE (Bit_Chain *dat, BITCODE_RLL value)
BITCODE_RD bit_read_RD (Bit_Chain *dat)
void bit_write_RD (Bit_Chain *dat, BITCODE_RD value)
BITCODE_BS bit_read_BS (Bit_Chain *dat)
void bit_write_BS (Bit_Chain *dat, BITCODE_BS value)
BITCODE_BL bit_read_BL (Bit_Chain *dat)
void bit_write_BL (Bit_Chain *dat, BITCODE_BL value)
void bit_write_BLd (Bit_Chain *dat, BITCODE_BLd value)
BITCODE_BS bit_read_BOT (Bit_Chain *dat)
void bit_write_BOT (Bit_Chain *dat, BITCODE_BS value)
BITCODE_BLL bit_read_BLL (Bit_Chain *dat)
void bit_write_BLL (Bit_Chain *dat, BITCODE_BLL value)
BITCODE_BD bit_read_BD (Bit_Chain *dat)
void bit_write_BD (Bit_Chain *dat, BITCODE_BD value)
BITCODE_MC bit_read_MC (Bit_Chain *dat)
void bit_write_MC (Bit_Chain *dat, BITCODE_MC value)
BITCODE_UMC bit_read_UMC (Bit_Chain *dat)
void bit_write_UMC (Bit_Chain *dat, BITCODE_UMC value)
BITCODE_MS bit_read_MS (Bit_Chain *dat)
void bit_write_MS (Bit_Chain *dat, BITCODE_MS value)
void bit_read_BE (Bit_Chain *__restrict__ dat, double *__restrict__ x, double *__restrict__ y, double *__restrict__ z)
void bit_write_BE (Bit_Chain *dat, double x, double y, double z)
void normalize_BE (BITCODE_3BD ext)
BITCODE_DD bit_read_DD (Bit_Chain *dat, double default_value)
BITCODE_BB bit_write_DD (Bit_Chain *dat, double value, double default_value)
int bit_eq_DD (double value, double default_value)
BITCODE_BT bit_read_BT (Bit_Chain *dat)
void bit_write_BT (Bit_Chain *dat, double value)
int bit_read_H (Bit_Chain *__restrict__ dat, Dwg_Handle *__restrict__ handle)
void bit_write_H (Bit_Chain *__restrict__ dat, Dwg_Handle *__restrict__ handle)
void bit_H_to_dat (Bit_Chain *__restrict__ dat, Dwg_Handle *__restrict__ handle)
uint16_t bit_read_CRC (Bit_Chain *dat)
int bit_check_CRC (Bit_Chain *dat, size_t start_address, const uint16_t seed)
uint16_t bit_write_CRC (Bit_Chain *dat, size_t start_address, const uint16_t seed)
uint16_t bit_write_CRC_BE (Bit_Chain *dat, size_t start_address, const uint16_t seed)
uint16_t bit_calc_CRC (const uint16_t seed, unsigned char *adr, size_t len)
uint32_t bit_calc_CRC32 (const uint32_t seed, unsigned char *adr, size_t len)
int bit_read_fixed (Bit_Chain *__restrict__ dat, BITCODE_RC *__restrict__ dest, size_t length)
BITCODE_TF bit_read_TF (Bit_Chain *dat, size_t length) __attribute__((malloc))
BITCODE_TF bit_read_bits (Bit_Chain *dat, size_t bits) __attribute__((malloc))
void bit_write_bits (Bit_Chain *__restrict__ dat, BITCODE_TF __restrict__ bits, size_t numbits)
void bit_write_TF (Bit_Chain *__restrict__ dat, BITCODE_TF __restrict__ chain, size_t length)
void bit_write_TFv (Bit_Chain *__restrict__ dat, BITCODE_TF __restrict__ chain, size_t length)
BITCODE_TV bit_read_TV (Bit_Chain *__restrict__ dat)
void bit_write_TV (Bit_Chain *__restrict__ dat, BITCODE_TV __restrict__ value)
BITCODE_TU bit_read_TU (Bit_Chain *__restrict__ dat) __attribute__((malloc))
BITCODE_TU bit_read_TU_len (Bit_Chain *__restrict__ dat, unsigned int *lenp) __attribute__((malloc))
BITCODE_TU bit_read_TU_size (Bit_Chain *__restrict__ dat, unsigned int len) __attribute__((malloc))
BITCODE_TV bit_read_T16 (Bit_Chain *__restrict__ dat) __attribute__((malloc))
BITCODE_TU bit_read_TU16 (Bit_Chain *__restrict__ dat) __attribute__((malloc))
BITCODE_TV bit_read_T32 (Bit_Chain *__restrict__ dat) __attribute__((malloc))
BITCODE_TV bit_read_TU32 (Bit_Chain *__restrict__ dat) __attribute__((malloc))
void bit_write_TU (Bit_Chain *__restrict__ dat, BITCODE_TU __restrict__ value)
void bit_write_TU16 (Bit_Chain *__restrict__ dat, BITCODE_TU __restrict__ value)
void bit_write_T16 (Bit_Chain *__restrict__ dat, BITCODE_TV __restrict__ value)
void bit_write_T32 (Bit_Chain *__restrict__ dat, BITCODE_TV __restrict__ value)
void bit_write_TU32 (Bit_Chain *__restrict__ dat, BITCODE_TV __restrict__ value)
BITCODE_TV bit_read_T (Bit_Chain *__restrict__ dat) __attribute__((malloc))
void bit_write_T (Bit_Chain *__restrict__ dat, BITCODE_TV __restrict__ chain)
char * bit_embed_TU (BITCODE_TU __restrict__ wstr) __attribute__((malloc))
char * bit_embed_TU_size (BITCODE_TU __restrict__ wstr, const int len) __attribute__((malloc))
size_t bit_wcs2len (const BITCODE_TU __restrict__ wstr)
size_t bit_wcs2nlen (const BITCODE_TU __restrict__ wstr, const size_t maxlen)
BITCODE_TU bit_wcs2cpy (BITCODE_TU __restrict__ dest, const BITCODE_TU __restrict__ src)
BITCODE_TU bit_wcs2dup (const BITCODE_TU __restrict__ src)
int bit_wcs2cmp (BITCODE_TU __restrict__ s1, const BITCODE_TU __restrict__ s2)
char * bit_convert_TU (const BITCODE_TU __restrict__ wstr) __attribute__((malloc))
char * bit_TU_to_utf8_len (const BITCODE_TU __restrict__ wstr, const int len) __attribute__((malloc))
char * bit_utf8_to_TV (char *__restrict__ dest, const unsigned char *__restrict__ src, const size_t destlen, const size_t srclen, const unsigned cquoted, const BITCODE_RS codepage)
char * bit_TV_to_utf8 (const char *__restrict__ src, const BITCODE_RS codepage) __attribute__((malloc))
BITCODE_TU bit_utf8_to_TU (char *__restrict__ str, const unsigned cquoted) __attribute__((malloc))
const char * bit_u_expand (const char *src)
int bit_eq_T (Bit_Chain *__restrict__ dat, const BITCODE_TV __restrict__ str1, const char *__restrict__ str2)
int bit_eq_TU (const char *str, BITCODE_TU __restrict__ wstr)
int bit_empty_T (Bit_Chain *__restrict__ dat, BITCODE_TV __restrict__ str)
BITCODE_TV bit_set_T (Bit_Chain *__restrict__ dat, const char *__restrict__ src)
BITCODE_TIMEBLL bit_read_TIMEBLL (Bit_Chain *dat)
void bit_write_TIMEBLL (Bit_Chain *dat, BITCODE_TIMEBLL date)
BITCODE_TIMERLL bit_read_TIMERLL (Bit_Chain *dat)
void bit_write_TIMERLL (Bit_Chain *dat, BITCODE_TIMERLL date)
int bit_read_CMC (Bit_Chain *dat, Bit_Chain *str_dat, Dwg_Color *__restrict__ color)
void bit_write_CMC (Bit_Chain *dat, Bit_Chain *str_dat, Dwg_Color *__restrict__ color)
void bit_downconvert_CMC (Bit_Chain *dat, Dwg_Color *__restrict__ color)
void bit_upconvert_CMC (Bit_Chain *dat, Dwg_Color *__restrict__ color)
void bit_read_ENC (Bit_Chain *dat, Bit_Chain *hdl_dat, Bit_Chain *str_dat, Dwg_Color *__restrict__ color)
void bit_write_ENC (Bit_Chain *dat, Bit_Chain *hdl_dat, Bit_Chain *str_dat, Dwg_Color *__restrict__ color)
int bit_search_sentinel (Bit_Chain *dat, const unsigned char sentinel[16])
void bit_chain_init (Bit_Chain *dat, const size_t size)
void bit_chain_init_dat (Bit_Chain *__restrict__ dat, const size_t size, const Bit_Chain *__restrict__ from_dat)
void bit_chain_alloc (Bit_Chain *dat)
void bit_chain_alloc_size (Bit_Chain *dat, const size_t size)
void bit_chain_free (Bit_Chain *dat)
void bit_print (Bit_Chain *dat, size_t size)
void bit_write_bits1 (Bit_Chain *__restrict__ dat, const char *__restrict__ bits)
long bit_write_hexbits (Bit_Chain *__restrict__ dat, const char *__restrict__ bytes)
void bit_print_bits (unsigned char *bits, size_t bitsize)
void bit_fprint_bits (FILE *fp, unsigned char *bits, size_t bitsize)
void bit_explore_chain (Bit_Chain *dat, size_t from, size_t size)
BITCODE_BD bit_nan (void)
int bit_isnan (BITCODE_BD number)
bool does_cross_unicode_datversion (Bit_Chain *__restrict__ dat)
void bit_copy_chain (Bit_Chain *__restrict__ orig_dat, Bit_Chain *__restrict__ tmp_dat)
size_t in_hex2bin (unsigned char *__restrict__ dest, char *__restrict__ src, size_t destlen)
bool bit_TF_contains_high (char *s, size_t len)

Macro Definition Documentation

◆ bit_chain_set_version

#define bit_chain_set_version ( to,
from )
Value:
(to)->opts = (from)->opts; \
(to)->version = (from)->version; \
(to)->from_version = (from)->from_version; \
(to)->fh = (from)->fh; \
(to)->codepage = (from)->codepage

◆ bit_read_BLd

#define bit_read_BLd ( dat)
Value:
BITCODE_BL bit_read_BL(Bit_Chain *dat)
Definition bits.c:595
int32_t BITCODE_BLd
Definition dwg.h:128

◆ bit_read_RLLd

#define bit_read_RLLd ( dat)
Value:
BITCODE_RLL bit_read_RLL(Bit_Chain *dat)
Definition bits.c:430
int64_t BITCODE_RLLd
Definition dwg.h:181

◆ bit_write_RLLd

#define bit_write_RLLd ( dat,
value )
Value:
void bit_write_RLL(Bit_Chain *dat, BITCODE_RLL value)
Definition bits.c:490
uint64_t BITCODE_RLL
Definition dwg.h:179

◆ EMPTY_CHAIN

#define EMPTY_CHAIN ( size)
Value:
{ \
NULL, size, 0UL, 0, 0, R_INVALID, R_INVALID, NULL, 0 \
}
@ R_INVALID
Definition dwg.h:283

◆ IS_FROM_TU

#define IS_FROM_TU ( dat)
Value:
(dat->from_version >= R_2007) && !(dat->opts & DWG_OPTS_IN)
@ R_2007
Definition dwg.h:321
#define DWG_OPTS_IN
Definition dwg.h:11447

◆ IS_FROM_TU_DWG

#define IS_FROM_TU_DWG ( dwg)
Value:
(dwg->header.from_version >= R_2007) && !(dwg->opts & DWG_OPTS_IN)

◆ MAX_MEM_ALLOC

#define MAX_MEM_ALLOC   0x10000000000

The position of bits within bytes is numerically ordered as depicted below:

position: 01234567 01234567 01234567 ...
bits: 76543210 76543210 76543210 ...
\______/ \______/ \______/
byte 1 byte 2 byte 3 ...

(i.e. little endian)

◆ TU_to_int

#define TU_to_int ( b)
Value:
le16toh (((uint16_t)b[1] << 8) + b[0])
#define le16toh(x)
Definition common.h:98

Typedef Documentation

◆ Bit_Chain

typedef struct _bit_chain Bit_Chain

Structure for DWG-files raw data streams.

Function Documentation

◆ bit_advance_position()

void bit_advance_position ( Bit_Chain * dat,
long advance )

◆ bit_calc_CRC()

uint16_t bit_calc_CRC ( const uint16_t seed,
unsigned char * adr,
size_t len )

◆ bit_calc_CRC32()

uint32_t bit_calc_CRC32 ( const uint32_t seed,
unsigned char * adr,
size_t len )

◆ bit_chain_alloc()

void bit_chain_alloc ( Bit_Chain * dat)

◆ bit_chain_alloc_size()

void bit_chain_alloc_size ( Bit_Chain * dat,
const size_t size )

◆ bit_chain_free()

void bit_chain_free ( Bit_Chain * dat)

◆ bit_chain_init()

void bit_chain_init ( Bit_Chain * dat,
const size_t size )

◆ bit_chain_init_dat()

void bit_chain_init_dat ( Bit_Chain *__restrict__ dat,
const size_t size,
const Bit_Chain *__restrict__ from_dat )

◆ bit_check_CRC()

int bit_check_CRC ( Bit_Chain * dat,
size_t start_address,
uint16_t seed )

Read and check old 16bit CRC.

◆ bit_convert_TU()

char * bit_convert_TU ( const BITCODE_TU __restrict__ wstr)

◆ bit_copy_chain()

void bit_copy_chain ( Bit_Chain *__restrict__ orig_dat,
Bit_Chain *__restrict__ tmp_dat )

◆ bit_downconvert_CMC()

void bit_downconvert_CMC ( Bit_Chain * dat,
Dwg_Color *__restrict__ color )

◆ bit_embed_TU()

char * bit_embed_TU ( BITCODE_TU __restrict__ wstr)

◆ bit_embed_TU_size()

char * bit_embed_TU_size ( BITCODE_TU __restrict__ wstr,
const int len )

◆ bit_empty_T()

int bit_empty_T ( Bit_Chain *__restrict__ dat,
BITCODE_TV __restrict__ str )

◆ bit_eq_DD()

int bit_eq_DD ( double value,
double default_value )

◆ bit_eq_T()

int bit_eq_T ( Bit_Chain *__restrict__ dat,
const BITCODE_TV __restrict__ str1,
const char *__restrict__ str2 )

◆ bit_eq_TU()

int bit_eq_TU ( const char * str,
BITCODE_TU __restrict__ wstr )

◆ bit_explore_chain()

void bit_explore_chain ( Bit_Chain * dat,
size_t from,
size_t size )

◆ bit_fprint_bits()

void bit_fprint_bits ( FILE * fp,
unsigned char * bits,
size_t bitsize )

◆ bit_H_to_dat()

void bit_H_to_dat ( Bit_Chain *__restrict__ dat,
Dwg_Handle *__restrict__ handle )

◆ bit_isnan()

int bit_isnan ( BITCODE_BD number)

◆ bit_nan()

BITCODE_BD bit_nan ( void )

◆ bit_position()

size_t bit_position ( Bit_Chain * dat)

◆ bit_print()

void bit_print ( Bit_Chain * dat,
size_t size )

◆ bit_print_bits()

void bit_print_bits ( unsigned char * bits,
size_t bitsize )

◆ bit_read_4BITS()

BITCODE_4BITS bit_read_4BITS ( Bit_Chain * dat)

Read 4 bits.

◆ bit_read_B()

BITCODE_B bit_read_B ( Bit_Chain * dat)

Read 1 bit.

◆ bit_read_BB()

BITCODE_BB bit_read_BB ( Bit_Chain * dat)

Read 2 bits.

◆ bit_read_BD()

BITCODE_BD bit_read_BD ( Bit_Chain * dat)

Read 1 bitdouble (compacted data).

◆ bit_read_BE()

void bit_read_BE ( Bit_Chain *__restrict__ dat,
double *__restrict__ x,
double *__restrict__ y,
double *__restrict__ z )

Read bit-extrusion.

◆ bit_read_bits()

BITCODE_TF bit_read_bits ( Bit_Chain * dat,
size_t bits )

◆ bit_read_BL()

BITCODE_BL bit_read_BL ( Bit_Chain * dat)

Read 1 bitlong (compacted data).

◆ bit_read_BLL()

BITCODE_BLL bit_read_BLL ( Bit_Chain * dat)

Read 1 bitlonglong (compacted uint64_t) for REQUIREDVERSIONS, preview_size. ODA doc bug. ODA say 1-3 bits until the first 0 bit. See 3BLL below. The first 3 bits indicate the length len (see paragraph 2.1). Then len bytes follow, which represent the number (the least significant byte is first).

◆ bit_read_BOT()

BITCODE_BS bit_read_BOT ( Bit_Chain * dat)

Read object type 2010+ (BB + 1 or 2 bytes). par 2.12

◆ bit_read_BS()

BITCODE_BS bit_read_BS ( Bit_Chain * dat)

Read 1 bitshort (compacted data).

◆ bit_read_BT()

BITCODE_BT bit_read_BT ( Bit_Chain * dat)

Read bit-thickness.

◆ bit_read_CMC()

int bit_read_CMC ( Bit_Chain * dat,
Bit_Chain * str_dat,
Dwg_Color *__restrict__ color )

Read color

◆ bit_read_CRC()

uint16_t bit_read_CRC ( Bit_Chain * dat)

Only read old 16bit CRC-numbers, without checking, only in order to go to the next byte, while skipping non-aligned bits.

◆ bit_read_DD()

BITCODE_DD bit_read_DD ( Bit_Chain * dat,
double default_value )

Read bit-double with default.

◆ bit_read_ENC()

void bit_read_ENC ( Bit_Chain * dat,
Bit_Chain * hdl_dat,
Bit_Chain * str_dat,
Dwg_Color *__restrict__ color )

Read entity color (2004+) (truecolor rgb and alpha support) Does also references, DBCOLOR lookups.

◆ bit_read_fixed()

int bit_read_fixed ( Bit_Chain *__restrict__ dat,
BITCODE_RC *__restrict__ dest,
size_t length )

◆ bit_read_H()

int bit_read_H ( Bit_Chain *__restrict__ dat,
Dwg_Handle *__restrict__ handle )

Read handle-references. Returns error code: DWG_ERR_INVALIDHANDLE or 0 on success.

◆ bit_read_MC()

BITCODE_MC bit_read_MC ( Bit_Chain * dat)

Read 1 modular char (max 5 bytes, signed). Read bytes until the high bit of the byte is 0, drop the highest bit and pad with 0. If the last byte has 0x40 set, it's negative. Since the result is int32_t (4 byte), but there needs to be the high/follow bit set, the stream can be max 5 byte long (5*7 = 35 bit) 10000000 10000000 10000000 10000000 00000100 => 0000000 0000000 0000000 0000000 0000100 (5*7 = 35) => 00001000 00000000 00000000 00000000 (4*8 = 32)

◆ bit_read_MS()

BITCODE_MS bit_read_MS ( Bit_Chain * dat)

Read 1 modular short (max 2 words).

◆ bit_read_RC()

BITCODE_RC bit_read_RC ( Bit_Chain * dat)

Read 1 byte (raw char).

◆ bit_read_RD()

BITCODE_RD bit_read_RD ( Bit_Chain * dat)

Read 1 raw double (8 bytes, IEEE-754).

◆ bit_read_RL()

BITCODE_RL bit_read_RL ( Bit_Chain * dat)

Read 1 raw long (4 byte, LE).

◆ bit_read_RL_BE()

BITCODE_RL bit_read_RL_BE ( Bit_Chain * dat)

Read 1 raw long (4 byte, BE).

◆ bit_read_RLL()

BITCODE_RLL bit_read_RLL ( Bit_Chain * dat)

Read 1 raw 64bit long (8 byte, LE).

◆ bit_read_RLL_BE()

BITCODE_RLL bit_read_RLL_BE ( Bit_Chain * dat)

Read 1 raw 64bit long (8 byte, BE).

◆ bit_read_RS()

BITCODE_RS bit_read_RS ( Bit_Chain * dat)

Read 1 raw short (LE).

◆ bit_read_RS_BE()

BITCODE_BS bit_read_RS_BE ( Bit_Chain * dat)

Read 1 raw short (BE).

◆ bit_read_T()

BITCODE_TV bit_read_T ( Bit_Chain *__restrict__ dat)

◆ bit_read_T16()

BITCODE_TV bit_read_T16 ( Bit_Chain *__restrict__ dat)

◆ bit_read_T32()

BITCODE_TV bit_read_T32 ( Bit_Chain *__restrict__ dat)

◆ bit_read_TF()

BITCODE_TF bit_read_TF ( Bit_Chain * dat,
size_t length )

◆ bit_read_TIMEBLL()

BITCODE_TIMEBLL bit_read_TIMEBLL ( Bit_Chain * dat)

Read 2 time BL bitlong (compacted data). julian days + milliseconds since midnight used for TDCREATE, TDUPDATE, and all other DATE variables. pre-R13 read 2xRL

◆ bit_read_TIMERLL()

BITCODE_TIMERLL bit_read_TIMERLL ( Bit_Chain * dat)

◆ bit_read_TU()

BITCODE_TU bit_read_TU ( Bit_Chain *__restrict__ dat)

◆ bit_read_TU16()

BITCODE_TU bit_read_TU16 ( Bit_Chain *__restrict__ dat)

◆ bit_read_TU32()

BITCODE_TV bit_read_TU32 ( Bit_Chain *__restrict__ dat)

◆ bit_read_TU_len()

BITCODE_TU bit_read_TU_len ( Bit_Chain *__restrict__ dat,
unsigned int * lenp )

◆ bit_read_TU_size()

BITCODE_TU bit_read_TU_size ( Bit_Chain *__restrict__ dat,
unsigned int len )

◆ bit_read_TV()

BITCODE_TV bit_read_TV ( Bit_Chain *__restrict__ dat)

◆ bit_read_UMC()

BITCODE_UMC bit_read_UMC ( Bit_Chain * dat)

Read unsigned modular char (max 5 bytes, unsigned). Can be quite large if there are many deleted handles.

◆ bit_reset_chain()

void bit_reset_chain ( Bit_Chain * dat)

◆ bit_search_sentinel()

int bit_search_sentinel ( Bit_Chain * dat,
const unsigned char sentinel[16] )

Search for a sentinel; if found, positions "dat->byte" immediately after it and returns -1

◆ bit_set_position()

void bit_set_position ( Bit_Chain * dat,
size_t bitpos )

◆ bit_set_T()

BITCODE_TV bit_set_T ( Bit_Chain *__restrict__ dat,
const char *__restrict__ src )

◆ bit_TF_contains_high()

bool bit_TF_contains_high ( char * s,
size_t len )

◆ bit_TU_to_utf8_len()

char * bit_TU_to_utf8_len ( const BITCODE_TU __restrict__ wstr,
const int len )

◆ bit_TV_to_utf8()

char * bit_TV_to_utf8 ( const char *__restrict__ src,
const BITCODE_RS codepage )

converts old codepage'd strings to UTF-8. convert \U+XXXX or \MnXXXX also if representable. returns NULL on errors, or the unchanged src string, or a copy.

◆ bit_u_expand()

const char * bit_u_expand ( const char * src)

◆ bit_upconvert_CMC()

void bit_upconvert_CMC ( Bit_Chain * dat,
Dwg_Color *__restrict__ color )

◆ bit_utf8_to_TU()

BITCODE_TU bit_utf8_to_TU ( char *__restrict__ str,
const unsigned cquoted )

Converts UTF-8 to UCS-2. Returns a copy. Needed by dwg importers, writers (e.g. dxf2dwg) cquoted is needed by in_json, to unquote "

◆ bit_utf8_to_TV()

char * bit_utf8_to_TV ( char *__restrict__ dest,
const unsigned char *__restrict__ src,
const size_t destlen,
const size_t srclen,
const unsigned cquoted,
const BITCODE_RS codepage )

Converts UTF-8 (dxf,json) to ASCII TV. \uxxxx or other unicode => \U+XXXX if not representable in this codepage. If cquoted unquotes " to ", undo json_cquote(), Returns NULL if not enough room in dest. converts UTF-8 (dxf,json) to ASCII TV. optionally unquotes \" to ", \ to \, undo json_cquote(), \uxxxx or other unicode => \U+XXXX. codepage conversion, MIF not yet (needs version arg) Returns NULL if not enough room in dest.

◆ bit_wcs2cmp()

int bit_wcs2cmp ( BITCODE_TU __restrict__ s1,
const BITCODE_TU __restrict__ s2 )

◆ bit_wcs2cpy()

BITCODE_TU bit_wcs2cpy ( BITCODE_TU __restrict__ dest,
const BITCODE_TU __restrict__ src )

◆ bit_wcs2dup()

BITCODE_TU bit_wcs2dup ( const BITCODE_TU __restrict__ src)

◆ bit_wcs2len()

size_t bit_wcs2len ( const BITCODE_TU __restrict__ wstr)

◆ bit_wcs2nlen()

size_t bit_wcs2nlen ( const BITCODE_TU __restrict__ wstr,
const size_t maxlen )

◆ bit_write_4BITS()

void bit_write_4BITS ( Bit_Chain * dat,
unsigned char value )

Write 4 bits.

◆ bit_write_B()

void bit_write_B ( Bit_Chain * dat,
unsigned char value )

Write 1 bit.

◆ bit_write_BB()

void bit_write_BB ( Bit_Chain * dat,
unsigned char value )

Write 2 bits.

◆ bit_write_BD()

void bit_write_BD ( Bit_Chain * dat,
double value )

Write 1 bitdouble (compacted data).

◆ bit_write_BE()

void bit_write_BE ( Bit_Chain * dat,
double x,
double y,
double z )

Write bit-extrusion.

◆ bit_write_bits()

void bit_write_bits ( Bit_Chain *__restrict__ dat,
BITCODE_TF __restrict__ bits,
size_t numbits )

◆ bit_write_bits1()

void bit_write_bits1 ( Bit_Chain *__restrict__ dat,
const char *__restrict__ bits )

◆ bit_write_BL()

void bit_write_BL ( Bit_Chain * dat,
BITCODE_BL value )

Write 1 bitlong (compacted data).

◆ bit_write_BLd()

void bit_write_BLd ( Bit_Chain * dat,
BITCODE_BLd value )

Write signed bitlong (compacted data).

◆ bit_write_BLL()

void bit_write_BLL ( Bit_Chain * dat,
BITCODE_BLL value )

Write 1 bitlonglong (compacted data). max 7 byte by design.

◆ bit_write_BOT()

void bit_write_BOT ( Bit_Chain * dat,
BITCODE_BS value )

Write object type 2010+ (BB + 1 or 2 bytes).

◆ bit_write_BS()

void bit_write_BS ( Bit_Chain * dat,
BITCODE_BS value )

Write 1 bitshort (compacted data).

◆ bit_write_BT()

void bit_write_BT ( Bit_Chain * dat,
double value )

Write bit-thickness.

◆ bit_write_CMC()

void bit_write_CMC ( Bit_Chain * dat,
Bit_Chain * str_dat,
Dwg_Color *__restrict__ color )

Write color

◆ bit_write_CRC()

uint16_t bit_write_CRC ( Bit_Chain * dat,
size_t start_address,
uint16_t seed )

Create and write old 16bit CRC.

◆ bit_write_CRC_BE()

uint16_t bit_write_CRC_BE ( Bit_Chain * dat,
size_t start_address,
const uint16_t seed )

◆ bit_write_DD()

BITCODE_BB bit_write_DD ( Bit_Chain * dat,
double value,
double default_value )

Write bit-double with default.

◆ bit_write_ENC()

void bit_write_ENC ( Bit_Chain * dat,
Bit_Chain * hdl_dat,
Bit_Chain * str_dat,
Dwg_Color *__restrict__ color )

Write entity color (2004+)

◆ bit_write_H()

void bit_write_H ( Bit_Chain *__restrict__ dat,
Dwg_Handle *__restrict__ handle )

Write handle-references. TODO separate SoftPtr: BB 0 + RL HardPtr: BB 1 + RL SoftOwner: BB 2 + RL HardOwner: BB 3 + RL downconvert relative handles to abs. 4 to r2000

◆ bit_write_hexbits()

long bit_write_hexbits ( Bit_Chain *__restrict__ dat,
const char *__restrict__ bytes )

◆ bit_write_MC()

void bit_write_MC ( Bit_Chain * dat,
BITCODE_MC val )

Write 1 modular char (max 5 bytes, signed).

◆ bit_write_MS()

void bit_write_MS ( Bit_Chain * dat,
BITCODE_MS value )

Write 1 modular short (max 2 words).

◆ bit_write_RC()

void bit_write_RC ( Bit_Chain * dat,
unsigned char value )

Write 1 byte (raw char).

◆ bit_write_RD()

void bit_write_RD ( Bit_Chain * dat,
double value )

Write 1 raw double (8 bytes, IEEE-754).

◆ bit_write_RL()

void bit_write_RL ( Bit_Chain * dat,
BITCODE_RL value )

Write 1 raw long (4 byte, LE).

◆ bit_write_RL_BE()

void bit_write_RL_BE ( Bit_Chain * dat,
BITCODE_RL value )

Write 1 raw long (4 byte, BE).

◆ bit_write_RLL()

void bit_write_RLL ( Bit_Chain * dat,
BITCODE_RLL value )

Write 1 raw 64bit long (8 byte, LE).

◆ bit_write_RLL_BE()

void bit_write_RLL_BE ( Bit_Chain * dat,
BITCODE_RLL value )

Write 1 raw 64bit long (8 byte, BE).

◆ bit_write_RS()

void bit_write_RS ( Bit_Chain * dat,
BITCODE_RS value )

Write 1 raw short (LE).

◆ bit_write_RS_BE()

void bit_write_RS_BE ( Bit_Chain * dat,
BITCODE_RS value )

Write 1 raw short (BE).

◆ bit_write_T()

void bit_write_T ( Bit_Chain *__restrict__ dat,
BITCODE_TV __restrict__ s )

Write ASCII or Unicode text.

◆ bit_write_T16()

void bit_write_T16 ( Bit_Chain *__restrict__ dat,
BITCODE_TV __restrict__ chain )

String16: Write ASCII/Unicode prefixed by a RS length, up-converts to TU16

◆ bit_write_T32()

void bit_write_T32 ( Bit_Chain *__restrict__ dat,
BITCODE_TV __restrict__ value )

◆ bit_write_TF()

void bit_write_TF ( Bit_Chain *__restrict__ dat,
BITCODE_TF __restrict__ chain,
size_t length )

Write fixed-length text.

◆ bit_write_TFv()

void bit_write_TFv ( Bit_Chain *__restrict__ dat,
BITCODE_TF __restrict__ chain,
size_t length )

Write fixed-length text from variable length string (possibly downgraded from shorter string).

◆ bit_write_TIMEBLL()

void bit_write_TIMEBLL ( Bit_Chain * dat,
BITCODE_TIMEBLL date )

Write 2 time BL bitlong (compacted data). Ignores the double value.

◆ bit_write_TIMERLL()

void bit_write_TIMERLL ( Bit_Chain * dat,
BITCODE_TIMERLL date )

◆ bit_write_TU()

void bit_write_TU ( Bit_Chain *__restrict__ dat,
BITCODE_TU __restrict__ chain )

Write UCS-2 unicode text. Must be zero-delimited.

◆ bit_write_TU16()

void bit_write_TU16 ( Bit_Chain *__restrict__ dat,
BITCODE_TU __restrict__ value )

◆ bit_write_TU32()

void bit_write_TU32 ( Bit_Chain *__restrict__ dat,
BITCODE_TV __restrict__ value )

◆ bit_write_TV()

void bit_write_TV ( Bit_Chain *__restrict__ dat,
BITCODE_TV __restrict__ chain )

Write ASCIIZ text. Starting with r2004 as writer (not target version) acad always writes a terminating zero, and includes it in the length. On DWG_OPTS_INJSON (imported from JSON), convert from UTF-8 to the codepage.

◆ bit_write_UMC()

void bit_write_UMC ( Bit_Chain * dat,
BITCODE_UMC val )

Write 1 modular char (max 8 bytes, unsigned).

◆ does_cross_unicode_datversion()

bool does_cross_unicode_datversion ( Bit_Chain *__restrict__ dat)

◆ in_hex2bin()

size_t in_hex2bin ( unsigned char *__restrict__ dest,
char *__restrict__ src,
size_t destlen )

◆ normalize_BE()

void normalize_BE ( BITCODE_3BD ext)