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

table.c

Go to the documentation of this file.
00001 
00040 #include "table.h"
00041 
00042 
00058 DxfTableCell *
00059 dxf_table_cell_new ()
00060 {
00061 #if DEBUG
00062         DXF_DEBUG_BEGIN
00063 #endif
00064         DxfTableCell *cell = NULL;
00065         size_t size;
00066 
00067         size = sizeof (DxfTableCell);
00068         /* avoid malloc of 0 bytes */
00069         if (size == 0) size = 1;
00070         if ((cell = malloc (size)) == NULL)
00071         {
00072                 fprintf (stderr,
00073                   (_("Error in %s () could not allocate memory for a DxfTableCell struct.\n")),
00074                   __FUNCTION__);
00075                 cell = NULL;
00076         }
00077         else
00078         {
00079                 memset (cell, 0, size);
00080         }
00081 #if DEBUG
00082         DXF_DEBUG_END
00083 #endif
00084         return (cell);
00085 }
00086 
00087 
00103 DxfTable *
00104 dxf_table_new ()
00105 {
00106 #if DEBUG
00107         DXF_DEBUG_BEGIN
00108 #endif
00109         DxfTable *table = NULL;
00110         size_t size;
00111 
00112         size = sizeof (DxfTable);
00113         /* avoid malloc of 0 bytes */
00114         if (size == 0) size = 1;
00115         if ((table = malloc (size)) == NULL)
00116         {
00117                 fprintf (stderr,
00118                   (_("Error in %s () could not allocate memory for a DxfTable struct.\n")),
00119                   __FUNCTION__);
00120                 table = NULL;
00121         }
00122         else
00123         {
00124                 memset (table, 0, size);
00125         }
00126 #if DEBUG
00127         DXF_DEBUG_END
00128 #endif
00129         return (table);
00130 }
00131 
00132 
00147 DxfTableCell *
00148 dxf_table_cell_init
00149 (
00150         DxfTableCell *cell
00152 )
00153 {
00154 #if DEBUG
00155         DXF_DEBUG_BEGIN
00156 #endif
00157         int i;
00158 
00159         /* Do some basic checks. */
00160         if (cell == NULL)
00161         {
00162                 fprintf (stderr,
00163                   (_("Warning in %s () a NULL pointer was passed.\n")),
00164                   __FUNCTION__);
00165                 cell = dxf_table_cell_new ();
00166         }
00167         if (cell == NULL)
00168         {
00169                 fprintf (stderr,
00170                   (_("Error in %s () could not allocate memory for a DxfTableCell struct.\n")),
00171                   __FUNCTION__);
00172                 return (NULL);
00173         }
00174         cell->text_string = strdup ("");
00175         for (i = 0; i < DXF_MAX_PARAM; i++)
00176         {
00177                 cell->optional_text_string[i] = strdup ("");
00178                 cell->attdef_soft_pointer[i] = strdup ("");
00179         }
00180         cell->text_style_name = strdup (DXF_DEFAULT_TEXTSTYLE);
00181         cell->color_bg = 0;
00182         cell->color_fg = DXF_COLOR_BYLAYER;
00183         cell->border_color_right = DXF_COLOR_BYLAYER;
00184         cell->border_color_bottom = DXF_COLOR_BYLAYER;
00185         cell->border_color_left = DXF_COLOR_BYLAYER;
00186         cell->border_color_top = DXF_COLOR_BYLAYER;
00187         cell->text_height = 1.0;
00188         cell->block_scale = 1.0;
00189         cell->block_rotation = 0.0;
00190         cell->alignment = 0;
00191         cell->type = 0;
00192         cell->flag = 0;
00193         cell->merged = 0;
00194         cell->autofit = 0;
00195         cell->border_width = 0.0;
00196         cell->border_height = 0.0;
00197         cell->override = 0;
00198         cell->virtual_edge = 0;
00199         cell->number_of_block_attdefs = 0;
00200         cell->border_lineweight_right = 1.0;
00201         cell->border_lineweight_bottom = 1.0;
00202         cell->border_lineweight_left = 1.0;
00203         cell->border_lineweight_top = 1.0;
00204         cell->color_fill_override = 0;
00205         cell->border_visibility_override_right = 0;
00206         cell->border_visibility_override_bottom = 0;
00207         cell->border_visibility_override_left = 0;
00208         cell->border_visibility_override_top = 0;
00209         cell->attdef_text_string = strdup ("");
00210         cell->block_table_record_hard_pointer = strdup ("");
00211         cell->field_object_pointer = strdup ("");
00212         cell->next = NULL;
00213 #if DEBUG
00214         DXF_DEBUG_END
00215 #endif
00216         return (cell);
00217 }
00218 
00219 
00234 DxfTable *
00235 dxf_table_init
00236 (
00237         DxfTable *table
00239 )
00240 {
00241 #if DEBUG
00242         DXF_DEBUG_BEGIN
00243 #endif
00244         int i;
00245 
00246         /* Do some basic checks. */
00247         if (table == NULL)
00248         {
00249                 fprintf (stderr,
00250                   (_("Warning in %s () a NULL pointer was passed.\n")),
00251                   __FUNCTION__);
00252                 table = dxf_table_new ();
00253         }
00254         if (table == NULL)
00255         {
00256                 fprintf (stderr,
00257                   (_("Error in %s () could not allocate memory for a DxfTable struct.\n")),
00258                   __FUNCTION__);
00259                 return (NULL);
00260         }
00261         table->id_code = 0;
00262         table->linetype = strdup (DXF_DEFAULT_LINETYPE);
00263         table->layer = strdup (DXF_DEFAULT_LAYER);
00264         table->elevation = 0.0;
00265         table->thickness = 0.0;
00266         table->visibility = 0;
00267         table->color = DXF_COLOR_BYLAYER;
00268         table->paperspace = DXF_MODELSPACE;
00269         table->graphics_data_size = 0;
00270         for (i = 0; i < DXF_MAX_PARAM; i++)
00271         {
00272                 table->binary_graphics_data[i] = strdup ("");
00273                 table->row_height[i] = 0.0;
00274                 table->column_height[i] = 0.0;
00275         }
00276         table->dictionary_owner_soft = strdup ("");
00277         table->dictionary_owner_hard = strdup ("");
00278         table->block_name = strdup ("");
00279         table->table_text_style_name = strdup ("");
00280         table->x0 = 0.0;
00281         table->y0 = 0.0;
00282         table->z0 = 0.0;
00283         table->x1 = 0.0;
00284         table->y1 = 0.0;
00285         table->z1 = 0.0;
00286         table->horizontal_cell_margin = 0.0;
00287         table->vertical_cell_margin = 0.0;
00288         table->table_cell_color_bg = 0;
00289         table->table_cell_color_fg = 0;
00290         table->table_cell_border_color_horizontal = DXF_COLOR_BYLAYER;
00291         table->table_cell_border_color_bottom = DXF_COLOR_BYLAYER;
00292         table->table_cell_border_color_vertical = DXF_COLOR_BYLAYER;
00293         table->table_cell_border_color_right = DXF_COLOR_BYLAYER;
00294         table->flow_direction = 0;
00295         table->table_value_flag = 0;
00296         table->number_of_rows = 0;
00297         table->number_of_columns = 0;
00298         table->override_flag = 0;
00299         table->border_color_override_flag = 0;
00300         table->border_lineweight_override_flag = 0;
00301         table->border_visibility_override_flag = 0;
00302         table->table_text_height = 0.0;
00303         table->table_cell_alignment = 0;
00304         table->table_cell_border_lineweight_right = 0.0;
00305         table->suppress_table_title = 0;
00306         table->suppress_header_row = 0;
00307         table->table_cell_color_fill_override = 0;
00308         table->tablestyle_object_pointer = strdup ("");
00309         table->owning_block_pointer = strdup ("");
00310         table->cells = NULL;
00311         table->next = NULL;
00312 #if DEBUG
00313         DXF_DEBUG_END
00314 #endif
00315         return (table);
00316 }
00317 
00318 
00337 DxfTable *
00338 dxf_table_read
00339 (
00340         DxfFile *fp,
00342         DxfTable *table
00344 )
00345 {
00346 #if DEBUG
00347         DXF_DEBUG_BEGIN
00348 #endif
00349         char *temp_string = NULL;
00350         int i;
00351         int j;
00352         int k;
00353         int l;
00354 
00355         /* Do some basic checks. */
00356         if (fp == NULL)
00357         {
00358                 fprintf (stderr,
00359                   (_("Error in %s () a NULL file pointer was passed.\n")),
00360                   __FUNCTION__);
00361                 /* Clean up. */
00362                 free (temp_string);
00363                 return (NULL);
00364         }
00365         if (table == NULL)
00366         {
00367                 fprintf (stderr,
00368                   (_("Warning in %s () a NULL pointer was passed.\n")),
00369                   __FUNCTION__);
00370                 table = dxf_table_new ();
00371                 table = dxf_table_init (table);
00372         }
00373         i = 0;
00374         j = 0;
00375         k = 0;
00376         l = 0;
00377         (fp->line_number)++;
00378         fscanf (fp->fp, "%[^\n]", temp_string);
00379         while (strcmp (temp_string, "0") != 0)
00380         {
00381                 if (ferror (fp->fp))
00382                 {
00383                         fprintf (stderr,
00384                           (_("Error in %s () while reading from: %s in line: %d.\n")),
00385                           __FUNCTION__, fp->filename, fp->line_number);
00386                         fclose (fp->fp);
00387                         /* Clean up. */
00388                         free (temp_string);
00389                         return (NULL);
00390                 }
00391                 else if (strcmp (temp_string, "2") == 0)
00392                 {
00393                         /* Now follows a string containing a block name;
00394                          * an anonymous block begins with a *T value. */
00395                         fscanf (fp->fp, "%s\n", table->block_name);
00396                 }
00397                 if (strcmp (temp_string, "5") == 0)
00398                 {
00399                         /* Now follows a string containing a sequential
00400                          * id number. */
00401                         (fp->line_number)++;
00402                         fscanf (fp->fp, "%x\n", &table->id_code);
00403                 }
00404                 else if (strcmp (temp_string, "10") == 0)
00405                 {
00406                         /* Now follows a string containing the
00407                          * X-coordinate of the insertion point. */
00408                         (fp->line_number)++;
00409                         fscanf (fp->fp, "%lf\n", &table->x0);
00410                 }
00411                 else if (strcmp (temp_string, "11") == 0)
00412                 {
00413                         /* Now follows a string containing the
00414                          * X-coordinate of the horizontal direction
00415                          * vector. */
00416                         (fp->line_number)++;
00417                         fscanf (fp->fp, "%lf\n", &table->x1);
00418                 }
00419                 else if (strcmp (temp_string, "20") == 0)
00420                 {
00421                         /* Now follows a string containing the
00422                          * Y-coordinate of the insertion point. */
00423                         (fp->line_number)++;
00424                         fscanf (fp->fp, "%lf\n", &table->y0);
00425                 }
00426                 else if (strcmp (temp_string, "21") == 0)
00427                 {
00428                         /* Now follows a string containing the
00429                          * Y-coordinate of the horizontal direction
00430                          * vector. */
00431                         (fp->line_number)++;
00432                         fscanf (fp->fp, "%lf\n", &table->y1);
00433                 }
00434                 else if (strcmp (temp_string, "30") == 0)
00435                 {
00436                         /* Now follows a string containing the
00437                          * Z-coordinate of the insertion point. */
00438                         (fp->line_number)++;
00439                         fscanf (fp->fp, "%lf\n", &table->z0);
00440                 }
00441                 else if (strcmp (temp_string, "31") == 0)
00442                 {
00443                         /* Now follows a string containing the
00444                          * Z-coordinate of the horizontal direction
00445                          * vector. */
00446                         (fp->line_number)++;
00447                         fscanf (fp->fp, "%lf\n", &table->z1);
00448                 }
00449                 else if (strcmp (temp_string, "90") == 0)
00450                 {
00451                         /* Now follows a string containing the flag for
00452                          * table value (unsigned integer). */
00453                         (fp->line_number)++;
00454                         fscanf (fp->fp, "%d\n", &table->table_value_flag);
00455                 }
00456                 else if (strcmp (temp_string, "91") == 0)
00457                 {
00458                         /* Now follows a string containing the number of
00459                          * rows. */
00460                         (fp->line_number)++;
00461                         fscanf (fp->fp, "%d\n", &table->number_of_rows);
00462                 }
00463                 else if ((strcmp (temp_string, "92") == 0)
00464                   && (i == 0))
00465                 {
00466                         /* Now follows a string containing the
00467                          * number of bytes in the proxy entity graphics. */
00468                         (fp->line_number)++;
00469                         fscanf (fp->fp, "%d\n", &table->graphics_data_size);
00470                         i++;
00471                 }
00472                 else if ((strcmp (temp_string, "92") == 0)
00473                   && (i == 1))
00474                 {
00475                         /* Now follows a string containing the number of
00476                          * columns. */
00477                         (fp->line_number)++;
00478                         fscanf (fp->fp, "%d\n", &table->number_of_columns);
00479                 }
00480                 else if (strcmp (temp_string, "93") == 0)
00481                 {
00482                         /* Now follows a string containing the flag for
00483                          * an override. */
00484                         (fp->line_number)++;
00485                         fscanf (fp->fp, "%d\n", &table->override_flag);
00486                 }
00487                 else if (strcmp (temp_string, "94") == 0)
00488                 {
00489                         /* Now follows a string containing the flag for
00490                          * an override of the border color. */
00491                         (fp->line_number)++;
00492                         fscanf (fp->fp, "%d\n", &table->border_color_override_flag);
00493                 }
00494                 else if (strcmp (temp_string, "95") == 0)
00495                 {
00496                         /* Now follows a string containing the flag for
00497                          * an override of the border lineweight. */
00498                         (fp->line_number)++;
00499                         fscanf (fp->fp, "%d\n", &table->border_lineweight_override_flag);
00500                 }
00501                 else if (strcmp (temp_string, "96") == 0)
00502                 {
00503                         /* Now follows a string containing the flag for
00504                          * an override of the border visibility. */
00505                         (fp->line_number)++;
00506                         fscanf (fp->fp, "%d\n", &table->border_visibility_override_flag);
00507                 }
00508                 else if ((fp->acad_version_number >= AutoCAD_13)
00509                         && (strcmp (temp_string, "100") == 0))
00510                 {
00511                         /* Now follows a string containing the
00512                          * subclass marker value. */
00513                         (fp->line_number)++;
00514                         fscanf (fp->fp, "%s\n", temp_string);
00515                         if ((strcmp (temp_string, "AcDbEntity") != 0)
00516                         && ((strcmp (temp_string, "AcDbBlockReference") != 0))
00517                         && ((strcmp (temp_string, "AcDbBlockTable") != 0)))
00518                         {
00519                                 fprintf (stderr,
00520                                   (_("Warning in %s () found a bad subclass marker in: %s in line: %d.\n")),
00521                                   __FUNCTION__, fp->filename, fp->line_number);
00522                         }
00523                 }
00524                 else if (strcmp (temp_string, "141") == 0)
00525                 {
00526                         /* Now follows a string containing the row
00527                          * height. */
00528                         (fp->line_number)++;
00529                         fscanf (fp->fp, "%lf\n", &table->row_height[k]);
00530                         k++;
00531                 }
00532                 else if (strcmp (temp_string, "142") == 0)
00533                 {
00534                         /* Now follows a string containing the column
00535                          * height. */
00536                         (fp->line_number)++;
00537                         fscanf (fp->fp, "%lf\n", &table->column_height[l]);
00538                         l++;
00539                 }
00540                 else if (strcmp (temp_string, "310") == 0)
00541                 {
00542                         /* Now follows a string containing binary
00543                          * graphics data. */
00544                         (fp->line_number)++;
00545                         fscanf (fp->fp, "%s\n", table->binary_graphics_data[j]);
00546                         j++;
00547                 }
00548                 else if (strcmp (temp_string, "330") == 0)
00549                 {
00550                         /* Now follows a string containing a soft-pointer
00551                          * ID/handle to owner dictionary. */
00552                         (fp->line_number)++;
00553                         fscanf (fp->fp, "%s\n", table->dictionary_owner_soft);
00554                 }
00555                 else if (strcmp (temp_string, "342") == 0)
00556                 {
00557                         /* Now follows a string containing a hard pointer
00558                          * ID of the TABLESTYLE object. */
00559                         (fp->line_number)++;
00560                         fscanf (fp->fp, "%s\n", table->tablestyle_object_pointer);
00561                 }
00562                 else if (strcmp (temp_string, "343") == 0)
00563                 {
00564                         /* Now follows a string containing a hard pointer
00565                          * ID of the owning BLOCK record. */
00566                         (fp->line_number)++;
00567                         fscanf (fp->fp, "%s\n", table->owning_block_pointer);
00568                 }
00569                 else if (strcmp (temp_string, "360") == 0)
00570                 {
00571                         /* Now follows a string containing a hard owner
00572                          * ID/handle to owner dictionary. */
00573                         (fp->line_number)++;
00574                         fscanf (fp->fp, "%s\n", table->dictionary_owner_hard);
00575                 }
00576                 else if (strcmp (temp_string, "999") == 0)
00577                 {
00578                         /* Now follows a string containing a comment. */
00579                         (fp->line_number)++;
00580                         fscanf (fp->fp, "%s\n", temp_string);
00581                         fprintf (stdout, "DXF comment: %s\n", temp_string);
00582                 }
00583                 else
00584                 {
00585                         fprintf (stderr,
00586                           (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")),
00587                           __FUNCTION__, fp->filename, fp->line_number);
00588                 }
00589         }
00590         /* Clean up. */
00591         free (temp_string);
00592 #if DEBUG
00593         DXF_DEBUG_END
00594 #endif
00595         return (table);
00596 }
00597 
00598 
00612 int
00613 dxf_table_cell_write
00614 (
00615         DxfFile *fp,
00617         DxfTableCell *cell
00619 )
00620 {
00621 #if DEBUG
00622         DXF_DEBUG_BEGIN
00623 #endif
00624         int i;
00625 
00626         /* Do some basic checks. */
00627         if (fp == NULL)
00628         {
00629                 fprintf (stderr,
00630                   (_("Error in %s () a NULL file pointer was passed.\n")),
00631                   __FUNCTION__);
00632                 return (EXIT_FAILURE);
00633         }
00634         if (cell == NULL)
00635         {
00636                 fprintf (stderr,
00637                   (_("Error in %s () a NULL pointer was passed.\n")),
00638                   __FUNCTION__);
00639                 return (EXIT_FAILURE);
00640         }
00641         /* Start writing output. */
00642         fprintf (fp->fp, "171\n%d\n", cell->type);
00643         fprintf (fp->fp, "172\n%d\n", cell->flag);
00644         fprintf (fp->fp, "173\n%d\n", cell->merged);
00645         fprintf (fp->fp, "174\n%d\n", cell->autofit);
00646         fprintf (fp->fp, "175\n%lf\n", cell->border_width);
00647         fprintf (fp->fp, "176\n%lf\n", cell->border_height);
00648         fprintf (fp->fp, " 91\n%d\n", cell->override_flag);
00649         fprintf (fp->fp, "178\n%d\n", cell->virtual_edge);
00650         fprintf (fp->fp, "145\n%lf\n", cell->block_rotation);
00651         fprintf (fp->fp, "344\n%s\n", cell->field_object_pointer);
00652         i = 0;
00653         while ((cell->optional_text_string[i] != NULL)
00654           && (strcmp (cell->optional_text_string[i], "") != 0))
00655         {
00656                 fprintf (fp->fp, "  2\n%s\n", cell->optional_text_string[i]);
00657                 i++;
00658         }
00659         fprintf (fp->fp, "  1\n%s\n", cell->text_string);
00660         fprintf (fp->fp, "340\n%s\n", cell->block_table_record_hard_pointer);
00661         fprintf (fp->fp, "144\n%lf\n", cell->block_scale);
00662         fprintf (fp->fp, "179\n%d\n", cell->number_of_block_attdefs);
00663         i = 0;
00664         while ((cell->attdef_soft_pointer[i] != NULL)
00665           && (strcmp (cell->attdef_soft_pointer[i], "") != 0))
00666         {
00667                 fprintf (fp->fp, "331\n%s\n", cell->attdef_soft_pointer[i]);
00668                 i++;
00669         }
00670         if (cell->number_of_block_attdefs < (i + 1))
00671         {
00672                 fprintf (stderr,
00673                   (_("Warning in %s () more attdefs encountered than expected.\n")),
00674                   __FUNCTION__);
00675         }
00676         else if (cell->number_of_block_attdefs > (i + 1))
00677         {
00678                 fprintf (stderr,
00679                   (_("Warning in %s () less attdefs encountered than expected.\n")),
00680                   __FUNCTION__);
00681         }
00682 
00683 #if DEBUG
00684         DXF_DEBUG_END
00685 #endif
00686         return (EXIT_SUCCESS);
00687 }
00688 
00689 
00703 int
00704 dxf_table_write
00705 (
00706         DxfFile *fp,
00708         DxfTable *table
00710 )
00711 {
00712 #if DEBUG
00713         DXF_DEBUG_BEGIN
00714 #endif
00715         char *dxf_entity_name = strdup ("ACAD_TABLE");
00716         int i;
00717 
00718         /* Do some basic checks. */
00719         if (fp == NULL)
00720         {
00721                 fprintf (stderr,
00722                   (_("Error in %s () a NULL file pointer was passed.\n")),
00723                   __FUNCTION__);
00724                 /* Clean up. */
00725                 free (dxf_entity_name);
00726                 return (EXIT_FAILURE);
00727         }
00728         if (table == NULL)
00729         {
00730                 fprintf (stderr,
00731                   (_("Error in %s () a NULL pointer was passed.\n")),
00732                   __FUNCTION__);
00733                 /* Clean up. */
00734                 free (dxf_entity_name);
00735                 return (EXIT_FAILURE);
00736         }
00737         /* Start writing output. */
00738         fprintf (fp->fp, "  0\n%s\n", dxf_entity_name);
00739         if (table->id_code != -1)
00740         {
00741                 fprintf (fp->fp, "  5\n%x\n", table->id_code);
00742         }
00743         fprintf (fp->fp, "330\n%s\n", table->dictionary_owner_soft);
00744         if (fp->acad_version_number >= AutoCAD_13)
00745         {
00746                 fprintf (fp->fp, "100\nAcDbEntity\n");
00747         }
00748         fprintf (fp->fp, " 92\n%d\n", table->graphics_data_size);
00749         i = 0;
00750         while (strlen (table->binary_graphics_data[i]) > 0)
00751         {
00752                 fprintf (fp->fp, "310\n%s\n", table->binary_graphics_data[i]);
00753                 i++;
00754         }
00755         if (fp->acad_version_number >= AutoCAD_13)
00756         {
00757                 fprintf (fp->fp, "100\nAcDbBlockReference\n");
00758         }
00759         fprintf (fp->fp, "  2\n%s\n", table->block_name);
00760         fprintf (fp->fp, " 10\n%f\n", table->x0);
00761         fprintf (fp->fp, " 20\n%f\n", table->y0);
00762         fprintf (fp->fp, " 30\n%f\n", table->z0);
00763         if (fp->acad_version_number >= AutoCAD_13)
00764         {
00765                 fprintf (fp->fp, "100\nAcDbTable\n");
00766         }
00767         fprintf (fp->fp, "280\n%d\n", table->table_data_version);
00768         fprintf (fp->fp, "342\n%s\n", table->tablestyle_object_pointer);
00769         fprintf (fp->fp, "343\n%s\n", table->owning_block_pointer);
00770         fprintf (fp->fp, " 11\n%f\n", table->x1);
00771         fprintf (fp->fp, " 21\n%f\n", table->y1);
00772         fprintf (fp->fp, " 31\n%f\n", table->z1);
00773         fprintf (fp->fp, " 90\n%d\n", table->table_value_flag);
00774         fprintf (fp->fp, " 91\n%d\n", table->number_of_rows);
00775         fprintf (fp->fp, " 92\n%d\n", table->number_of_columns);
00776         fprintf (fp->fp, " 93\n%d\n", table->override_flag);
00777         fprintf (fp->fp, " 94\n%d\n", table->border_color_override_flag);
00778         fprintf (fp->fp, " 95\n%d\n", table->border_lineweight_override_flag);
00779         fprintf (fp->fp, " 96\n%d\n", table->border_visibility_override_flag);
00780         for (i = 0; i < table->number_of_rows; i++)
00781         {
00782                 fprintf (fp->fp, "141\n%f\n", table->row_height[i]);
00783         }
00784         for (i = 0; i < table->number_of_columns; i++)
00785         {
00786                 fprintf (fp->fp, "142\n%f\n", table->column_height[i]);
00787         }
00788 
00789         /* Clean up. */
00790         free (dxf_entity_name);
00791 #if DEBUG
00792         DXF_DEBUG_END
00793 #endif
00794         return (EXIT_SUCCESS);
00795 }
00796 
00797 
00812 int
00813 dxf_table_cell_free
00814 (
00815         DxfTableCell *cell
00817 )
00818 {
00819 #if DEBUG
00820         DXF_DEBUG_BEGIN
00821 #endif
00822         int i;
00823 
00824         /* Do some basic checks. */
00825         if (cell == NULL)
00826         {
00827                 fprintf (stderr,
00828                   (_("Error in %s () a NULL pointer was passed.\n")),
00829                   __FUNCTION__);
00830                 return (EXIT_FAILURE);
00831         }
00832         if (cell->next != NULL)
00833         {
00834               fprintf (stderr,
00835                 (_("Error in %s () pointer to next was not NULL.\n")),
00836                 __FUNCTION__);
00837               return (EXIT_FAILURE);
00838         }
00839         free (cell->text_string);
00840         for (i = 0; i < DXF_MAX_PARAM; i++)
00841         {
00842                 free (cell->optional_text_string[i]);
00843                 free (cell->attdef_soft_pointer[i]);
00844         }
00845         free (cell->text_style_name);
00846         free (cell->attdef_text_string);
00847         free (cell->block_table_record_hard_pointer);
00848         free (cell->field_object_pointer);
00849         free (cell);
00850         cell = NULL;
00851 #if DEBUG
00852         DXF_DEBUG_END
00853 #endif
00854         return (EXIT_SUCCESS);
00855 }
00856 
00857 
00872 int
00873 dxf_table_free
00874 (
00875         DxfTable *table
00877 )
00878 {
00879 #if DEBUG
00880         DXF_DEBUG_BEGIN
00881 #endif
00882         int i;
00883 
00884         /* Do some basic checks. */
00885         if (table == NULL)
00886         {
00887                 fprintf (stderr,
00888                   (_("Error in %s () a NULL pointer was passed.\n")),
00889                   __FUNCTION__);
00890                 return (EXIT_FAILURE);
00891         }
00892         if (table->next != NULL)
00893         {
00894               fprintf (stderr,
00895                 (_("Error in %s () pointer to next was not NULL.\n")),
00896                 __FUNCTION__);
00897               return (EXIT_FAILURE);
00898         }
00899         free (table->linetype);
00900         free (table->layer);
00901         for (i = 0; i < DXF_MAX_PARAM; i++)
00902         {
00903                 free (table->binary_graphics_data[i]);
00904         }
00905         free (table->dictionary_owner_soft);
00906         free (table->dictionary_owner_hard);
00907         free (table->block_name);
00908         free (table->table_text_style_name);
00909         free (table->tablestyle_object_pointer);
00910         free (table->owning_block_pointer);
00911 //        dxf_table_cells_free_chain (table->cells);
00912         free (table);
00913         table = NULL;
00914 #if DEBUG
00915         DXF_DEBUG_END
00916 #endif
00917         return (EXIT_SUCCESS);
00918 }
00919 
00920 
00932 void
00933 dxf_table_cell_free_chain
00934 (
00935         DxfTableCell *cells
00937 )
00938 {
00939 #ifdef DEBUG
00940         DXF_DEBUG_BEGIN
00941 #endif
00942         /* Do some basic checks. */
00943         if (cells == NULL)
00944         {
00945                 fprintf (stderr,
00946                   (_("Warning in %s () a NULL pointer was passed.\n")),
00947                   __FUNCTION__);
00948         }
00949         while (cells != NULL)
00950         {
00951                 struct DxfTableCell *iter = cells->next;
00952                 dxf_table_cell_free (cells);
00953                 cells = (DxfTableCell *) iter;
00954         }
00955 #if DEBUG
00956         DXF_DEBUG_END
00957 #endif
00958 }
00959 
00960 
00972 void
00973 dxf_table_free_chain
00974 (
00975         DxfTable *tables
00977 )
00978 {
00979 #ifdef DEBUG
00980         DXF_DEBUG_BEGIN
00981 #endif
00982         /* Do some basic checks. */
00983         if (tables == NULL)
00984         {
00985                 fprintf (stderr,
00986                   (_("Warning in %s () a NULL pointer was passed.\n")),
00987                   __FUNCTION__);
00988         }
00989         while (tables != NULL)
00990         {
00991                 struct DxfTable *iter = tables->next;
00992                 dxf_table_free (tables);
00993                 tables = (DxfTable *) iter;
00994         }
00995 #if DEBUG
00996         DXF_DEBUG_END
00997 #endif
00998 }
00999 
01000 
01001 /* EOF */