libDXF 0.0.1
A library with DXF related functions written in C.
Functions

util.c File Reference

Functions for libDXF coding utilities. More...

#include <stdarg.h>
#include "util.h"
Include dependency graph for util.c:

Go to the source code of this file.

Functions

DxfChardxf_char_new ()
 Allocate memory for a DxfChar.
DxfChardxf_char_init (DxfChar *c)
 Allocate memory and initialize data fields in a DxfChar object.
int dxf_char_free (DxfChar *c)
 Free the allocated memory for a DxfChar object and all it's data fields.
int dxf_char_free_chain (DxfChar *chars)
 Free the allocated memory for a single linked list of DxfChar objects and all their data fields.
DxfDoubledxf_double_new ()
 Allocate memory for a DxfDouble.
DxfDoubledxf_double_init (DxfDouble *d)
 Allocate memory and initialize data fields in a DxfDouble object.
int dxf_double_free (DxfDouble *d)
 Free the allocated memory for a DxfDouble object and all it's data fields.
int dxf_double_free_chain (DxfDouble *doubles)
 Free the allocated memory for a single linked list of DxfDouble objects and all their data fields.
DxfIntdxf_int_new ()
 Allocate memory for a DxfInt.
DxfIntdxf_int_init (DxfInt *i)
 Allocate memory and initialize data fields in a DxfInt object.
int dxf_int_free (DxfInt *i)
 Free the allocated memory for a DxfInt object and all it's data fields.
int dxf_int_free_chain (DxfInt *ints)
 Free the allocated memory for a single linked list of DxfInt objects and all their data fields.
int dxf_read_is_double (int type)
int dxf_read_is_int (int type)
int dxf_read_is_string (int type)
DxfFiledxf_read_init (const char *filename)
 Opens a DxfFile, does error checking and resets the line number counter.
void dxf_read_close (DxfFile *file)
int dxf_read_line (char *temp_string, DxfFile *fp)
 Reads a line from a file.
int dxf_read_scanf (DxfFile *fp, const char *template,...)
 Uses of fscanf with other features.

Detailed Description

Functions for libDXF coding utilities.

Author:
Copyright (C) 2010 by Luis Matos <gass@otiliamatos.ath.cx>.
Copyright (C) 2010, 2012, 2015, 2017 by Bert Timmerman <bert.timmerman@xs4all.nl>.

Copyright Notices.


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to:
Free Software Foundation, Inc.,
59 Temple Place,
Suite 330,
Boston,
MA 02111 USA.

Drawing eXchange Format (DXF) is a defacto industry standard for the exchange of drawing files between various Computer Aided Drafting programs.
DXF is an industry standard designed by Autodesk(TM).
For more details see http://www.autodesk.com.


Definition in file util.c.


Function Documentation

DxfChar* dxf_char_new ( )

Allocate memory for a DxfChar.

Fill the memory contents with zeros.

Definition at line 48 of file util.c.

References _, DXF_DEBUG_BEGIN, and DXF_DEBUG_END.

Referenced by dxf_char_init(), dxf_ole2frame_init(), dxf_oleframe_init(), and dxf_region_init().

DxfChar* dxf_char_init ( DxfChar c)

Allocate memory and initialize data fields in a DxfChar object.

Returns:
NULL when no memory was allocated, a pointer to the allocated memory when succesful.
Parameters:
ca pointer to the DxfChar object.

Definition at line 86 of file util.c.

References _, dxf_char_new(), DXF_DEBUG_BEGIN, DXF_DEBUG_END, dxf_char_struct::length, dxf_char_struct::next, and dxf_char_struct::value.

Referenced by dxf_ole2frame_init(), dxf_ole2frame_read(), dxf_oleframe_init(), dxf_oleframe_read(), dxf_region_init(), dxf_region_read(), dxf_sortentstable_init(), and dxf_sortentstable_read().

Here is the call graph for this function:

int dxf_char_free ( DxfChar c)

Free the allocated memory for a DxfChar object and all it's data fields.

Returns:
EXIT_SUCCESS when done, or EXIT_FAILURE when an error occurred.
Parameters:
ca pointer to the memory occupied by the DxfChar object.

Definition at line 128 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, dxf_char_struct::next, and dxf_char_struct::value.

Referenced by dxf_char_free_chain().

int dxf_char_free_chain ( DxfChar chars)

Free the allocated memory for a single linked list of DxfChar objects and all their data fields.

Parameters:
charsa pointer to the single linked list of DxfChar objects.

Definition at line 168 of file util.c.

References _, dxf_char_free(), DXF_DEBUG_BEGIN, DXF_DEBUG_END, and dxf_char_struct::next.

Referenced by dxf_oleframe_free(), dxf_region_free(), and dxf_sortentstable_free().

Here is the call graph for this function:

DxfDouble* dxf_double_new ( )

Allocate memory for a DxfDouble.

Fill the memory contents with zeros.

Definition at line 203 of file util.c.

References _, DXF_DEBUG_BEGIN, and DXF_DEBUG_END.

Referenced by dxf_double_init(), and dxf_spline_init().

DxfDouble* dxf_double_init ( DxfDouble d)

Allocate memory and initialize data fields in a DxfDouble object.

Returns:
NULL when no memory was allocated, a pointer to the allocated memory when succesful.
Parameters:
da pointer to the DxfDouble object.

Definition at line 241 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, dxf_double_new(), dxf_double_struct::next, and dxf_double_struct::value.

Referenced by dxf_spline_init(), and dxf_spline_read().

Here is the call graph for this function:

int dxf_double_free ( DxfDouble d)

Free the allocated memory for a DxfDouble object and all it's data fields.

Returns:
EXIT_SUCCESS when done, or EXIT_FAILURE when an error occurred.
Parameters:
da pointer to the memory occupied by the DxfDouble object.

Definition at line 282 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, and dxf_double_struct::next.

Referenced by dxf_double_free_chain().

int dxf_double_free_chain ( DxfDouble doubles)

Free the allocated memory for a single linked list of DxfDouble objects and all their data fields.

Parameters:
doublesa pointer to the single linked list of DxfDouble objects.

Definition at line 321 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, dxf_double_free(), and dxf_double_struct::next.

Referenced by dxf_spline_free().

Here is the call graph for this function:

DxfInt* dxf_int_new ( )

Allocate memory for a DxfInt.

Fill the memory contents with zeros.

Definition at line 356 of file util.c.

References _, DXF_DEBUG_BEGIN, and DXF_DEBUG_END.

Referenced by dxf_int_init().

DxfInt* dxf_int_init ( DxfInt i)

Allocate memory and initialize data fields in a DxfInt object.

Returns:
NULL when no memory was allocated, a pointer to the allocated memory when succesful.
Parameters:
ia pointer to the DxfInt object.

Definition at line 394 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, dxf_int_new(), dxf_int_struct::next, and dxf_int_struct::value.

Referenced by dxf_sortentstable_read().

Here is the call graph for this function:

int dxf_int_free ( DxfInt i)

Free the allocated memory for a DxfInt object and all it's data fields.

Returns:
EXIT_SUCCESS when done, or EXIT_FAILURE when an error occurred.
Parameters:
ia pointer to the memory occupied by the DxfInt object.

Definition at line 435 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, and dxf_int_struct::next.

Referenced by dxf_int_free_chain().

int dxf_int_free_chain ( DxfInt ints)

Free the allocated memory for a single linked list of DxfInt objects and all their data fields.

Parameters:
intsa pointer to the single linked list of DxfInt objects.

Definition at line 474 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, dxf_int_free(), and dxf_int_struct::next.

Here is the call graph for this function:

int dxf_read_is_double ( int  type)

Definition at line 504 of file util.c.

References DXF_DEBUG_BEGIN, DXF_DEBUG_END, FALSE, and TRUE.

Referenced by dxf_header_read_parse_n_double().

int dxf_read_is_int ( int  type)

Definition at line 527 of file util.c.

References DXF_DEBUG_BEGIN, DXF_DEBUG_END, FALSE, and TRUE.

Referenced by dxf_header_read_parse_int().

int dxf_read_is_string ( int  type)

Definition at line 550 of file util.c.

References DXF_DEBUG_BEGIN, DXF_DEBUG_END, FALSE, and TRUE.

Referenced by dxf_header_read_parse_string().

DxfFile* dxf_read_init ( const char *  filename)

Opens a DxfFile, does error checking and resets the line number counter.

Reset the line counting to 0.

Todo:
FIXME: dxf header and blocks need initialized ? dxf_header_init (file->dxf_header); dxf_block_init (file->dxf_block);

Definition at line 579 of file util.c.

References _, DXF_DEBUG_BEGIN, and DXF_DEBUG_END.

Referenced by dxf_file_read().

void dxf_read_close ( DxfFile file)

Todo:
FIXME: how to free other sub structures

Definition at line 622 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, dxf_file_struct::filename, and dxf_file_struct::fp.

Referenced by dxf_file_read().

int dxf_read_line ( char *  temp_string,
DxfFile fp 
)

Reads a line from a file.

Reads the next line from fp file and stores it into the temp_string.

Definition at line 653 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, dxf_file_struct::filename, dxf_file_struct::fp, and dxf_file_struct::line_number.

Referenced by dxf_file_read(), and dxf_section_read().

int dxf_read_scanf ( DxfFile fp,
const char *  template,
  ... 
)

Uses of fscanf with other features.

Uses fscanf for file parsing, but also tracks the lines it reads;

Definition at line 685 of file util.c.

References _, DXF_DEBUG_BEGIN, DXF_DEBUG_END, dxf_file_struct::filename, dxf_file_struct::fp, dxf_file_struct::line_number, and TRUE.

Referenced by dxf_header_read(), dxf_header_read_parse_int(), dxf_header_read_parse_n_double(), and dxf_header_read_parse_string().