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

layer.c

Go to the documentation of this file.
00001 
00040 #include "layer.h"
00041 
00042 
00051 DxfLayer *
00052 dxf_layer_new ()
00053 {
00054 #if DEBUG
00055         DXF_DEBUG_BEGIN
00056 #endif
00057         DxfLayer *layer = NULL;
00058         size_t size;
00059 
00060         size = sizeof (DxfLayer);
00061         /* avoid malloc of 0 bytes */
00062         if (size == 0) size = 1;
00063         if ((layer = malloc (size)) == NULL)
00064         {
00065                 fprintf (stderr,
00066                   (_("Error in %s () could not allocate memory for a DxfLayer struct.\n")),
00067                   __FUNCTION__);
00068                 layer = NULL;
00069         }
00070         else
00071         {
00072                 memset (layer, 0, size);
00073         }
00074 #if DEBUG
00075         DXF_DEBUG_END
00076 #endif
00077         return (layer);
00078 }
00079 
00080 
00088 DxfLayer *
00089 dxf_layer_init
00090 (
00091         DxfLayer *layer
00093 )
00094 {
00095 #if DEBUG
00096         DXF_DEBUG_BEGIN
00097 #endif
00098         /* Do some basic checks. */
00099         if (layer == NULL)
00100         {
00101                 fprintf (stderr,
00102                   (_("Warning in %s () a NULL pointer was passed.\n")),
00103                   __FUNCTION__);
00104                 layer = dxf_layer_new ();
00105         }
00106         if (layer == NULL)
00107         {
00108               fprintf (stderr,
00109                 (_("Error in %s () could not allocate memory for a DxfLayer struct.\n")),
00110                 __FUNCTION__);
00111               return (NULL);
00112         }
00113         dxf_layer_set_id_code (layer, 0);
00114         dxf_layer_set_layer_name (layer, strdup (""));
00115         dxf_layer_set_linetype (layer, strdup (DXF_DEFAULT_LINETYPE));
00116         dxf_layer_set_color (layer, DXF_COLOR_BYLAYER);
00117         dxf_layer_set_flag (layer, 0);
00118         dxf_layer_set_plotting_flag (layer, 0);
00119         dxf_layer_set_dictionary_owner_soft (layer, strdup (""));
00120         dxf_layer_set_material (layer, strdup (""));
00121         dxf_layer_set_dictionary_owner_hard (layer, strdup (""));
00122         dxf_layer_set_lineweight (layer, 0);
00123         dxf_layer_set_plot_style_name (layer, strdup (""));
00124         dxf_layer_set_next (layer, NULL);
00125 #if DEBUG
00126         DXF_DEBUG_END
00127 #endif
00128         return (layer);
00129 }
00130 
00131 
00143 DxfLayer *
00144 dxf_layer_read
00145 (
00146         DxfFile *fp,
00148         DxfLayer *layer
00150 )
00151 {
00152 #if DEBUG
00153         DXF_DEBUG_BEGIN
00154 #endif
00155         char *temp_string = NULL;
00156 
00157         /* Do some basic checks. */
00158         if (fp == NULL)
00159         {
00160                 fprintf (stderr,
00161                   (_("Error in %s () a NULL file pointer was passed.\n")),
00162                   __FUNCTION__);
00163                 /* Clean up. */
00164                 free (temp_string);
00165                 return (NULL);
00166         }
00167         if (layer == NULL)
00168         {
00169                 fprintf (stderr,
00170                   (_("Warning in %s () a NULL pointer was passed.\n")),
00171                   __FUNCTION__);
00172                 layer = dxf_layer_new ();
00173                 layer = dxf_layer_init (layer);
00174         }
00175         (fp->line_number)++;
00176         fscanf (fp->fp, "%[^\n]", temp_string);
00177         while (strcmp (temp_string, "0") != 0)
00178         {
00179                 if (ferror (fp->fp))
00180                 {
00181                         fprintf (stderr,
00182                           (_("Error in %s () while reading from: %s in line: %d.\n")),
00183                           __FUNCTION__, fp->filename, fp->line_number);
00184                         fclose (fp->fp);
00185                         /* Clean up. */
00186                         free (temp_string);
00187                         return (NULL);
00188                 }
00189                 if (strcmp (temp_string, "2") == 0)
00190                 {
00191                         /* Now follows a string containing the layer
00192                          * name. */
00193                         (fp->line_number)++;
00194                         fscanf (fp->fp, "%s\n", layer->layer_name);
00195                 }
00196                 else if (strcmp (temp_string, "6") == 0)
00197                 {
00198                         /* Now follows a string containing the linetype
00199                          * name. */
00200                         (fp->line_number)++;
00201                         fscanf (fp->fp, "%s\n", layer->linetype);
00202                 }
00203                 else if (strcmp (temp_string, "62") == 0)
00204                 {
00205                         /* Now follows a string containing the
00206                          * color value. */
00207                         (fp->line_number)++;
00208                         fscanf (fp->fp, "%d\n", &layer->color);
00209                 }
00210                 else if (strcmp (temp_string, "70") == 0)
00211                 {
00212                         /* Now follows a string containing the
00213                          * flag value. */
00214                         (fp->line_number)++;
00215                         fscanf (fp->fp, "%d\n", &layer->flag);
00216                 }
00217                 else if ((fp->acad_version_number >= AutoCAD_13)
00218                         && (strcmp (temp_string, "100") == 0))
00219                 {
00220                         /* Now follows a string containing the
00221                          * subclass marker value. */
00222                         (fp->line_number)++;
00223                         fscanf (fp->fp, "%s\n", temp_string);
00224                         if ((strcmp (temp_string, "AcDbSymbolTable") != 0)
00225                         && ((strcmp (temp_string, "AcDbLayerTableRecord") != 0)))
00226                         {
00227                                 fprintf (stderr,
00228                                   (_("Warning in %s () found a bad subclass marker in: %s in line: %d.\n")),
00229                                   __FUNCTION__, fp->filename, fp->line_number);
00230                         }
00231                 }
00232                 else if (strcmp (temp_string, "290") == 0)
00233                 {
00234                         /* Now follows a string containing the plotting
00235                          * flag value. */
00236                         (fp->line_number)++;
00237                         fscanf (fp->fp, "%d\n", &layer->plotting_flag);
00238                 }
00239                 else if (strcmp (temp_string, "330") == 0)
00240                 {
00241                         /* Now follows a string containing Soft-pointer
00242                          * ID/handle to owner dictionary. */
00243                         (fp->line_number)++;
00244                         fscanf (fp->fp, "%s\n", layer->dictionary_owner_soft);
00245                 }
00246                 else if (strcmp (temp_string, "347") == 0)
00247                 {
00248                         /* Now follows a string containing the material. */
00249                         (fp->line_number)++;
00250                         fscanf (fp->fp, "%s\n", layer->material);
00251                 }
00252                 else if (strcmp (temp_string, "360") == 0)
00253                 {
00254                         /* Now follows a string containing Hard owner
00255                          * ID/handle to owner dictionary. */
00256                         (fp->line_number)++;
00257                         fscanf (fp->fp, "%s\n", layer->dictionary_owner_hard);
00258                 }
00259                 else if (strcmp (temp_string, "370") == 0)
00260                 {
00261                         /* Now follows a string containing the
00262                          * lineweight. */
00263                         (fp->line_number)++;
00264                         fscanf (fp->fp, "%hd\n", &layer->lineweight);
00265                 }
00266                 else if (strcmp (temp_string, "390") == 0)
00267                 {
00268                         /* Now follows a string containing the plot style
00269                          * name. */
00270                         (fp->line_number)++;
00271                         fscanf (fp->fp, "%s\n", layer->plot_style_name);
00272                 }
00273                 else if (strcmp (temp_string, "999") == 0)
00274                 {
00275                         /* Now follows a string containing a comment. */
00276                         (fp->line_number)++;
00277                         fscanf (fp->fp, "%s\n", temp_string);
00278                         fprintf (stdout, "DXF comment: %s\n", temp_string);
00279                 }
00280                 else
00281                 {
00282                         fprintf (stderr,
00283                           (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")),
00284                           __FUNCTION__, fp->filename, fp->line_number);
00285                 }
00286         }
00287         /* Handle omitted members and/or illegal values. */
00288         if (strcmp (layer->layer_name, "") == 0)
00289         {
00290                 fprintf (stderr,
00291                   (_("Error in %s () found a bad layer name in: %s in line: %d.\n")),
00292                   __FUNCTION__, fp->filename, fp->line_number);
00293                 fprintf (stderr,
00294                   (_("\tskipping layer.\n")));
00295                 return (NULL);
00296         }
00297         if (strcmp (layer->linetype, "") == 0)
00298         {
00299                 layer->linetype = strdup (DXF_DEFAULT_LINETYPE);
00300         }
00301         /* Clean up. */
00302         free (temp_string);
00303 #if DEBUG
00304         DXF_DEBUG_END
00305 #endif
00306         return (layer);
00307 }
00308 
00309 
00316 int
00317 dxf_layer_write
00318 (
00319         DxfFile *fp,
00321         DxfLayer *layer
00323 )
00324 {
00325 #if DEBUG
00326         DXF_DEBUG_BEGIN
00327 #endif
00328         char *dxf_entity_name = strdup ("LAYER");
00329 
00330         /* Do some basic checks. */
00331         if (fp == NULL)
00332         {
00333                 fprintf (stderr,
00334                   (_("Error in %s () a NULL file pointer was passed.\n")),
00335                   __FUNCTION__);
00336                 /* Clean up. */
00337                 free (dxf_entity_name);
00338                 return (EXIT_FAILURE);
00339         }
00340         if (layer == NULL)
00341         {
00342                 fprintf (stderr,
00343                   (_("Error in %s () a NULL pointer was passed.\n")),
00344                   __FUNCTION__);
00345                 /* Clean up. */
00346                 free (dxf_entity_name);
00347                 return (EXIT_FAILURE);
00348         }
00349         if (strcmp (dxf_layer_get_layer_name (layer), "") == 0)
00350         {
00351                 fprintf (stderr,
00352                   (_("Error in %s () empty layer string for the %s table.\n")),
00353                   __FUNCTION__, dxf_entity_name);
00354                 /* Clean up. */
00355                 free (dxf_entity_name);
00356                 return (EXIT_FAILURE);
00357         }
00358         if (strcmp (dxf_layer_get_linetype (layer), "") == 0)
00359         {
00360                 fprintf (stderr,
00361                   (_("Warning in %s () empty linetype string for the %s layer\n")),
00362                   __FUNCTION__, dxf_entity_name);
00363                 fprintf (stderr,
00364                   (_("\t%s entity is reset to default linetype")),
00365                   dxf_entity_name);
00366                 dxf_layer_set_linetype (layer, strdup (DXF_DEFAULT_LINETYPE));
00367         }
00368         /* Start writing output. */
00369         fprintf (fp->fp, "  0\n%s\n", dxf_entity_name);
00370         if (layer->id_code != -1)
00371         {
00372                 fprintf (fp->fp, "  5\n%x\n", dxf_layer_get_id_code (layer));
00373         }
00384         if ((strcmp (dxf_layer_get_dictionary_owner_soft (layer), "") != 0)
00385           && (fp->acad_version_number >= AutoCAD_14))
00386         {
00387                 fprintf (fp->fp, "102\n{ACAD_REACTORS\n");
00388                 fprintf (fp->fp, "330\n%s\n", dxf_layer_get_dictionary_owner_soft (layer));
00389                 fprintf (fp->fp, "102\n}\n");
00390         }
00391         if (fp->acad_version_number >= AutoCAD_14)
00392         {
00393                 fprintf (fp->fp, "100\nAcDbSymbolTable\n");
00394         }
00395         if (fp->acad_version_number >= AutoCAD_14)
00396         {
00397                 fprintf (fp->fp, "100\nAcDbLayerTableRecord\n");
00398         }
00399         fprintf (fp->fp, "  2\n%s\n", dxf_layer_get_layer_name (layer));
00400         fprintf (fp->fp, " 70\n%d\n", dxf_layer_get_flag (layer));
00401         fprintf (fp->fp, " 62\n%d\n", dxf_layer_get_color (layer));
00402         fprintf (fp->fp, "  6\n%s\n", dxf_layer_get_linetype (layer));
00403         if (fp->acad_version_number >= AutoCAD_2000)
00404         {
00405                 fprintf (fp->fp, "290\n%d\n", dxf_layer_get_plotting_flag (layer));
00406                 fprintf (fp->fp, "370\n%hd\n", dxf_layer_get_lineweight (layer));
00407                 fprintf (fp->fp, "390\n%s\n", dxf_layer_get_plot_style_name (layer));
00408         }
00409         if (fp->acad_version_number >= AutoCAD_2007)
00410         {
00411                 fprintf (fp->fp, "347\n%s\n", dxf_layer_get_material (layer));
00412         }
00413         /* Clean up. */
00414         free (dxf_entity_name);
00415 #if DEBUG
00416         DXF_DEBUG_END
00417 #endif
00418         return (EXIT_SUCCESS);
00419 }
00420 
00421 
00429 int
00430 dxf_layer_free
00431 (
00432         DxfLayer *layer
00435 )
00436 {
00437 #if DEBUG
00438         DXF_DEBUG_BEGIN
00439 #endif
00440         /* Do some basic checks. */
00441         if (layer == NULL)
00442         {
00443                 fprintf (stderr,
00444                   (_("Error in %s () a NULL pointer was passed.\n")),
00445                   __FUNCTION__);
00446                 return (EXIT_FAILURE);
00447         }
00448         if (layer->next != NULL)
00449         {
00450                 fprintf (stderr,
00451                   (_("Error in %s () pointer to next was not NULL.\n")),
00452                   __FUNCTION__);
00453                 return (EXIT_FAILURE);
00454         }
00455         free (dxf_layer_get_layer_name (layer));
00456         free (dxf_layer_get_linetype (layer));
00457         free (dxf_layer_get_dictionary_owner_soft (layer));
00458         free (dxf_layer_get_material (layer));
00459         free (dxf_layer_get_dictionary_owner_hard (layer));
00460         free (dxf_layer_get_plot_style_name (layer));
00461         free (layer);
00462         layer = NULL;
00463 #if DEBUG
00464         DXF_DEBUG_END
00465 #endif
00466         return (EXIT_SUCCESS);
00467 }
00468 
00469 
00480 void
00481 dxf_layer_free_chain
00482 (
00483         DxfLayer *layers
00485 )
00486 {
00487 #ifdef DEBUG
00488         DXF_DEBUG_BEGIN
00489 #endif
00490         if (layers == NULL)
00491         {
00492                 fprintf (stderr,
00493                   (_("Warning in %s () a NULL pointer was passed.\n")),
00494                   __FUNCTION__);
00495         }
00496         while (layers != NULL)
00497         {
00498                 struct DxfLayer *iter = layers->next;
00499                 dxf_layer_free (layers);
00500                 layers = (DxfLayer *) iter;
00501         }
00502 #if DEBUG
00503         DXF_DEBUG_END
00504 #endif
00505 }
00506 
00507 
00513 int
00514 dxf_layer_get_id_code
00515 (
00516         DxfLayer *layer
00518 )
00519 {
00520 #if DEBUG
00521         DXF_DEBUG_BEGIN
00522 #endif
00523         /* Do some basic checks. */
00524         if (layer == NULL)
00525         {
00526                 fprintf (stderr,
00527                   (_("Error in %s () a NULL pointer was passed.\n")),
00528                   __FUNCTION__);
00529                 return (EXIT_FAILURE);
00530         }
00531         if (layer->id_code < 0)
00532         {
00533                 fprintf (stderr,
00534                   (_("Error in %s () a negative value was found.\n")),
00535                   __FUNCTION__);
00536                 return (EXIT_FAILURE);
00537         }
00538 #if DEBUG
00539         DXF_DEBUG_END
00540 #endif
00541         return (layer->id_code);
00542 }
00543 
00544 
00548 DxfLayer *
00549 dxf_layer_set_id_code
00550 (
00551         DxfLayer *layer,
00553         int id_code
00557 )
00558 {
00559 #if DEBUG
00560         DXF_DEBUG_BEGIN
00561 #endif
00562         /* Do some basic checks. */
00563         if (layer == NULL)
00564         {
00565                 fprintf (stderr,
00566                   (_("Error in %s () a NULL pointer was passed.\n")),
00567                   __FUNCTION__);
00568                 return (NULL);
00569         }
00570         if (id_code < 0)
00571         {
00572                 fprintf (stderr,
00573                   (_("Error in %s () a negative value was passed.\n")),
00574                   __FUNCTION__);
00575                 return (NULL);
00576         }
00577         layer->id_code = id_code;
00578 #if DEBUG
00579         DXF_DEBUG_END
00580 #endif
00581         return (layer);
00582 }
00583 
00584 
00590 char *
00591 dxf_layer_get_layer_name
00592 (
00593         DxfLayer *layer
00595 )
00596 {
00597 #if DEBUG
00598         DXF_DEBUG_BEGIN
00599 #endif
00600         /* Do some basic checks. */
00601         if (layer == NULL)
00602         {
00603                 fprintf (stderr,
00604                   (_("Error in %s () a NULL pointer was passed.\n")),
00605                   __FUNCTION__);
00606                 return (NULL);
00607         }
00608         if (layer->layer_name ==  NULL)
00609         {
00610                 fprintf (stderr,
00611                   (_("Error in %s () a NULL pointer was found.\n")),
00612                   __FUNCTION__);
00613                 return (NULL);
00614         }
00615 #if DEBUG
00616         DXF_DEBUG_END
00617 #endif
00618         return (strdup (layer->layer_name));
00619 }
00620 
00621 
00625 DxfLayer *
00626 dxf_layer_set_layer_name
00627 (
00628         DxfLayer *layer,
00630         char *layer_name
00633 )
00634 {
00635 #if DEBUG
00636         DXF_DEBUG_BEGIN
00637 #endif
00638         /* Do some basic checks. */
00639         if (layer == NULL)
00640         {
00641                 fprintf (stderr,
00642                   (_("Error in %s () a NULL pointer was passed.\n")),
00643                   __FUNCTION__);
00644                 return (NULL);
00645         }
00646         if (layer_name == NULL)
00647         {
00648                 fprintf (stderr,
00649                   (_("Error in %s () a NULL pointer was passed.\n")),
00650                   __FUNCTION__);
00651                 return (NULL);
00652         }
00653         layer->layer_name = strdup (layer_name);
00654 #if DEBUG
00655         DXF_DEBUG_END
00656 #endif
00657         return (layer);
00658 }
00659 
00660 
00666 char *
00667 dxf_layer_get_linetype
00668 (
00669         DxfLayer *layer
00671 )
00672 {
00673 #if DEBUG
00674         DXF_DEBUG_BEGIN
00675 #endif
00676         /* Do some basic checks. */
00677         if (layer == NULL)
00678         {
00679                 fprintf (stderr,
00680                   (_("Error in %s () a NULL pointer was passed.\n")),
00681                   __FUNCTION__);
00682                 return (NULL);
00683         }
00684         if (layer->linetype ==  NULL)
00685         {
00686                 fprintf (stderr,
00687                   (_("Error in %s () a NULL pointer was found.\n")),
00688                   __FUNCTION__);
00689                 return (NULL);
00690         }
00691 #if DEBUG
00692         DXF_DEBUG_END
00693 #endif
00694         return (strdup (layer->linetype));
00695 }
00696 
00697 
00701 DxfLayer *
00702 dxf_layer_set_linetype
00703 (
00704         DxfLayer *layer,
00706         char *linetype
00708 )
00709 {
00710 #if DEBUG
00711         DXF_DEBUG_BEGIN
00712 #endif
00713         /* Do some basic checks. */
00714         if (layer == NULL)
00715         {
00716                 fprintf (stderr,
00717                   (_("Error in %s () a NULL pointer was passed.\n")),
00718                   __FUNCTION__);
00719                 return (NULL);
00720         }
00721         if (linetype == NULL)
00722         {
00723                 fprintf (stderr,
00724                   (_("Error in %s () a NULL pointer was passed.\n")),
00725                   __FUNCTION__);
00726                 return (NULL);
00727         }
00728         layer->linetype = strdup (linetype);
00729 #if DEBUG
00730         DXF_DEBUG_END
00731 #endif
00732         return (layer);
00733 }
00734 
00735 
00741 int
00742 dxf_layer_get_color
00743 (
00744         DxfLayer *layer
00746 )
00747 {
00748 #if DEBUG
00749         DXF_DEBUG_BEGIN
00750 #endif
00751         /* Do some basic checks. */
00752         if (layer == NULL)
00753         {
00754                 fprintf (stderr,
00755                   (_("Error in %s () a NULL pointer was passed.\n")),
00756                   __FUNCTION__);
00757                 return (EXIT_FAILURE);
00758         }
00759         if (layer->color < 0)
00760         {
00761                 fprintf (stderr,
00762                   (_("Warning in %s () a negative value was found.\n")),
00763                   __FUNCTION__);
00764         }
00765 #if DEBUG
00766         DXF_DEBUG_END
00767 #endif
00768         return (layer->color);
00769 }
00770 
00771 
00775 DxfLayer *
00776 dxf_layer_set_color
00777 (
00778         DxfLayer *layer,
00780         int color
00782 )
00783 {
00784 #if DEBUG
00785         DXF_DEBUG_BEGIN
00786 #endif
00787         /* Do some basic checks. */
00788         if (layer == NULL)
00789         {
00790                 fprintf (stderr,
00791                   (_("Error in %s () a NULL pointer was passed.\n")),
00792                   __FUNCTION__);
00793                 return (NULL);
00794         }
00795         if (color < 0)
00796         {
00797                 fprintf (stderr,
00798                   (_("Warning in %s () a negative value was passed.\n")),
00799                   __FUNCTION__);
00800         }
00801         layer->color = color;
00802 #if DEBUG
00803         DXF_DEBUG_END
00804 #endif
00805         return (layer);
00806 }
00807 
00808 
00815 int
00816 dxf_layer_is_off
00817 (
00818         DxfLayer *layer
00820 )
00821 {
00822 #if DEBUG
00823         DXF_DEBUG_BEGIN
00824 #endif
00825         int result = FALSE;
00826 
00827         /* Do some basic checks. */
00828         if (layer == NULL)
00829         {
00830                 fprintf (stderr,
00831                   (_("Error in %s () a NULL pointer was passed.\n")),
00832                   __FUNCTION__);
00833                 return (-1);
00834         }
00835         result = (layer->color < 0);
00836 #if DEBUG
00837         DXF_DEBUG_END
00838 #endif
00839         return (result);
00840 }
00841 
00842 
00848 int
00849 dxf_layer_get_flag
00850 (
00851         DxfLayer *layer
00853 )
00854 {
00855 #if DEBUG
00856         DXF_DEBUG_BEGIN
00857 #endif
00858         /* Do some basic checks. */
00859         if (layer == NULL)
00860         {
00861                 fprintf (stderr,
00862                   (_("Error in %s () a NULL pointer was passed.\n")),
00863                   __FUNCTION__);
00864                 return (EXIT_FAILURE);
00865         }
00866         if (layer->flag < 0)
00867         {
00868                 fprintf (stderr,
00869                   (_("Error in %s () a negative value was found.\n")),
00870                   __FUNCTION__);
00871                 return (EXIT_FAILURE);
00872         }
00873 #if DEBUG
00874         DXF_DEBUG_END
00875 #endif
00876         return (layer->flag);
00877 }
00878 
00879 
00883 DxfLayer *
00884 dxf_layer_set_flag
00885 (
00886         DxfLayer *layer,
00888         int flag
00890 )
00891 {
00892 #if DEBUG
00893         DXF_DEBUG_BEGIN
00894 #endif
00895         /* Do some basic checks. */
00896         if (layer == NULL)
00897         {
00898                 fprintf (stderr,
00899                   (_("Error in %s () a NULL pointer was passed.\n")),
00900                   __FUNCTION__);
00901                 return (NULL);
00902         }
00903         if (flag < 0)
00904         {
00905                 fprintf (stderr,
00906                   (_("Error in %s () a negative value was passed.\n")),
00907                   __FUNCTION__);
00908                 return (NULL);
00909         }
00910         layer->flag = flag;
00911 #if DEBUG
00912         DXF_DEBUG_END
00913 #endif
00914         return (layer);
00915 }
00916 
00917 
00924 int
00925 dxf_layer_is_frozen
00926 (
00927         DxfLayer *layer
00929 )
00930 {
00931 #if DEBUG
00932         DXF_DEBUG_BEGIN
00933 #endif
00934         int result = FALSE;
00935 
00936         /* Do some basic checks. */
00937         if (layer == NULL)
00938         {
00939                 fprintf (stderr,
00940                   (_("Error in %s () a NULL pointer was passed.\n")),
00941                   __FUNCTION__);
00942                 return (-1);
00943         }
00944         result = ((DXF_CHECK_BIT (layer->flag, 0))
00945           || (DXF_CHECK_BIT (layer->flag, 1)));
00946 #if DEBUG
00947         DXF_DEBUG_END
00948 #endif
00949         return (result);
00950 }
00951 
00952 
00959 int
00960 dxf_layer_is_locked
00961 (
00962         DxfLayer *layer
00964 )
00965 {
00966 #if DEBUG
00967         DXF_DEBUG_BEGIN
00968 #endif
00969         int result = FALSE;
00970 
00971         /* Do some basic checks. */
00972         if (layer == NULL)
00973         {
00974                 fprintf (stderr,
00975                   (_("Error in %s () a NULL pointer was passed.\n")),
00976                   __FUNCTION__);
00977                 return (-1);
00978         }
00979         result = DXF_CHECK_BIT (layer->flag, 2);
00980 #if DEBUG
00981         DXF_DEBUG_END
00982 #endif
00983         return (result);
00984 }
00985 
00986 
00994 int
00995 dxf_layer_is_xreferenced
00996 (
00997         DxfLayer *layer
00999 )
01000 {
01001 #if DEBUG
01002         DXF_DEBUG_BEGIN
01003 #endif
01004         int result = FALSE;
01005 
01006         /* Do some basic checks. */
01007         if (layer == NULL)
01008         {
01009                 fprintf (stderr,
01010                   (_("Error in %s () a NULL pointer was passed.\n")),
01011                   __FUNCTION__);
01012                 return (-1);
01013         }
01014         result = DXF_CHECK_BIT (layer->flag, 4);
01015 #if DEBUG
01016         DXF_DEBUG_END
01017 #endif
01018         return (result);
01019 }
01020 
01021 
01031 int
01032 dxf_layer_is_xresolved
01033 (
01034         DxfLayer *layer
01036 )
01037 {
01038 #if DEBUG
01039         DXF_DEBUG_BEGIN
01040 #endif
01041         int result = FALSE;
01042 
01043         /* Do some basic checks. */
01044         if (layer == NULL)
01045         {
01046                 fprintf (stderr,
01047                   (_("Error in %s () a NULL pointer was passed.\n")),
01048                   __FUNCTION__);
01049                 return (-1);
01050         }
01051         result = ((DXF_CHECK_BIT (layer->flag, 4))
01052           && (DXF_CHECK_BIT (layer->flag, 5)));
01053 #if DEBUG
01054         DXF_DEBUG_END
01055 #endif
01056         return (result);
01057 }
01058 
01059 
01067 int
01068 dxf_layer_is_referenced
01069 (
01070         DxfLayer *layer
01072 )
01073 {
01074 #if DEBUG
01075         DXF_DEBUG_BEGIN
01076 #endif
01077         int result = FALSE;
01078 
01079         /* Do some basic checks. */
01080         if (layer == NULL)
01081         {
01082                 fprintf (stderr,
01083                   (_("Error in %s () a NULL pointer was passed.\n")),
01084                   __FUNCTION__);
01085                 return (-1);
01086         }
01087         result = DXF_CHECK_BIT (layer->flag, 6);
01088 #if DEBUG
01089         DXF_DEBUG_END
01090 #endif
01091         return (result);
01092 }
01093 
01094 
01100 int
01101 dxf_layer_get_plotting_flag
01102 (
01103         DxfLayer *layer
01105 )
01106 {
01107 #if DEBUG
01108         DXF_DEBUG_BEGIN
01109 #endif
01110         /* Do some basic checks. */
01111         if (layer == NULL)
01112         {
01113                 fprintf (stderr,
01114                   (_("Error in %s () a NULL pointer was passed.\n")),
01115                   __FUNCTION__);
01116                 return (EXIT_FAILURE);
01117         }
01118         if (layer->plotting_flag < 0)
01119         {
01120                 fprintf (stderr,
01121                   (_("Error in %s () a negative value was found.\n")),
01122                   __FUNCTION__);
01123                 return (EXIT_FAILURE);
01124         }
01125 #if DEBUG
01126         DXF_DEBUG_END
01127 #endif
01128         return (layer->plotting_flag);
01129 }
01130 
01131 
01135 DxfLayer *
01136 dxf_layer_set_plotting_flag
01137 (
01138         DxfLayer *layer,
01140         int plotting_flag
01142 )
01143 {
01144 #if DEBUG
01145         DXF_DEBUG_BEGIN
01146 #endif
01147         /* Do some basic checks. */
01148         if (layer == NULL)
01149         {
01150                 fprintf (stderr,
01151                   (_("Error in %s () a NULL pointer was passed.\n")),
01152                   __FUNCTION__);
01153                 return (NULL);
01154         }
01155         if (plotting_flag < 0)
01156         {
01157                 fprintf (stderr,
01158                   (_("Error in %s () a negative value was passed.\n")),
01159                   __FUNCTION__);
01160                 return (NULL);
01161         }
01162         layer->plotting_flag = plotting_flag;
01163 #if DEBUG
01164         DXF_DEBUG_END
01165 #endif
01166         return (layer);
01167 }
01168 
01169 
01178 char *
01179 dxf_layer_get_dictionary_owner_soft
01180 (
01181         DxfLayer *layer
01183 )
01184 {
01185 #if DEBUG
01186         DXF_DEBUG_BEGIN
01187 #endif
01188         /* Do some basic checks. */
01189         if (layer == NULL)
01190         {
01191                 fprintf (stderr,
01192                   (_("Error in %s () a NULL pointer was passed.\n")),
01193                   __FUNCTION__);
01194                 return (NULL);
01195         }
01196         if (layer->dictionary_owner_soft ==  NULL)
01197         {
01198                 fprintf (stderr,
01199                   (_("Error in %s () a NULL pointer was found.\n")),
01200                   __FUNCTION__);
01201                 return (NULL);
01202         }
01203 #if DEBUG
01204         DXF_DEBUG_END
01205 #endif
01206         return (strdup (layer->dictionary_owner_soft));
01207 }
01208 
01209 
01214 DxfLayer *
01215 dxf_layer_set_dictionary_owner_soft
01216 (
01217         DxfLayer *layer,
01219         char *dictionary_owner_soft
01222 )
01223 {
01224 #if DEBUG
01225         DXF_DEBUG_BEGIN
01226 #endif
01227         /* Do some basic checks. */
01228         if (layer == NULL)
01229         {
01230                 fprintf (stderr,
01231                   (_("Error in %s () a NULL pointer was passed.\n")),
01232                   __FUNCTION__);
01233                 return (NULL);
01234         }
01235         if (dictionary_owner_soft == NULL)
01236         {
01237                 fprintf (stderr,
01238                   (_("Error in %s () a NULL pointer was passed.\n")),
01239                   __FUNCTION__);
01240                 return (NULL);
01241         }
01242         layer->dictionary_owner_soft = strdup (dictionary_owner_soft);
01243 #if DEBUG
01244         DXF_DEBUG_END
01245 #endif
01246         return (layer);
01247 }
01248 
01249 
01258 char *
01259 dxf_layer_get_material
01260 (
01261         DxfLayer *layer
01263 )
01264 {
01265 #if DEBUG
01266         DXF_DEBUG_BEGIN
01267 #endif
01268         /* Do some basic checks. */
01269         if (layer == NULL)
01270         {
01271                 fprintf (stderr,
01272                   (_("Error in %s () a NULL pointer was passed.\n")),
01273                   __FUNCTION__);
01274                 return (NULL);
01275         }
01276         if (layer->material ==  NULL)
01277         {
01278                 fprintf (stderr,
01279                   (_("Error in %s () a NULL pointer was found.\n")),
01280                   __FUNCTION__);
01281                 return (NULL);
01282         }
01283 #if DEBUG
01284         DXF_DEBUG_END
01285 #endif
01286         return (strdup (layer->material));
01287 }
01288 
01289 
01296 DxfLayer *
01297 dxf_layer_set_material
01298 (
01299         DxfLayer *layer,
01301         char *material
01304 )
01305 {
01306 #if DEBUG
01307         DXF_DEBUG_BEGIN
01308 #endif
01309         /* Do some basic checks. */
01310         if (layer == NULL)
01311         {
01312                 fprintf (stderr,
01313                   (_("Error in %s () a NULL pointer was passed.\n")),
01314                   __FUNCTION__);
01315                 return (NULL);
01316         }
01317         if (material == NULL)
01318         {
01319                 fprintf (stderr,
01320                   (_("Error in %s () a NULL pointer was passed.\n")),
01321                   __FUNCTION__);
01322                 return (NULL);
01323         }
01324         layer->material = strdup (material);
01325 #if DEBUG
01326         DXF_DEBUG_END
01327 #endif
01328         return (layer);
01329 }
01330 
01331 
01340 char *
01341 dxf_layer_get_dictionary_owner_hard
01342 (
01343         DxfLayer *layer
01345 )
01346 {
01347 #if DEBUG
01348         DXF_DEBUG_BEGIN
01349 #endif
01350         /* Do some basic checks. */
01351         if (layer == NULL)
01352         {
01353                 fprintf (stderr,
01354                   (_("Error in %s () a NULL pointer was passed.\n")),
01355                   __FUNCTION__);
01356                 return (NULL);
01357         }
01358         if (layer->dictionary_owner_hard ==  NULL)
01359         {
01360                 fprintf (stderr,
01361                   (_("Error in %s () a NULL pointer was found.\n")),
01362                   __FUNCTION__);
01363                 return (NULL);
01364         }
01365 #if DEBUG
01366         DXF_DEBUG_END
01367 #endif
01368         return (strdup (layer->dictionary_owner_hard));
01369 }
01370 
01371 
01376 DxfLayer *
01377 dxf_layer_set_dictionary_owner_hard
01378 (
01379         DxfLayer *layer,
01381         char *dictionary_owner_hard
01384 )
01385 {
01386 #if DEBUG
01387         DXF_DEBUG_BEGIN
01388 #endif
01389         /* Do some basic checks. */
01390         if (layer == NULL)
01391         {
01392                 fprintf (stderr,
01393                   (_("Error in %s () a NULL pointer was passed.\n")),
01394                   __FUNCTION__);
01395                 return (NULL);
01396         }
01397         if (dictionary_owner_hard == NULL)
01398         {
01399                 fprintf (stderr,
01400                   (_("Error in %s () a NULL pointer was passed.\n")),
01401                   __FUNCTION__);
01402                 return (NULL);
01403         }
01404         layer->dictionary_owner_hard = strdup (dictionary_owner_hard);
01405 #if DEBUG
01406         DXF_DEBUG_END
01407 #endif
01408         return (layer);
01409 }
01410 
01411 
01418 int16_t
01419 dxf_layer_get_lineweight
01420 (
01421         DxfLayer *layer
01423 )
01424 {
01425 #if DEBUG
01426         DXF_DEBUG_BEGIN
01427 #endif
01428         /* Do some basic checks. */
01429         if (layer == NULL)
01430         {
01431                 fprintf (stderr,
01432                   (_("Error in %s () a NULL pointer was passed.\n")),
01433                   __FUNCTION__);
01434                 return (EXIT_FAILURE);
01435         }
01436 #if DEBUG
01437         DXF_DEBUG_END
01438 #endif
01439         return (layer->lineweight);
01440 }
01441 
01442 
01449 DxfLayer *
01450 dxf_layer_set_lineweight
01451 (
01452         DxfLayer *layer,
01454         int16_t lineweight
01456 )
01457 {
01458 #if DEBUG
01459         DXF_DEBUG_BEGIN
01460 #endif
01461         /* Do some basic checks. */
01462         if (layer == NULL)
01463         {
01464                 fprintf (stderr,
01465                   (_("Error in %s () a NULL pointer was passed.\n")),
01466                   __FUNCTION__);
01467                 return (NULL);
01468         }
01469         layer->lineweight = lineweight;
01470 #if DEBUG
01471         DXF_DEBUG_END
01472 #endif
01473         return (layer);
01474 }
01475 
01476 
01483 char *
01484 dxf_layer_get_plot_style_name
01485 (
01486         DxfLayer *layer
01488 )
01489 {
01490 #if DEBUG
01491         DXF_DEBUG_BEGIN
01492 #endif
01493         /* Do some basic checks. */
01494         if (layer == NULL)
01495         {
01496                 fprintf (stderr,
01497                   (_("Error in %s () a NULL pointer was passed.\n")),
01498                   __FUNCTION__);
01499                 return (NULL);
01500         }
01501         if (layer->plot_style_name ==  NULL)
01502         {
01503                 fprintf (stderr,
01504                   (_("Error in %s () a NULL pointer was found.\n")),
01505                   __FUNCTION__);
01506                 return (NULL);
01507         }
01508 #if DEBUG
01509         DXF_DEBUG_END
01510 #endif
01511         return (strdup (layer->plot_style_name));
01512 }
01513 
01514 
01521 DxfLayer *
01522 dxf_layer_set_plot_style_name
01523 (
01524         DxfLayer *layer,
01526         char *plot_style_name
01529 )
01530 {
01531 #if DEBUG
01532         DXF_DEBUG_BEGIN
01533 #endif
01534         /* Do some basic checks. */
01535         if (layer == NULL)
01536         {
01537                 fprintf (stderr,
01538                   (_("Error in %s () a NULL pointer was passed.\n")),
01539                   __FUNCTION__);
01540                 return (NULL);
01541         }
01542         if (plot_style_name == NULL)
01543         {
01544                 fprintf (stderr,
01545                   (_("Error in %s () a NULL pointer was passed.\n")),
01546                   __FUNCTION__);
01547                 return (NULL);
01548         }
01549         layer->plot_style_name = strdup (plot_style_name);
01550 #if DEBUG
01551         DXF_DEBUG_END
01552 #endif
01553         return (layer);
01554 }
01555 
01556 
01565 DxfLayer *
01566 dxf_layer_get_next
01567 (
01568         DxfLayer *layer
01570 )
01571 {
01572 #if DEBUG
01573         DXF_DEBUG_BEGIN
01574 #endif
01575         /* Do some basic checks. */
01576         if (layer == NULL)
01577         {
01578                 fprintf (stderr,
01579                   (_("Error in %s () a NULL pointer was passed.\n")),
01580                   __FUNCTION__);
01581                 return (NULL);
01582         }
01583         if (layer->next == NULL)
01584         {
01585                 fprintf (stderr,
01586                   (_("Error in %s () a NULL pointer was found.\n")),
01587                   __FUNCTION__);
01588                 return (NULL);
01589         }
01590 #if DEBUG
01591         DXF_DEBUG_END
01592 #endif
01593         return ((DxfLayer *) layer->next);
01594 }
01595 
01596 
01601 DxfLayer *
01602 dxf_layer_set_next
01603 (
01604         DxfLayer *layer,
01606         DxfLayer *next
01608 )
01609 {
01610 #if DEBUG
01611         DXF_DEBUG_BEGIN
01612 #endif
01613         /* Do some basic checks. */
01614         if (layer == NULL)
01615         {
01616                 fprintf (stderr,
01617                   (_("Error in %s () a NULL pointer was passed.\n")),
01618                   __FUNCTION__);
01619                 return (NULL);
01620         }
01621         if (next == NULL)
01622         {
01623                 fprintf (stderr,
01624                   (_("Error in %s () a NULL pointer was passed.\n")),
01625                   __FUNCTION__);
01626                 return (NULL);
01627         }
01628         layer->next = (struct DxfLayer *) next;
01629 #if DEBUG
01630         DXF_DEBUG_END
01631 #endif
01632         return (layer);
01633 }
01634 
01635 
01644 DxfLayer *
01645 dxf_layer_get_last
01646 (
01647         DxfLayer *layer
01649 )
01650 {
01651 #if DEBUG
01652         DXF_DEBUG_BEGIN
01653 #endif
01654         /* Do some basic checks. */
01655         if (layer == NULL)
01656         {
01657                 fprintf (stderr,
01658                   (_("Error in %s () a NULL pointer was passed.\n")),
01659                   __FUNCTION__);
01660                 return (NULL);
01661         }
01662         if (layer->next == NULL)
01663         {
01664                 fprintf (stderr,
01665                   (_("Warning in %s () a NULL pointer was found.\n")),
01666                   __FUNCTION__);
01667                 return ((DxfLayer *) layer);
01668         }
01669         DxfLayer *iter = (DxfLayer *) layer->next;
01670         while (iter->next != NULL)
01671         {
01672                 iter = (DxfLayer *) iter->next;
01673         }
01674 #if DEBUG
01675         DXF_DEBUG_END
01676 #endif
01677         return ((DxfLayer *) iter);
01678 }
01679 
01680 
01681 /* EOF */