libDXF 0.0.1
A library with DXF related functions written in C.
|
00001 00043 #include "group.h" 00044 00045 00051 DxfGroup * 00052 dxf_group_new () 00053 { 00054 #if DEBUG 00055 DXF_DEBUG_BEGIN 00056 #endif 00057 DxfGroup *group = NULL; 00058 size_t size; 00059 00060 size = sizeof (DxfGroup); 00061 /* avoid malloc of 0 bytes */ 00062 if (size == 0) size = 1; 00063 if ((group = malloc (size)) == NULL) 00064 { 00065 fprintf (stderr, 00066 (_("Error in %s () could not allocate memory for a DxfGroup struct.\n")), 00067 __FUNCTION__); 00068 group = NULL; 00069 } 00070 else 00071 { 00072 memset (group, 0, size); 00073 } 00074 #if DEBUG 00075 DXF_DEBUG_END 00076 #endif 00077 return (group); 00078 } 00079 00080 00088 DxfGroup * 00089 dxf_group_init 00090 ( 00091 DxfGroup *group 00093 ) 00094 { 00095 #if DEBUG 00096 DXF_DEBUG_BEGIN 00097 #endif 00098 /* Do some basic checks. */ 00099 if (group == NULL) 00100 { 00101 fprintf (stderr, 00102 (_("Warning in %s () a NULL pointer was passed.\n")), 00103 __FUNCTION__); 00104 group = dxf_group_new (); 00105 } 00106 if (group == NULL) 00107 { 00108 fprintf (stderr, 00109 (_("Error in %s () could not allocate memory for a DxfGroup struct.\n")), 00110 __FUNCTION__); 00111 return (NULL); 00112 } 00113 group->id_code = 0; 00114 group->description = strdup (""); 00115 group->handle_entity_in_group = strdup (""); 00116 group->unnamed_flag = 0; 00117 group->selectability_flag = 0; 00118 group->dictionary_owner_soft = strdup (""); 00119 group->dictionary_owner_hard = strdup (""); 00120 group->next = NULL; 00121 #if DEBUG 00122 DXF_DEBUG_END 00123 #endif 00124 return (group); 00125 } 00126 00127 00138 DxfGroup * 00139 dxf_group_read 00140 ( 00141 DxfFile *fp, 00143 DxfGroup *group 00145 ) 00146 { 00147 #if DEBUG 00148 DXF_DEBUG_BEGIN 00149 #endif 00150 char *temp_string = NULL; 00151 00152 /* Do some basic checks. */ 00153 if (fp == NULL) 00154 { 00155 fprintf (stderr, 00156 (_("Error in %s () a NULL file pointer was passed.\n")), 00157 __FUNCTION__); 00158 /* Clean up. */ 00159 free (temp_string); 00160 return (NULL); 00161 } 00162 if (fp->acad_version_number < AutoCAD_13) 00163 { 00164 fprintf (stderr, 00165 (_("Warning in %s () illegal DXF version for this entity.\n")), 00166 __FUNCTION__); 00167 } 00168 if (group == NULL) 00169 { 00170 fprintf (stderr, 00171 (_("Warning in %s () a NULL pointer was passed.\n")), 00172 __FUNCTION__); 00173 group = dxf_group_new (); 00174 group = dxf_group_init (group); 00175 } 00176 (fp->line_number)++; 00177 fscanf (fp->fp, "%[^\n]", temp_string); 00178 while (strcmp (temp_string, "0") != 0) 00179 { 00180 if (ferror (fp->fp)) 00181 { 00182 fprintf (stderr, 00183 (_("Error in %s () while reading from: %s in line: %d.\n")), 00184 __FUNCTION__, fp->filename, fp->line_number); 00185 /* Clean up. */ 00186 free (temp_string); 00187 fclose (fp->fp); 00188 return (NULL); 00189 } 00190 if (strcmp (temp_string, "5") == 0) 00191 { 00192 /* Now follows a string containing a sequential 00193 * id number. */ 00194 (fp->line_number)++; 00195 fscanf (fp->fp, "%x\n", &group->id_code); 00196 } 00197 else if (strcmp (temp_string, "70") == 0) 00198 { 00199 /* Now follows a string containing the 00200 * unnamed flag value. */ 00201 (fp->line_number)++; 00202 fscanf (fp->fp, "%d\n", &group->unnamed_flag); 00203 } 00204 else if (strcmp (temp_string, "71") == 0) 00205 { 00206 /* Now follows a string containing the 00207 * selectability flag value. */ 00208 (fp->line_number)++; 00209 fscanf (fp->fp, "%d\n", &group->selectability_flag); 00210 } 00211 else if ((fp->acad_version_number >= AutoCAD_13) 00212 && (strcmp (temp_string, "100") == 0)) 00213 { 00214 /* Now follows a string containing the 00215 * subclass marker value. */ 00216 (fp->line_number)++; 00217 fscanf (fp->fp, "%s\n", temp_string); 00218 if (strcmp (temp_string, "AcDbGroup") != 0) 00219 { 00220 fprintf (stderr, 00221 (_("Warning in %s () found a bad subclass marker in: %s in line: %d.\n")), 00222 __FUNCTION__, fp->filename, fp->line_number); 00223 } 00224 } 00225 else if (strcmp (temp_string, "300") == 0) 00226 { 00227 /* Now follows a string containing a description. */ 00228 (fp->line_number)++; 00229 fscanf (fp->fp, "%s\n", group->description); 00230 } 00231 else if (strcmp (temp_string, "330") == 0) 00232 { 00233 /* Now follows a string containing Soft-pointer 00234 * ID/handle to owner dictionary. */ 00235 (fp->line_number)++; 00236 fscanf (fp->fp, "%s\n", group->dictionary_owner_soft); 00237 } 00238 else if (strcmp (temp_string, "340") == 0) 00239 { 00240 /* Now follows a string containing a handle to an 00241 * entry in group object. */ 00242 (fp->line_number)++; 00243 fscanf (fp->fp, "%s\n", group->handle_entity_in_group); 00244 } 00245 else if (strcmp (temp_string, "360") == 0) 00246 { 00247 /* Now follows a string containing Hard owner 00248 * ID/handle to owner dictionary. */ 00249 (fp->line_number)++; 00250 fscanf (fp->fp, "%s\n", group->dictionary_owner_hard); 00251 } 00252 else if (strcmp (temp_string, "999") == 0) 00253 { 00254 /* Now follows a string containing a comment. */ 00255 (fp->line_number)++; 00256 fscanf (fp->fp, "%s\n", temp_string); 00257 fprintf (stdout, (_("DXF comment: %s\n")), temp_string); 00258 } 00259 else 00260 { 00261 fprintf (stderr, 00262 (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")), 00263 __FUNCTION__, fp->filename, fp->line_number); 00264 } 00265 } 00266 /* Clean up. */ 00267 free (temp_string); 00268 #if DEBUG 00269 DXF_DEBUG_END 00270 #endif 00271 return (group); 00272 } 00273 00274 00281 int 00282 dxf_group_write 00283 ( 00284 DxfFile *fp, 00286 DxfGroup *group 00288 ) 00289 { 00290 #if DEBUG 00291 DXF_DEBUG_BEGIN 00292 #endif 00293 char *dxf_entity_name = strdup ("GROUP"); 00294 00295 /* Do some basic checks. */ 00296 if (fp == NULL) 00297 { 00298 fprintf (stderr, 00299 (_("Error in %s () a NULL file pointer was passed.\n")), 00300 __FUNCTION__); 00301 /* Clean up. */ 00302 free (dxf_entity_name); 00303 return (EXIT_FAILURE); 00304 } 00305 if (group == NULL) 00306 { 00307 fprintf (stderr, 00308 (_("Error in %s () a NULL pointer was passed.\n")), 00309 __FUNCTION__); 00310 /* Clean up. */ 00311 free (dxf_entity_name); 00312 return (EXIT_FAILURE); 00313 } 00314 if (strcmp (group->description, "") == 0) 00315 { 00316 fprintf (stderr, 00317 (_("Error in %s () empty description string for the %s entity with id-code: %x\n")), 00318 __FUNCTION__, dxf_entity_name, group->id_code); 00319 /* Clean up. */ 00320 free (dxf_entity_name); 00321 return (EXIT_FAILURE); 00322 } 00323 if (strcmp (group->handle_entity_in_group, "") == 0) 00324 { 00325 fprintf (stderr, 00326 (_("Error in %s () empty string for handle entity in group for the %s entity with id-code: %x\n")), 00327 __FUNCTION__, dxf_entity_name, group->id_code); 00328 /* Clean up. */ 00329 free (dxf_entity_name); 00330 return (EXIT_FAILURE); 00331 } 00332 if (fp->acad_version_number < AutoCAD_13) 00333 { 00334 fprintf (stderr, 00335 (_("Warning in %s () illegal DXF version for this %s entity with id-code: %x.\n")), 00336 __FUNCTION__, dxf_entity_name, group->id_code); 00337 } 00338 /* Start writing output. */ 00339 fprintf (fp->fp, " 0\n%s\n", dxf_entity_name); 00340 if (group->id_code != -1) 00341 { 00342 fprintf (fp->fp, " 5\n%x\n", group->id_code); 00343 } 00354 if ((strcmp (group->dictionary_owner_soft, "") != 0) 00355 && (fp->acad_version_number >= AutoCAD_14)) 00356 { 00357 fprintf (fp->fp, "102\n{ACAD_REACTORS\n"); 00358 fprintf (fp->fp, "330\n%s\n", group->dictionary_owner_soft); 00359 fprintf (fp->fp, "102\n}\n"); 00360 } 00361 if ((strcmp (group->dictionary_owner_hard, "") != 0) 00362 && (fp->acad_version_number >= AutoCAD_14)) 00363 { 00364 fprintf (fp->fp, "102\n{ACAD_XDICTIONARY\n"); 00365 fprintf (fp->fp, "360\n%s\n", group->dictionary_owner_hard); 00366 fprintf (fp->fp, "102\n}\n"); 00367 } 00368 if (fp->acad_version_number >= AutoCAD_13) 00369 { 00370 fprintf (fp->fp, "100\nAcDbGroup\n"); 00371 } 00372 fprintf (fp->fp, "300\n%s\n", group->description); 00373 fprintf (fp->fp, " 70\n%d\n", group->unnamed_flag); 00374 fprintf (fp->fp, " 71\n%d\n", group->selectability_flag); 00375 fprintf (fp->fp, "340\n%s\n", group->handle_entity_in_group); 00376 /* Clean up. */ 00377 free (dxf_entity_name); 00378 #if DEBUG 00379 DXF_DEBUG_END 00380 #endif 00381 return (EXIT_SUCCESS); 00382 } 00383 00384 00392 int 00393 dxf_group_free 00394 ( 00395 DxfGroup *group 00398 ) 00399 { 00400 #if DEBUG 00401 DXF_DEBUG_BEGIN 00402 #endif 00403 /* Do some basic checks. */ 00404 if (group == NULL) 00405 { 00406 fprintf (stderr, 00407 (_("Error in %s () a NULL pointer was passed.\n")), 00408 __FUNCTION__); 00409 return (EXIT_FAILURE); 00410 } 00411 if (group->next != NULL) 00412 { 00413 fprintf (stderr, 00414 (_("Error in %s () pointer to next was not NULL.\n")), 00415 __FUNCTION__); 00416 return (EXIT_FAILURE); 00417 } 00418 free (group->dictionary_owner_soft); 00419 free (group->dictionary_owner_hard); 00420 free (group->description); 00421 free (group->handle_entity_in_group); 00422 free (group); 00423 group = NULL; 00424 #if DEBUG 00425 DXF_DEBUG_END 00426 #endif 00427 return (EXIT_SUCCESS); 00428 } 00429 00430 00435 void 00436 dxf_group_free_chain 00437 ( 00438 DxfGroup *groups 00440 ) 00441 { 00442 #ifdef DEBUG 00443 DXF_DEBUG_BEGIN 00444 #endif 00445 if (groups == NULL) 00446 { 00447 fprintf (stderr, 00448 (_("Warning in %s () a NULL pointer was passed.\n")), 00449 __FUNCTION__); 00450 } 00451 while (groups != NULL) 00452 { 00453 struct DxfGroup *iter = groups->next; 00454 dxf_group_free (groups); 00455 groups = (DxfGroup *) iter; 00456 } 00457 #if DEBUG 00458 DXF_DEBUG_END 00459 #endif 00460 } 00461 00462 00468 int 00469 dxf_group_get_id_code 00470 ( 00471 DxfGroup *group 00473 ) 00474 { 00475 #if DEBUG 00476 DXF_DEBUG_BEGIN 00477 #endif 00478 int result; 00479 00480 /* Do some basic checks. */ 00481 if (group == NULL) 00482 { 00483 fprintf (stderr, 00484 (_("Error in %s () a NULL pointer was passed.\n")), 00485 __FUNCTION__); 00486 return (EXIT_FAILURE); 00487 } 00488 if (group->id_code < 0) 00489 { 00490 fprintf (stderr, 00491 (_("Error in %s () a negative value was found in the id-code member.\n")), 00492 __FUNCTION__); 00493 return (EXIT_FAILURE); 00494 } 00495 result = group->id_code; 00496 #if DEBUG 00497 DXF_DEBUG_END 00498 #endif 00499 return (result); 00500 } 00501 00502 00506 DxfGroup * 00507 dxf_group_set_id_code 00508 ( 00509 DxfGroup *group, 00511 int id_code 00515 ) 00516 { 00517 #if DEBUG 00518 DXF_DEBUG_BEGIN 00519 #endif 00520 /* Do some basic checks. */ 00521 if (group == NULL) 00522 { 00523 fprintf (stderr, 00524 (_("Error in %s () a NULL pointer was passed.\n")), 00525 __FUNCTION__); 00526 return (NULL); 00527 } 00528 if (id_code < 0) 00529 { 00530 fprintf (stderr, 00531 (_("Error in %s () a negative id-code value was passed.\n")), 00532 __FUNCTION__); 00533 return (NULL); 00534 } 00535 group->id_code = id_code; 00536 #if DEBUG 00537 DXF_DEBUG_END 00538 #endif 00539 return (group); 00540 } 00541 00542 00551 char * 00552 dxf_group_get_dictionary_owner_soft 00553 ( 00554 DxfGroup *group 00556 ) 00557 { 00558 #if DEBUG 00559 DXF_DEBUG_BEGIN 00560 #endif 00561 char *result; 00562 00563 /* Do some basic checks. */ 00564 if (group == NULL) 00565 { 00566 fprintf (stderr, 00567 (_("Error in %s () a NULL pointer was passed.\n")), 00568 __FUNCTION__); 00569 return (NULL); 00570 } 00571 if (group->dictionary_owner_soft == NULL) 00572 { 00573 fprintf (stderr, 00574 (_("Error in %s () a NULL pointer was found in the dictionary_owner_soft member.\n")), 00575 __FUNCTION__); 00576 return (NULL); 00577 } 00578 result = strdup (group->dictionary_owner_soft); 00579 #if DEBUG 00580 DXF_DEBUG_END 00581 #endif 00582 return (result); 00583 } 00584 00585 00590 DxfGroup * 00591 dxf_group_set_dictionary_owner_soft 00592 ( 00593 DxfGroup *group, 00595 char *dictionary_owner_soft 00598 ) 00599 { 00600 #if DEBUG 00601 DXF_DEBUG_BEGIN 00602 #endif 00603 /* Do some basic checks. */ 00604 if (group == NULL) 00605 { 00606 fprintf (stderr, 00607 (_("Error in %s () a NULL pointer was passed.\n")), 00608 __FUNCTION__); 00609 return (NULL); 00610 } 00611 if (dictionary_owner_soft == NULL) 00612 { 00613 fprintf (stderr, 00614 (_("Error in %s () a NULL pointer was passed.\n")), 00615 __FUNCTION__); 00616 return (NULL); 00617 } 00618 group->dictionary_owner_soft = strdup (dictionary_owner_soft); 00619 #if DEBUG 00620 DXF_DEBUG_END 00621 #endif 00622 return (group); 00623 } 00624 00625 00634 char * 00635 dxf_group_get_dictionary_owner_hard 00636 ( 00637 DxfGroup *group 00639 ) 00640 { 00641 #if DEBUG 00642 DXF_DEBUG_BEGIN 00643 #endif 00644 char *result; 00645 00646 /* Do some basic checks. */ 00647 if (group == NULL) 00648 { 00649 fprintf (stderr, 00650 (_("Error in %s () a NULL pointer was passed.\n")), 00651 __FUNCTION__); 00652 return (NULL); 00653 } 00654 if (group->dictionary_owner_hard == NULL) 00655 { 00656 fprintf (stderr, 00657 (_("Error in %s () a NULL pointer was found in the dictionary_owner_hard member.\n")), 00658 __FUNCTION__); 00659 return (NULL); 00660 } 00661 result = strdup (group->dictionary_owner_hard); 00662 #if DEBUG 00663 DXF_DEBUG_END 00664 #endif 00665 return (result); 00666 } 00667 00668 00673 DxfGroup * 00674 dxf_group_set_dictionary_owner_hard 00675 ( 00676 DxfGroup *group, 00678 char *dictionary_owner_hard 00681 ) 00682 { 00683 #if DEBUG 00684 DXF_DEBUG_BEGIN 00685 #endif 00686 /* Do some basic checks. */ 00687 if (group == NULL) 00688 { 00689 fprintf (stderr, 00690 (_("Error in %s () a NULL pointer was passed.\n")), 00691 __FUNCTION__); 00692 return (NULL); 00693 } 00694 if (dictionary_owner_hard == NULL) 00695 { 00696 fprintf (stderr, 00697 (_("Error in %s () a NULL pointer was passed.\n")), 00698 __FUNCTION__); 00699 return (NULL); 00700 } 00701 group->dictionary_owner_hard = strdup (dictionary_owner_hard); 00702 #if DEBUG 00703 DXF_DEBUG_END 00704 #endif 00705 return (group); 00706 } 00707 00708 00714 int 00715 dxf_group_get_unnamed_flag 00716 ( 00717 DxfGroup *group 00719 ) 00720 { 00721 #if DEBUG 00722 DXF_DEBUG_BEGIN 00723 #endif 00724 int result; 00725 00726 /* Do some basic checks. */ 00727 if (group == NULL) 00728 { 00729 fprintf (stderr, 00730 (_("Error in %s () a NULL pointer was passed.\n")), 00731 __FUNCTION__); 00732 return (EXIT_FAILURE); 00733 } 00734 if (group->unnamed_flag < 0) 00735 { 00736 fprintf (stderr, 00737 (_("Warning in %s () a negative value was found in the unnamed_flag member.\n")), 00738 __FUNCTION__); 00739 } 00740 if (group->unnamed_flag > 1) 00741 { 00742 fprintf (stderr, 00743 (_("Warning in %s () an out of range value was found in the unnamed_flag member.\n")), 00744 __FUNCTION__); 00745 } 00746 result = group->unnamed_flag; 00747 #if DEBUG 00748 DXF_DEBUG_END 00749 #endif 00750 return (result); 00751 } 00752 00753 00757 DxfGroup * 00758 dxf_group_set_unnamed_flag 00759 ( 00760 DxfGroup *group, 00762 int unnamed_flag 00764 ) 00765 { 00766 #if DEBUG 00767 DXF_DEBUG_BEGIN 00768 #endif 00769 /* Do some basic checks. */ 00770 if (group == NULL) 00771 { 00772 fprintf (stderr, 00773 (_("Error in %s () a NULL pointer was passed.\n")), 00774 __FUNCTION__); 00775 return (NULL); 00776 } 00777 if (unnamed_flag < 0) 00778 { 00779 fprintf (stderr, 00780 (_("Warning in %s () a negative unnamed flag value was passed.\n")), 00781 __FUNCTION__); 00782 } 00783 group->unnamed_flag = unnamed_flag; 00784 #if DEBUG 00785 DXF_DEBUG_END 00786 #endif 00787 return (group); 00788 } 00789 00790 00796 int 00797 dxf_group_get_selectability_flag 00798 ( 00799 DxfGroup *group 00801 ) 00802 { 00803 #if DEBUG 00804 DXF_DEBUG_BEGIN 00805 #endif 00806 int result; 00807 00808 /* Do some basic checks. */ 00809 if (group == NULL) 00810 { 00811 fprintf (stderr, 00812 (_("Error in %s () a NULL pointer was passed.\n")), 00813 __FUNCTION__); 00814 return (EXIT_FAILURE); 00815 } 00816 if (group->selectability_flag < 0) 00817 { 00818 fprintf (stderr, 00819 (_("Warning in %s () a negative value was found in the selectability_flag member.\n")), 00820 __FUNCTION__); 00821 } 00822 if (group->selectability_flag > 1) 00823 { 00824 fprintf (stderr, 00825 (_("Warning in %s () an out of range value was found in the selectability_flag member.\n")), 00826 __FUNCTION__); 00827 } 00828 result = group->selectability_flag; 00829 #if DEBUG 00830 DXF_DEBUG_END 00831 #endif 00832 return (result); 00833 } 00834 00835 00839 DxfGroup * 00840 dxf_group_set_selectability_flag 00841 ( 00842 DxfGroup *group, 00844 int selectability_flag 00846 ) 00847 { 00848 #if DEBUG 00849 DXF_DEBUG_BEGIN 00850 #endif 00851 /* Do some basic checks. */ 00852 if (group == NULL) 00853 { 00854 fprintf (stderr, 00855 (_("Error in %s () a NULL pointer was passed.\n")), 00856 __FUNCTION__); 00857 return (NULL); 00858 } 00859 if (selectability_flag < 0) 00860 { 00861 fprintf (stderr, 00862 (_("Warning in %s () a negative selectability flag value was passed.\n")), 00863 __FUNCTION__); 00864 } 00865 if (selectability_flag > 1) 00866 { 00867 fprintf (stderr, 00868 (_("Warning in %s () an out of range selectability flag value was passed.\n")), 00869 __FUNCTION__); 00870 } 00871 group->selectability_flag = selectability_flag; 00872 #if DEBUG 00873 DXF_DEBUG_END 00874 #endif 00875 return (group); 00876 } 00877 00878 00884 char * 00885 dxf_group_get_description 00886 ( 00887 DxfGroup *group 00889 ) 00890 { 00891 #if DEBUG 00892 DXF_DEBUG_BEGIN 00893 #endif 00894 char *result = NULL; 00895 00896 /* Do some basic checks. */ 00897 if (group == NULL) 00898 { 00899 fprintf (stderr, 00900 (_("Error in %s () a NULL pointer was passed.\n")), 00901 __FUNCTION__); 00902 return (NULL); 00903 } 00904 if (group->description == NULL) 00905 { 00906 fprintf (stderr, 00907 (_("Error in %s () a NULL pointer was found in the description member.\n")), 00908 __FUNCTION__); 00909 return (NULL); 00910 } 00911 result = strdup (group->description); 00912 #if DEBUG 00913 DXF_DEBUG_END 00914 #endif 00915 return (result); 00916 } 00917 00918 00922 DxfGroup * 00923 dxf_group_set_description 00924 ( 00925 DxfGroup *group, 00927 char *description 00929 ) 00930 { 00931 #if DEBUG 00932 DXF_DEBUG_BEGIN 00933 #endif 00934 /* Do some basic checks. */ 00935 if (group == NULL) 00936 { 00937 fprintf (stderr, 00938 (_("Error in %s () a NULL pointer was passed.\n")), 00939 __FUNCTION__); 00940 return (NULL); 00941 } 00942 if (description == NULL) 00943 { 00944 fprintf (stderr, 00945 (_("Error in %s () a NULL pointer was passed.\n")), 00946 __FUNCTION__); 00947 return (NULL); 00948 } 00949 group->description = strdup (description); 00950 #if DEBUG 00951 DXF_DEBUG_END 00952 #endif 00953 return (group); 00954 } 00955 00956 00963 char * 00964 dxf_group_get_handle_entity_in_group 00965 ( 00966 DxfGroup *group 00968 ) 00969 { 00970 #if DEBUG 00971 DXF_DEBUG_BEGIN 00972 #endif 00973 char *result = NULL; 00974 00975 /* Do some basic checks. */ 00976 if (group == NULL) 00977 { 00978 fprintf (stderr, 00979 (_("Error in %s () a NULL pointer was passed.\n")), 00980 __FUNCTION__); 00981 return (NULL); 00982 } 00983 if (group->handle_entity_in_group == NULL) 00984 { 00985 fprintf (stderr, 00986 (_("Error in %s () a NULL pointer was found in the handle_entity_in_group member.\n")), 00987 __FUNCTION__); 00988 return (NULL); 00989 } 00990 result = strdup (group->handle_entity_in_group); 00991 #if DEBUG 00992 DXF_DEBUG_END 00993 #endif 00994 return (result); 00995 } 00996 00997 01001 DxfGroup * 01002 dxf_group_set_handle_entity_in_group 01003 ( 01004 DxfGroup *group, 01006 char *handle_entity_in_group 01009 ) 01010 { 01011 #if DEBUG 01012 DXF_DEBUG_BEGIN 01013 #endif 01014 /* Do some basic checks. */ 01015 if (group == NULL) 01016 { 01017 fprintf (stderr, 01018 (_("Error in %s () a NULL pointer was passed.\n")), 01019 __FUNCTION__); 01020 return (NULL); 01021 } 01022 if (handle_entity_in_group == NULL) 01023 { 01024 fprintf (stderr, 01025 (_("Error in %s () a NULL pointer was passed.\n")), 01026 __FUNCTION__); 01027 return (NULL); 01028 } 01029 group->handle_entity_in_group = strdup (handle_entity_in_group); 01030 #if DEBUG 01031 DXF_DEBUG_END 01032 #endif 01033 return (group); 01034 } 01035 01036 01045 DxfGroup * 01046 dxf_group_get_next 01047 ( 01048 DxfGroup *group 01050 ) 01051 { 01052 #if DEBUG 01053 DXF_DEBUG_BEGIN 01054 #endif 01055 DxfGroup *result; 01056 01057 /* Do some basic checks. */ 01058 if (group == NULL) 01059 { 01060 fprintf (stderr, 01061 (_("Error in %s () a NULL pointer was passed.\n")), 01062 __FUNCTION__); 01063 return (NULL); 01064 } 01065 if (group->next == NULL) 01066 { 01067 fprintf (stderr, 01068 (_("Error in %s () a NULL pointer was found in the next member.\n")), 01069 __FUNCTION__); 01070 return (NULL); 01071 } 01072 result = (DxfGroup *) group->next; 01073 #if DEBUG 01074 DXF_DEBUG_END 01075 #endif 01076 return (result); 01077 } 01078 01079 01084 DxfGroup * 01085 dxf_group_set_next 01086 ( 01087 DxfGroup *group, 01089 DxfGroup *next 01091 ) 01092 { 01093 #if DEBUG 01094 DXF_DEBUG_BEGIN 01095 #endif 01096 /* Do some basic checks. */ 01097 if (group == NULL) 01098 { 01099 fprintf (stderr, 01100 (_("Error in %s () a NULL pointer was passed.\n")), 01101 __FUNCTION__); 01102 return (NULL); 01103 } 01104 if (next == NULL) 01105 { 01106 fprintf (stderr, 01107 (_("Error in %s () a NULL pointer was passed.\n")), 01108 __FUNCTION__); 01109 return (NULL); 01110 } 01111 group->next = (struct DxfGroup *) next; 01112 #if DEBUG 01113 DXF_DEBUG_END 01114 #endif 01115 return (group); 01116 } 01117 01118 01127 DxfGroup * 01128 dxf_group_get_last 01129 ( 01130 DxfGroup *group 01132 ) 01133 { 01134 #if DEBUG 01135 DXF_DEBUG_BEGIN 01136 #endif 01137 /* Do some basic checks. */ 01138 if (group == NULL) 01139 { 01140 fprintf (stderr, 01141 (_("Error in %s () a NULL pointer was passed.\n")), 01142 __FUNCTION__); 01143 return (NULL); 01144 } 01145 if (group->next == NULL) 01146 { 01147 fprintf (stderr, 01148 (_("Warning in %s () a NULL pointer was found.\n")), 01149 __FUNCTION__); 01150 return ((DxfGroup *) group); 01151 } 01152 DxfGroup *iter = (DxfGroup *) group->next; 01153 while (iter->next != NULL) 01154 { 01155 iter = (DxfGroup *) iter->next; 01156 } 01157 #if DEBUG 01158 DXF_DEBUG_END 01159 #endif 01160 return ((DxfGroup *) iter); 01161 } 01162 01163 01164 /* EOF*/