(root)/
libredwg-0.13/
src/
decode.h
       1  /*****************************************************************************/
       2  /*  LibreDWG - free implementation of the DWG file format                    */
       3  /*                                                                           */
       4  /*  Copyright (C) 2009-2019 Free Software Foundation, Inc.                   */
       5  /*                                                                           */
       6  /*  This library is free software, licensed under the terms of the GNU       */
       7  /*  General Public License as published by the Free Software Foundation,     */
       8  /*  either version 3 of the License, or (at your option) any later version.  */
       9  /*  You should have received a copy of the GNU General Public License        */
      10  /*  along with this program.  If not, see <http://www.gnu.org/licenses/>.    */
      11  /*****************************************************************************/
      12  
      13  /*
      14   * decode.h: decoding function prototypes
      15   * written by Felipe Castro
      16   * modified by Felipe CorrĂȘa da Silva Sances
      17   * modified by Rodrigo Rodrigues da Silva
      18   * modified by Reini Urban
      19   */
      20  
      21  #ifndef DECODE_H
      22  #define DECODE_H
      23  
      24  #include "bits.h"
      25  #include "dwg.h"
      26  #include "decode_r11.h"
      27  
      28  #ifdef IN_DXF_H
      29  #  error in_dxf.h must be included after decode.h because of FORMAT_BD
      30  #endif
      31  
      32  #define REFS_PER_REALLOC 16384
      33  
      34  typedef enum ENTITY_SECTION_INDEX_R11
      35  {
      36    ENTITIES_SECTION_INDEX = 0,
      37    BLOCKS_SECTION_INDEX,
      38    EXTRAS_SECTION_INDEX
      39  } EntitySectionIndexR11;
      40  
      41  EXPORT int dwg_decode (Bit_Chain *restrict dat, Dwg_Data *restrict dwg);
      42  int dwg_decode_unknown_bits (Bit_Chain *restrict dat,
      43                               Dwg_Object *restrict obj);
      44  int dwg_decode_unknown_rest (Bit_Chain *restrict dat,
      45                               Dwg_Object *restrict obj);
      46  Dwg_Object_Ref *dwg_find_objectref (const Dwg_Data *restrict dwg,
      47                                      const Dwg_Object *restrict obj);
      48  
      49  int dwg_decode_BLOCK_HEADER (Bit_Chain *restrict dat,
      50                               Dwg_Object *restrict obj);
      51  int dwg_decode_LAYER (Bit_Chain *restrict dat, Dwg_Object *restrict obj);
      52  int dwg_decode_STYLE (Bit_Chain *restrict dat, Dwg_Object *restrict obj);
      53  int dwg_decode_LTYPE (Bit_Chain *restrict dat, Dwg_Object *restrict obj);
      54  int dwg_decode_VIEW (Bit_Chain *restrict dat, Dwg_Object *restrict obj);
      55  int dwg_decode_UCS (Bit_Chain *restrict dat, Dwg_Object *restrict obj);
      56  int dwg_decode_VPORT (Bit_Chain *restrict dat, Dwg_Object *restrict obj);
      57  int dwg_decode_APPID (Bit_Chain *restrict dat, Dwg_Object *restrict obj);
      58  int dwg_decode_DIMSTYLE (Bit_Chain *restrict dat, Dwg_Object *restrict obj);
      59  int dwg_decode_VX_TABLE_RECORD (Bit_Chain *restrict dat,
      60                                  Dwg_Object *restrict obj);
      61  
      62  // reused with the importers
      63  void decode_BACKGROUND_type (const Dwg_Object *obj);
      64  
      65  /*------------------------------------------------------------------------------
      66   * Functions reused with decode_r11
      67   */
      68  int dwg_decode_eed (Bit_Chain *restrict dat, Dwg_Object_Object *restrict obj);
      69  
      70  /*------------------------------------------------------------------------------
      71   * Functions reused with decode_r2007
      72   */
      73  Dwg_Object_Ref *dwg_decode_handleref (Bit_Chain *restrict hdl_dat,
      74                                        Dwg_Object *restrict obj,
      75                                        Dwg_Data *restrict dwg);
      76  Dwg_Object_Ref *dwg_decode_handleref_with_code (Bit_Chain *restrict hdl_dat,
      77                                                  Dwg_Object *restrict obj,
      78                                                  Dwg_Data *restrict dwg,
      79                                                  unsigned int code);
      80  int dwg_decode_header_variables (Bit_Chain *dat, Bit_Chain *hdl_dat,
      81                                   Bit_Chain *str_dat, Dwg_Data *restrict dwg);
      82  int dwg_decode_add_object (Dwg_Data *restrict dwg, Bit_Chain *dat,
      83                             Bit_Chain *hdl_dat, size_t address);
      84  int obj_handle_stream (Bit_Chain *restrict dat, Dwg_Object *restrict obj,
      85                         Bit_Chain *restrict hdl_dat);
      86  void bfr_read (void *restrict dst, BITCODE_RC *restrict *restrict src,
      87                 size_t size);
      88  void bfr_read_32 (void *restrict dst, BITCODE_RC *restrict *restrict src,
      89                    size_t size);
      90  void bfr_read_64 (void *restrict dst, BITCODE_RC *restrict *restrict src,
      91                    size_t size);
      92  
      93  /* reused with free */
      94  void dwg_free_xdata_resbuf (Dwg_Resbuf *restrict rbuf);
      95  
      96  /* reused with encode */
      97  void decrypt_R2004_header (BITCODE_RC *restrict dest,
      98                             const BITCODE_RC *restrict src, size_t size);
      99  void dwg_resolve_objectrefs_silent (Dwg_Data *restrict dwg);
     100  uint32_t dwg_section_page_checksum (const uint32_t seed,
     101                                      Bit_Chain *restrict dat, int32_t size);
     102  unsigned int section_max_decomp_size (const Dwg_Data *dwg,
     103                                        const Dwg_Section_Type id);
     104  
     105  /* reused with out_dxf */
     106  char *dwg_dim_blockname (Dwg_Data *restrict dwg,
     107                           const Dwg_Object *restrict obj);
     108  
     109  int dwg_validate_INSERT (Dwg_Object *restrict obj);
     110  int dwg_validate_POLYLINE (Dwg_Object *restrict obj);
     111  /* reused with many */
     112  int dwg_fixup_BLOCKS_entities (Dwg_Data *restrict dwg);
     113  void dxf_3dsolid_revisionguid (Dwg_Entity_3DSOLID *_obj);
     114  
     115  /* from decode_r2007.c */
     116  int obj_string_stream (Bit_Chain *dat, Dwg_Object *restrict obj,
     117                         Bit_Chain *str_dat);
     118  size_t obj_stream_position (Bit_Chain *restrict dat,
     119                              Bit_Chain *restrict hdl_dat,
     120                              Bit_Chain *restrict str_dat);
     121  
     122  void read_r2007_init (Dwg_Data *restrict dwg);
     123  int read_r2007_meta_data (Bit_Chain *dat, Bit_Chain *hdl_dat,
     124                            Dwg_Data *restrict dwg);
     125  void section_string_stream (Dwg_Data *restrict dwg, Bit_Chain *restrict dat,
     126                              BITCODE_RL bitsize, Bit_Chain *restrict str);
     127  /* for decode_r11.c */
     128  int decode_r11_auxheader (Bit_Chain *restrict dat, Dwg_Data *restrict dwg);
     129  int decode_preR13_DIMENSION (Bit_Chain *restrict dat,
     130                               Dwg_Object *restrict obj);
     131  int decode_preR13_sentinel (const Dwg_Sentinel sentinel,
     132                              const char *restrict sentinel_name,
     133                              Bit_Chain *restrict dat, Dwg_Data *restrict dwg);
     134  int decode_preR13_entities (BITCODE_RL start, BITCODE_RL end,
     135                              unsigned num_entities, BITCODE_RL size,
     136                              Bit_Chain *restrict dat, Dwg_Data *restrict dwg,
     137                              const EntitySectionIndexR11 entity_section_index);
     138  
     139  /* from dwg.c */
     140  // from dat.fh
     141  EXPORT int dat_read_size (Bit_Chain *restrict dat);
     142  EXPORT int dat_read_file (Bit_Chain *restrict dat, FILE *restrict fp,
     143                            const char *restrict filename);
     144  EXPORT int dat_read_stream (Bit_Chain *restrict dat, FILE *restrict fp);
     145  
     146  #endif