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

class.c

Go to the documentation of this file.
00001 
00046 #include "class.h"
00047 
00048 
00054 DxfClass *
00055 dxf_class_new ()
00056 {
00057 #if DEBUG
00058         DXF_DEBUG_BEGIN
00059 #endif
00060         DxfClass *class = NULL;
00061         size_t size;
00062 
00063         size = sizeof (DxfClass);
00064         /* avoid malloc of 0 bytes */
00065         if (size == 0) size = 1;
00066         if ((class = malloc (size)) == NULL)
00067         {
00068                 fprintf (stderr,
00069                   (_("Error in %s () could not allocate memory for a DxfClass struct.\n")),
00070                   __FUNCTION__);
00071                 class = NULL;
00072         }
00073         else
00074         {
00075                 memset (class, 0, size);
00076         }
00077 #if DEBUG
00078         DXF_DEBUG_END
00079 #endif
00080         return (class);
00081 }
00082 
00083 
00091 DxfClass *
00092 dxf_class_init
00093 (
00094         DxfClass *class
00096 )
00097 {
00098 #if DEBUG
00099         DXF_DEBUG_BEGIN
00100 #endif
00101         /* Do some basic checks. */
00102         if (class == NULL)
00103         {
00104                 fprintf (stderr,
00105                   (_("Warning in %s () a NULL pointer was passed.\n")),
00106                   __FUNCTION__);
00107                 class = dxf_class_new ();
00108         }
00109         if (class == NULL)
00110         {
00111               fprintf (stderr,
00112                 (_("Error in %s () could not allocate memory for a DxfClass struct.\n")),
00113                 __FUNCTION__);
00114               return (NULL);
00115         }
00116         dxf_class_set_record_type (class, strdup (""));
00117         dxf_class_set_record_name (class, strdup (""));
00118         dxf_class_set_class_name (class, strdup (""));
00119         dxf_class_set_app_name (class, strdup (""));
00120         dxf_class_set_proxy_cap_flag (class, 0);
00121         dxf_class_set_was_a_proxy_flag (class, 0);
00122         dxf_class_set_is_an_entity_flag (class, 0);
00123         dxf_class_set_next (class, NULL);
00124 #if DEBUG
00125         DXF_DEBUG_END
00126 #endif
00127         return (class);
00128 }
00129 
00130 
00142 DxfClass *
00143 dxf_class_read
00144 (
00145         DxfFile *fp,
00147         DxfClass *class
00149 )
00150 {
00151 #if DEBUG
00152         DXF_DEBUG_BEGIN
00153 #endif
00154         char *temp_string = NULL;
00155 
00156         /* Do some basic checks. */
00157         if (fp == NULL)
00158         {
00159                 fprintf (stderr,
00160                   (_("Error in %s () a NULL file pointer was passed.\n")),
00161                   __FUNCTION__);
00162                 /* Clean up. */
00163                 free (temp_string);
00164                 return (NULL);
00165         }
00166         if (class == NULL)
00167         {
00168                 fprintf (stderr,
00169                   (_("Warning in %s () a NULL pointer was passed.\n")),
00170                   __FUNCTION__);
00171                 class = dxf_class_new ();
00172                 class = dxf_class_init (class);
00173         }
00174         (fp->line_number)++;
00175         fscanf (fp->fp, "%[^\n]", temp_string);
00176         while (strcmp (temp_string, "0") != 0)
00177         {
00178                 if (ferror (fp->fp))
00179                 {
00180                         fprintf (stderr,
00181                           (_("Error in %s () while reading from: %s in line: %d.\n")),
00182                           __FUNCTION__, fp->filename, fp->line_number);
00183                         fclose (fp->fp);
00184                         /* Clean up. */
00185                         free (temp_string);
00186                         return (NULL);
00187                 }
00188                 if (strcmp (temp_string, "0") == 0)
00189                 {
00190                         /* Now follows a string containing a record type
00191                          * number. */
00197                         (fp->line_number)++;
00198                         fscanf (fp->fp, "%s\n", class->record_type);
00199                 }
00200                 else if (strcmp (temp_string, "1") == 0)
00201                 {
00202                         /* Now follows a string containing a record
00203                          * name. */
00204                         (fp->line_number)++;
00205                         fscanf (fp->fp, "%s\n", class->record_name);
00206                 }
00207                 else if (strcmp (temp_string, "2") == 0)
00208                 {
00209                         /* Now follows a string containing a class name.
00210                          */
00211                         (fp->line_number)++;
00212                         fscanf (fp->fp, "%s\n", class->class_name);
00213                 }
00214                 else if (strcmp (temp_string, "3") == 0)
00215                 {
00216                         /* Now follows a string containing the
00217                          * application name. */
00218                         (fp->line_number)++;
00219                         fscanf (fp->fp, "%s\n", class->app_name);
00220                 }
00221                 else if (strcmp (temp_string, "90") == 0)
00222                 {
00223                         /* Now follows a string containing the
00224                          * proxy cap flag value. */
00225                         (fp->line_number)++;
00226                         fscanf (fp->fp, "%d\n", &class->proxy_cap_flag);
00227                 }
00228                 else if (strcmp (temp_string, "280") == 0)
00229                 {
00230                         /* Now follows a string containing the
00231                          * was a proxy flag value. */
00232                         (fp->line_number)++;
00233                         fscanf (fp->fp, "%d\n", &class->was_a_proxy_flag);
00234                 }
00235                 else if (strcmp (temp_string, "281") == 0)
00236                 {
00237                         /* Now follows a string containing the
00238                          * is an entity flag value. */
00239                         (fp->line_number)++;
00240                         fscanf (fp->fp, "%d\n", &class->is_an_entity_flag);
00241                 }
00242                 else if (strcmp (temp_string, "999") == 0)
00243                 {
00244                         /* Now follows a string containing a comment. */
00245                         (fp->line_number)++;
00246                         fscanf (fp->fp, "%s\n", temp_string);
00247                         fprintf (stdout, "DXF comment: %s\n", temp_string);
00248                 }
00249                 else
00250                 {
00251                         fprintf (stderr,
00252                           (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")),
00253                           __FUNCTION__, fp->filename, fp->line_number);
00254                 }
00255         }
00256         /* Handle omitted members and/or illegal values. */
00257         if (strcmp (dxf_class_get_record_type (class), "") == 0)
00258         {
00259                 fprintf (stderr,
00260                   (_("Error in %s () empty record type string after reading from: %s before line: %d.\n")),
00261                   __FUNCTION__, fp->filename, fp->line_number);
00262                 return (NULL);
00263 
00264         }
00265         if (strcmp (dxf_class_get_record_name (class), "") == 0)
00266         {
00267                 fprintf (stderr,
00268                   (_("Error in %s () empty record name string after reading from: %s before line: %d.\n")),
00269                   __FUNCTION__, fp->filename, fp->line_number);
00270                 return (NULL);
00271         }
00272         if (strcmp (dxf_class_get_class_name (class), "") == 0)
00273         {
00274                 fprintf (stderr,
00275                   (_("Error in %s () empty class name string after reading from: %s before line: %d.\n")),
00276                   __FUNCTION__, fp->filename, fp->line_number);
00277                 return (NULL);
00278         }
00279         /* Clean up. */
00280         free (temp_string);
00281 #if DEBUG
00282         DXF_DEBUG_END
00283 #endif
00284         return (class);
00285 }
00286 
00287 
00294 int
00295 dxf_class_write
00296 (
00297         DxfFile *fp,
00299         DxfClass *class
00301 )
00302 {
00303 #if DEBUG
00304         DXF_DEBUG_BEGIN
00305 #endif
00306         char *dxf_entity_name = strdup ("CLASS");
00307 
00308         /* Do some basic checks. */
00309         if (fp == NULL)
00310         {
00311                 fprintf (stderr,
00312                   (_("Error in %s () a NULL file pointer was passed.\n")),
00313                   __FUNCTION__);
00314                 /* Clean up. */
00315                 free (dxf_entity_name);
00316                 return (EXIT_FAILURE);
00317         }
00318         if (class == NULL)
00319         {
00320                 fprintf (stderr,
00321                   (_("Error in %s () a NULL pointer was passed.\n")),
00322                   __FUNCTION__);
00323                 /* Clean up. */
00324                 free (dxf_entity_name);
00325                 return (EXIT_FAILURE);
00326         }
00327         if (!dxf_class_get_record_type (class)
00328                 || (strcmp (dxf_class_get_record_type (class), "") == 0))
00329         {
00330                 fprintf (stderr,
00331                   (_("Error in %s () empty record type string for the %s entity\n")),
00332                   __FUNCTION__, dxf_entity_name);
00333                 /* Clean up. */
00334                 free (dxf_entity_name);
00335                 return (EXIT_FAILURE);
00336         }
00337         if (!dxf_class_get_class_name (class)
00338                 || (strcmp (dxf_class_get_class_name (class), "") == 0))
00339         {
00340                 fprintf (stderr,
00341                   (_("Error in %s () empty class name string for the %s entity\n")),
00342                   __FUNCTION__, dxf_entity_name);
00343                 /* Clean up. */
00344                 free (dxf_entity_name);
00345                 return (EXIT_FAILURE);
00346         }
00347         if (!dxf_class_get_record_name (class))
00348         {
00349                 fprintf (stderr,
00350                   (_("Warning in %s () empty record name string for the %s entity\n")),
00351                   __FUNCTION__, dxf_entity_name);
00352                 fprintf (stderr,
00353                   (_("\trecord_name of %s entity is reset to \"\"")),
00354                   dxf_entity_name );
00355                 dxf_class_set_record_name (class, strdup (""));
00356         }
00357         if (!dxf_class_get_app_name (class))
00358         {
00359                 fprintf (stderr,
00360                   (_("Warning in %s () empty app name string for the %s entity\n")),
00361                   __FUNCTION__, dxf_entity_name);
00362                 fprintf (stderr,
00363                   (_("\tapp_name of %s entity is reset to \"\"")),
00364                   dxf_entity_name );
00365                 dxf_class_set_app_name (class, strdup (""));
00366         }
00367         /* Start writing output. */
00368         fprintf (fp->fp, "  0\n%s\n", dxf_entity_name);
00369         fprintf (fp->fp, "  1\n%s\n", dxf_class_get_record_name (class));
00370         fprintf (fp->fp, "  2\n%s\n", dxf_class_get_class_name (class));
00371         if (fp->acad_version_number >= AutoCAD_14)
00372         {
00373                 fprintf (fp->fp, "  3\n%s\n", dxf_class_get_app_name (class));
00374         }
00375         fprintf (fp->fp, " 90\n%d\n", dxf_class_get_proxy_cap_flag (class));
00376         fprintf (fp->fp, "280\n%d\n", dxf_class_get_was_a_proxy_flag (class));
00377         fprintf (fp->fp, "281\n%d\n", dxf_class_get_is_an_entity_flag (class));
00378         /* Clean up. */
00379         free (dxf_entity_name);
00380 #if DEBUG
00381         DXF_DEBUG_END
00382 #endif
00383         return (EXIT_SUCCESS);
00384 }
00385 
00386 
00394 int
00395 dxf_class_write_endclass
00396 (
00397         DxfFile *fp
00398 )
00399 {
00400 #if DEBUG
00401         DXF_DEBUG_BEGIN
00402 #endif
00403         /* Do some basic checks. */
00404         if (fp == NULL)
00405         {
00406                 fprintf (stderr,
00407                   (_("Error in %s () a NULL file pointer was passed.\n")),
00408                   __FUNCTION__);
00409                 return (EXIT_FAILURE);
00410         }
00411         /* Start writing output. */
00412         fprintf (fp->fp, "  0\nENDSEC\n");
00413 #if DEBUG
00414         DXF_DEBUG_END
00415 #endif
00416         return (EXIT_SUCCESS);
00417 }
00418 
00419 
00427 int
00428 dxf_class_free
00429 (
00430         DxfClass *class
00433 )
00434 {
00435 #if DEBUG
00436         DXF_DEBUG_BEGIN
00437 #endif
00438         if (class == NULL)
00439         {
00440                 fprintf (stderr,
00441                   (_("Error in %s () a NULL pointer was passed.\n")),
00442                   __FUNCTION__);
00443                 return (EXIT_FAILURE);
00444         }
00445         if (class->next != NULL)
00446         {
00447                 fprintf (stderr,
00448                   (_("Error in %s () pointer to next was not NULL.\n")),
00449                   __FUNCTION__);
00450                 return (EXIT_FAILURE);
00451         }
00452         free (class->record_type);
00453         free (class->record_name);
00454         free (class->class_name);
00455         free (class->app_name);
00456         free (class);
00457         class = NULL;
00458 #if DEBUG
00459         DXF_DEBUG_END
00460 #endif
00461         return (EXIT_SUCCESS);
00462 }
00463 
00464 
00469 void
00470 dxf_class_free_chain
00471 (
00472         DxfClass *classes
00474 )
00475 {
00476 #ifdef DEBUG
00477         DXF_DEBUG_BEGIN
00478 #endif
00479         if (classes == NULL)
00480         {
00481                 fprintf (stderr,
00482                   (_("Warning in %s () a NULL pointer was passed.\n")),
00483                   __FUNCTION__);
00484         }
00485         while (classes != NULL)
00486         {
00487                 struct DxfClass *iter = classes->next;
00488                 dxf_class_free (classes);
00489                 classes = (DxfClass *) iter;
00490         }
00491 #if DEBUG
00492         DXF_DEBUG_END
00493 #endif
00494 }
00495 
00496 
00502 char *
00503 dxf_class_get_record_type
00504 (
00505         DxfClass *class
00507 )
00508 {
00509 #if DEBUG
00510         DXF_DEBUG_BEGIN
00511 #endif
00512         char *result = NULL;
00513 
00514         /* Do some basic checks. */
00515         if (class == NULL)
00516         {
00517                 fprintf (stderr,
00518                   (_("Error in %s () a NULL pointer was passed.\n")),
00519                   __FUNCTION__);
00520                 return (NULL);
00521         }
00522         if (class->record_type ==  NULL)
00523         {
00524                 fprintf (stderr,
00525                   (_("Error in %s () a NULL pointer was found in the record type member.\n")),
00526                   __FUNCTION__);
00527                 return (NULL);
00528         }
00529         result = strdup (class->record_type);
00530 #if DEBUG
00531         DXF_DEBUG_END
00532 #endif
00533         return (result);
00534 }
00535 
00536 
00540 DxfClass *
00541 dxf_class_set_record_type
00542 (
00543         DxfClass *class,
00545         char *record_type
00547 )
00548 {
00549 #if DEBUG
00550         DXF_DEBUG_BEGIN
00551 #endif
00552         /* Do some basic checks. */
00553         if (class == NULL)
00554         {
00555                 fprintf (stderr,
00556                   (_("Error in %s () a NULL pointer was passed.\n")),
00557                   __FUNCTION__);
00558                 return (NULL);
00559         }
00560         if (record_type == NULL)
00561         {
00562                 fprintf (stderr,
00563                   (_("Error in %s () a NULL pointer was passed.\n")),
00564                   __FUNCTION__);
00565                 return (NULL);
00566         }
00567         class->record_type = strdup (record_type);
00568 #if DEBUG
00569         DXF_DEBUG_END
00570 #endif
00571         return (class);
00572 }
00573 
00574 
00580 char *
00581 dxf_class_get_record_name
00582 (
00583         DxfClass *class
00585 )
00586 {
00587 #if DEBUG
00588         DXF_DEBUG_BEGIN
00589 #endif
00590         char *result = NULL;
00591 
00592         /* Do some basic checks. */
00593         if (class == NULL)
00594         {
00595                 fprintf (stderr,
00596                   (_("Error in %s () a NULL pointer was passed.\n")),
00597                   __FUNCTION__);
00598                 return (NULL);
00599         }
00600         if (class->record_name ==  NULL)
00601         {
00602                 fprintf (stderr,
00603                   (_("Error in %s () a NULL pointer was found in the record name member.\n")),
00604                   __FUNCTION__);
00605                 return (NULL);
00606         }
00607         result = strdup (class->record_name);
00608 #if DEBUG
00609         DXF_DEBUG_END
00610 #endif
00611         return (result);
00612 }
00613 
00614 
00618 DxfClass *
00619 dxf_class_set_record_name
00620 (
00621         DxfClass *class,
00623         char *record_name
00625 )
00626 {
00627 #if DEBUG
00628         DXF_DEBUG_BEGIN
00629 #endif
00630         /* Do some basic checks. */
00631         if (class == NULL)
00632         {
00633                 fprintf (stderr,
00634                   (_("Error in %s () a NULL pointer was passed.\n")),
00635                   __FUNCTION__);
00636                 return (NULL);
00637         }
00638         if (record_name == NULL)
00639         {
00640                 fprintf (stderr,
00641                   (_("Error in %s () a NULL pointer was passed.\n")),
00642                   __FUNCTION__);
00643                 return (NULL);
00644         }
00645         class->record_name = strdup (record_name);
00646 #if DEBUG
00647         DXF_DEBUG_END
00648 #endif
00649         return (class);
00650 }
00651 
00652 
00658 char *
00659 dxf_class_get_class_name
00660 (
00661         DxfClass *class
00663 )
00664 {
00665 #if DEBUG
00666         DXF_DEBUG_BEGIN
00667 #endif
00668         char *result = NULL;
00669 
00670         /* Do some basic checks. */
00671         if (class == NULL)
00672         {
00673                 fprintf (stderr,
00674                   (_("Error in %s () a NULL pointer was passed.\n")),
00675                   __FUNCTION__);
00676                 return (NULL);
00677         }
00678         if (class->class_name ==  NULL)
00679         {
00680                 fprintf (stderr,
00681                   (_("Error in %s () a NULL pointer was found in the class name member.\n")),
00682                   __FUNCTION__);
00683                 return (NULL);
00684         }
00685         result = strdup (class->class_name);
00686 #if DEBUG
00687         DXF_DEBUG_END
00688 #endif
00689         return (result);
00690 }
00691 
00692 
00696 DxfClass *
00697 dxf_class_set_class_name
00698 (
00699         DxfClass *class,
00701         char *class_name
00703 )
00704 {
00705 #if DEBUG
00706         DXF_DEBUG_BEGIN
00707 #endif
00708         /* Do some basic checks. */
00709         if (class == NULL)
00710         {
00711                 fprintf (stderr,
00712                   (_("Error in %s () a NULL pointer was passed.\n")),
00713                   __FUNCTION__);
00714                 return (NULL);
00715         }
00716         if (class_name == NULL)
00717         {
00718                 fprintf (stderr,
00719                   (_("Error in %s () a NULL pointer was passed.\n")),
00720                   __FUNCTION__);
00721                 return (NULL);
00722         }
00723         class->class_name = strdup (class_name);
00724 #if DEBUG
00725         DXF_DEBUG_END
00726 #endif
00727         return (class);
00728 }
00729 
00730 
00736 char *
00737 dxf_class_get_app_name
00738 (
00739         DxfClass *class
00741 )
00742 {
00743 #if DEBUG
00744         DXF_DEBUG_BEGIN
00745 #endif
00746         char *result = NULL;
00747 
00748         /* Do some basic checks. */
00749         if (class == NULL)
00750         {
00751                 fprintf (stderr,
00752                   (_("Error in %s () a NULL pointer was passed.\n")),
00753                   __FUNCTION__);
00754                 return (NULL);
00755         }
00756         if (class->app_name ==  NULL)
00757         {
00758                 fprintf (stderr,
00759                   (_("Error in %s () a NULL pointer was found in the class name member.\n")),
00760                   __FUNCTION__);
00761                 return (NULL);
00762         }
00763         result = strdup (class->app_name);
00764 #if DEBUG
00765         DXF_DEBUG_END
00766 #endif
00767         return (result);
00768 }
00769 
00770 
00774 DxfClass *
00775 dxf_class_set_app_name
00776 (
00777         DxfClass *class,
00779         char *app_name
00782 )
00783 {
00784 #if DEBUG
00785         DXF_DEBUG_BEGIN
00786 #endif
00787         /* Do some basic checks. */
00788         if (class == NULL)
00789         {
00790                 fprintf (stderr,
00791                   (_("Error in %s () a NULL pointer was passed.\n")),
00792                   __FUNCTION__);
00793                 return (NULL);
00794         }
00795         if (app_name == NULL)
00796         {
00797                 fprintf (stderr,
00798                   (_("Error in %s () a NULL pointer was passed.\n")),
00799                   __FUNCTION__);
00800                 return (NULL);
00801         }
00802         class->app_name = strdup (app_name);
00803 #if DEBUG
00804         DXF_DEBUG_END
00805 #endif
00806         return (class);
00807 }
00808 
00809 
00815 int
00816 dxf_class_get_proxy_cap_flag
00817 (
00818         DxfClass *class
00820 )
00821 {
00822 #if DEBUG
00823         DXF_DEBUG_BEGIN
00824 #endif
00825         int result;
00826 
00827         /* Do some basic checks. */
00828         if (class == NULL)
00829         {
00830                 fprintf (stderr,
00831                   (_("Error in %s () a NULL pointer was passed.\n")),
00832                   __FUNCTION__);
00833                 return (EXIT_FAILURE);
00834         }
00835         if (class->proxy_cap_flag < 0)
00836         {
00837                 fprintf (stderr,
00838                   (_("Error in %s () a negative value was found in the proxy_cap_flag member.\n")),
00839                   __FUNCTION__);
00840                 return (EXIT_FAILURE);
00841         }
00842         result = class->proxy_cap_flag;
00843 #if DEBUG
00844         DXF_DEBUG_END
00845 #endif
00846         return (result);
00847 }
00848 
00849 
00853 DxfClass *
00854 dxf_class_set_proxy_cap_flag
00855 (
00856         DxfClass *class,
00858         int proxy_cap_flag
00860 )
00861 {
00862 #if DEBUG
00863         DXF_DEBUG_BEGIN
00864 #endif
00865         /* Do some basic checks. */
00866         if (class == NULL)
00867         {
00868                 fprintf (stderr,
00869                   (_("Error in %s () a NULL pointer was passed.\n")),
00870                   __FUNCTION__);
00871                 return (NULL);
00872         }
00873         if (proxy_cap_flag < 0)
00874         {
00875                 fprintf (stderr,
00876                   (_("Error in %s () a negative proxy_cap_flag value was passed.\n")),
00877                   __FUNCTION__);
00878                 return (NULL);
00879         }
00880         class->proxy_cap_flag = proxy_cap_flag;
00881 #if DEBUG
00882         DXF_DEBUG_END
00883 #endif
00884         return (class);
00885 }
00886 
00887 
00896 int
00897 dxf_class_is_editable
00898 (
00899         DxfClass *class
00901 )
00902 {
00903 #if DEBUG
00904         DXF_DEBUG_BEGIN
00905 #endif
00906         int result = FALSE;
00907 
00908         /* Do some basic checks. */
00909         if (class == NULL)
00910         {
00911                 fprintf (stderr,
00912                   (_("Error in %s () a NULL pointer was passed.\n")),
00913                   __FUNCTION__);
00914                 return (EXIT_FAILURE);
00915         }
00916         /* The result is TRUE if the bit test returns FALSE (0).*/
00917         result = !DXF_CHECK_BIT (class->proxy_cap_flag, 0);
00918 #if DEBUG
00919         DXF_DEBUG_END
00920 #endif
00921         return (result);
00922 }
00923 
00924 
00932 int
00933 dxf_class_erase_allowed
00934 (
00935         DxfClass *class
00937 )
00938 {
00939 #if DEBUG
00940         DXF_DEBUG_BEGIN
00941 #endif
00942         int result = FALSE;
00943 
00944         /* Do some basic checks. */
00945         if (class == NULL)
00946         {
00947                 fprintf (stderr,
00948                   (_("Error in %s () a NULL pointer was passed.\n")),
00949                   __FUNCTION__);
00950                 return (EXIT_FAILURE);
00951         }
00952         result = DXF_CHECK_BIT (class->proxy_cap_flag, 0);
00953 #if DEBUG
00954         DXF_DEBUG_END
00955 #endif
00956         return (result);
00957 }
00958 
00959 
00968 int
00969 dxf_class_transform_allowed
00970 (
00971         DxfClass *class
00973 )
00974 {
00975 #if DEBUG
00976         DXF_DEBUG_BEGIN
00977 #endif
00978         int result = FALSE;
00979 
00980         /* Do some basic checks. */
00981         if (class == NULL)
00982         {
00983                 fprintf (stderr,
00984                   (_("Error in %s () a NULL pointer was passed.\n")),
00985                   __FUNCTION__);
00986                 return (EXIT_FAILURE);
00987         }
00988         result = DXF_CHECK_BIT (class->proxy_cap_flag, 1);
00989 #if DEBUG
00990         DXF_DEBUG_END
00991 #endif
00992         return (result);
00993 }
00994 
00995 
01004 int
01005 dxf_class_color_change_allowed
01006 (
01007         DxfClass *class
01009 )
01010 {
01011 #if DEBUG
01012         DXF_DEBUG_BEGIN
01013 #endif
01014         int result = FALSE;
01015 
01016         /* Do some basic checks. */
01017         if (class == NULL)
01018         {
01019                 fprintf (stderr,
01020                   (_("Error in %s () a NULL pointer was passed.\n")),
01021                   __FUNCTION__);
01022                 return (EXIT_FAILURE);
01023         }
01024         result = DXF_CHECK_BIT (class->proxy_cap_flag, 2);
01025 #if DEBUG
01026         DXF_DEBUG_END
01027 #endif
01028         return (result);
01029 }
01030 
01031 
01040 int
01041 dxf_class_layer_change_allowed
01042 (
01043         DxfClass *class
01045 )
01046 {
01047 #if DEBUG
01048         DXF_DEBUG_BEGIN
01049 #endif
01050         int result = FALSE;
01051 
01052         /* Do some basic checks. */
01053         if (class == NULL)
01054         {
01055                 fprintf (stderr,
01056                   (_("Error in %s () a NULL pointer was passed.\n")),
01057                   __FUNCTION__);
01058                 return (EXIT_FAILURE);
01059         }
01060         result = DXF_CHECK_BIT (class->proxy_cap_flag, 3);
01061 #if DEBUG
01062         DXF_DEBUG_END
01063 #endif
01064         return (result);
01065 }
01066 
01067 
01076 int
01077 dxf_class_linetype_change_allowed
01078 (
01079         DxfClass *class
01081 )
01082 {
01083 #if DEBUG
01084         DXF_DEBUG_BEGIN
01085 #endif
01086         int result = FALSE;
01087 
01088         /* Do some basic checks. */
01089         if (class == NULL)
01090         {
01091                 fprintf (stderr,
01092                   (_("Error in %s () a NULL pointer was passed.\n")),
01093                   __FUNCTION__);
01094                 return (EXIT_FAILURE);
01095         }
01096         result = DXF_CHECK_BIT (class->proxy_cap_flag, 4);
01097 #if DEBUG
01098         DXF_DEBUG_END
01099 #endif
01100         return (result);
01101 }
01102 
01103 
01112 int
01113 dxf_class_linetype_scale_change_allowed
01114 (
01115         DxfClass *class
01117 )
01118 {
01119 #if DEBUG
01120         DXF_DEBUG_BEGIN
01121 #endif
01122         int result = FALSE;
01123 
01124         /* Do some basic checks. */
01125         if (class == NULL)
01126         {
01127                 fprintf (stderr,
01128                   (_("Error in %s () a NULL pointer was passed.\n")),
01129                   __FUNCTION__);
01130                 return (EXIT_FAILURE);
01131         }
01132         result = DXF_CHECK_BIT (class->proxy_cap_flag, 5);
01133 #if DEBUG
01134         DXF_DEBUG_END
01135 #endif
01136         return (result);
01137 }
01138 
01139 
01148 int
01149 dxf_class_visibility_change_allowed
01150 (
01151         DxfClass *class
01153 )
01154 {
01155 #if DEBUG
01156         DXF_DEBUG_BEGIN
01157 #endif
01158         int result = FALSE;
01159 
01160         /* Do some basic checks. */
01161         if (class == NULL)
01162         {
01163                 fprintf (stderr,
01164                   (_("Error in %s () a NULL pointer was passed.\n")),
01165                   __FUNCTION__);
01166                 return (EXIT_FAILURE);
01167         }
01168         result = DXF_CHECK_BIT (class->proxy_cap_flag, 6);
01169 #if DEBUG
01170         DXF_DEBUG_END
01171 #endif
01172         return (result);
01173 }
01174 
01175 
01183 int
01184 dxf_class_cloning_allowed
01185 (
01186         DxfClass *class
01188 )
01189 {
01190 #if DEBUG
01191         DXF_DEBUG_BEGIN
01192 #endif
01193         int result = FALSE;
01194 
01195         /* Do some basic checks. */
01196         if (class == NULL)
01197         {
01198                 fprintf (stderr,
01199                   (_("Error in %s () a NULL pointer was passed.\n")),
01200                   __FUNCTION__);
01201                 return (EXIT_FAILURE);
01202         }
01203         result = DXF_CHECK_BIT (class->proxy_cap_flag, 7);
01204 #if DEBUG
01205         DXF_DEBUG_END
01206 #endif
01207         return (result);
01208 }
01209 
01210 
01219 int
01220 dxf_class_lineweight_change_allowed
01221 (
01222         DxfClass *class
01224 )
01225 {
01226 #if DEBUG
01227         DXF_DEBUG_BEGIN
01228 #endif
01229         int result = FALSE;
01230 
01231         /* Do some basic checks. */
01232         if (class == NULL)
01233         {
01234                 fprintf (stderr,
01235                   (_("Error in %s () a NULL pointer was passed.\n")),
01236                   __FUNCTION__);
01237                 return (EXIT_FAILURE);
01238         }
01239         result = DXF_CHECK_BIT (class->proxy_cap_flag, 8);
01240 #if DEBUG
01241         DXF_DEBUG_END
01242 #endif
01243         return (result);
01244 }
01245 
01246 
01255 int
01256 dxf_class_plot_style_name_change_allowed
01257 (
01258         DxfClass *class
01260 )
01261 {
01262 #if DEBUG
01263         DXF_DEBUG_BEGIN
01264 #endif
01265         int result = FALSE;
01266 
01267         /* Do some basic checks. */
01268         if (class == NULL)
01269         {
01270                 fprintf (stderr,
01271                   (_("Error in %s () a NULL pointer was passed.\n")),
01272                   __FUNCTION__);
01273                 return (EXIT_FAILURE);
01274         }
01275         result = DXF_CHECK_BIT (class->proxy_cap_flag, 9);
01276 #if DEBUG
01277         DXF_DEBUG_END
01278 #endif
01279         return (result);
01280 }
01281 
01282 
01291 int
01292 dxf_class_is_R13_format_proxy
01293 (
01294         DxfClass *class
01296 )
01297 {
01298 #if DEBUG
01299         DXF_DEBUG_BEGIN
01300 #endif
01301         int result = FALSE;
01302 
01303         /* Do some basic checks. */
01304         if (class == NULL)
01305         {
01306                 fprintf (stderr,
01307                   (_("Error in %s () a NULL pointer was passed.\n")),
01308                   __FUNCTION__);
01309                 return (EXIT_FAILURE);
01310         }
01311         result = DXF_CHECK_BIT (class->proxy_cap_flag, 15);
01312 #if DEBUG
01313         DXF_DEBUG_END
01314 #endif
01315         return (result);
01316 }
01317 
01318 
01324 int
01325 dxf_class_get_was_a_proxy_flag
01326 (
01327         DxfClass *class
01329 )
01330 {
01331 #if DEBUG
01332         DXF_DEBUG_BEGIN
01333 #endif
01334         int result;
01335 
01336         /* Do some basic checks. */
01337         if (class == NULL)
01338         {
01339                 fprintf (stderr,
01340                   (_("Error in %s () a NULL pointer was passed.\n")),
01341                   __FUNCTION__);
01342                 return (EXIT_FAILURE);
01343         }
01344         if (class->was_a_proxy_flag < 0)
01345         {
01346                 fprintf (stderr,
01347                   (_("Error in %s () a negative value was found in the was_a_proxy_flag member.\n")),
01348                   __FUNCTION__);
01349                 return (EXIT_FAILURE);
01350         }
01351         if (class->was_a_proxy_flag > 1)
01352         {
01353                 fprintf (stderr,
01354                   (_("Error in %s () an invalid value was found in the was_a_proxy_flag member.\n")),
01355                   __FUNCTION__);
01356                 return (EXIT_FAILURE);
01357         }
01358         result = class->was_a_proxy_flag;
01359 #if DEBUG
01360         DXF_DEBUG_END
01361 #endif
01362         return (result);
01363 }
01364 
01365 
01369 DxfClass *
01370 dxf_class_set_was_a_proxy_flag
01371 (
01372         DxfClass *class,
01374         int was_a_proxy_flag
01376 )
01377 {
01378 #if DEBUG
01379         DXF_DEBUG_BEGIN
01380 #endif
01381         /* Do some basic checks. */
01382         if (class == NULL)
01383         {
01384                 fprintf (stderr,
01385                   (_("Error in %s () a NULL pointer was passed.\n")),
01386                   __FUNCTION__);
01387                 return (NULL);
01388         }
01389         if (was_a_proxy_flag < 0)
01390         {
01391                 fprintf (stderr,
01392                   (_("Error in %s () a negative was_a_proxy_flag value was passed.\n")),
01393                   __FUNCTION__);
01394                 return (NULL);
01395         }
01396         if (was_a_proxy_flag > 1)
01397         {
01398                 fprintf (stderr,
01399                   (_("Error in %s () an invalid was_a_proxy_flag value was passed.\n")),
01400                   __FUNCTION__);
01401                 return (NULL);
01402         }
01403         class->was_a_proxy_flag = was_a_proxy_flag;
01404 #if DEBUG
01405         DXF_DEBUG_END
01406 #endif
01407         return (class);
01408 }
01409 
01410 
01416 int
01417 dxf_class_get_is_an_entity_flag
01418 (
01419         DxfClass *class
01421 )
01422 {
01423 #if DEBUG
01424         DXF_DEBUG_BEGIN
01425 #endif
01426         int result;
01427 
01428         /* Do some basic checks. */
01429         if (class == NULL)
01430         {
01431                 fprintf (stderr,
01432                   (_("Error in %s () a NULL pointer was passed.\n")),
01433                   __FUNCTION__);
01434                 return (EXIT_FAILURE);
01435         }
01436         if (class->is_an_entity_flag < 0)
01437         {
01438                 fprintf (stderr,
01439                   (_("Error in %s () a negative value was found in the is_an_entity_flag member.\n")),
01440                   __FUNCTION__);
01441                 return (EXIT_FAILURE);
01442         }
01443         if (class->is_an_entity_flag > 1)
01444         {
01445                 fprintf (stderr,
01446                   (_("Error in %s () an invalid value was found in the is_an_entity_flag member.\n")),
01447                   __FUNCTION__);
01448                 return (EXIT_FAILURE);
01449         }
01450         result = class->is_an_entity_flag;
01451 #if DEBUG
01452         DXF_DEBUG_END
01453 #endif
01454         return (result);
01455 }
01456 
01457 
01461 DxfClass *
01462 dxf_class_set_is_an_entity_flag
01463 (
01464         DxfClass *class,
01466         int is_an_entity_flag
01468 )
01469 {
01470 #if DEBUG
01471         DXF_DEBUG_BEGIN
01472 #endif
01473         /* Do some basic checks. */
01474         if (class == NULL)
01475         {
01476                 fprintf (stderr,
01477                   (_("Error in %s () a NULL pointer was passed.\n")),
01478                   __FUNCTION__);
01479                 return (NULL);
01480         }
01481         if (is_an_entity_flag < 0)
01482         {
01483                 fprintf (stderr,
01484                   (_("Error in %s () a negative is_an_entity_flag value was passed.\n")),
01485                   __FUNCTION__);
01486                 return (NULL);
01487         }
01488         if (is_an_entity_flag > 1)
01489         {
01490                 fprintf (stderr,
01491                   (_("Error in %s () an invalid is_an_entity_flag value was passed.\n")),
01492                   __FUNCTION__);
01493                 return (NULL);
01494         }
01495         class->is_an_entity_flag = is_an_entity_flag;
01496 #if DEBUG
01497         DXF_DEBUG_END
01498 #endif
01499         return (class);
01500 }
01501 
01502 
01511 DxfClass *
01512 dxf_class_get_next
01513 (
01514         DxfClass *class
01516 )
01517 {
01518 #if DEBUG
01519         DXF_DEBUG_BEGIN
01520 #endif
01521         DxfClass *result;
01522 
01523         /* Do some basic checks. */
01524         if (class == NULL)
01525         {
01526                 fprintf (stderr,
01527                   (_("Error in %s () a NULL pointer was passed.\n")),
01528                   __FUNCTION__);
01529                 return (NULL);
01530         }
01531         if (class->next == NULL)
01532         {
01533                 fprintf (stderr,
01534                   (_("Error in %s () a NULL pointer was found in the next member.\n")),
01535                   __FUNCTION__);
01536                 return (NULL);
01537         }
01538         result = (DxfClass *) class->next;
01539 #if DEBUG
01540         DXF_DEBUG_END
01541 #endif
01542         return (result);
01543 }
01544 
01545 
01550 DxfClass *
01551 dxf_class_set_next
01552 (
01553         DxfClass *class,
01555         DxfClass *next
01557 )
01558 {
01559 #if DEBUG
01560         DXF_DEBUG_BEGIN
01561 #endif
01562         /* Do some basic checks. */
01563         if (class == NULL)
01564         {
01565                 fprintf (stderr,
01566                   (_("Error in %s () a NULL pointer was passed.\n")),
01567                   __FUNCTION__);
01568                 return (NULL);
01569         }
01570         if (next == NULL)
01571         {
01572                 fprintf (stderr,
01573                   (_("Error in %s () a NULL pointer was passed.\n")),
01574                   __FUNCTION__);
01575                 return (NULL);
01576         }
01577         class->next = (struct DxfClass *) next;
01578 #if DEBUG
01579         DXF_DEBUG_END
01580 #endif
01581         return (class);
01582 }
01583 
01584 
01593 DxfClass *
01594 dxf_class_get_last
01595 (
01596         DxfClass *class
01598 )
01599 {
01600 #if DEBUG
01601         DXF_DEBUG_BEGIN
01602 #endif
01603         /* Do some basic checks. */
01604         if (class == NULL)
01605         {
01606                 fprintf (stderr,
01607                   (_("Error in %s () a NULL pointer was passed.\n")),
01608                   __FUNCTION__);
01609                 return (NULL);
01610         }
01611         if (class->next == NULL)
01612         {
01613                 fprintf (stderr,
01614                   (_("Warning in %s () a NULL pointer was found in the next member.\n")),
01615                   __FUNCTION__);
01616                 return ((DxfClass *) class);
01617         }
01618         DxfClass *iter = (DxfClass *) class->next;
01619         while (iter->next != NULL)
01620         {
01621                 iter = (DxfClass *) iter->next;
01622         }
01623 #if DEBUG
01624         DXF_DEBUG_END
01625 #endif
01626         return ((DxfClass *) iter);
01627 }
01628 
01629 
01630 /* EOF */