libDXF 0.0.1
A library with DXF related functions written in C.
|
00001 00044 #include "block_record.h" 00045 00046 00052 DxfBlockRecord * 00053 dxf_block_record_new () 00054 { 00055 #if DEBUG 00056 DXF_DEBUG_BEGIN 00057 #endif 00058 DxfBlockRecord *block_record = NULL; 00059 size_t size; 00060 00061 size = sizeof (DxfBlockRecord); 00062 /* avoid malloc of 0 bytes */ 00063 if (size == 0) size = 1; 00064 if ((block_record = malloc (size)) == NULL) 00065 { 00066 fprintf (stderr, 00067 (_("Error in %s () could not allocate memory for a DxfBlockRecord struct.\n")), 00068 __FUNCTION__); 00069 block_record = NULL; 00070 } 00071 else 00072 { 00073 memset (block_record, 0, size); 00074 } 00075 #if DEBUG 00076 DXF_DEBUG_END 00077 #endif 00078 return (block_record); 00079 } 00080 00081 00089 DxfBlockRecord * 00090 dxf_block_record_init 00091 ( 00092 DxfBlockRecord *block_record 00094 ) 00095 { 00096 #if DEBUG 00097 DXF_DEBUG_BEGIN 00098 #endif 00099 /* Do some basic checks. */ 00100 if (block_record == NULL) 00101 { 00102 fprintf (stderr, 00103 (_("Warning in %s () a NULL pointer was passed.\n")), 00104 __FUNCTION__); 00105 block_record = dxf_block_record_new (); 00106 } 00107 if (block_record == NULL) 00108 { 00109 fprintf (stderr, 00110 (_("Error in %s () could not allocate memory for a DxfBlockRecord struct.\n")), 00111 __FUNCTION__); 00112 return (NULL); 00113 } 00114 dxf_block_record_set_id_code (block_record, 0); 00115 dxf_block_record_set_block_name (block_record, strdup ("")); 00116 dxf_block_record_set_flag (block_record, 0); 00117 dxf_block_record_set_dictionary_owner_soft (block_record, strdup ("")); 00118 dxf_block_record_set_dictionary_owner_hard (block_record, strdup ("")); 00119 dxf_block_record_set_next (block_record, NULL); 00120 #if DEBUG 00121 DXF_DEBUG_END 00122 #endif 00123 return (block_record); 00124 } 00125 00126 00139 DxfBlockRecord * 00140 dxf_block_record_read 00141 ( 00142 DxfFile *fp, 00144 DxfBlockRecord *block_record 00146 ) 00147 { 00148 #if DEBUG 00149 DXF_DEBUG_BEGIN 00150 #endif 00151 char *temp_string = NULL; 00152 00153 /* Do some basic checks. */ 00154 if (fp == NULL) 00155 { 00156 fprintf (stderr, 00157 (_("Error in %s () a NULL file pointer was passed.\n")), 00158 __FUNCTION__); 00159 /* Clean up. */ 00160 free (temp_string); 00161 return (NULL); 00162 } 00163 if (block_record == NULL) 00164 { 00165 fprintf (stderr, 00166 (_("Warning in %s () a NULL pointer was passed.\n")), 00167 __FUNCTION__); 00168 block_record = dxf_block_record_new (); 00169 block_record = dxf_block_record_init (block_record); 00170 } 00171 (fp->line_number)++; 00172 fscanf (fp->fp, "%[^\n]", temp_string); 00173 while (strcmp (temp_string, "0") != 0) 00174 { 00175 if (ferror (fp->fp)) 00176 { 00177 fprintf (stderr, 00178 (_("Error in %s () while reading from: %s in line: %d.\n")), 00179 __FUNCTION__, fp->filename, fp->line_number); 00180 fclose (fp->fp); 00181 /* Clean up. */ 00182 free (temp_string); 00183 return (NULL); 00184 } 00185 if (strcmp (temp_string, "5") == 0) 00186 { 00187 /* Now follows a string containing a sequential 00188 * id number. */ 00189 (fp->line_number)++; 00190 fscanf (fp->fp, "%x\n", &block_record->id_code); 00191 } 00192 else if (strcmp (temp_string, "2") == 0) 00193 { 00194 /* Now follows a string containing an application 00195 * name. */ 00196 (fp->line_number)++; 00197 fscanf (fp->fp, "%s\n", block_record->block_name); 00198 } 00199 else if (strcmp (temp_string, "70") == 0) 00200 { 00201 /* Now follows a string containing the 00202 * standard flag value. */ 00203 (fp->line_number)++; 00204 fscanf (fp->fp, "%d\n", &block_record->flag); 00205 } 00206 else if (strcmp (temp_string, "330") == 0) 00207 { 00208 /* Now follows a string containing Soft-pointer 00209 * ID/handle to owner dictionary. */ 00210 (fp->line_number)++; 00211 fscanf (fp->fp, "%s\n", block_record->dictionary_owner_soft); 00212 } 00213 else if (strcmp (temp_string, "360") == 0) 00214 { 00215 /* Now follows a string containing Hard owner 00216 * ID/handle to owner dictionary. */ 00217 (fp->line_number)++; 00218 fscanf (fp->fp, "%s\n", block_record->dictionary_owner_hard); 00219 } 00220 else if (strcmp (temp_string, "999") == 0) 00221 { 00222 /* Now follows a string containing a comment. */ 00223 (fp->line_number)++; 00224 fscanf (fp->fp, "%s\n", temp_string); 00225 fprintf (stdout, "DXF comment: %s\n", temp_string); 00226 } 00227 else 00228 { 00229 fprintf (stderr, 00230 (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")), 00231 __FUNCTION__, fp->filename, fp->line_number); 00232 } 00233 } 00234 /* Clean up. */ 00235 free (temp_string); 00236 #if DEBUG 00237 DXF_DEBUG_END 00238 #endif 00239 return (block_record); 00240 } 00241 00242 00247 int 00248 dxf_block_record_write 00249 ( 00250 DxfFile *fp, 00252 DxfBlockRecord *block_record 00254 ) 00255 { 00256 #if DEBUG 00257 DXF_DEBUG_BEGIN 00258 #endif 00259 char *dxf_entity_name = strdup ("BLOCK_RECORD"); 00260 00261 /* Do some basic checks. */ 00262 if (fp == NULL) 00263 { 00264 fprintf (stderr, 00265 (_("Error in %s () a NULL file pointer was passed.\n")), 00266 __FUNCTION__); 00267 /* Clean up. */ 00268 free (dxf_entity_name); 00269 return (EXIT_FAILURE); 00270 } 00271 if (fp->acad_version_number < AutoCAD_13) 00272 { 00273 fprintf (stderr, 00274 (_("Error in %s () illegal DXF version for this entity.\n")), 00275 __FUNCTION__); 00276 /* Clean up. */ 00277 free (dxf_entity_name); 00278 return (EXIT_FAILURE); 00279 } 00280 if (block_record == NULL) 00281 { 00282 fprintf (stderr, 00283 (_("Error in %s () a NULL pointer was passed.\n")), 00284 __FUNCTION__); 00285 /* Clean up. */ 00286 free (dxf_entity_name); 00287 return (EXIT_FAILURE); 00288 } 00289 if ((dxf_block_record_get_block_name (block_record) == NULL) 00290 || (strcmp (dxf_block_record_get_block_name (block_record), "") == 0)) 00291 { 00292 fprintf (stderr, 00293 (_("Error in %s empty block name string for the %s entity with id-code: %x\n")), 00294 __FUNCTION__, dxf_entity_name, dxf_block_record_get_id_code (block_record)); 00295 fprintf (stderr, 00296 (_("\t%s entity is discarded from output.\n")), 00297 dxf_entity_name); 00298 /* Clean up. */ 00299 free (dxf_entity_name); 00300 return (EXIT_FAILURE); 00301 } 00302 /* Start writing output. */ 00303 fprintf (fp->fp, " 0\n%s\n", dxf_entity_name); 00304 if (dxf_block_record_get_id_code (block_record) != -1) 00305 { 00306 fprintf (fp->fp, " 5\n%x\n", dxf_block_record_get_id_code (block_record)); 00307 } 00318 if ((strcmp (dxf_block_record_get_dictionary_owner_soft (block_record), "") != 0) 00319 && (fp->acad_version_number >= AutoCAD_14)) 00320 { 00321 fprintf (fp->fp, "102\n{ACAD_REACTORS\n"); 00322 fprintf (fp->fp, "330\n%s\n", dxf_block_record_get_dictionary_owner_soft (block_record)); 00323 fprintf (fp->fp, "102\n}\n"); 00324 } 00325 if ((strcmp (dxf_block_record_get_dictionary_owner_hard (block_record), "") != 0) 00326 && (fp->acad_version_number >= AutoCAD_14)) 00327 { 00328 fprintf (fp->fp, "102\n{ACAD_XDICTIONARY\n"); 00329 fprintf (fp->fp, "360\n%s\n", dxf_block_record_get_dictionary_owner_hard (block_record)); 00330 fprintf (fp->fp, "102\n}\n"); 00331 } 00332 if (fp->acad_version_number >= AutoCAD_13) 00333 { 00334 fprintf (fp->fp, "100\nAcDbSymbolTableRecord\n"); 00335 fprintf (fp->fp, "100\nAcDbRegAppTableRecord\n"); 00336 } 00337 fprintf (fp->fp, " 2\n%s\n", dxf_block_record_get_block_name (block_record)); 00338 fprintf (fp->fp, " 70\n%d\n", dxf_block_record_get_flag (block_record)); 00339 /* Clean up. */ 00340 free (dxf_entity_name); 00341 #if DEBUG 00342 DXF_DEBUG_END 00343 #endif 00344 return (EXIT_SUCCESS); 00345 } 00346 00347 00355 int 00356 dxf_block_record_free 00357 ( 00358 DxfBlockRecord *block_record 00360 ) 00361 { 00362 #if DEBUG 00363 DXF_DEBUG_BEGIN 00364 #endif 00365 if (block_record == NULL) 00366 { 00367 fprintf (stderr, 00368 (_("Error in %s () a NULL pointer was passed.\n")), 00369 __FUNCTION__); 00370 return (EXIT_FAILURE); 00371 } 00372 if (block_record->next != NULL) 00373 { 00374 fprintf (stderr, 00375 (_("Error in %s () pointer to next was not NULL.\n")), 00376 __FUNCTION__); 00377 return (EXIT_FAILURE); 00378 } 00379 free (block_record->block_name); 00380 free (block_record->dictionary_owner_soft); 00381 free (block_record->dictionary_owner_hard); 00382 free (block_record); 00383 block_record = NULL; 00384 #if DEBUG 00385 DXF_DEBUG_END 00386 #endif 00387 return (EXIT_SUCCESS); 00388 } 00389 00390 00395 void 00396 dxf_block_record_free_chain 00397 ( 00398 DxfBlockRecord *block_records 00400 ) 00401 { 00402 #ifdef DEBUG 00403 DXF_DEBUG_BEGIN 00404 #endif 00405 if (block_records == NULL) 00406 { 00407 fprintf (stderr, 00408 (_("Warning in %s () a NULL pointer was passed.\n")), 00409 __FUNCTION__); 00410 } 00411 while (block_records != NULL) 00412 { 00413 struct DxfBlockRecord *iter= block_records->next; 00414 dxf_block_record_free (block_records); 00415 block_records = (DxfBlockRecord *) iter; 00416 } 00417 #if DEBUG 00418 DXF_DEBUG_END 00419 #endif 00420 } 00421 00422 00428 int 00429 dxf_block_record_get_id_code 00430 ( 00431 DxfBlockRecord *block_record 00434 ) 00435 { 00436 #if DEBUG 00437 DXF_DEBUG_BEGIN 00438 #endif 00439 /* Do some basic checks. */ 00440 if (block_record == NULL) 00441 { 00442 fprintf (stderr, 00443 (_("Error in %s () a NULL pointer was passed.\n")), 00444 __FUNCTION__); 00445 return (EXIT_FAILURE); 00446 } 00447 if (block_record->id_code < 0) 00448 { 00449 fprintf (stderr, 00450 (_("Error in %s () a negative value was found in the id-code member.\n")), 00451 __FUNCTION__); 00452 return (EXIT_FAILURE); 00453 } 00454 #if DEBUG 00455 DXF_DEBUG_END 00456 #endif 00457 return (block_record->id_code); 00458 } 00459 00460 00464 DxfBlockRecord * 00465 dxf_block_record_set_id_code 00466 ( 00467 DxfBlockRecord *block_record, 00470 int id_code 00474 ) 00475 { 00476 #if DEBUG 00477 DXF_DEBUG_BEGIN 00478 #endif 00479 /* Do some basic checks. */ 00480 if (block_record == NULL) 00481 { 00482 fprintf (stderr, 00483 (_("Error in %s () a NULL pointer was passed.\n")), 00484 __FUNCTION__); 00485 return (NULL); 00486 } 00487 if (id_code < 0) 00488 { 00489 fprintf (stderr, 00490 (_("Error in %s () a negative id-code value was passed.\n")), 00491 __FUNCTION__); 00492 return (NULL); 00493 } 00494 block_record->id_code = id_code; 00495 #if DEBUG 00496 DXF_DEBUG_END 00497 #endif 00498 return (block_record); 00499 } 00500 00501 00508 char * 00509 dxf_block_record_get_block_name 00510 ( 00511 DxfBlockRecord *block_record 00514 ) 00515 { 00516 #if DEBUG 00517 DXF_DEBUG_BEGIN 00518 #endif 00519 /* Do some basic checks. */ 00520 if (block_record == NULL) 00521 { 00522 fprintf (stderr, 00523 (_("Error in %s () a NULL pointer was passed.\n")), 00524 __FUNCTION__); 00525 return (NULL); 00526 } 00527 if (block_record->block_name == NULL) 00528 { 00529 fprintf (stderr, 00530 (_("Error in %s () a NULL pointer was found in the block_name member.\n")), 00531 __FUNCTION__); 00532 return (NULL); 00533 } 00534 #if DEBUG 00535 DXF_DEBUG_END 00536 #endif 00537 return (strdup (block_record->block_name)); 00538 } 00539 00540 00545 DxfBlockRecord * 00546 dxf_block_record_set_block_name 00547 ( 00548 DxfBlockRecord *block_record, 00551 char *block_name 00554 ) 00555 { 00556 #if DEBUG 00557 DXF_DEBUG_BEGIN 00558 #endif 00559 /* Do some basic checks. */ 00560 if (block_record == NULL) 00561 { 00562 fprintf (stderr, 00563 (_("Error in %s () a NULL pointer was passed.\n")), 00564 __FUNCTION__); 00565 return (NULL); 00566 } 00567 if (block_name == NULL) 00568 { 00569 fprintf (stderr, 00570 (_("Error in %s () a NULL pointer was passed.\n")), 00571 __FUNCTION__); 00572 return (NULL); 00573 } 00574 block_record->block_name= strdup (block_name); 00575 #if DEBUG 00576 DXF_DEBUG_END 00577 #endif 00578 return (block_record); 00579 } 00580 00581 00588 int 00589 dxf_block_record_get_flag 00590 ( 00591 DxfBlockRecord *block_record 00594 ) 00595 { 00596 #if DEBUG 00597 DXF_DEBUG_BEGIN 00598 #endif 00599 /* Do some basic checks. */ 00600 if (block_record == NULL) 00601 { 00602 fprintf (stderr, 00603 (_("Error in %s () a NULL pointer was passed.\n")), 00604 __FUNCTION__); 00605 return (EXIT_FAILURE); 00606 } 00607 if (block_record->flag < 0) 00608 { 00609 fprintf (stderr, 00610 (_("Error in %s () a negative value was found in the flag member.\n")), 00611 __FUNCTION__); 00612 return (EXIT_FAILURE); 00613 } 00614 if (block_record->flag > 64) 00615 { 00616 fprintf (stderr, 00617 (_("Error in %s () an out of range value was found in the flag member.\n")), 00618 __FUNCTION__); 00619 return (EXIT_FAILURE); 00620 } 00621 #if DEBUG 00622 DXF_DEBUG_END 00623 #endif 00624 return (block_record->flag); 00625 } 00626 00627 00632 DxfBlockRecord * 00633 dxf_block_record_set_flag 00634 ( 00635 DxfBlockRecord *block_record, 00638 int flag 00642 ) 00643 { 00644 #if DEBUG 00645 DXF_DEBUG_BEGIN 00646 #endif 00647 /* Do some basic checks. */ 00648 if (block_record == NULL) 00649 { 00650 fprintf (stderr, 00651 (_("Error in %s () a NULL pointer was passed.\n")), 00652 __FUNCTION__); 00653 return (NULL); 00654 } 00655 if (flag < 0) 00656 { 00657 fprintf (stderr, 00658 (_("Error in %s () a negative flag value was passed.\n")), 00659 __FUNCTION__); 00660 return (NULL); 00661 } 00662 if (flag > 64) 00663 { 00664 fprintf (stderr, 00665 (_("Error in %s () an out of range flag value was passed.\n")), 00666 __FUNCTION__); 00667 return (NULL); 00668 } 00669 block_record->flag = flag; 00670 #if DEBUG 00671 DXF_DEBUG_END 00672 #endif 00673 return (block_record); 00674 } 00675 00676 00685 int 00686 dxf_block_record_is_xreferenced 00687 ( 00688 DxfBlockRecord *block_record 00690 ) 00691 { 00692 #if DEBUG 00693 DXF_DEBUG_BEGIN 00694 #endif 00695 /* Do some basic checks. */ 00696 if (block_record == NULL) 00697 { 00698 fprintf (stderr, 00699 (_("Error in %s () a NULL pointer was passed.\n")), 00700 __FUNCTION__); 00701 return (-1); 00702 } 00703 #if DEBUG 00704 DXF_DEBUG_END 00705 #endif 00706 return (DXF_CHECK_BIT (block_record->flag, 4)); 00707 } 00708 00709 00719 int 00720 dxf_block_record_is_xresolved 00721 ( 00722 DxfBlockRecord *block_record 00724 ) 00725 { 00726 #if DEBUG 00727 DXF_DEBUG_BEGIN 00728 #endif 00729 /* Do some basic checks. */ 00730 if (block_record == NULL) 00731 { 00732 fprintf (stderr, 00733 (_("Error in %s () a NULL pointer was passed.\n")), 00734 __FUNCTION__); 00735 return (-1); 00736 } 00737 #if DEBUG 00738 DXF_DEBUG_END 00739 #endif 00740 return ((DXF_CHECK_BIT (block_record->flag, 4)) 00741 && (DXF_CHECK_BIT (block_record->flag, 5))); 00742 } 00743 00744 00753 int 00754 dxf_block_record_is_referenced 00755 ( 00756 DxfBlockRecord *block_record 00758 ) 00759 { 00760 #if DEBUG 00761 DXF_DEBUG_BEGIN 00762 #endif 00763 /* Do some basic checks. */ 00764 if (block_record == NULL) 00765 { 00766 fprintf (stderr, 00767 (_("Error in %s () a NULL pointer was passed.\n")), 00768 __FUNCTION__); 00769 return (-1); 00770 } 00771 #if DEBUG 00772 DXF_DEBUG_END 00773 #endif 00774 return (DXF_CHECK_BIT (block_record->flag, 6)); 00775 } 00776 00777 00786 char * 00787 dxf_block_record_get_dictionary_owner_soft 00788 ( 00789 DxfBlockRecord *block_record 00792 ) 00793 { 00794 #if DEBUG 00795 DXF_DEBUG_BEGIN 00796 #endif 00797 /* Do some basic checks. */ 00798 if (block_record == NULL) 00799 { 00800 fprintf (stderr, 00801 (_("Error in %s () a NULL pointer was passed.\n")), 00802 __FUNCTION__); 00803 return (NULL); 00804 } 00805 if (block_record->dictionary_owner_soft == NULL) 00806 { 00807 fprintf (stderr, 00808 (_("Error in %s () a NULL pointer was found in the dictionary_owner_soft member.\n")), 00809 __FUNCTION__); 00810 return (NULL); 00811 } 00812 #if DEBUG 00813 DXF_DEBUG_END 00814 #endif 00815 return (strdup (block_record->dictionary_owner_soft)); 00816 } 00817 00818 00823 DxfBlockRecord * 00824 dxf_block_record_set_dictionary_owner_soft 00825 ( 00826 DxfBlockRecord *block_record, 00829 char *dictionary_owner_soft 00832 ) 00833 { 00834 #if DEBUG 00835 DXF_DEBUG_BEGIN 00836 #endif 00837 /* Do some basic checks. */ 00838 if (block_record == NULL) 00839 { 00840 fprintf (stderr, 00841 (_("Error in %s () a NULL pointer was passed.\n")), 00842 __FUNCTION__); 00843 return (NULL); 00844 } 00845 if (dictionary_owner_soft == NULL) 00846 { 00847 fprintf (stderr, 00848 (_("Error in %s () a NULL pointer was passed.\n")), 00849 __FUNCTION__); 00850 return (NULL); 00851 } 00852 block_record->dictionary_owner_soft = strdup (dictionary_owner_soft); 00853 #if DEBUG 00854 DXF_DEBUG_END 00855 #endif 00856 return (block_record); 00857 } 00858 00859 00868 char * 00869 dxf_block_record_get_dictionary_owner_hard 00870 ( 00871 DxfBlockRecord *block_record 00874 ) 00875 { 00876 #if DEBUG 00877 DXF_DEBUG_BEGIN 00878 #endif 00879 /* Do some basic checks. */ 00880 if (block_record == NULL) 00881 { 00882 fprintf (stderr, 00883 (_("Error in %s () a NULL pointer was passed.\n")), 00884 __FUNCTION__); 00885 return (NULL); 00886 } 00887 if (block_record->dictionary_owner_hard == NULL) 00888 { 00889 fprintf (stderr, 00890 (_("Error in %s () a NULL pointer was found in the dictionary_owner_hard member.\n")), 00891 __FUNCTION__); 00892 return (NULL); 00893 } 00894 #if DEBUG 00895 DXF_DEBUG_END 00896 #endif 00897 return (strdup (block_record->dictionary_owner_hard)); 00898 } 00899 00900 00905 DxfBlockRecord * 00906 dxf_block_record_set_dictionary_owner_hard 00907 ( 00908 DxfBlockRecord *block_record, 00911 char *dictionary_owner_hard 00914 ) 00915 { 00916 #if DEBUG 00917 DXF_DEBUG_BEGIN 00918 #endif 00919 /* Do some basic checks. */ 00920 if (block_record == NULL) 00921 { 00922 fprintf (stderr, 00923 (_("Error in %s () a NULL pointer was passed.\n")), 00924 __FUNCTION__); 00925 return (NULL); 00926 } 00927 if (dictionary_owner_hard == NULL) 00928 { 00929 fprintf (stderr, 00930 (_("Error in %s () a NULL pointer was passed.\n")), 00931 __FUNCTION__); 00932 return (NULL); 00933 } 00934 block_record->dictionary_owner_hard = strdup (dictionary_owner_hard); 00935 #if DEBUG 00936 DXF_DEBUG_END 00937 #endif 00938 return (block_record); 00939 } 00940 00941 00950 DxfBlockRecord * 00951 dxf_block_record_get_next 00952 ( 00953 DxfBlockRecord *block_record 00956 ) 00957 { 00958 #if DEBUG 00959 DXF_DEBUG_BEGIN 00960 #endif 00961 /* Do some basic checks. */ 00962 if (block_record == NULL) 00963 { 00964 fprintf (stderr, 00965 (_("Error in %s () a NULL pointer was passed.\n")), 00966 __FUNCTION__); 00967 return (NULL); 00968 } 00969 if (block_record->next == NULL) 00970 { 00971 fprintf (stderr, 00972 (_("Error in %s () a NULL pointer was found in the next member.\n")), 00973 __FUNCTION__); 00974 return (NULL); 00975 } 00976 #if DEBUG 00977 DXF_DEBUG_END 00978 #endif 00979 return ((DxfBlockRecord *) block_record->next); 00980 } 00981 00982 00987 DxfBlockRecord * 00988 dxf_block_record_set_next 00989 ( 00990 DxfBlockRecord *block_record, 00992 DxfBlockRecord *next 00995 ) 00996 { 00997 #if DEBUG 00998 DXF_DEBUG_BEGIN 00999 #endif 01000 /* Do some basic checks. */ 01001 if (block_record == NULL) 01002 { 01003 fprintf (stderr, 01004 (_("Error in %s () a NULL pointer was passed.\n")), 01005 __FUNCTION__); 01006 return (NULL); 01007 } 01008 if (next == NULL) 01009 { 01010 fprintf (stderr, 01011 (_("Error in %s () a NULL pointer was passed.\n")), 01012 __FUNCTION__); 01013 return (NULL); 01014 } 01015 block_record->next = (struct DxfBlockRecord *) next; 01016 #if DEBUG 01017 DXF_DEBUG_END 01018 #endif 01019 return (block_record); 01020 } 01021 01022 01031 DxfBlockRecord * 01032 dxf_block_record_get_last 01033 ( 01034 DxfBlockRecord *block_record 01037 ) 01038 { 01039 #if DEBUG 01040 DXF_DEBUG_BEGIN 01041 #endif 01042 /* Do some basic checks. */ 01043 if (block_record == NULL) 01044 { 01045 fprintf (stderr, 01046 (_("Error in %s () a NULL pointer was passed.\n")), 01047 __FUNCTION__); 01048 return (NULL); 01049 } 01050 if (block_record->next == NULL) 01051 { 01052 fprintf (stderr, 01053 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 01054 __FUNCTION__); 01055 return ((DxfBlockRecord *) block_record); 01056 } 01057 DxfBlockRecord *iter = (DxfBlockRecord *) block_record->next; 01058 while (iter->next != NULL) 01059 { 01060 iter = (DxfBlockRecord *) iter->next; 01061 } 01062 #if DEBUG 01063 DXF_DEBUG_END 01064 #endif 01065 return ((DxfBlockRecord *) iter); 01066 } 01067 01068 01069 /* EOF*/