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

section.c

Go to the documentation of this file.
00001 
00038 #include "section.h"
00039 
00040 
00044 int
00045 dxf_section_read
00046 (
00047         DxfFile *fp
00049 )
00050 {
00051 #if DEBUG
00052         DXF_DEBUG_BEGIN
00053 #endif
00054         char *temp_string = NULL;
00055         DxfHeader dxf_header;
00056         DxfBlock dxf_block;
00057         char *dxf_entities_list = NULL;
00058 
00059         /* Do some basic checks. */
00060         if (fp == NULL)
00061         {
00062                 fprintf (stderr,
00063                   (_("Error in %s () a NULL file pointer was passed.\n")),
00064                   __FUNCTION__);
00065                 /* Clean up. */
00066                 free (temp_string);
00067                 return (EXIT_FAILURE);
00068         }
00069         dxf_read_line (temp_string, fp);
00070         if (strcmp (temp_string, "2") == 0)
00071         {
00072                 while (!feof (fp->fp))
00073                 {
00074                         dxf_read_line (temp_string, fp);
00075                         if (strcmp (temp_string, "HEADER") == 0)
00076                         {
00077                                 /* We have found the begin of the HEADER section. */
00078                                 dxf_header_read (fp, &dxf_header);
00079                         }
00080                         else if (strcmp (temp_string, "CLASSES") == 0)
00081                         {
00082                                 /* We have found the begin of the CLASSES sction. */
00084                         }
00085                         else if (strcmp (temp_string, "TABLES") == 0)
00086                         {
00087                                 /* We have found the begin of the TABLES sction. */
00089                         }
00090                         else if (strcmp (temp_string, "BLOCKS") == 0)
00091                         {
00092                                 /* We have found the begin of the BLOCKS sction. */
00093 
00095 //                                dxf_read_blocks
00096 //                                (
00097 //                                        fp->fp,
00098 //                                        &dxf_blocks_list,
00099 //                                        dxf_header._AcadVer
00100 //                                );
00101                         }
00102                         else if (strcmp (temp_string, "ENTITIES") == 0)
00103                         {
00104                                 /* We have found the begin of the ENTITIES sction. */
00105                                 dxf_entities_read_table (fp->filename,
00106                                                    fp->fp,
00107                                                    fp->line_number,
00108                                                    dxf_entities_list,
00109                                                    dxf_header._AcadVer);                        }
00110                         else if (strcmp (temp_string, "OBJECTS") == 0)
00111                         {
00112                                 /* We have found the begin of the OBJECTS sction. */
00114                         }
00115                         else if (strcmp (temp_string, "THUMBNAIL") == 0)
00116                         {
00117                                 /* We have found the begin of the THUMBNAIL sction. */
00119                         }
00120                 }
00121         }
00122         else
00123         {
00124                 fprintf (stderr,
00125                   (_("Warning in %s () unexpected string encountered while reading line %d from: %s.\n")),
00126                   __FUNCTION__, fp->line_number, fp->filename);
00127         }
00128         /* Clean up. */
00129         free (temp_string);
00130 #if DEBUG
00131         DXF_DEBUG_END
00132 #endif
00133         return EXIT_SUCCESS;
00134 }
00135 
00136 
00140 int
00141 dxf_section_write
00142 (
00143         DxfFile *fp,
00144         char *section_name
00145 )
00146 {
00147 #if DEBUG
00148         DXF_DEBUG_BEGIN
00149 #endif
00150         /* Do some basic checks. */
00151         if (fp == NULL)
00152         {
00153                 fprintf (stderr,
00154                   (_("Error in %s () a NULL file pointer was passed.\n")),
00155                   __FUNCTION__);
00156                 return (EXIT_FAILURE);
00157         }
00158         if (section_name == NULL)
00159         {
00160                 fprintf (stderr,
00161                   (_("Error in %s () a NULL pointer was passed.\n")),
00162                   __FUNCTION__);
00163                 return (EXIT_FAILURE);
00164         }
00165         fprintf (fp->fp, "  0\nSECTION\n  2\n%s\n", section_name);
00166 #if DEBUG
00167         DXF_DEBUG_END
00168 #endif
00169         return (EXIT_SUCCESS);
00170 }
00171 
00172 
00173 /* EOF */