/*! * \brief Function reads a SECTION in a DXF file. */ int dxf_section_read ( DxfFile *fp /*!< DXF file handle of input file (or device). */ ) { char temp_string[DXF_MAX_STRING_LENGTH]; DxfHeader dxf_header; DxfBlock dxf_block; char *dxf_entities_list = NULL; #if DEBUG fprintf (stderr, "[File: %s: line: %d] Entering dxf_section_read () function.\n", __FILE__, __LINE__); #endif dxf_read_line (temp_string, fp); if (strcmp (temp_string, "2") == 0) { while (!feof (fp->fp)) { dxf_read_line (temp_string, fp); if (strcmp (temp_string, "HEADER") == 0) { /* We have found the begin of the HEADER section. */ dxf_read_header (fp, dxf_header); } else if (strcmp (temp_string, "CLASSES") == 0) { /* We have found the begin of the CLASSES sction. */ /*! \todo Invoke a function for parsing the \c CLASSES section. */ } else if (strcmp (temp_string, "TABLES") == 0) { /* We have found the begin of the TABLES sction. */ /*! \todo Invoke a function for parsing the \c TABLES section. */ } else if (strcmp (temp_string, "BLOCKS") == 0) { /* We have found the begin of the BLOCKS sction. */ /* FIXME experimental usage of block_read */ // dxf_read_blocks // ( // fp->fp, // &dxf_blocks_list, // dxf_header._AcadVer // ); } else if (strcmp (temp_string, "ENTITIES") == 0) { /* We have found the begin of the ENTITIES sction. */ dxf_read_entities (fp->filename, fp->fp, fp->line_number, dxf_entities_list, dxf_header._AcadVer); } else if (strcmp (temp_string, "OBJECTS") == 0) { /* We have found the begin of the OBJECTS sction. */ /*! \todo Invoke a function for parsing the \c OBJECTS section. */ } else if (strcmp (temp_string, "THUMBNAIL") == 0) { /* We have found the begin of the THUMBNAIL sction. */ /*! \todo Invoke a function for parsing the \c THUMBNAIL section. */ } } } else { fprintf (stderr, "Warning: unexpected string encountered while reading line %d from: %s.\n", fp->line_number, fp->filename); } #if DEBUG fprintf (stderr, "[File: %s: line: %d] Leaving dxf_section_read () function.\n", __FILE__, __LINE__); #endif return EXIT_SUCCESS; }
/*! * \brief Function reads a SECTION in a DXF file. */ int dxf_section_read ( DxfFile *fp /*!< DXF file handle of input file (or device). */ ) { #if DEBUG DXF_DEBUG_BEGIN #endif char temp_string[DXF_MAX_STRING_LENGTH]; DxfHeader dxf_header; DxfBlock dxf_block; char *dxf_entities_list = NULL; /* Do some basic checks. */ if (fp == NULL) { fprintf (stderr, (_("Error in %s () a NULL file pointer was passed.\n")), __FUNCTION__); return (EXIT_FAILURE); } memset(temp_string, 0, sizeof(temp_string)); dxf_read_line (temp_string, fp); if (strcmp (temp_string, "2") == 0) { while (!feof (fp->fp)) /* Does this actually work? */ { memset(temp_string, 0, sizeof(temp_string)); dxf_read_line (temp_string, fp); if (strcmp (temp_string, "HEADER") == 0) { /* We have found the begin of the HEADER section. */ dxf_header_read (fp, &dxf_header); } else if (strcmp (temp_string, "CLASSES") == 0) { /* We have found the begin of the CLASSES sction. */ /*! \todo Invoke a function for parsing the \c CLASSES section. */ } else if (strcmp (temp_string, "TABLES") == 0) { /* We have found the begin of the TABLES sction. */ /*! \todo Invoke a function for parsing the \c TABLES section. */ } else if (strcmp (temp_string, "BLOCKS") == 0) { /* We have found the begin of the BLOCKS sction. */ /*! \todo Experimental usage of block_read */ // dxf_read_blocks // ( // fp->fp, // &dxf_blocks_list, // dxf_header._AcadVer // ); } else if (strcmp (temp_string, "ENTITIES") == 0) { /* We have found the begin of the ENTITIES sction. */ dxf_entities_read_table (fp->filename, fp->fp, fp->line_number, dxf_entities_list, dxf_header._AcadVer); } else if (strcmp (temp_string, "OBJECTS") == 0) { /* We have found the begin of the OBJECTS sction. */ /*! \todo Invoke a function for parsing the \c OBJECTS section. */ } else if (strcmp (temp_string, "THUMBNAIL") == 0) { /* We have found the begin of the THUMBNAIL sction. */ /*! \todo Invoke a function for parsing the \c THUMBNAIL section. */ } } } else { fprintf (stderr, (_("Warning in %s () unexpected string encountered while reading line %d from: %s.\n")), __FUNCTION__, fp->line_number, fp->filename); } #if DEBUG DXF_DEBUG_END #endif return EXIT_SUCCESS; }