libDXF 0.0.1
A library with DXF related functions written in C.
|
00001 00044 #include "block.h" 00045 00046 00053 DxfBlock * 00054 dxf_block_new () 00055 { 00056 #if DEBUG 00057 DXF_DEBUG_BEGIN 00058 #endif 00059 DxfBlock *block = NULL; 00060 size_t size; 00061 00062 size = sizeof (DxfBlock); 00063 /* avoid malloc of 0 bytes */ 00064 if (size == 0) size = 1; 00065 if ((block = malloc (size)) == NULL) 00066 { 00067 fprintf (stderr, 00068 (_("Error in %s () could not allocate memory for a DxfBlock struct.\n")), 00069 __FUNCTION__); 00070 block = NULL; 00071 } 00072 else 00073 { 00074 memset (block, 0, size); 00075 } 00076 #if DEBUG 00077 DXF_DEBUG_END 00078 #endif 00079 return (block); 00080 } 00081 00082 00090 DxfBlock * 00091 dxf_block_init 00092 ( 00093 DxfBlock *block 00095 ) 00096 { 00097 #if DEBUG 00098 DXF_DEBUG_BEGIN 00099 #endif 00100 /* Do some basic checks. */ 00101 if (block == NULL) 00102 { 00103 fprintf (stderr, 00104 (_("Warning in %s () a NULL pointer was passed.\n")), 00105 __FUNCTION__); 00106 block = dxf_block_new (); 00107 } 00108 if (block == NULL) 00109 { 00110 fprintf (stderr, 00111 (_("Error in %s () could not allocate memory for a DxfBlock struct.\n")), 00112 __FUNCTION__); 00113 return (NULL); 00114 } 00115 dxf_block_set_xref_name (block, strdup ("")); 00116 dxf_block_set_block_name (block, strdup ("")); 00117 dxf_block_set_block_name_additional (block, strdup ("")); 00118 dxf_block_set_description (block, strdup ("")); 00119 dxf_block_set_id_code (block, 0); 00120 dxf_block_set_layer (block, strdup (DXF_DEFAULT_LAYER)); 00121 dxf_block_set_p0 (block, dxf_point_new ()); 00122 dxf_point_init ((DxfPoint *) dxf_block_get_p0 (block)); 00123 dxf_block_set_x0 (block, 0.0); 00124 dxf_block_set_y0 (block, 0.0); 00125 dxf_block_set_z0 (block, 0.0); 00126 dxf_block_set_block_type (block, 0); /* 0 = invalid type */ 00127 dxf_block_set_extr_x0 (block, 0.0); 00128 dxf_block_set_extr_y0 (block, 0.0); 00129 dxf_block_set_extr_z0 (block, 1.0); 00130 dxf_block_set_dictionary_owner_soft (block, strdup ("")); 00131 dxf_block_set_endblk (block, (struct DxfEndblk *) dxf_endblk_new ()); 00132 dxf_block_set_next (block, NULL); 00133 #if DEBUG 00134 DXF_DEBUG_END 00135 #endif 00136 return (block); 00137 } 00138 00139 00157 DxfBlock * 00158 dxf_block_read 00159 ( 00160 DxfFile *fp, 00162 DxfBlock *block 00164 ) 00165 { 00166 #if DEBUG 00167 DXF_DEBUG_BEGIN 00168 #endif 00169 char *temp_string = NULL; 00170 00171 /* Do some basic checks. */ 00172 if (fp == NULL) 00173 { 00174 fprintf (stderr, 00175 (_("Error in %s () a NULL file pointer was passed.\n")), 00176 __FUNCTION__); 00177 /* Clean up. */ 00178 free (temp_string); 00179 return (NULL); 00180 } 00181 if (block == NULL) 00182 { 00183 fprintf (stderr, 00184 (_("Warning in %s () a NULL pointer was passed.\n")), 00185 __FUNCTION__); 00186 block = dxf_block_new (); 00187 block = dxf_block_init (block); 00188 } 00189 fscanf (fp->fp, "%[^\n]", temp_string); 00190 while (strcmp (temp_string, "0") != 0) 00191 { 00192 if (ferror (fp->fp)) 00193 { 00194 fprintf (stderr, 00195 (_("Error in %s () while reading from: %s in line: %d.\n")), 00196 __FUNCTION__, fp->filename, fp->line_number); 00197 fclose (fp->fp); 00198 /* Clean up. */ 00199 free (temp_string); 00200 return (NULL); 00201 } 00202 if (strcmp (temp_string, "1") == 0) 00203 { 00204 /* Now follows a string containing a external 00205 * reference name. */ 00206 fscanf (fp->fp, "%s\n", block->xref_name); 00207 } 00208 else if (strcmp (temp_string, "2") == 0) 00209 { 00210 /* Now follows a string containing a block name. */ 00211 fscanf (fp->fp, "%s\n", block->block_name); 00212 } 00213 else if (strcmp (temp_string, "3") == 0) 00214 { 00215 /* Now follows a string containing a block name. */ 00216 fscanf (fp->fp, "%s\n", block->block_name_additional); 00217 } 00218 else if (strcmp (temp_string, "4") == 0) 00219 { 00220 /* Now follows a string containing a description. */ 00221 fscanf (fp->fp, "%s\n", block->description); 00222 } 00223 else if (strcmp (temp_string, "5") == 0) 00224 { 00225 /* Now follows a string containing a sequential 00226 * id number. */ 00227 fscanf (fp->fp, "%x\n", &block->id_code); 00228 } 00229 else if (strcmp (temp_string, "8") == 0) 00230 { 00231 /* Now follows a string containing a layer name. */ 00232 fscanf (fp->fp, "%s\n", block->layer); 00233 } 00234 else if (strcmp (temp_string, "10") == 0) 00235 { 00236 /* Now follows a string containing the 00237 * X-coordinate of the center point. */ 00238 fscanf (fp->fp, "%lf\n", &block->p0->x0); 00239 } 00240 else if (strcmp (temp_string, "20") == 0) 00241 { 00242 /* Now follows a string containing the 00243 * Y-coordinate of the center point. */ 00244 fscanf (fp->fp, "%lf\n", &block->p0->y0); 00245 } 00246 else if (strcmp (temp_string, "30") == 0) 00247 { 00248 /* Now follows a string containing the 00249 * Z-coordinate of the center point. */ 00250 fscanf (fp->fp, "%lf\n", &block->p0->z0); 00251 } 00252 else if ((fp->acad_version_number <= AutoCAD_11) 00253 && (strcmp (temp_string, "38") == 0) 00254 && (block->p0->z0 = 0.0)) 00255 { 00256 /* Elevation is a pre AutoCAD R11 variable 00257 * so additional testing for the version should 00258 * probably be added. 00259 * Now follows a string containing the 00260 * elevation. */ 00261 fscanf (fp->fp, "%lf\n", &block->p0->z0); 00262 } 00263 else if (strcmp (temp_string, "70") == 0) 00264 { 00265 /* Now follows a string containing the block 00266 * type value. */ 00267 fscanf (fp->fp, "%d\n", &block->block_type); 00268 } 00269 else if ((fp->acad_version_number >= AutoCAD_13) 00270 && (strcmp (temp_string, "100") == 0)) 00271 { 00272 /* Now follows a string containing the 00273 * subclass marker value. */ 00274 fscanf (fp->fp, "%s\n", temp_string); 00275 if ((strcmp (temp_string, "AcDbEntity") != 0) 00276 && ((strcmp (temp_string, "AcDbBlockBegin") != 0))) 00277 { 00278 fprintf (stderr, 00279 (_("Warning in %s () found a bad subclass marker in: %s in line: %d.\n")), 00280 __FUNCTION__, fp->filename, fp->line_number); 00281 } 00282 } 00283 else if (strcmp (temp_string, "210") == 0) 00284 { 00285 /* Now follows a string containing the 00286 * X-value of the extrusion vector. */ 00287 fscanf (fp->fp, "%lf\n", &block->extr_x0); 00288 } 00289 else if (strcmp (temp_string, "220") == 0) 00290 { 00291 /* Now follows a string containing the 00292 * Y-value of the extrusion vector. */ 00293 fscanf (fp->fp, "%lf\n", &block->extr_y0); 00294 } 00295 else if (strcmp (temp_string, "230") == 0) 00296 { 00297 /* Now follows a string containing the 00298 * Z-value of the extrusion vector. */ 00299 fscanf (fp->fp, "%lf\n", &block->extr_z0); 00300 } 00301 else if (strcmp (temp_string, "330") == 0) 00302 { 00303 /* Now follows a string containing Soft-pointer 00304 * ID/handle to owner object. */ 00305 fscanf (fp->fp, "%s\n", block->dictionary_owner_soft); 00306 } 00307 else if (strcmp (temp_string, "999") == 0) 00308 { 00309 /* Now follows a string containing a comment. */ 00310 fscanf (fp->fp, "%s\n", temp_string); 00311 fprintf (stdout, "DXF comment: %s\n", temp_string); 00312 } 00313 else 00314 { 00315 fprintf (stderr, 00316 (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")), 00317 __FUNCTION__, fp->filename, fp->line_number); 00318 } 00319 } 00320 /* Handle omitted members and/or illegal values. */ 00325 if (strcmp (dxf_block_get_block_name (block), "") == 0) 00326 { 00327 sprintf (block->block_name, "%i", block->id_code); 00328 } 00329 if (strcmp (dxf_block_get_layer (block), "") == 0) 00330 { 00331 dxf_block_set_layer (block, strdup (DXF_DEFAULT_LAYER)); 00332 } 00333 if (dxf_block_get_block_type (block) == 0) 00334 { 00335 fprintf (stderr, 00336 (_("Warning in %s () illegal block type value found while reading from: %s in line: %d.\n")), 00337 __FUNCTION__, fp->filename, fp->line_number); 00338 fprintf (stderr, 00339 (_("\tblock type value is reset to 1.\n"))); 00340 dxf_block_set_block_type (block, 1); 00341 } 00342 /* Clean up. */ 00343 free (temp_string); 00344 #if DEBUG 00345 DXF_DEBUG_END 00346 #endif 00347 return (block); 00348 } 00349 00350 00357 int 00358 dxf_block_write 00359 ( 00360 DxfFile *fp, 00362 DxfBlock *block 00364 ) 00365 { 00366 #if DEBUG 00367 DXF_DEBUG_BEGIN 00368 #endif 00369 char *dxf_entity_name = strdup ("BLOCK"); 00370 DxfEndblk *endblk = NULL; 00371 00372 /* Do some basic checks. */ 00373 if (fp == NULL) 00374 { 00375 fprintf (stderr, 00376 (_("Error in %s () a NULL file pointer was passed.\n")), 00377 __FUNCTION__); 00378 /* Clean up. */ 00379 free (dxf_entity_name); 00380 return (EXIT_FAILURE); 00381 } 00382 if (block == NULL) 00383 { 00384 fprintf (stderr, 00385 (_("Error in %s () a NULL pointer was passed.\n")), 00386 __FUNCTION__); 00387 /* Clean up. */ 00388 free (dxf_entity_name); 00389 return (EXIT_FAILURE); 00390 } 00391 if (dxf_block_get_block_name (block) == NULL) 00392 { 00393 fprintf (stderr, 00394 (_("Error in %s () empty block name string for the %s entity with id-code: %x\n")), 00395 __FUNCTION__, dxf_entity_name, dxf_block_get_id_code (block)); 00396 fprintf (stderr, 00397 (_("\t%s entity is discarded from output.\n")), 00398 dxf_entity_name); 00399 /* Clean up. */ 00400 free (dxf_entity_name); 00401 return (EXIT_FAILURE); 00402 } 00403 if (dxf_block_get_endblk (block) == NULL) 00404 { 00405 fprintf (stderr, 00406 (_("Error in %s () NULL pointer to endblk was passed or the %s entity with id-code: %x\n")), 00407 __FUNCTION__, dxf_entity_name, dxf_block_get_id_code (block)); 00408 fprintf (stderr, 00409 (_("\t%s entity is discarded from output.\n")), 00410 dxf_entity_name); 00411 /* Clean up. */ 00412 free (dxf_entity_name); 00413 return (EXIT_FAILURE); 00414 } 00415 if (((dxf_block_get_xref_name (block) == NULL) 00416 || (strcmp (dxf_block_get_xref_name (block) , "") == 0)) 00417 && ((dxf_block_get_block_type (block) != 4) 00418 || (dxf_block_get_block_type (block) != 32))) 00419 { 00420 fprintf (stderr, 00421 (_("Error in %s () empty xref path name string for the %s entity with id-code: %x\n")), 00422 __FUNCTION__, dxf_entity_name, dxf_block_get_id_code (block)); 00423 fprintf (stderr, 00424 (_("\t%s entity is discarded from output.\n")), 00425 dxf_entity_name); 00426 /* Clean up. */ 00427 free (dxf_entity_name); 00428 return (EXIT_FAILURE); 00429 } 00430 if (dxf_block_get_description (block) == NULL) 00431 { 00432 fprintf (stderr, 00433 (_("Warning in %s () NULL pointer to description string for the %s entity with id-code: %x\n")), 00434 __FUNCTION__, dxf_entity_name, dxf_block_get_id_code (block)); 00435 dxf_block_set_description (block, strdup ("")); 00436 } 00437 if (strcmp (dxf_block_get_layer (block), "") == 0) 00438 { 00439 fprintf (stderr, 00440 (_("Warning in %s () empty layer string for the %s entity with id-code: %x\n")), 00441 __FUNCTION__, dxf_entity_name, dxf_block_get_id_code (block)); 00442 fprintf (stderr, 00443 (_("\t%s entity is relocated to layer 0.\n")), 00444 dxf_entity_name); 00445 dxf_block_set_layer (block, strdup (DXF_DEFAULT_LAYER)); 00446 } 00447 if (dxf_block_get_dictionary_owner_soft (block) == NULL) 00448 { 00449 fprintf (stderr, 00450 (_("Warning in %s () NULL pointer to soft owner object string for the %s entity with id-code: %x\n")), 00451 __FUNCTION__, dxf_entity_name, dxf_block_get_id_code (block)); 00452 dxf_block_set_dictionary_owner_soft (block, strdup ("")); 00453 } 00454 /* Start writing output. */ 00455 fprintf (fp->fp, " 0\n%s\n", dxf_entity_name); 00456 if ((fp->acad_version_number >= AutoCAD_13) 00457 && (dxf_block_get_id_code (block) != -1)) 00458 { 00459 fprintf (fp->fp, " 5\n%x\n", dxf_block_get_id_code (block)); 00460 } 00471 if ((strcmp (dxf_block_get_dictionary_owner_soft (block), "") != 0) 00472 && (fp->acad_version_number >= AutoCAD_14)) 00473 { 00474 fprintf (fp->fp, "330\n%s\n", dxf_block_get_dictionary_owner_soft (block)); 00475 } 00476 if (fp->acad_version_number >= AutoCAD_13) 00477 { 00478 fprintf (fp->fp, "100\nAcDbEntity\n"); 00479 } 00480 fprintf (fp->fp, " 8\n%s\n", dxf_block_get_layer (block)); 00481 if (fp->acad_version_number >= AutoCAD_13) 00482 { 00483 fprintf (fp->fp, "100\nAcDbBlockBegin\n"); 00484 } 00485 fprintf (fp->fp, " 2\n%s\n", dxf_block_get_block_name (block)); 00486 fprintf (fp->fp, " 70\n%d\n", dxf_block_get_block_type (block)); 00487 fprintf (fp->fp, " 10\n%f\n", dxf_block_get_x0 (block)); 00488 fprintf (fp->fp, " 20\n%f\n", dxf_block_get_y0 (block)); 00489 fprintf (fp->fp, " 30\n%f\n", dxf_block_get_z0 (block)); 00490 if (fp->acad_version_number >= AutoCAD_13) 00491 { 00492 fprintf (fp->fp, " 3\n%s\n", dxf_block_get_block_name (block)); 00493 } 00494 if ((fp->acad_version_number >= AutoCAD_13) 00495 && ((dxf_block_get_block_type (block) && 4) 00496 || (dxf_block_get_block_type (block) && 32))) 00497 { 00498 fprintf (fp->fp, " 1\n%s\n", dxf_block_get_xref_name (block)); 00499 } 00500 if ((fp->acad_version_number >= AutoCAD_2000) 00501 && (strcmp (dxf_block_get_description (block), "") != 0)) 00502 { 00503 fprintf (fp->fp, " 4\n%s\n", dxf_block_get_description (block)); 00504 } 00505 endblk = (DxfEndblk *) dxf_block_get_endblk (block); 00506 dxf_endblk_write (fp, endblk); 00507 /* Clean up. */ 00508 free (dxf_entity_name); 00509 #if DEBUG 00510 DXF_DEBUG_END 00511 #endif 00512 return (EXIT_SUCCESS); 00513 } 00514 00515 00521 int 00522 dxf_block_write_table 00523 ( 00524 DxfFile *fp, 00526 DxfBlock *blocks_list 00528 ) 00529 { 00530 #if DEBUG 00531 DXF_DEBUG_BEGIN 00532 #endif 00533 /* Do some basic checks. */ 00534 if (fp == NULL) 00535 { 00536 fprintf (stderr, 00537 (_("Error in %s () a NULL file pointer was passed.\n")), 00538 __FUNCTION__); 00539 return (EXIT_FAILURE); 00540 } 00541 00543 #if DEBUG 00544 DXF_DEBUG_END 00545 #endif 00546 return (EXIT_SUCCESS); 00547 } 00548 00549 00557 int 00558 dxf_block_free 00559 ( 00560 DxfBlock *block 00563 ) 00564 { 00565 #if DEBUG 00566 DXF_DEBUG_BEGIN 00567 #endif 00568 if (block == NULL) 00569 { 00570 fprintf (stderr, 00571 (_("Error in %s () a NULL pointer was passed.\n")), 00572 __FUNCTION__); 00573 return (EXIT_FAILURE); 00574 } 00575 if (block->next != NULL) 00576 { 00577 fprintf (stderr, 00578 (_("Error in %s () pointer to next was not NULL.\n")), 00579 __FUNCTION__); 00580 return (EXIT_FAILURE); 00581 } 00582 free (block->xref_name); 00583 free (block->block_name); 00584 free (block->block_name_additional); 00585 free (block->description); 00586 free (block->layer); 00587 free (block->dictionary_owner_soft); 00588 free (block); 00589 block = NULL; 00590 #if DEBUG 00591 DXF_DEBUG_END 00592 #endif 00593 return (EXIT_SUCCESS); 00594 } 00595 00596 00601 void 00602 dxf_block_free_chain 00603 ( 00604 DxfBlock *blocks 00606 ) 00607 { 00608 #ifdef DEBUG 00609 DXF_DEBUG_BEGIN 00610 #endif 00611 if (blocks == NULL) 00612 { 00613 fprintf (stderr, 00614 (_("Warning in %s () a NULL pointer was passed.\n")), 00615 __FUNCTION__); 00616 } 00617 while (blocks != NULL) 00618 { 00619 struct DxfBlock *iter = blocks->next; 00620 dxf_block_free (blocks); 00621 blocks = (DxfBlock *) iter; 00622 } 00623 #if DEBUG 00624 DXF_DEBUG_END 00625 #endif 00626 } 00627 00628 00636 char * 00637 dxf_block_get_xref_name 00638 ( 00639 DxfBlock *block 00641 ) 00642 { 00643 #if DEBUG 00644 DXF_DEBUG_BEGIN 00645 #endif 00646 /* Do some basic checks. */ 00647 if (block == NULL) 00648 { 00649 fprintf (stderr, 00650 (_("Error in %s () a NULL pointer was passed.\n")), 00651 __FUNCTION__); 00652 return (NULL); 00653 } 00654 if (block->xref_name == NULL) 00655 { 00656 fprintf (stderr, 00657 (_("Error in %s () a NULL pointer was found in the xref_name member.\n")), 00658 __FUNCTION__); 00659 return (NULL); 00660 } 00661 #if DEBUG 00662 DXF_DEBUG_END 00663 #endif 00664 return (strdup (block->xref_name)); 00665 } 00666 00667 00671 DxfBlock * 00672 dxf_block_set_xref_name 00673 ( 00674 DxfBlock *block, 00676 char *xref_name 00679 ) 00680 { 00681 #if DEBUG 00682 DXF_DEBUG_BEGIN 00683 #endif 00684 /* Do some basic checks. */ 00685 if (block == NULL) 00686 { 00687 fprintf (stderr, 00688 (_("Error in %s () a NULL pointer was passed.\n")), 00689 __FUNCTION__); 00690 return (NULL); 00691 } 00692 if (xref_name == NULL) 00693 { 00694 fprintf (stderr, 00695 (_("Error in %s () a NULL pointer was passed.\n")), 00696 __FUNCTION__); 00697 return (NULL); 00698 } 00699 block->xref_name = strdup (xref_name); 00700 #if DEBUG 00701 DXF_DEBUG_END 00702 #endif 00703 return (block); 00704 } 00705 00706 00714 char * 00715 dxf_block_get_block_name 00716 ( 00717 DxfBlock *block 00719 ) 00720 { 00721 #if DEBUG 00722 DXF_DEBUG_BEGIN 00723 #endif 00724 /* Do some basic checks. */ 00725 if (block == NULL) 00726 { 00727 fprintf (stderr, 00728 (_("Error in %s () a NULL pointer was passed.\n")), 00729 __FUNCTION__); 00730 return (NULL); 00731 } 00732 if (block->block_name == NULL) 00733 { 00734 fprintf (stderr, 00735 (_("Error in %s () a NULL pointer was found in the block_name member.\n")), 00736 __FUNCTION__); 00737 return (NULL); 00738 } 00739 #if DEBUG 00740 DXF_DEBUG_END 00741 #endif 00742 return (strdup (block->block_name)); 00743 } 00744 00745 00749 DxfBlock * 00750 dxf_block_set_block_name 00751 ( 00752 DxfBlock *block, 00754 char *block_name 00757 ) 00758 { 00759 #if DEBUG 00760 DXF_DEBUG_BEGIN 00761 #endif 00762 /* Do some basic checks. */ 00763 if (block == NULL) 00764 { 00765 fprintf (stderr, 00766 (_("Error in %s () a NULL pointer was passed.\n")), 00767 __FUNCTION__); 00768 return (NULL); 00769 } 00770 if (block_name == NULL) 00771 { 00772 fprintf (stderr, 00773 (_("Error in %s () a NULL pointer was passed.\n")), 00774 __FUNCTION__); 00775 return (NULL); 00776 } 00777 block->block_name = strdup (block_name); 00778 #if DEBUG 00779 DXF_DEBUG_END 00780 #endif 00781 return (block); 00782 } 00783 00784 00792 char * 00793 dxf_block_get_block_name_additional 00794 ( 00795 DxfBlock *block 00797 ) 00798 { 00799 #if DEBUG 00800 DXF_DEBUG_BEGIN 00801 #endif 00802 /* Do some basic checks. */ 00803 if (block == NULL) 00804 { 00805 fprintf (stderr, 00806 (_("Error in %s () a NULL pointer was passed.\n")), 00807 __FUNCTION__); 00808 return (NULL); 00809 } 00810 if (block->block_name_additional == NULL) 00811 { 00812 fprintf (stderr, 00813 (_("Error in %s () a NULL pointer was found in the block_name_additional member.\n")), 00814 __FUNCTION__); 00815 return (NULL); 00816 } 00817 #if DEBUG 00818 DXF_DEBUG_END 00819 #endif 00820 return (strdup (block->block_name_additional)); 00821 } 00822 00823 00827 DxfBlock * 00828 dxf_block_set_block_name_additional 00829 ( 00830 DxfBlock *block, 00832 char *block_name_additional 00835 ) 00836 { 00837 #if DEBUG 00838 DXF_DEBUG_BEGIN 00839 #endif 00840 /* Do some basic checks. */ 00841 if (block == NULL) 00842 { 00843 fprintf (stderr, 00844 (_("Error in %s () a NULL pointer was passed.\n")), 00845 __FUNCTION__); 00846 return (NULL); 00847 } 00848 if (block_name_additional == NULL) 00849 { 00850 fprintf (stderr, 00851 (_("Error in %s () a NULL pointer was passed.\n")), 00852 __FUNCTION__); 00853 return (NULL); 00854 } 00855 block->block_name_additional = strdup (block_name_additional); 00856 #if DEBUG 00857 DXF_DEBUG_END 00858 #endif 00859 return (block); 00860 } 00861 00862 00870 char * 00871 dxf_block_get_description 00872 ( 00873 DxfBlock *block 00875 ) 00876 { 00877 #if DEBUG 00878 DXF_DEBUG_BEGIN 00879 #endif 00880 /* Do some basic checks. */ 00881 if (block == NULL) 00882 { 00883 fprintf (stderr, 00884 (_("Error in %s () a NULL pointer was passed.\n")), 00885 __FUNCTION__); 00886 return (NULL); 00887 } 00888 if (block->description == NULL) 00889 { 00890 fprintf (stderr, 00891 (_("Error in %s () a NULL pointer was found in the description member.\n")), 00892 __FUNCTION__); 00893 return (NULL); 00894 } 00895 #if DEBUG 00896 DXF_DEBUG_END 00897 #endif 00898 return (strdup (block->description)); 00899 } 00900 00901 00905 DxfBlock * 00906 dxf_block_set_description 00907 ( 00908 DxfBlock *block, 00910 char *description 00913 ) 00914 { 00915 #if DEBUG 00916 DXF_DEBUG_BEGIN 00917 #endif 00918 /* Do some basic checks. */ 00919 if (block == NULL) 00920 { 00921 fprintf (stderr, 00922 (_("Error in %s () a NULL pointer was passed.\n")), 00923 __FUNCTION__); 00924 return (NULL); 00925 } 00926 if (description == NULL) 00927 { 00928 fprintf (stderr, 00929 (_("Error in %s () a NULL pointer was passed.\n")), 00930 __FUNCTION__); 00931 return (NULL); 00932 } 00933 block->description = strdup (description); 00934 #if DEBUG 00935 DXF_DEBUG_END 00936 #endif 00937 return (block); 00938 } 00939 00940 00946 int 00947 dxf_block_get_id_code 00948 ( 00949 DxfBlock *block 00951 ) 00952 { 00953 #if DEBUG 00954 DXF_DEBUG_BEGIN 00955 #endif 00956 /* Do some basic checks. */ 00957 if (block == NULL) 00958 { 00959 fprintf (stderr, 00960 (_("Error in %s () a NULL pointer was passed.\n")), 00961 __FUNCTION__); 00962 return (EXIT_FAILURE); 00963 } 00964 if (block->id_code < 0) 00965 { 00966 fprintf (stderr, 00967 (_("Error in %s () a negative value was found in the id-code member.\n")), 00968 __FUNCTION__); 00969 return (EXIT_FAILURE); 00970 } 00971 #if DEBUG 00972 DXF_DEBUG_END 00973 #endif 00974 return (block->id_code); 00975 } 00976 00977 00981 DxfBlock * 00982 dxf_block_set_id_code 00983 ( 00984 DxfBlock *block, 00986 int id_code 00990 ) 00991 { 00992 #if DEBUG 00993 DXF_DEBUG_BEGIN 00994 #endif 00995 /* Do some basic checks. */ 00996 if (block == NULL) 00997 { 00998 fprintf (stderr, 00999 (_("Error in %s () a NULL pointer was passed.\n")), 01000 __FUNCTION__); 01001 return (NULL); 01002 } 01003 if (id_code < 0) 01004 { 01005 fprintf (stderr, 01006 (_("Error in %s () a negative id-code value was passed.\n")), 01007 __FUNCTION__); 01008 return (NULL); 01009 } 01010 block->id_code = id_code; 01011 #if DEBUG 01012 DXF_DEBUG_END 01013 #endif 01014 return (block); 01015 } 01016 01017 01023 char * 01024 dxf_block_get_layer 01025 ( 01026 DxfBlock *block 01028 ) 01029 { 01030 #if DEBUG 01031 DXF_DEBUG_BEGIN 01032 #endif 01033 /* Do some basic checks. */ 01034 if (block == NULL) 01035 { 01036 fprintf (stderr, 01037 (_("Error in %s () a NULL pointer was passed.\n")), 01038 __FUNCTION__); 01039 return (NULL); 01040 } 01041 if (block->layer == NULL) 01042 { 01043 fprintf (stderr, 01044 (_("Error in %s () a NULL pointer was found in the layer member.\n")), 01045 __FUNCTION__); 01046 return (NULL); 01047 } 01048 #if DEBUG 01049 DXF_DEBUG_END 01050 #endif 01051 return (strdup (block->layer)); 01052 } 01053 01054 01058 DxfBlock * 01059 dxf_block_set_layer 01060 ( 01061 DxfBlock *block, 01063 char *layer 01065 ) 01066 { 01067 #if DEBUG 01068 DXF_DEBUG_BEGIN 01069 #endif 01070 /* Do some basic checks. */ 01071 if (block == NULL) 01072 { 01073 fprintf (stderr, 01074 (_("Error in %s () a NULL pointer was passed.\n")), 01075 __FUNCTION__); 01076 return (NULL); 01077 } 01078 if (layer == NULL) 01079 { 01080 fprintf (stderr, 01081 (_("Error in %s () a NULL pointer was passed.\n")), 01082 __FUNCTION__); 01083 return (NULL); 01084 } 01085 block->layer = strdup (layer); 01086 #if DEBUG 01087 DXF_DEBUG_END 01088 #endif 01089 return (block); 01090 } 01091 01092 01098 DxfPoint * 01099 dxf_block_get_p0 01100 ( 01101 DxfBlock *block 01103 ) 01104 { 01105 #ifdef DEBUG 01106 DXF_DEBUG_BEGIN 01107 #endif 01108 /* Do some basic checks. */ 01109 if (block == NULL) 01110 { 01111 fprintf (stderr, 01112 (_("Error in %s () a NULL pointer was passed.\n")), 01113 __FUNCTION__); 01114 return (NULL); 01115 } 01116 if (block->p0 == NULL) 01117 { 01118 fprintf (stderr, 01119 (_("Error in %s () a NULL pointer was found.\n")), 01120 __FUNCTION__); 01121 return (NULL); 01122 } 01123 #if DEBUG 01124 DXF_DEBUG_END 01125 #endif 01126 return (block->p0); 01127 } 01128 01129 01135 DxfBlock * 01136 dxf_block_set_p0 01137 ( 01138 DxfBlock *block, 01140 DxfPoint *p0 01142 ) 01143 { 01144 #ifdef DEBUG 01145 DXF_DEBUG_BEGIN 01146 #endif 01147 /* Do some basic checks. */ 01148 if (block == NULL) 01149 { 01150 fprintf (stderr, 01151 (_("Error in %s () a NULL pointer was passed.\n")), 01152 __FUNCTION__); 01153 return (NULL); 01154 } 01155 if (p0 == NULL) 01156 { 01157 fprintf (stderr, 01158 (_("Error in %s () a NULL pointer was passed.\n")), 01159 __FUNCTION__); 01160 return (NULL); 01161 } 01162 block->p0 = p0; 01163 #if DEBUG 01164 DXF_DEBUG_END 01165 #endif 01166 return (block); 01167 } 01168 01169 01176 double 01177 dxf_block_get_x0 01178 ( 01179 DxfBlock *block 01181 ) 01182 { 01183 #ifdef DEBUG 01184 DXF_DEBUG_BEGIN 01185 #endif 01186 01187 /* Do some basic checks. */ 01188 if (block == NULL) 01189 { 01190 fprintf (stderr, 01191 (_("Error in %s () a NULL pointer was passed.\n")), 01192 __FUNCTION__); 01193 return (EXIT_FAILURE); 01194 } 01195 if (block->p0 == NULL) 01196 { 01197 fprintf (stderr, 01198 (_("Error in %s () a NULL pointer was found.\n")), 01199 __FUNCTION__); 01200 return (EXIT_FAILURE); 01201 } 01202 #if DEBUG 01203 DXF_DEBUG_END 01204 #endif 01205 return (block->p0->x0); 01206 } 01207 01208 01216 DxfBlock * 01217 dxf_block_set_x0 01218 ( 01219 DxfBlock *block, 01221 double x0 01224 ) 01225 { 01226 #ifdef DEBUG 01227 DXF_DEBUG_BEGIN 01228 #endif 01229 /* Do some basic checks. */ 01230 if (block == NULL) 01231 { 01232 fprintf (stderr, 01233 (_("Error in %s () a NULL pointer was passed.\n")), 01234 __FUNCTION__); 01235 return (NULL); 01236 } 01237 if (block->p0 == NULL) 01238 { 01239 fprintf (stderr, 01240 (_("Error in %s () a NULL pointer was found.\n")), 01241 __FUNCTION__); 01242 return (NULL); 01243 } 01244 block->p0->x0 = x0; 01245 #if DEBUG 01246 DXF_DEBUG_END 01247 #endif 01248 return (block); 01249 } 01250 01251 01258 double 01259 dxf_block_get_y0 01260 ( 01261 DxfBlock *block 01263 ) 01264 { 01265 #ifdef DEBUG 01266 DXF_DEBUG_BEGIN 01267 #endif 01268 01269 /* Do some basic checks. */ 01270 if (block == NULL) 01271 { 01272 fprintf (stderr, 01273 (_("Error in %s () a NULL pointer was passed.\n")), 01274 __FUNCTION__); 01275 return (EXIT_FAILURE); 01276 } 01277 if (block->p0 == NULL) 01278 { 01279 fprintf (stderr, 01280 (_("Error in %s () a NULL pointer was found.\n")), 01281 __FUNCTION__); 01282 return (EXIT_FAILURE); 01283 } 01284 #if DEBUG 01285 DXF_DEBUG_END 01286 #endif 01287 return (block->p0->y0); 01288 } 01289 01290 01298 DxfBlock * 01299 dxf_block_set_y0 01300 ( 01301 DxfBlock *block, 01303 double y0 01306 ) 01307 { 01308 #ifdef DEBUG 01309 DXF_DEBUG_BEGIN 01310 #endif 01311 /* Do some basic checks. */ 01312 if (block == NULL) 01313 { 01314 fprintf (stderr, 01315 (_("Error in %s () a NULL pointer was passed.\n")), 01316 __FUNCTION__); 01317 return (NULL); 01318 } 01319 if (block->p0 == NULL) 01320 { 01321 fprintf (stderr, 01322 (_("Error in %s () a NULL pointer was found.\n")), 01323 __FUNCTION__); 01324 return (NULL); 01325 } 01326 block->p0->y0 = y0; 01327 #if DEBUG 01328 DXF_DEBUG_END 01329 #endif 01330 return (block); 01331 } 01332 01333 01340 double 01341 dxf_block_get_z0 01342 ( 01343 DxfBlock *block 01345 ) 01346 { 01347 #ifdef DEBUG 01348 DXF_DEBUG_BEGIN 01349 #endif 01350 01351 /* Do some basic checks. */ 01352 if (block == NULL) 01353 { 01354 fprintf (stderr, 01355 (_("Error in %s () a NULL pointer was passed.\n")), 01356 __FUNCTION__); 01357 return (EXIT_FAILURE); 01358 } 01359 if (block->p0 == NULL) 01360 { 01361 fprintf (stderr, 01362 (_("Error in %s () a NULL pointer was found.\n")), 01363 __FUNCTION__); 01364 return (EXIT_FAILURE); 01365 } 01366 #if DEBUG 01367 DXF_DEBUG_END 01368 #endif 01369 return (block->p0->z0); 01370 } 01371 01372 01380 DxfBlock * 01381 dxf_block_set_z0 01382 ( 01383 DxfBlock *block, 01385 double z0 01388 ) 01389 { 01390 #ifdef DEBUG 01391 DXF_DEBUG_BEGIN 01392 #endif 01393 /* Do some basic checks. */ 01394 if (block == NULL) 01395 { 01396 fprintf (stderr, 01397 (_("Error in %s () a NULL pointer was passed.\n")), 01398 __FUNCTION__); 01399 return (NULL); 01400 } 01401 if (block->p0 == NULL) 01402 { 01403 fprintf (stderr, 01404 (_("Error in %s () a NULL pointer was found.\n")), 01405 __FUNCTION__); 01406 return (NULL); 01407 } 01408 block->p0->z0 = z0; 01409 #if DEBUG 01410 DXF_DEBUG_END 01411 #endif 01412 return (block); 01413 } 01414 01415 01421 int 01422 dxf_block_get_block_type 01423 ( 01424 DxfBlock *block 01426 ) 01427 { 01428 #if DEBUG 01429 DXF_DEBUG_BEGIN 01430 #endif 01431 /* Do some basic checks. */ 01432 if (block == NULL) 01433 { 01434 fprintf (stderr, 01435 (_("Error in %s () a NULL pointer was passed.\n")), 01436 __FUNCTION__); 01437 return (EXIT_FAILURE); 01438 } 01439 if (block->block_type < 0) 01440 { 01441 fprintf (stderr, 01442 (_("Warning in %s () a negative value was found in the block_type member.\n")), 01443 __FUNCTION__); 01444 } 01445 #if DEBUG 01446 DXF_DEBUG_END 01447 #endif 01448 return (block->block_type); 01449 } 01450 01451 01455 DxfBlock * 01456 dxf_block_set_block_type 01457 ( 01458 DxfBlock *block, 01460 int block_type 01462 ) 01463 { 01464 #if DEBUG 01465 DXF_DEBUG_BEGIN 01466 #endif 01467 /* Do some basic checks. */ 01468 if (block == NULL) 01469 { 01470 fprintf (stderr, 01471 (_("Error in %s () a NULL pointer was passed.\n")), 01472 __FUNCTION__); 01473 return (NULL); 01474 } 01475 if (block_type < 0) 01476 { 01477 fprintf (stderr, 01478 (_("Error in %s () a negative block type value was passed.\n")), 01479 __FUNCTION__); 01480 return (NULL); 01481 } 01482 block->block_type = block_type; 01483 #if DEBUG 01484 DXF_DEBUG_END 01485 #endif 01486 return (block); 01487 } 01488 01489 01496 int 01497 dxf_block_is_anonymous 01498 ( 01499 DxfBlock *block 01501 ) 01502 { 01503 #if DEBUG 01504 DXF_DEBUG_BEGIN 01505 #endif 01506 /* Do some basic checks. */ 01507 if (block == NULL) 01508 { 01509 fprintf (stderr, 01510 (_("Error in %s () a NULL pointer was passed.\n")), 01511 __FUNCTION__); 01512 return (EXIT_FAILURE); 01513 } 01514 #if DEBUG 01515 DXF_DEBUG_END 01516 #endif 01517 return (DXF_CHECK_BIT (block->block_type, 0)); 01518 } 01519 01520 01527 int 01528 dxf_block_has_attributes 01529 ( 01530 DxfBlock *block 01532 ) 01533 { 01534 #if DEBUG 01535 DXF_DEBUG_BEGIN 01536 #endif 01537 /* Do some basic checks. */ 01538 if (block == NULL) 01539 { 01540 fprintf (stderr, 01541 (_("Error in %s () a NULL pointer was passed.\n")), 01542 __FUNCTION__); 01543 return (EXIT_FAILURE); 01544 } 01545 #if DEBUG 01546 DXF_DEBUG_END 01547 #endif 01548 return (DXF_CHECK_BIT (block->block_type, 1)); 01549 } 01550 01551 01558 int 01559 dxf_block_is_xreferenced 01560 ( 01561 DxfBlock *block 01563 ) 01564 { 01565 #if DEBUG 01566 DXF_DEBUG_BEGIN 01567 #endif 01568 /* Do some basic checks. */ 01569 if (block == NULL) 01570 { 01571 fprintf (stderr, 01572 (_("Error in %s () a NULL pointer was passed.\n")), 01573 __FUNCTION__); 01574 return (EXIT_FAILURE); 01575 } 01576 #if DEBUG 01577 DXF_DEBUG_END 01578 #endif 01579 return (DXF_CHECK_BIT (block->block_type, 2)); 01580 } 01581 01582 01589 int 01590 dxf_block_is_xdependent 01591 ( 01592 DxfBlock *block 01594 ) 01595 { 01596 #if DEBUG 01597 DXF_DEBUG_BEGIN 01598 #endif 01599 /* Do some basic checks. */ 01600 if (block == NULL) 01601 { 01602 fprintf (stderr, 01603 (_("Error in %s () a NULL pointer was passed.\n")), 01604 __FUNCTION__); 01605 return (EXIT_FAILURE); 01606 } 01607 #if DEBUG 01608 DXF_DEBUG_END 01609 #endif 01610 return (DXF_CHECK_BIT (block->block_type, 4)); 01611 } 01612 01613 01621 int 01622 dxf_block_is_xresolved 01623 ( 01624 DxfBlock *block 01626 ) 01627 { 01628 #if DEBUG 01629 DXF_DEBUG_BEGIN 01630 #endif 01631 /* Do some basic checks. */ 01632 if (block == NULL) 01633 { 01634 fprintf (stderr, 01635 (_("Error in %s () a NULL pointer was passed.\n")), 01636 __FUNCTION__); 01637 return (EXIT_FAILURE); 01638 } 01639 #if DEBUG 01640 DXF_DEBUG_END 01641 #endif 01642 return (DXF_CHECK_BIT (block->block_type, 5)); 01643 } 01644 01645 01652 int 01653 dxf_block_is_referenced 01654 ( 01655 DxfBlock *block 01657 ) 01658 { 01659 #if DEBUG 01660 DXF_DEBUG_BEGIN 01661 #endif 01662 /* Do some basic checks. */ 01663 if (block == NULL) 01664 { 01665 fprintf (stderr, 01666 (_("Error in %s () a NULL pointer was passed.\n")), 01667 __FUNCTION__); 01668 return (EXIT_FAILURE); 01669 } 01670 #if DEBUG 01671 DXF_DEBUG_END 01672 #endif 01673 return (DXF_CHECK_BIT (block->block_type, 6)); 01674 } 01675 01676 01683 double 01684 dxf_block_get_extr_x0 01685 ( 01686 DxfBlock *block 01688 ) 01689 { 01690 #ifdef DEBUG 01691 DXF_DEBUG_BEGIN 01692 #endif 01693 01694 /* Do some basic checks. */ 01695 if (block == NULL) 01696 { 01697 fprintf (stderr, 01698 (_("Error in %s () a NULL pointer was passed.\n")), 01699 __FUNCTION__); 01700 return (EXIT_FAILURE); 01701 } 01702 #if DEBUG 01703 DXF_DEBUG_END 01704 #endif 01705 return (block->extr_x0); 01706 } 01707 01708 01716 DxfBlock * 01717 dxf_block_set_extr_x0 01718 ( 01719 DxfBlock *block, 01721 double extr_x0 01724 ) 01725 { 01726 #ifdef DEBUG 01727 DXF_DEBUG_BEGIN 01728 #endif 01729 /* Do some basic checks. */ 01730 if (block == NULL) 01731 { 01732 fprintf (stderr, 01733 (_("Error in %s () a NULL pointer was passed.\n")), 01734 __FUNCTION__); 01735 return (NULL); 01736 } 01737 block->extr_x0 = extr_x0; 01738 #if DEBUG 01739 DXF_DEBUG_END 01740 #endif 01741 return (block); 01742 } 01743 01744 01751 double 01752 dxf_block_get_extr_y0 01753 ( 01754 DxfBlock *block 01756 ) 01757 { 01758 #ifdef DEBUG 01759 DXF_DEBUG_BEGIN 01760 #endif 01761 01762 /* Do some basic checks. */ 01763 if (block == NULL) 01764 { 01765 fprintf (stderr, 01766 (_("Error in %s () a NULL pointer was passed.\n")), 01767 __FUNCTION__); 01768 return (EXIT_FAILURE); 01769 } 01770 #if DEBUG 01771 DXF_DEBUG_END 01772 #endif 01773 return (block->extr_y0); 01774 } 01775 01776 01784 DxfBlock * 01785 dxf_block_set_extr_y0 01786 ( 01787 DxfBlock *block, 01789 double extr_y0 01792 ) 01793 { 01794 #ifdef DEBUG 01795 DXF_DEBUG_BEGIN 01796 #endif 01797 /* Do some basic checks. */ 01798 if (block == NULL) 01799 { 01800 fprintf (stderr, 01801 (_("Error in %s () a NULL pointer was passed.\n")), 01802 __FUNCTION__); 01803 return (NULL); 01804 } 01805 block->extr_y0 = extr_y0; 01806 #if DEBUG 01807 DXF_DEBUG_END 01808 #endif 01809 return (block); 01810 } 01811 01812 01819 double 01820 dxf_block_get_extr_z0 01821 ( 01822 DxfBlock *block 01824 ) 01825 { 01826 #ifdef DEBUG 01827 DXF_DEBUG_BEGIN 01828 #endif 01829 01830 /* Do some basic checks. */ 01831 if (block == NULL) 01832 { 01833 fprintf (stderr, 01834 (_("Error in %s () a NULL pointer was passed.\n")), 01835 __FUNCTION__); 01836 return (EXIT_FAILURE); 01837 } 01838 #if DEBUG 01839 DXF_DEBUG_END 01840 #endif 01841 return (block->extr_z0); 01842 } 01843 01844 01852 DxfBlock * 01853 dxf_block_set_extr_z0 01854 ( 01855 DxfBlock *block, 01857 double extr_z0 01860 ) 01861 { 01862 #ifdef DEBUG 01863 DXF_DEBUG_BEGIN 01864 #endif 01865 /* Do some basic checks. */ 01866 if (block == NULL) 01867 { 01868 fprintf (stderr, 01869 (_("Error in %s () a NULL pointer was passed.\n")), 01870 __FUNCTION__); 01871 return (NULL); 01872 } 01873 block->extr_z0 = extr_z0; 01874 #if DEBUG 01875 DXF_DEBUG_END 01876 #endif 01877 return (block); 01878 } 01879 01880 01889 DxfPoint * 01890 dxf_block_get_extrusion_vector_as_point 01891 ( 01892 DxfBlock *block 01894 ) 01895 { 01896 #ifdef DEBUG 01897 DXF_DEBUG_BEGIN 01898 #endif 01899 DxfPoint *point = NULL; 01900 01901 /* Do some basic checks. */ 01902 if (block == NULL) 01903 { 01904 fprintf (stderr, 01905 (_("Error in %s () a NULL pointer was passed.\n")), 01906 __FUNCTION__); 01907 return (NULL); 01908 } 01909 point = dxf_point_init (point); 01910 if (point == NULL) 01911 { 01912 fprintf (stderr, 01913 (_("Error in %s () could not allocate memory for a DxfPoint struct.\n")), 01914 __FUNCTION__); 01915 return (NULL); 01916 } 01917 point->x0 = block->extr_x0; 01918 point->y0 = block->extr_y0; 01919 point->z0 = block->extr_z0; 01920 #if DEBUG 01921 DXF_DEBUG_END 01922 #endif 01923 return (point); 01924 } 01925 01926 01930 DxfBlock * 01931 dxf_block_set_extrusion_vector 01932 ( 01933 DxfBlock *block, 01935 double extr_x0, 01937 double extr_y0, 01939 double extr_z0 01941 ) 01942 { 01943 #if DEBUG 01944 DXF_DEBUG_BEGIN 01945 #endif 01946 /* Do some basic checks. */ 01947 if (block == NULL) 01948 { 01949 fprintf (stderr, 01950 (_("Error in %s () a NULL pointer was passed.\n")), 01951 __FUNCTION__); 01952 return (NULL); 01953 } 01954 block->extr_x0 = extr_x0; 01955 block->extr_y0 = extr_y0; 01956 block->extr_z0 = extr_z0; 01957 #if DEBUG 01958 DXF_DEBUG_END 01959 #endif 01960 return (block); 01961 } 01962 01963 01972 char * 01973 dxf_block_get_dictionary_owner_soft 01974 ( 01975 DxfBlock *block 01977 ) 01978 { 01979 #if DEBUG 01980 DXF_DEBUG_BEGIN 01981 #endif 01982 /* Do some basic checks. */ 01983 if (block == NULL) 01984 { 01985 fprintf (stderr, 01986 (_("Error in %s () a NULL pointer was passed.\n")), 01987 __FUNCTION__); 01988 return (NULL); 01989 } 01990 if (block->dictionary_owner_soft == NULL) 01991 { 01992 fprintf (stderr, 01993 (_("Error in %s () a NULL pointer was found in the dictionary_owner_soft member.\n")), 01994 __FUNCTION__); 01995 return (NULL); 01996 } 01997 #if DEBUG 01998 DXF_DEBUG_END 01999 #endif 02000 return (strdup (block->dictionary_owner_soft)); 02001 } 02002 02003 02008 DxfBlock * 02009 dxf_block_set_dictionary_owner_soft 02010 ( 02011 DxfBlock *block, 02013 char *dictionary_owner_soft 02016 ) 02017 { 02018 #if DEBUG 02019 DXF_DEBUG_BEGIN 02020 #endif 02021 /* Do some basic checks. */ 02022 if (block == NULL) 02023 { 02024 fprintf (stderr, 02025 (_("Error in %s () a NULL pointer was passed.\n")), 02026 __FUNCTION__); 02027 return (NULL); 02028 } 02029 if (dictionary_owner_soft == NULL) 02030 { 02031 fprintf (stderr, 02032 (_("Error in %s () a NULL pointer was passed.\n")), 02033 __FUNCTION__); 02034 return (NULL); 02035 } 02036 block->dictionary_owner_soft = strdup (dictionary_owner_soft); 02037 #if DEBUG 02038 DXF_DEBUG_END 02039 #endif 02040 return (block); 02041 } 02042 02043 02052 struct DxfEndblk * 02053 dxf_block_get_endblk 02054 ( 02055 DxfBlock *block 02057 ) 02058 { 02059 #if DEBUG 02060 DXF_DEBUG_BEGIN 02061 #endif 02062 /* Do some basic checks. */ 02063 if (block == NULL) 02064 { 02065 fprintf (stderr, 02066 (_("Error in %s () a NULL pointer was passed.\n")), 02067 __FUNCTION__); 02068 return (NULL); 02069 } 02070 if (block->endblk == NULL) 02071 { 02072 fprintf (stderr, 02073 (_("Error in %s () a NULL pointer was found in the endblk member.\n")), 02074 __FUNCTION__); 02075 return (NULL); 02076 } 02077 #if DEBUG 02078 DXF_DEBUG_END 02079 #endif 02080 return ((struct DxfEndblk *) block->endblk); 02081 } 02082 02083 02088 DxfBlock * 02089 dxf_block_set_endblk 02090 ( 02091 DxfBlock *block, 02093 struct DxfEndblk *endblk 02096 ) 02097 { 02098 #if DEBUG 02099 DXF_DEBUG_BEGIN 02100 #endif 02101 /* Do some basic checks. */ 02102 if (block == NULL) 02103 { 02104 fprintf (stderr, 02105 (_("Error in %s () a NULL pointer was passed.\n")), 02106 __FUNCTION__); 02107 return (NULL); 02108 } 02109 if (endblk == NULL) 02110 { 02111 fprintf (stderr, 02112 (_("Error in %s () a NULL pointer was passed.\n")), 02113 __FUNCTION__); 02114 return (NULL); 02115 } 02116 block->endblk = (struct DxfEndblk *) endblk; 02117 #if DEBUG 02118 DXF_DEBUG_END 02119 #endif 02120 return (block); 02121 } 02122 02123 02132 DxfBlock * 02133 dxf_block_get_next 02134 ( 02135 DxfBlock *block 02137 ) 02138 { 02139 #if DEBUG 02140 DXF_DEBUG_BEGIN 02141 #endif 02142 /* Do some basic checks. */ 02143 if (block == NULL) 02144 { 02145 fprintf (stderr, 02146 (_("Error in %s () a NULL pointer was passed.\n")), 02147 __FUNCTION__); 02148 return (NULL); 02149 } 02150 if (block->next == NULL) 02151 { 02152 fprintf (stderr, 02153 (_("Error in %s () a NULL pointer was found in the next member.\n")), 02154 __FUNCTION__); 02155 return (NULL); 02156 } 02157 #if DEBUG 02158 DXF_DEBUG_END 02159 #endif 02160 return ((DxfBlock *) block->next); 02161 } 02162 02163 02168 DxfBlock * 02169 dxf_block_set_next 02170 ( 02171 DxfBlock *block, 02173 DxfBlock *next 02175 ) 02176 { 02177 #if DEBUG 02178 DXF_DEBUG_BEGIN 02179 #endif 02180 /* Do some basic checks. */ 02181 if (block == NULL) 02182 { 02183 fprintf (stderr, 02184 (_("Error in %s () a NULL pointer was passed.\n")), 02185 __FUNCTION__); 02186 return (NULL); 02187 } 02188 if (next == NULL) 02189 { 02190 fprintf (stderr, 02191 (_("Error in %s () a NULL pointer was passed.\n")), 02192 __FUNCTION__); 02193 return (NULL); 02194 } 02195 block->next = (struct DxfBlock *) next; 02196 #if DEBUG 02197 DXF_DEBUG_END 02198 #endif 02199 return (block); 02200 } 02201 02202 02211 DxfBlock * 02212 dxf_block_get_last 02213 ( 02214 DxfBlock *block 02216 ) 02217 { 02218 #if DEBUG 02219 DXF_DEBUG_BEGIN 02220 #endif 02221 /* Do some basic checks. */ 02222 if (block == NULL) 02223 { 02224 fprintf (stderr, 02225 (_("Error in %s () a NULL pointer was passed.\n")), 02226 __FUNCTION__); 02227 return (NULL); 02228 } 02229 if (block->next == NULL) 02230 { 02231 fprintf (stderr, 02232 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 02233 __FUNCTION__); 02234 return ((DxfBlock *) block); 02235 } 02236 DxfBlock *iter = (DxfBlock *) block->next; 02237 while (iter->next != NULL) 02238 { 02239 iter = (DxfBlock *) iter->next; 02240 } 02241 #if DEBUG 02242 DXF_DEBUG_END 02243 #endif 02244 return ((DxfBlock *) iter); 02245 } 02246 02247 02248 /* EOF */