00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #ifndef __BU_H__
00064 #define __BU_H__
00065
00066 #include "common.h"
00067
00068 __BEGIN_DECLS
00069
00070
00071 #include "tcl.h"
00072
00073 #ifndef BU_EXPORT
00074 # if defined(_WIN32) && !defined(__CYGWIN__) && defined(BRLCAD_DLL)
00075 # ifdef BU_EXPORT_DLL
00076 # define BU_EXPORT __declspec(dllexport)
00077 # else
00078 # define BU_EXPORT __declspec(dllimport)
00079 # endif
00080 # else
00081 # define BU_EXPORT
00082 # endif
00083 #endif
00084
00085 #include <setjmp.h>
00086
00087 #define BU_H_VERSION "@(#)$Header: /cvsroot/brlcad/brlcad/include/bu.h,v 14.38 2006/09/18 05:24:07 lbutler Exp $ (BRL)"
00088
00089
00090
00091
00092
00093 #ifdef DIR_SEPARATOR
00094 # define BU_DIR_SEPARATOR DIR_SEPARATOR
00095 #else
00096 # ifdef DIR_SEPARATOR_2
00097 # define BU_DIR_SEPARATOR DIR_SEPARATOR_2
00098 # else
00099 # ifdef _WIN32
00100 # define BU_DIR_SEPARATOR '\\'
00101 # else
00102 # define BU_DIR_SEPARATOR '/'
00103 # endif
00104 # endif
00105 #endif
00106
00107
00108
00109
00110
00111 #ifndef MAXPATHLEN
00112 # define MAXPATHLEN 1024
00113 #endif
00114
00115
00116
00117
00118 #if defined(PATH_SEPARATOR)
00119 # define BU_PATH_SEPARATOR PATH_SEPARATOR
00120 #else
00121 # if defined(_WIN32)
00122 # define BU_PATH_SEPARATOR ';'
00123 # else
00124 # define BU_PATH_SEPARATOR ':'
00125 # endif
00126 #endif
00127
00128
00129
00130
00131
00132
00133
00134
00135 #define bu_cpp_str(s) # s
00136 #define bu_cpp_xstr(s) bu_cpp_str(s)
00137 #define bu_cpp_glue(a, b) a ## b
00138 #define bu_cpp_xglue(a, b) bu_cpp_glue(a, b)
00139 #define BU_FLSTR __FILE__ ":" bu_cpp_xstr(__LINE__)
00140 #define BU_QFLSTR bu_cpp_xstr(__FILE__ line __LINE__)
00141
00142
00143
00144
00145
00146
00147
00148
00149 #if USE_PROTOTYPES
00150 # define BU_EXTERN(type_and_name,args) extern type_and_name args
00151 # define BU_ARGS(args) args
00152 #else
00153 # define BU_EXTERN(type_and_name,args) extern type_and_name()
00154 # define BU_ARGS(args) ()
00155 #endif
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 #if defined(CRAY)
00170 # define BU_FORTRAN(lc,uc) uc
00171 #endif
00172 #if defined(apollo) || defined(mips) || defined(aux) || defined(linux)
00173
00174 #ifdef __STDC__
00175 # define BU_FORTRAN(lc,uc) lc ## _
00176 #else
00177 # define BU_FORTRAN(lc,uc) lc_
00178 #endif
00179 #endif
00180 #if !defined(BU_FORTRAN)
00181 # define BU_FORTRAN(lc,uc) lc
00182 #endif
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 #if __STDC__
00195 # define BU_GETSTRUCT(_p,_str) \
00196 _p = (struct _str *)bu_calloc(1,sizeof(struct _str), #_str " (getstruct)" BU_FLSTR)
00197 # define BU_GETUNION(_p,_unn) \
00198 _p = (union _unn *)bu_calloc(1,sizeof(union _unn), #_unn " (getunion)" BU_FLSTR)
00199 #else
00200 # define BU_GETSTRUCT(_p,_str) \
00201 _p = (struct _str *)bu_calloc(1,sizeof(struct _str), "_str (getstruct)" )
00202 # define BU_GETUNION(_p,_unn) \
00203 _p = (union _unn *)bu_calloc(1,sizeof(union _unn), "_unn (getunion)" )
00204 #endif
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 #if __STDC__
00215 # define BU_GETTYPE(_p,_type) \
00216 _p = (_type *)bu_calloc(1,sizeof(_type), #_type " (gettype)" )
00217 #else
00218 # define BU_GETTYPE(_p,_type) \
00219 _p = (_type *)bu_calloc(1,sizeof(_type), "_type (getstruct)")
00220 #endif
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 #ifdef NO_BOMBING_MACROS
00232 # define BU_CKMAG(_ptr, _magic, _str)
00233 # define BU_CKMAG_TCL(_interp, _ptr, _magic, _str)
00234 #else
00235 # define BU_CKMAG(_ptr, _magic, _str) \
00236 if( !(_ptr) || ( ((long)(_ptr)) & (sizeof(long)-1) ) || \
00237 *((unsigned long *)(_ptr)) != (unsigned long)(_magic) ) { \
00238 bu_badmagic( (long *)(_ptr), (unsigned long)_magic, _str, __FILE__, __LINE__ ); \
00239 }
00240 # define BU_CKMAG_TCL(_interp, _ptr, _magic, _str) \
00241 if( !(_ptr) || ( ((long)(_ptr)) & (sizeof(long)-1) ) || \
00242 *((long *)(_ptr)) != (_magic) ) { \
00243 bu_badmagic_tcl( (_interp), (long *)(_ptr), (unsigned long)_magic, _str, __FILE__, __LINE__ ); \
00244 return TCL_ERROR; \
00245 }
00246 #endif
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 #ifdef NO_BOMBING_MACROS
00266 # define BU_ASSERT(_equation)
00267 #else
00268 # ifdef __STDC__
00269 # define BU_ASSERT(_equation) \
00270 if( !(_equation) ) { \
00271 bu_log("BU_ASSERT( " #_equation " ) failed, file %s, line %d\n", \
00272 __FILE__, __LINE__ ); \
00273 bu_bomb("assertion failure\n"); \
00274 }
00275 # else
00276 # define BU_ASSERT(_equation) \
00277 if( !(_equation) ) { \
00278 bu_log("BU_ASSERT( _equation ) failed, file %s, line %d\n", \
00279 __FILE__, __LINE__ ); \
00280 bu_bomb("assertion failure\n"); \
00281 }
00282 # endif
00283 #endif
00284
00285 #ifdef NO_BOMBING_MACROS
00286 # define BU_ASSERT_PTR(_lhs,_relation,_rhs)
00287 #else
00288 # ifdef __STDC__
00289 # define BU_ASSERT_PTR(_lhs,_relation,_rhs) \
00290 if( !((_lhs) _relation (_rhs)) ) { \
00291 bu_log("BU_ASSERT_PTR( " #_lhs #_relation #_rhs " ) failed, lhs=x%lx, rhs=x%lx, file %s, line %d\n", \
00292 (long)(_lhs), (long)(_rhs),\
00293 __FILE__, __LINE__ ); \
00294 bu_bomb("BU_ASSERT_PTR failure\n"); \
00295 }
00296 # else
00297 # define BU_ASSERT_PTR(_lhs,_relation,_rhs) \
00298 if( !((_lhs) _relation (_rhs)) ) { \
00299 bu_log("BU_ASSERT_PTR( _lhs _relation _rhs ) failed, lhs=x%lx, rhs=x%lx, file %s, line %d\n", \
00300 (long)(_lhs), (long)(_rhs),\
00301 __FILE__, __LINE__ ); \
00302 bu_bomb("BU_ASSERT_PTR failure\n"); \
00303 }
00304 # endif
00305 #endif
00306
00307
00308 #ifdef NO_BOMBING_MACROS
00309 # define BU_ASSERT_LONG(_lhs,_relation,_rhs)
00310 #else
00311 # ifdef __STDC__
00312 # define BU_ASSERT_LONG(_lhs,_relation,_rhs) \
00313 if( !((_lhs) _relation (_rhs)) ) { \
00314 bu_log("BU_ASSERT_LONG( " #_lhs #_relation #_rhs " ) failed, lhs=%ld, rhs=%ld, file %s, line %d\n", \
00315 (long)(_lhs), (long)(_rhs),\
00316 __FILE__, __LINE__ ); \
00317 bu_bomb("BU_ASSERT_LONG failure\n"); \
00318 }
00319 # else
00320 # define BU_ASSERT_LONG(_lhs,_relation,_rhs) \
00321 if( !((_lhs) _relation (_rhs)) ) { \
00322 bu_log("BU_ASSERT_LONG( _lhs _relation _rhs ) failed, lhs=%ld, rhs=%ld, file %s, line %d\n", \
00323 (long)(_lhs), (long)(_rhs),\
00324 __FILE__, __LINE__ ); \
00325 bu_bomb("BU_ASSERT_LONG failure\n"); \
00326 }
00327 # endif
00328 #endif
00329
00330
00331 #ifdef NO_BOMBING_MACROS
00332 # define BU_ASSERT_DOUBLE(_lhs,_relation,_rhs)
00333 #else
00334 # ifdef __STDC__
00335 # define BU_ASSERT_DOUBLE(_lhs,_relation,_rhs) \
00336 if( !((_lhs) _relation (_rhs)) ) { \
00337 bu_log("BU_ASSERT_DOUBLE( " #_lhs #_relation #_rhs " ) failed, lhs=%lf, rhs=%lf, file %s, line %d\n", \
00338 (double)(_lhs), (double)(_rhs),\
00339 __FILE__, __LINE__ ); \
00340 bu_bomb("BU_ASSERT_DOUBLE failure\n"); \
00341 }
00342 # else
00343 # define BU_ASSERT_DOUBLE(_lhs,_relation,_rhs) \
00344 if( !((_lhs) _relation (_rhs)) ) { \
00345 bu_log("BU_ASSERT_DOUBLE( _lhs _relation _rhs ) failed, lhs=%lf, rhs=%lf, file %s, line %d\n", \
00346 (long)(_lhs), (long)(_rhs),\
00347 __FILE__, __LINE__ ); \
00348 bu_bomb("BU_ASSERT_DOUBLE failure\n"); \
00349 }
00350 # endif
00351 #endif
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 #define SIZEOF_NETWORK_SHORT 2
00366 #define SIZEOF_NETWORK_LONG 4
00367 #define SIZEOF_NETWORK_FLOAT 4
00368 #define SIZEOF_NETWORK_DOUBLE 8
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379 BU_EXPORT BU_EXTERN(int bu_cv_itemlen,
00380 (int cookie));
00381 BU_EXPORT BU_EXTERN(int bu_cv_cookie,
00382 (char *in));
00383 BU_EXPORT BU_EXTERN(int bu_cv_optimize,
00384 (int cookie));
00385 BU_EXPORT BU_EXTERN(int bu_cv_w_cookie,
00386 (genptr_t,
00387 int,
00388 size_t,
00389 genptr_t,
00390 int,
00391 int));
00392
00393 BU_EXPORT BU_EXTERN(int bu_cv_ntohss,
00394 (signed short *,
00395 size_t,
00396 genptr_t,
00397 int));
00398 BU_EXPORT BU_EXTERN(int bu_cv_ntohus,
00399 (unsigned short *,
00400 size_t,
00401 genptr_t,
00402 int));
00403 BU_EXPORT BU_EXTERN(int bu_cv_ntohsl,
00404 (signed long int *,
00405 size_t,
00406 genptr_t,
00407 int));
00408 BU_EXPORT BU_EXTERN(int bu_cv_ntohul,
00409 (unsigned long int *,
00410 size_t,
00411 genptr_t,
00412 int));
00413 BU_EXPORT BU_EXTERN(int bu_cv_htonss,
00414 (genptr_t,
00415 size_t,
00416 signed short *,
00417 int));
00418 BU_EXPORT BU_EXTERN(int bu_cv_htonus,
00419 (genptr_t,
00420 size_t,
00421 unsigned short *,
00422 int));
00423 BU_EXPORT BU_EXTERN(int bu_cv_htonsl,
00424 (genptr_t,
00425 size_t,
00426 long *,
00427 int));
00428 BU_EXPORT BU_EXTERN(int bu_cv_htonul,
00429 (genptr_t,
00430 size_t,
00431 unsigned long *,
00432 int));
00433
00434
00435
00436
00437 #define CV_CHANNEL_MASK 0x00ff
00438 #define CV_HOST_MASK 0x0100
00439 #define CV_SIGNED_MASK 0x0200
00440 #define CV_TYPE_MASK 0x1c00
00441 #define CV_CONVERT_MASK 0x6000
00442
00443 #define CV_TYPE_SHIFT 10
00444 #define CV_CONVERT_SHIFT 13
00445
00446 #define CV_8 0x0400
00447 #define CV_16 0x0800
00448 #define CV_32 0x0c00
00449 #define CV_64 0x1000
00450 #define CV_D 0x1400
00451
00452 #define CV_CLIP 0x0000
00453 #define CV_NORMAL 0x2000
00454 #define CV_LIT 0x4000
00455
00456 #define IND_NOTSET 0
00457 #define IND_BIG 1
00458 #define IND_LITTLE 2
00459 #define IND_ILL 3
00460 #define IND_CRAY 4
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521 struct bu_list {
00522 long magic;
00523 struct bu_list *forw;
00524 struct bu_list *back;
00525 };
00526 #define BU_LIST_HEAD_MAGIC 0x01016580
00527 #define BU_LIST_NULL ((struct bu_list *)0)
00528
00529 typedef struct bu_list bu_list_t;
00530
00531 BU_EXPORT BU_EXTERN(struct bu_list *bu_list_new, ());
00532 BU_EXPORT BU_EXTERN(struct bu_list *bu_list_pop, (struct bu_list *hp));
00533
00534 #define BU_LIST_CLOSE( hp ) { \
00535 assert( (hp) != NULL ); \
00536 if( (hp) == NULL ) \
00537 return; \
00538 assert( BU_LIST_IS_EMPTY( (hp) ) ); \
00539 bu_list_free( (hp) ); \
00540 bu_free( (char *)(hp), "bu_list head" ); \
00541 }
00542
00543
00544
00545
00546
00547
00548
00549 #define BU_LIST_INSERT(old,new) { \
00550 (new)->back = (old)->back; \
00551 (old)->back = (new); \
00552 (new)->forw = (old); \
00553 (new)->back->forw = (new); }
00554
00555
00556
00557
00558
00559
00560 #define BU_LIST_APPEND(old,new) { \
00561 (new)->forw = (old)->forw; \
00562 (new)->back = (old); \
00563 (old)->forw = (new); \
00564 (new)->forw->back = (new); }
00565
00566
00567 #define BU_LIST_DEQUEUE(cur) { \
00568 (cur)->forw->back = (cur)->back; \
00569 (cur)->back->forw = (cur)->forw; \
00570 (cur)->forw = (cur)->back = BU_LIST_NULL; }
00571
00572
00573 #define BU_LIST_DQ(cur) {\
00574 (cur)->forw->back = (cur)->back; \
00575 (cur)->back->forw = (cur)->forw; }
00576
00577 #define BU_LIST_DQ_T(cur, type) (\
00578 (cur)->forw->back = (cur)->back, \
00579 (cur)->back->forw = (cur)->forw, \
00580 (type *)(cur) )
00581
00582
00583
00584
00585 #define BU_LIST_DEQUEUE_T( cur, type ) (\
00586 (cur)->forw->back = (cur)->back, \
00587 (cur)->back->forw = (cur)->forw, \
00588 (cur)->forw = (cur)->back = BU_LIST_NULL, \
00589 (type *)(cur) )
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599 #define BU_LIST_PUSH(hp,p) \
00600 BU_LIST_APPEND(hp, (struct bu_list *)(p))
00601
00602 #define BU_LIST_POP(structure,hp,p) \
00603 { \
00604 if (BU_LIST_NON_EMPTY(hp)) \
00605 { \
00606 (p) = ((struct structure *)((hp)->forw)); \
00607 BU_LIST_DEQUEUE((struct bu_list *)(p)); \
00608 } \
00609 else \
00610 (p) = (struct structure *) 0; \
00611 }
00612
00613 #define BU_LIST_POP_T(hp, type ) \
00614 (type *)bu_list_pop( hp )
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624 #define BU_LIST_INSERT_LIST(dest_hp,src_hp) \
00625 if( BU_LIST_NON_EMPTY(src_hp) ) { \
00626 register struct bu_list *_first = (src_hp)->forw; \
00627 register struct bu_list *_last = (src_hp)->back; \
00628 (dest_hp)->forw->back = _last; \
00629 _last->forw = (dest_hp)->forw; \
00630 (dest_hp)->forw = _first; \
00631 _first->back = (dest_hp); \
00632 (src_hp)->forw = (src_hp)->back = (src_hp); \
00633 }
00634
00635 #define BU_LIST_APPEND_LIST(dest_hp,src_hp) \
00636 if( BU_LIST_NON_EMPTY(src_hp) ) {\
00637 register struct bu_list *_first = (src_hp)->forw; \
00638 register struct bu_list *_last = (src_hp)->back; \
00639 _first->back = (dest_hp)->back; \
00640 (dest_hp)->back->forw = _first; \
00641 (dest_hp)->back = _last; \
00642 _last->forw = (dest_hp); \
00643 (src_hp)->forw = (src_hp)->back = (src_hp); \
00644 }
00645
00646
00647 #define BU_LIST_IS_EMPTY(hp) ((hp)->forw == (hp))
00648 #define BU_LIST_NON_EMPTY(hp) ((hp)->forw != (hp))
00649 #define BU_LIST_NON_EMPTY_P(p,structure,hp) \
00650 (((p)=(struct structure *)((hp)->forw)) != (struct structure *)(hp))
00651 #define BU_LIST_IS_CLEAR(hp) ((hp)->magic == 0 && \
00652 (hp)->forw == BU_LIST_NULL && \
00653 (hp)->back == BU_LIST_NULL)
00654
00655
00656 #define BU_LIST_UNINITIALIZED(hp) ((hp)->forw == BU_LIST_NULL)
00657 #define BU_LIST_IS_INITIALIZED(hp) ((hp)->forw != BU_LIST_NULL)
00658 #define BU_LIST_INIT(hp) { \
00659 (hp)->forw = (hp)->back = (hp); \
00660 (hp)->magic = BU_LIST_HEAD_MAGIC; }
00661 #define BU_LIST_MAGIC_SET(hp,val) {(hp)->magic = (val);}
00662 #define BU_LIST_MAGIC_OK(hp,val) ((hp)->magic == (val))
00663 #define BU_LIST_MAGIC_WRONG(hp,val) ((hp)->magic != (val))
00664
00665
00666
00667
00668 #define BU_LIST_LAST(structure,hp) \
00669 ((struct structure *)((hp)->back))
00670 #define BU_LIST_BACK(structure,hp) \
00671 ((struct structure *)((hp)->back))
00672 #define BU_LIST_PREV(structure,hp) \
00673 ((struct structure *)((hp)->back))
00674 #define BU_LIST_FIRST(structure,hp) \
00675 ((struct structure *)((hp)->forw))
00676 #define BU_LIST_FORW(structure,hp) \
00677 ((struct structure *)((hp)->forw))
00678 #define BU_LIST_NEXT(structure,hp) \
00679 ((struct structure *)((hp)->forw))
00680
00681
00682 #define BU_LIST_IS_HEAD(p,hp) \
00683 (((struct bu_list *)(p)) == (hp))
00684 #define BU_LIST_NOT_HEAD(p,hp) \
00685 (((struct bu_list *)(p)) != (hp))
00686 #define BU_CK_LIST_HEAD( _p ) BU_CKMAG( (_p), BU_LIST_HEAD_MAGIC, "bu_list")
00687
00688
00689 #define BU_LIST_PREV_IS_HEAD(p,hp)\
00690 (((struct bu_list *)(p))->back == (hp))
00691 #define BU_LIST_PREV_NOT_HEAD(p,hp)\
00692 (((struct bu_list *)(p))->back != (hp))
00693
00694
00695 #define BU_LIST_NEXT_IS_HEAD(p,hp) \
00696 (((struct bu_list *)(p))->forw == (hp))
00697 #define BU_LIST_NEXT_NOT_HEAD(p,hp) \
00698 (((struct bu_list *)(p))->forw != (hp))
00699
00700 #define BU_LIST_EACH( hp, p, type ) \
00701 for( (p)=(type *)BU_LIST_FIRST(bu_list,hp); \
00702 BU_LIST_NOT_HEAD(p,hp); \
00703 (p)=(type *)BU_LIST_PNEXT(bu_list,p) ) \
00704
00705 #define BU_LIST_REVEACH( hp, p, type ) \
00706 for( (p)=(type *)BU_LIST_LAST(bu_list,hp); \
00707 BU_LIST_NOT_HEAD(p,hp); \
00708 (p)=(type *)BU_LIST_PREV(bu_list,((struct bu_list *)(p))) ) \
00709
00710 #define BU_LIST_TAIL( hp, start, p, type ) \
00711 for( (p)=(type *)start ; \
00712 BU_LIST_NOT_HEAD(p,hp); \
00713 (p)=(type *)BU_LIST_PNEXT(bu_list,(p)) )
00714
00715
00716
00717
00718
00719
00720
00721 #define BU_LIST_FOR(p,structure,hp) \
00722 (p)=BU_LIST_FIRST(structure,hp); \
00723 BU_LIST_NOT_HEAD(p,hp); \
00724 (p)=BU_LIST_PNEXT(structure,p)
00725
00726 #define BU_LIST_FOR_BACKWARDS(p,structure,hp) \
00727 (p)=BU_LIST_LAST(structure,hp); \
00728 BU_LIST_NOT_HEAD(p,hp); \
00729 (p)=BU_LIST_PLAST(structure,p)
00730
00731
00732
00733
00734
00735 #define BU_LIST_FOR_CIRC(p,structure,hp) \
00736 (p)=BU_LIST_PNEXT_CIRC(structure,hp); \
00737 (p) != (hp); \
00738 (p)=BU_LIST_PNEXT_CIRC(structure,p)
00739
00740
00741
00742
00743
00744
00745
00746
00747 #define BU_LIST_FOR2(p1,p2,structure,hp1,hp2) \
00748 (p1)=BU_LIST_FIRST(structure,hp1), \
00749 (p2)=BU_LIST_FIRST(structure,hp2); \
00750 BU_LIST_NOT_HEAD((struct bu_list *)(p1),(hp1)) && \
00751 BU_LIST_NOT_HEAD((struct bu_list *)(p2),(hp2)); \
00752 (p1)=BU_LIST_NEXT(structure,(struct bu_list *)(p1)), \
00753 (p2)=BU_LIST_NEXT(structure,(struct bu_list *)(p2))
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763 #define BU_LIST_WHILE(p,structure,hp) \
00764 (((p)=(struct structure *)((hp)->forw)) != (struct structure *)(hp))
00765
00766
00767 #define BU_LIST_FIRST_MAGIC(hp) ((hp)->forw->magic)
00768 #define BU_LIST_LAST_MAGIC(hp) ((hp)->back->magic)
00769
00770
00771 #define BU_LIST_PNEXT(structure,p) \
00772 ((struct structure *)(((struct bu_list *)(p))->forw))
00773 #define BU_LIST_PLAST(structure,p) \
00774 ((struct structure *)(((struct bu_list *)(p))->back))
00775
00776
00777 #define BU_LIST_PNEXT_PNEXT(structure,p) \
00778 ((struct structure *)(((struct bu_list *)(p))->forw->forw))
00779 #define BU_LIST_PNEXT_PLAST(structure,p) \
00780 ((struct structure *)(((struct bu_list *)(p))->forw->back))
00781 #define BU_LIST_PLAST_PNEXT(structure,p) \
00782 ((struct structure *)(((struct bu_list *)(p))->back->forw))
00783 #define BU_LIST_PLAST_PLAST(structure,p) \
00784 ((struct structure *)(((struct bu_list *)(p))->back->back))
00785
00786
00787 #define BU_LIST_PNEXT_CIRC(structure,p) \
00788 ((BU_LIST_FIRST_MAGIC((struct bu_list *)(p)) == BU_LIST_HEAD_MAGIC) ? \
00789 BU_LIST_PNEXT_PNEXT(structure,(struct bu_list *)(p)) : \
00790 BU_LIST_PNEXT(structure,p) )
00791
00792
00793 #define BU_LIST_PPREV_CIRC(structure,p) \
00794 ((BU_LIST_LAST_MAGIC((struct bu_list *)(p)) == BU_LIST_HEAD_MAGIC) ? \
00795 BU_LIST_PLAST_PLAST(structure,(struct bu_list *)(p)) : \
00796 BU_LIST_PLAST(structure,p) )
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813 #define BU_LIST_MAIN_PTR(_type, _ptr2, _name2) \
00814 ((struct _type *)(((char *)(_ptr2)) - offsetof(struct _type, _name2.magic)))
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841 struct bu_bitv {
00842 struct bu_list l;
00843 unsigned int nbits;
00844 bitv_t bits[2];
00845 };
00846
00847 #define BU_BITV_MAGIC 0x62697476
00848 #define BU_CK_BITV(_vp) BU_CKMAG(_vp, BU_BITV_MAGIC, "bu_bitv")
00849
00850
00851
00852
00853
00854 #define BU_BITS2BYTES(_nb) (BU_BITS2WORDS(_nb)*sizeof(bitv_t))
00855 #define BU_BITS2WORDS(_nb) (((_nb)+BITV_MASK)>>BITV_SHIFT)
00856 #define BU_WORDS2BITS(_nw) ((_nw)*sizeof(bitv_t)*8)
00857
00858 #if 1
00859 #define BU_BITTEST(_bv,bit) \
00860 (((_bv)->bits[(bit)>>BITV_SHIFT] & (((bitv_t)1)<<((bit)&BITV_MASK)))!=0)
00861 #else
00862 static __inline__ int BU_BITTEST(volatile void * addr, int nr)
00863 {
00864 int oldbit;
00865
00866 __asm__ __volatile__(
00867 "btl %2,%1\n\tsbbl %0,%0"
00868 :"=r" (oldbit)
00869 :"m" (addr),"Ir" (nr));
00870 return oldbit;
00871 }
00872 #endif
00873
00874 #define BU_BITSET(_bv,bit) \
00875 ((_bv)->bits[(bit)>>BITV_SHIFT] |= (((bitv_t)1)<<((bit)&BITV_MASK)))
00876 #define BU_BITCLR(_bv,bit) \
00877 ((_bv)->bits[(bit)>>BITV_SHIFT] &= ~(((bitv_t)1)<<((bit)&BITV_MASK)))
00878 #define BU_BITV_ZEROALL(_bv) \
00879 { memset( (char *)((_bv)->bits), 0, BU_BITS2BYTES( (_bv)->nbits ) ); }
00880
00881
00882 #ifdef NO_BOMBING_MACROS
00883 # define BU_BITV_BITNUM_CHECK(_bv,_bit)
00884 #else
00885 # define BU_BITV_BITNUM_CHECK(_bv,_bit) \
00886 if( ((unsigned)(_bit)) >= (_bv)->nbits ) {\
00887 bu_log("BU_BITV_BITNUM_CHECK bit number (%u) out of range (0..%u)\n", \
00888 ((unsigned)(_bit)), (_bv)->nbits); \
00889 bu_bomb("process self-terminating\n");\
00890 }
00891 #endif
00892
00893 #ifdef NO_BOMBING_MACROS
00894 # define BU_BITV_NBITS_CHECK(_bv,_nbits)
00895 #else
00896 # define BU_BITV_NBITS_CHECK(_bv,_nbits) \
00897 if( ((unsigned)(_nbits)) > (_bv)->nbits ) {\
00898 bu_log("BU_BITV_NBITS_CHECK number of bits (%u) out of range (> %u)", \
00899 ((unsigned)(_nbits)), (_bv)->nbits ); \
00900 bu_bomb("process self-terminating"); \
00901 }
00902 #endif
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918 #define BU_BITV_LOOP_START(_bv) \
00919 { \
00920 register int _wd; \
00921 BU_CK_BITV(_bv); \
00922 for( _wd=BU_BITS2WORDS((_bv)->nbits)-1; _wd>=0; _wd-- ) { \
00923 register int _b; \
00924 register bitv_t _val; \
00925 if((_val = (_bv)->bits[_wd])==0) continue; \
00926 for(_b=0; _b < BITV_MASK+1; _b++, _val >>= 1 ) { \
00927 if( !(_val & 1) ) continue;
00928
00929
00930
00931
00932
00933 #define BU_BITV_LOOP_INDEX ((_wd << BITV_SHIFT) | _b)
00934
00935 #define BU_BITV_LOOP_END \
00936 } \
00937 } \
00938 }
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952 struct bu_hist {
00953 long magic;
00954 fastf_t hg_min;
00955 fastf_t hg_max;
00956 fastf_t hg_clumpsize;
00957 long hg_nsamples;
00958 long hg_nbins;
00959 long *hg_bins;
00960 };
00961 #define BU_HIST_MAGIC 0x48697374
00962 #define BU_CK_HIST(_p) BU_CKMAG(_p, BU_HIST_MAGIC, "struct bu_hist")
00963
00964 #define BU_HIST_TALLY( _hp, _val ) { \
00965 if( (_val) <= (_hp)->hg_min ) { \
00966 (_hp)->hg_bins[0]++; \
00967 } else if( (_val) >= (_hp)->hg_max ) { \
00968 (_hp)->hg_bins[(_hp)->hg_nbins]++; \
00969 } else { \
00970 (_hp)->hg_bins[(int)(((_val)-(_hp)->hg_min)/(_hp)->hg_clumpsize)]++; \
00971 } \
00972 (_hp)->hg_nsamples++; }
00973
00974 #define BU_HIST_TALLY_MULTIPLE( _hp, _val, _count ) { \
00975 register int __count = (_count); \
00976 if( (_val) <= (_hp)->hg_min ) { \
00977 (_hp)->hg_bins[0] += __count; \
00978 } else if( (_val) >= (_hp)->hg_max ) { \
00979 (_hp)->hg_bins[(_hp)->hg_nbins] += __count; \
00980 } else { \
00981 (_hp)->hg_bins[(int)(((_val)-(_hp)->hg_min)/(_hp)->hg_clumpsize)] += __count; \
00982 } \
00983 (_hp)->hg_nsamples += __count; }
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996 struct bu_ptbl {
00997 struct bu_list l;
00998 int end;
00999 int blen;
01000 long **buffer;
01001 };
01002 #define BU_PTBL_MAGIC 0x7074626c
01003 #define BU_CK_PTBL(_p) BU_CKMAG(_p, BU_PTBL_MAGIC, "bu_ptbl")
01004
01005 #define BU_PTBL_INIT 0
01006 #define BU_PTBL_INS 1
01007 #define BU_PTBL_LOC 2
01008 #define BU_PTBL_FREE 3
01009 #define BU_PTBL_RST 4
01010 #define BU_PTBL_CAT 5
01011 #define BU_PTBL_RM 6
01012 #define BU_PTBL_INS_UNIQUE 7
01013 #define BU_PTBL_ZERO 8
01014
01015
01016
01017 #define BU_PTBL_BASEADDR(ptbl) ((ptbl)->buffer)
01018 #define BU_PTBL_LASTADDR(ptbl) ((ptbl)->buffer + (ptbl)->end - 1)
01019 #define BU_PTBL_END(ptbl) ((ptbl)->end)
01020 #define BU_PTBL_LEN(p) ((p)->end)
01021 #define BU_PTBL_GET(ptbl,i) ((ptbl)->buffer[(i)])
01022 #define BU_PTBL_SET(ptbl,i,val) ((ptbl)->buffer[(i)] = (long*)(val))
01023 #define BU_PTBL_TEST(ptbl) ((ptbl)->l.magic == BU_PTBL_MAGIC)
01024 #define BU_PTBL_CLEAR_I(_ptbl, _i) ((_ptbl)->buffer[(_i)] = (long *)0)
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039 #define BU_PTBL_FOR(ip,cast,ptbl) \
01040 ip = cast BU_PTBL_LASTADDR(ptbl); ip >= cast BU_PTBL_BASEADDR(ptbl); ip--
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070 struct bu_mapped_file {
01071 struct bu_list l;
01072 char *name;
01073 genptr_t buf;
01074 long buflen;
01075 int is_mapped;
01076 char *appl;
01077 genptr_t apbuf;
01078 long apbuflen;
01079 long modtime;
01080 int uses;
01081 int dont_restat;
01082 };
01083 #define BU_MAPPED_FILE_MAGIC 0x4d617066
01084 #define BU_CK_MAPPED_FILE(_p) BU_CKMAG(_p, BU_MAPPED_FILE_MAGIC, "bu_mapped_file")
01085
01086
01087
01088
01089
01090 typedef int (*bu_hook_t)BU_ARGS((genptr_t, genptr_t));
01091
01092 struct bu_hook_list {
01093 struct bu_list l;
01094 bu_hook_t hookfunc;
01095 genptr_t clientdata;
01096 };
01097
01098 #define BUHOOK_NULL 0
01099 #define BUHOOK_LIST_MAGIC 0x90d5dead
01100 #define BUHOOK_LIST_NULL ((struct bu_hook_list *) 0)
01101
01102 BU_EXPORT extern struct bu_hook_list bu_log_hook_list;
01103 BU_EXPORT extern struct bu_hook_list bu_bomb_hook_list;
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119 struct bu_attribute_value_pair {
01120 const char *name;
01121 const char *value;
01122 };
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140 struct bu_attribute_value_set {
01141 long magic;
01142 int count;
01143 int max;
01144 genptr_t readonly_min;
01145 genptr_t readonly_max;
01146 struct bu_attribute_value_pair *avp;
01147 };
01148 #define BU_AVS_MAGIC 0x41765321
01149 #define BU_CK_AVS(_avp) BU_CKMAG(_avp, BU_AVS_MAGIC, "bu_attribute_value_set")
01150
01151 #define BU_AVS_FOR(_pp, _avp) \
01152 (_pp) = &(_avp)->avp[(_avp)->count-1]; (_pp) >= (_avp)->avp; (_pp)--
01153
01154
01155
01156
01157
01158
01159
01160 #define AVS_IS_FREEABLE(_avsp, _p) \
01161 ( (_avsp)->readonly_max == NULL || \
01162 ((genptr_t)(_p) < (genptr_t)(_avsp)->readonly_min || (genptr_t)(_p) > (genptr_t)(_avsp)->readonly_max) )
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172 struct bu_vls {
01173 long vls_magic;
01174 char *vls_str;
01175 int vls_offset;
01176 int vls_len;
01177 int vls_max;
01178 };
01179 #define BU_VLS_MAGIC 0x89333bbb
01180 #define BU_CK_VLS(_vp) BU_CKMAG(_vp, BU_VLS_MAGIC, "bu_vls")
01181 #define BU_VLS_IS_INITIALIZED(_vp) \
01182 ((_vp) && ((_vp)->vls_magic == BU_VLS_MAGIC))
01183
01184
01185
01186
01187 #define BU_SEM_SYSCALL 0
01188 #define BU_SEM_LISTS 1
01189 #define BU_SEM_BN_NOISE 2
01190 #define BU_SEM_MAPPEDFILE 3
01191 #define BU_SEM_LAST (BU_SEM_MAPPEDFILE+1)
01192
01193
01194
01195
01196
01197
01198
01199 #define BU_SETJUMP setjmp((bu_setjmp_valid=1,bu_jmpbuf))
01200 #define BU_UNSETJUMP (bu_setjmp_valid=0)
01201
01202 BU_EXPORT extern int bu_setjmp_valid;
01203 BU_EXPORT extern jmp_buf bu_jmpbuf;
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213 struct bu_mro {
01214 long magic;
01215 struct bu_vls string_rep;
01216 char long_rep_is_valid;
01217 long long_rep;
01218 char double_rep_is_valid;
01219 double double_rep;
01220 };
01221
01222 #define BU_MRO_MAGIC 0x4D524F4F
01223 #define BU_CK_MRO(_vp) BU_CKMAG(_vp, BU_MRO_MAGIC, "bu_mro")
01224
01225 #define BU_MRO_INVALIDATE(_p ) {\
01226 _p->long_rep_is_valid = '\0';\
01227 _p->double_rep_is_valid = '\0';\
01228 }
01229
01230 #define BU_MRO_GETDOUBLE( _p ) ( _p->double_rep_is_valid ? _p->double_rep : \
01231 (_p->double_rep = strtod( bu_vls_addr( &_p->string_rep ), NULL ), \
01232 ( _p->double_rep_is_valid='y', _p->double_rep ) ) )
01233
01234 #define BU_MRO_GETLONG( _p ) ( _p->long_rep_is_valid ? _p->long_rep : \
01235 (_p->long_rep = strtol( bu_vls_addr( &_p->string_rep ), NULL, 10 ), \
01236 ( _p->long_rep_is_valid='y', _p->long_rep ) ) )
01237
01238 #define BU_MRO_GETSTRING( _p ) bu_vls_addr( &_p->string_rep )
01239
01240 #define BU_MRO_STRLEN( _p ) bu_vls_strlen( &_p->string_rep )
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254 BU_EXPORT extern int bu_debug;
01255
01256 #define BU_DEBUG_OFF 0
01257
01258 #define BU_DEBUG_COREDUMP 0x00000001
01259
01260 #define BU_DEBUG_MEM_CHECK 0x00000002
01261 #define BU_DEBUG_MEM_LOG 0x00000004
01262 #define BU_DEBUG_DB 0x00000008
01263
01264 #define BU_DEBUG_PARALLEL 0x00000010
01265 #define BU_DEBUG_MEM_QCHECK 0x00000020
01266 #define BU_DEBUG_MATH 0x00000100
01267 #define BU_DEBUG_PTBL 0x00000200
01268 #define BU_DEBUG_AVS 0x00000400
01269 #define BU_DEBUG_MAPPED_FILE 0x00000800
01270
01271 #define BU_DEBUG_TABDATA 0x00010000
01272
01273
01274 #define BU_DEBUG_FORMAT \
01275 "\020\
01276 \025TABDATA\
01277 \015?\
01278 \014MAPPED_FILE\013AVS\012PTBL\011MATH\010?\7?\6MEM_QCHECK\5PARALLEL\
01279 \4?\3MEM_LOG\2MEM_CHECK\1COREDUMP"
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306 #if __STDC__ && !defined(ipsc860)
01307 # define bu_offsetofarray(_t, _m) offsetof(_t, _m[0])
01308 #else
01309 # define bu_offsetofarray(_t, _m) (int)( (((_t *)0)->_m))
01310 #endif
01311 #if !defined(offsetof)
01312 # define bu_offsetof(_t, _m) (int)(&(((_t *)0)->_m))
01313 #else
01314 # define bu_offsetof(_t, _m) offsetof(_t, _m)
01315 #endif
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327 #if defined(CRAY)
01328 # define bu_byteoffset(_i) (((int)&(_i)))
01329 #else
01330 # if defined(IRIX) && IRIX > 5 && _MIPS_SIM != _ABIN32 && _MIPS_SIM != _MIPS_SIM_ABI32
01331 # define bu_byteoffset(_i) ((size_t)__INTADDR__(&(_i)))
01332 # else
01333 # if defined(sgi) || defined(__convexc__) || defined(ultrix) || defined(_HPUX_SOURCE)
01334
01335 # define bu_byteoffset(_i) ((int)((char *)&(_i)))
01336 # else
01337 # if defined(__ia64__) || defined(__x86_64__) || defined(__sparc64__)
01338 # if defined (__INTEL_COMPILER)
01339 # define bu_byteoffset(_i) ((long)((char *)&(_i)))
01340 # else
01341 # define bu_byteoffset(_i) ((long)(((void *)&(_i))-((void *)0)))
01342 # endif
01343 # else
01344
01345 # define bu_byteoffset(_i) ((int)(((char *)&(_i))-((char *)0)))
01346 # endif
01347 # endif
01348 # endif
01349 #endif
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412 struct bu_structparse {
01413 char sp_fmt[4];
01414 long sp_count;
01415 char *sp_name;
01416 long sp_offset;
01417 void (*sp_hook)();
01418 char *sp_desc;
01419 void *sp_default;
01420 };
01421 #define BU_STRUCTPARSE_FUNC_NULL ((void (*)())0)
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436 struct bu_external {
01437 long ext_magic;
01438 long ext_nbytes;
01439 genptr_t ext_buf;
01440 };
01441 #define BU_EXTERNAL_MAGIC 0x768dbbd0
01442 #define BU_INIT_EXTERNAL(_p) {(_p)->ext_magic = BU_EXTERNAL_MAGIC; \
01443 (_p)->ext_buf = (genptr_t)NULL; (_p)->ext_nbytes = 0;}
01444 #define BU_CK_EXTERNAL(_p) BU_CKMAG(_p, BU_EXTERNAL_MAGIC, "bu_external")
01445
01446
01447
01448
01449 #define HUE 0
01450 #define SAT 1
01451 #define VAL 2
01452 #define ACHROMATIC -1.0
01453
01454 struct bu_color
01455 {
01456 long buc_magic;
01457 fastf_t buc_rgb[3];
01458 };
01459 #define BU_COLOR_MAGIC 0x6275636c
01460 #define BU_COLOR_NULL ((struct bu_color *) 0)
01461 #define BU_CK_COLOR(_bp) BU_CKMAG(_bp, BU_COLOR_MAGIC, "bu_color")
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488 struct bu_rb_list
01489 {
01490 struct bu_list l;
01491 union
01492 {
01493 struct bu_rb_node *rbl_n;
01494 struct bu_rb_package *rbl_p;
01495 } rbl_u;
01496 };
01497 #define rbl_magic l.magic
01498 #define rbl_node rbl_u.rbl_n
01499 #define rbl_package rbl_u.rbl_p
01500 #define BU_RB_LIST_NULL ((struct bu_rb_list *) 0)
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519 typedef struct
01520 {
01521
01522 long rbt_magic;
01523 int rbt_nm_nodes;
01524
01525 void (*rbt_print)();
01526 int rbt_debug;
01527 char *rbt_description;
01528
01529 int rbt_nm_orders;
01530 int (**rbt_order)();
01531 struct bu_rb_node **rbt_root;
01532 char *rbt_unique;
01533 struct bu_rb_node *rbt_current;
01534 struct bu_rb_list rbt_nodes;
01535 struct bu_rb_list rbt_packages;
01536 struct bu_rb_node *rbt_empty_node;
01537 } bu_rb_tree;
01538 #define BU_RB_TREE_NULL ((bu_rb_tree *) 0)
01539 #define BU_RB_TREE_MAGIC 0x72627472
01540
01541
01542
01543
01544 #define BU_RB_DEBUG_INSERT 0x00000001
01545 #define BU_RB_DEBUG_UNIQ 0x00000002
01546 #define BU_RB_DEBUG_ROTATE 0x00000004
01547 #define BU_RB_DEBUG_OS 0x00000008
01548 #define BU_RB_DEBUG_DELETE 0x00000010
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563 struct bu_rb_package
01564 {
01565 long rbp_magic;
01566 struct bu_rb_node **rbp_node;
01567 struct bu_rb_list *rbp_list_pos;
01568 void *rbp_data;
01569 };
01570 #define BU_RB_PKG_NULL ((struct bu_rb_package *) 0)
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582 struct bu_rb_node
01583 {
01584 long rbn_magic;
01585 bu_rb_tree *rbn_tree;
01586 struct bu_rb_node **rbn_parent;
01587 struct bu_rb_node **rbn_left;
01588 struct bu_rb_node **rbn_right;
01589 char *rbn_color;
01590 int *rbn_size;
01591 struct bu_rb_package **rbn_package;
01592 int rbn_pkg_refs;
01593 struct bu_rb_list *rbn_list_pos;
01594 };
01595 #define BU_RB_NODE_NULL ((struct bu_rb_node *) 0)
01596
01597
01598
01599
01600 #define SENSE_MIN 0
01601 #define SENSE_MAX 1
01602 #define bu_rb_min(t,o) bu_rb_extreme((t), (o), SENSE_MIN)
01603 #define bu_rb_max(t,o) bu_rb_extreme((t), (o), SENSE_MAX)
01604 #define bu_rb_pred(t,o) bu_rb_neighbor((t), (o), SENSE_MIN)
01605 #define bu_rb_succ(t,o) bu_rb_neighbor((t), (o), SENSE_MAX)
01606
01607
01608
01609
01610 #define PREORDER 0
01611 #define INORDER 1
01612 #define POSTORDER 2
01613
01614
01615
01616
01617
01618
01619 struct bu_observer {
01620 struct bu_list l;
01621 struct bu_vls observer;
01622 struct bu_vls cmd;
01623 };
01624 #define BU_OBSERVER_NULL ((struct bu_observer *)0)
01625
01626
01627
01628
01629 struct bu_cmdtab {
01630 char *ct_name;
01631 int (*ct_func)();
01632 };
01633
01634
01635
01636 #define bu_made_it() bu_log("Made it to %s:%d\n", \
01637 __FILE__, __LINE__)
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648 BU_EXPORT BU_EXTERN(void bu_avs_init,
01649 (struct bu_attribute_value_set *avp,
01650 int len,
01651 const char *str));
01652 BU_EXPORT BU_EXTERN(void bu_avs_init_empty,
01653 (struct bu_attribute_value_set *avp));
01654 BU_EXPORT BU_EXTERN(struct bu_attribute_value_set *bu_avs_new,
01655 (int len,
01656 const char *str));
01657 BU_EXPORT BU_EXTERN(int bu_avs_add,
01658 (struct bu_attribute_value_set *avp,
01659 const char *attribute,
01660 const char *value));
01661 BU_EXPORT BU_EXTERN(int bu_avs_add_vls,
01662 (struct bu_attribute_value_set *avp,
01663 const char *attribute,
01664 const struct bu_vls *value_vls));
01665 BU_EXPORT BU_EXTERN(void bu_avs_merge,
01666 (struct bu_attribute_value_set *dest,
01667 const struct bu_attribute_value_set *src));
01668 BU_EXPORT BU_EXTERN(const char *bu_avs_get,
01669 (const struct bu_attribute_value_set *avp,
01670 const char *attribute));
01671 BU_EXPORT BU_EXTERN(int bu_avs_remove,
01672 (struct bu_attribute_value_set *avp,
01673 const char *attribute));
01674 BU_EXPORT BU_EXTERN(void bu_avs_free,
01675 (struct bu_attribute_value_set *avp));
01676 BU_EXPORT BU_EXTERN(void bu_avs_print,
01677 (const struct bu_attribute_value_set *avp,
01678 const char *title));
01679 BU_EXPORT BU_EXTERN(void bu_avs_add_nonunique,
01680 (struct bu_attribute_value_set *avsp,
01681 char *attribute,
01682 char *value));
01683
01684
01685
01686
01687
01688 BU_EXPORT BU_EXTERN(void bu_badmagic,
01689 (const long *ptr,
01690 unsigned long magic,
01691 const char *str,
01692 const char *file,
01693 int line));
01694
01695
01696
01697
01698
01699 BU_EXPORT BU_EXTERN(struct bu_bitv *bu_bitv_new,
01700 (unsigned int nbits));
01701 BU_EXPORT BU_EXTERN(void bu_bitv_clear,
01702 (struct bu_bitv *bv));
01703 BU_EXPORT BU_EXTERN(void bu_bitv_or,
01704 (struct bu_bitv *ov,
01705 const struct bu_bitv *iv));
01706 BU_EXPORT BU_EXTERN(void bu_bitv_and,
01707 (struct bu_bitv *ov,
01708 const struct bu_bitv *iv));
01709 BU_EXPORT BU_EXTERN(void bu_bitv_vls,
01710 (struct bu_vls *v,
01711 const struct bu_bitv *bv));
01712 BU_EXPORT BU_EXTERN(void bu_pr_bitv,
01713 (const char *str,
01714 const struct bu_bitv *bv));
01715 BU_EXPORT BU_EXTERN(void bu_bitv_to_hex,
01716 (struct bu_vls *v,
01717 const struct bu_bitv *bv));
01718 BU_EXPORT BU_EXTERN(struct bu_bitv *bu_hex_to_bitv,
01719 (const char *str));
01720 BU_EXPORT BU_EXTERN(struct bu_bitv *bu_bitv_dup,
01721 (const struct bu_bitv *bv));
01722 BU_EXPORT BU_EXTERN(void bu_bitv_free,
01723 (struct bu_bitv *bv));
01724
01725
01726
01727
01728
01729
01730 BU_EXPORT BU_EXTERN(void bu_bomb,
01731 (const char *str));
01732
01733
01734 BU_EXPORT BU_EXTERN(char *bu_fgets,
01735 ( char *s, int size, FILE *stream));
01736
01737
01738
01739
01740
01741
01742 BU_EXPORT BU_EXTERN(void bu_rgb_to_hsv,
01743 (unsigned char *rgb,
01744 fastf_t *hsv));
01745 BU_EXPORT BU_EXTERN(int bu_hsv_to_rgb,
01746 (fastf_t *hsv,
01747 unsigned char *rgb));
01748 BU_EXPORT BU_EXTERN(int bu_str_to_rgb,
01749 (char *str,
01750 unsigned char *rgb));
01751 BU_EXPORT BU_EXTERN(void bu_color_of_rgb_chars,
01752 (struct bu_color *cp,
01753 unsigned char *rgb));
01754 BU_EXPORT BU_EXTERN(int bu_color_to_rgb_chars,
01755 (struct bu_color *cp,
01756 unsigned char *rgb));
01757 BU_EXPORT BU_EXTERN(int bu_color_of_rgb_floats,
01758 (struct bu_color *cp,
01759 fastf_t *rgb));
01760 BU_EXPORT BU_EXTERN(int bu_color_to_rgb_floats,
01761 (struct bu_color *cp,
01762 fastf_t *rgb));
01763 BU_EXPORT BU_EXTERN(int bu_color_of_hsv_floats,
01764 (struct bu_color *cp,
01765 fastf_t *hsv));
01766 BU_EXPORT BU_EXTERN(int bu_color_to_hsv_floats,
01767 (struct bu_color *cp,
01768 fastf_t *hsv));
01769
01770
01771
01772
01773
01774 BU_EXPORT BU_EXTERN(struct bu_file *bu_fopen,
01775 (char *fname, char *type));
01776 BU_EXPORT BU_EXTERN(int bu_fclose,
01777 (struct bu_file *bfp));
01778 BU_EXPORT BU_EXTERN(int bu_fgetc,
01779 (struct bu_file *bfp));
01780 BU_EXPORT BU_EXTERN(void bu_printfile,
01781 (struct bu_file *bfp));
01782
01783
01784 BU_EXPORT BU_EXTERN(int bu_file_exists, (const char *path));
01785
01786
01787 BU_EXPORT BU_EXTERN(const char *bu_getprogname, (void));
01788 BU_EXPORT BU_EXTERN(void bu_setprogname, (const char *path));
01789 BU_EXPORT BU_EXTERN(char *bu_brlcad_path,
01790 (const char *rhs, int fail_quietly));
01791 BU_EXPORT BU_EXTERN(char *bu_brlcad_root,
01792 (const char *rhs, int fail_quietly));
01793 BU_EXPORT BU_EXTERN(char *bu_brlcad_data,
01794 (const char *rhs, int fail_quietly));
01795
01796
01797 BU_EXPORT BU_EXTERN(FILE *bu_fopen_uniq,
01798 (const char *outfmt,
01799 const char *namefmt,
01800 int n));
01801
01802
01803 BU_EXPORT BU_EXTERN(struct bu_file *bu_fopen,
01804 (char *fname, char *type));
01805 BU_EXPORT BU_EXTERN(int bu_fclose,
01806 (struct bu_file *bfp));
01807 BU_EXPORT BU_EXTERN(int bu_fgetc,
01808 (struct bu_file *bfp));
01809 BU_EXPORT BU_EXTERN(void bu_printfile,
01810 (struct bu_file *bfp));
01811
01812
01813
01814
01815
01816
01817 BU_EXPORT extern int bu_opterr;
01818 BU_EXPORT extern int bu_optind;
01819 BU_EXPORT extern int bu_optopt;
01820 BU_EXPORT extern char * bu_optarg;
01821 BU_EXPORT BU_EXTERN(int bu_getopt,
01822 (int nargc, char * const nargv[],
01823 const char *ostr));
01824
01825
01826
01827
01828
01829
01830 BU_EXPORT BU_EXTERN(void bu_hist_free,
01831 (struct bu_hist *histp));
01832 BU_EXPORT BU_EXTERN(void bu_hist_init,
01833 (struct bu_hist *histp,
01834 fastf_t min,
01835 fastf_t max,
01836 unsigned int nbins));
01837 BU_EXPORT BU_EXTERN(void bu_hist_range,
01838 (struct bu_hist *hp,
01839 fastf_t low,
01840 fastf_t high));
01841 BU_EXPORT BU_EXTERN(void bu_hist_pr,
01842 (const struct bu_hist *histp,
01843 const char *title));
01844
01845
01846
01847
01848
01849
01850 BU_EXPORT BU_EXTERN(void htond,
01851 (unsigned char *out,
01852 const unsigned char *in,
01853 int count));
01854 BU_EXPORT BU_EXTERN(void ntohd,
01855 (unsigned char *out,
01856 const unsigned char *in,
01857 int count));
01858
01859
01860 BU_EXPORT BU_EXTERN(void htonf,
01861 (unsigned char *out,
01862 const unsigned char *in,
01863 int count));
01864 BU_EXPORT BU_EXTERN(void ntohf,
01865 (unsigned char *out,
01866 const unsigned char *in,
01867 int count));
01868
01869
01870
01871
01872
01873
01874 BU_EXPORT BU_EXTERN(int bu_is_parallel,
01875 ());
01876 BU_EXPORT BU_EXTERN(void bu_kill_parallel,
01877 ());
01878
01879
01880
01881
01882
01883
01884 BU_EXPORT BU_EXTERN(void bu_setlinebuf,
01885 (FILE *fp));
01886
01887
01888
01889
01890
01891
01892 BU_EXPORT BU_EXTERN(int bu_list_len,
01893 (const struct bu_list *hd));
01894 BU_EXPORT BU_EXTERN(void bu_list_reverse,
01895 (struct bu_list *hd));
01896 BU_EXPORT BU_EXTERN(void bu_list_free,
01897 (struct bu_list *hd));
01898 BU_EXPORT BU_EXTERN(void bu_list_parallel_append,
01899 (struct bu_list *headp,
01900 struct bu_list *itemp));
01901 BU_EXPORT BU_EXTERN(struct bu_list *bu_list_parallel_dequeue,
01902 (struct bu_list *headp));
01903 BU_EXPORT BU_EXTERN(void bu_ck_list,
01904 (const struct bu_list *hd,
01905 const char *str));
01906 BU_EXPORT BU_EXTERN(void bu_ck_list_magic,
01907 (const struct bu_list *hd,
01908 const char *str,
01909 const long magic));
01910
01911
01912
01913
01914
01915 BU_EXPORT BU_EXTERN(void bu_hook_list_init,
01916 (struct bu_hook_list *hlp));
01917 BU_EXPORT BU_EXTERN(void bu_add_hook,
01918 (struct bu_hook_list *hlp,
01919 bu_hook_t func,
01920 genptr_t clientdata));
01921 BU_EXPORT BU_EXTERN(void bu_delete_hook,
01922 (struct bu_hook_list *hlp,
01923 bu_hook_t func,
01924 genptr_t clientdata));
01925 BU_EXPORT BU_EXTERN(void bu_call_hook,
01926 (struct bu_hook_list *hlp,
01927 genptr_t buf));
01928
01929
01930
01931
01932
01933 BU_EXPORT BU_EXTERN(void bu_log_indent_delta,
01934 (int delta));
01935 BU_EXPORT BU_EXTERN(void bu_log_indent_vls,
01936 (struct bu_vls *v));
01937 BU_EXPORT BU_EXTERN(void bu_log_add_hook,
01938 (bu_hook_t func,
01939 genptr_t clientdata));
01940 BU_EXPORT BU_EXTERN(void bu_log_delete_hook,
01941 (bu_hook_t func,
01942 genptr_t clientdata));
01943 BU_EXPORT BU_EXTERN(void bu_putchar,
01944 (int c));
01945 #if defined(HAVE_STDARG_H)
01946 BU_EXPORT BU_EXTERN(void bu_log,
01947 (char *, ... ));
01948 BU_EXPORT BU_EXTERN(void bu_flog,
01949 (FILE *, char *, ... ));
01950 #else
01951 BU_EXPORT BU_EXTERN(void bu_log,
01952 ());
01953 BU_EXPORT BU_EXTERN(void bu_flog,
01954 ());
01955 #endif
01956
01957
01958
01959
01960
01961
01962 BU_EXPORT BU_EXTERN(const char *bu_identify_magic,
01963 (long magic));
01964
01965
01966
01967
01968
01969
01970 BU_EXPORT extern long bu_n_malloc;
01971 BU_EXPORT extern long bu_n_free;
01972 BU_EXPORT extern long bu_n_realloc;
01973 BU_EXPORT BU_EXTERN(genptr_t bu_malloc,
01974 (unsigned int cnt,
01975 const char *str));
01976 BU_EXPORT BU_EXTERN(void bu_free,
01977 (genptr_t ptr,
01978 const char *str));
01979 BU_EXPORT BU_EXTERN(genptr_t bu_realloc,
01980 (genptr_t ptr,
01981 unsigned int cnt,
01982 const char *str));
01983 BU_EXPORT BU_EXTERN(genptr_t bu_calloc,
01984 (unsigned int nelem,
01985 unsigned int elsize,
01986 const char *str));
01987 BU_EXPORT BU_EXTERN(void bu_prmem,
01988 (const char *str));
01989 BU_EXPORT BU_EXTERN(char *bu_strdupm,
01990 (const char *cp, const char *label));
01991
01992 #define bu_strdup(s) bu_strdupm(s, "bu_srtdup " BU_FLSTR)
01993 #if 0
01994 BU_EXPORT BU_EXTERN(char *bu_strdup,
01995 (const char *cp));
01996 #endif
01997 BU_EXPORT BU_EXTERN(char *bu_dirname,
01998 (const char *cp));
01999 BU_EXPORT BU_EXTERN(int bu_malloc_len_roundup,
02000 (int nbytes));
02001 BU_EXPORT BU_EXTERN(void bu_ck_malloc_ptr,
02002 (genptr_t ptr, const char *str));
02003 BU_EXPORT BU_EXTERN(int bu_mem_barriercheck,
02004 ());
02005
02006
02007
02008
02009
02010
02011 BU_EXPORT BU_EXTERN(struct bu_mapped_file *bu_open_mapped_file,
02012 (const char *name,
02013 const char *appl));
02014 BU_EXPORT BU_EXTERN(void bu_close_mapped_file,
02015 (struct bu_mapped_file *mp));
02016 BU_EXPORT BU_EXTERN(void bu_pr_mapped_file,
02017 (const char *title,
02018 const struct bu_mapped_file *mp));
02019 BU_EXPORT BU_EXTERN(void bu_free_mapped_files,
02020 (int verbose));
02021 BU_EXPORT BU_EXTERN(struct bu_mapped_file *bu_open_mapped_file_with_path,
02022 (char * const *path,
02023 const char *name,
02024 const char *appl));
02025
02026
02027
02028
02029
02030
02031
02032 BU_EXPORT BU_EXTERN(void bu_nice_set,
02033 (int newnice));
02034 BU_EXPORT BU_EXTERN(int bu_cpulimit_get,
02035 ());
02036 BU_EXPORT BU_EXTERN(void bu_cpulimit_set,
02037 (int sec));
02038 BU_EXPORT BU_EXTERN(int bu_avail_cpus,
02039 ());
02040 BU_EXPORT BU_EXTERN(fastf_t bu_get_load_average,
02041 ());
02042 BU_EXPORT BU_EXTERN(int bu_get_public_cpus,
02043 ());
02044 BU_EXPORT BU_EXTERN(int bu_set_realtime,
02045 ());
02046 BU_EXPORT BU_EXTERN(void bu_parallel,
02047 (void (*func)BU_ARGS((int ncpu, genptr_t arg)),
02048 int ncpu,
02049 genptr_t arg));
02050
02051
02052
02053
02054
02055
02056 BU_EXPORT BU_EXTERN(int bu_struct_export,
02057 (struct bu_external *ext,
02058 const genptr_t base,
02059 const struct bu_structparse *imp));
02060 BU_EXPORT BU_EXTERN(int bu_struct_import,
02061 (genptr_t base,
02062 const struct bu_structparse *imp,
02063 const struct bu_external *ext));
02064 BU_EXPORT BU_EXTERN(int bu_struct_put,
02065 (FILE *fp,
02066 const struct bu_external *ext));
02067 BU_EXPORT BU_EXTERN(int bu_struct_get,
02068 (struct bu_external *ext,
02069 FILE *fp));
02070 BU_EXPORT BU_EXTERN(void bu_struct_wrap_buf,
02071 (struct bu_external *ext,
02072 genptr_t buf));
02073 BU_EXPORT BU_EXTERN(int bu_struct_parse,
02074 (const struct bu_vls *in_vls,
02075 const struct bu_structparse *desc,
02076 const char *base));
02077 BU_EXPORT BU_EXTERN(void bu_struct_print,
02078 (const char *title,
02079 const struct bu_structparse *parsetab,
02080 const char *base));
02081 BU_EXPORT BU_EXTERN(void bu_vls_struct_print,
02082 (struct bu_vls *vls,
02083 const struct bu_structparse *sdp,
02084 const char *base));
02085 BU_EXPORT BU_EXTERN(void bu_vls_struct_print2,
02086 (struct bu_vls *vls,
02087 const char *title,
02088 const struct bu_structparse *sdp,
02089 const char *base));
02090 BU_EXPORT BU_EXTERN(void bu_vls_struct_item,
02091 (struct bu_vls *vp,
02092 const struct bu_structparse *sdp,
02093 const char *base,
02094 int sep_char));
02095 BU_EXPORT BU_EXTERN(int bu_vls_struct_item_named,
02096 (struct bu_vls *vp,
02097 const struct bu_structparse *sdp,
02098 const char *name,
02099 const char *base,
02100 int sep_char));
02101 BU_EXPORT BU_EXTERN(void bu_parse_mm,
02102 (const struct bu_structparse *sdp,
02103 const char *name,
02104 char *base,
02105 const char *value));
02106 BU_EXPORT BU_EXTERN(int bu_key_eq_to_key_val,
02107 (char *in,
02108 char **next,
02109 struct bu_vls *vls));
02110 BU_EXPORT BU_EXTERN(int bu_shader_to_tcl_list,
02111 (char *in,
02112 struct bu_vls *vls));
02113 BU_EXPORT BU_EXTERN(int bu_key_val_to_key_eq,
02114 (char *in));
02115 BU_EXPORT BU_EXTERN(int bu_shader_to_key_eq,
02116 (char *in, struct bu_vls *vls));
02117 BU_EXPORT BU_EXTERN(int bu_fwrite_external,
02118 (FILE *fp,
02119 const struct bu_external *ep));
02120 BU_EXPORT BU_EXTERN(void bu_hexdump_external,
02121 (FILE *fp, const struct bu_external *ep,
02122 const char *str));
02123 BU_EXPORT BU_EXTERN(void bu_free_external,
02124 (struct bu_external *ep));
02125 BU_EXPORT BU_EXTERN(void bu_copy_external,
02126 (struct bu_external *op,
02127 const struct bu_external *ip));
02128 BU_EXPORT BU_EXTERN(char *bu_next_token,
02129 (char *str));
02130
02131
02132
02133
02134
02135
02136 BU_EXPORT BU_EXTERN(void bu_vls_printb,
02137 (struct bu_vls *vls,
02138 const char *s, unsigned long v,
02139 const char *bits));
02140 BU_EXPORT BU_EXTERN(void bu_printb,
02141 (const char *s,
02142 unsigned long v,
02143 const char *bits));
02144
02145
02146 BU_EXPORT BU_EXTERN(void bu_ptbl_init,
02147 (struct bu_ptbl *b,
02148 int len,
02149 const char *str));
02150 BU_EXPORT BU_EXTERN(void bu_ptbl_reset,
02151 (struct bu_ptbl *b));
02152 BU_EXPORT BU_EXTERN(int bu_ptbl_ins,
02153 (struct bu_ptbl *b,
02154 long *p));
02155 BU_EXPORT BU_EXTERN(int bu_ptbl_locate,
02156 (const struct bu_ptbl *b,
02157 const long *p));
02158 BU_EXPORT BU_EXTERN(void bu_ptbl_zero,
02159 (struct bu_ptbl *b,
02160 const long *p));
02161 BU_EXPORT BU_EXTERN(int bu_ptbl_ins_unique,
02162 (struct bu_ptbl *b, long *p));
02163 BU_EXPORT BU_EXTERN(int bu_ptbl_rm,
02164 (struct bu_ptbl *b,
02165 const long *p));
02166 BU_EXPORT BU_EXTERN(void bu_ptbl_cat,
02167 (struct bu_ptbl *dest,
02168 const struct bu_ptbl *src));
02169 BU_EXPORT BU_EXTERN(void bu_ptbl_cat_uniq,
02170 (struct bu_ptbl *dest,
02171 const struct bu_ptbl *src));
02172 BU_EXPORT BU_EXTERN(void bu_ptbl_free,
02173 (struct bu_ptbl *b));
02174 BU_EXPORT BU_EXTERN(int bu_ptbl,
02175 (struct bu_ptbl *b,
02176 int func, long *p));
02177 BU_EXPORT BU_EXTERN(void bu_pr_ptbl,
02178 (const char *title,
02179 const struct bu_ptbl *tbl,
02180 int verbose));
02181 BU_EXPORT BU_EXTERN(void bu_ptbl_trunc,
02182 (struct bu_ptbl *tbl,
02183 int end));
02184
02185
02186
02187
02188
02189
02190 BU_EXPORT BU_EXTERN(bu_rb_tree *bu_rb_create,
02191 (char *description,
02192 int nm_orders,
02193 int (**order_funcs)()));
02194 BU_EXPORT BU_EXTERN(bu_rb_tree *bu_rb_create1,
02195 (char *description,
02196 int (*order_func)()));
02197
02198 BU_EXPORT BU_EXTERN(void bu_rb_delete,
02199 (bu_rb_tree *tree,
02200 int order));
02201 #define bu_rb_delete1(t) bu_rb_delete((t), 0)
02202
02203
02204 BU_EXPORT BU_EXTERN(void bu_rb_diagnose_tree,
02205 (bu_rb_tree *tree,
02206 int order,
02207 int trav_type));
02208 BU_EXPORT BU_EXTERN(void bu_rb_summarize_tree,
02209 (bu_rb_tree *tree));
02210
02211 BU_EXPORT BU_EXTERN(void *bu_rb_curr,
02212 (bu_rb_tree *tree,
02213 int order));
02214 #define bu_rb_curr1(t) bu_rb_curr((t), 0)
02215 BU_EXPORT BU_EXTERN(void *bu_rb_extreme,
02216 (bu_rb_tree *tree,
02217 int order,
02218 int sense));
02219 BU_EXPORT BU_EXTERN(void *bu_rb_neighbor,
02220 (bu_rb_tree *tree,
02221 int order,
02222 int sense));
02223
02224 BU_EXPORT BU_EXTERN(void bu_rb_free,
02225 (bu_rb_tree *tree,
02226 void (*free_data)()));
02227 #define BU_RB_RETAIN_DATA ((void (*)()) 0)
02228 #define bu_rb_free1(t,f) \
02229 { \
02230 BU_CKMAG((t), BU_RB_TREE_MAGIC, "red-black tree"); \
02231 bu_free((char *) ((t) -> rbt_order), \
02232 "red-black order function"); \
02233 bu_rb_free(t,f); \
02234 }
02235
02236 BU_EXPORT BU_EXTERN(int bu_rb_insert,
02237 (bu_rb_tree *tree,
02238 void *data));
02239 BU_EXPORT BU_EXTERN(int bu_rb_is_uniq,
02240 (bu_rb_tree *tree,
02241 int order));
02242 #define bu_rb_is_uniq1(t) bu_rb_is_uniq((t), 0)
02243 BU_EXPORT BU_EXTERN(void bu_rb_set_uniqv,
02244 (bu_rb_tree *tree,
02245 bitv_t vec));
02246 BU_EXPORT BU_EXTERN(void bu_rb_uniq_all_off,
02247 (bu_rb_tree *tree));
02248 BU_EXPORT BU_EXTERN(void bu_rb_uniq_all_on,
02249 (bu_rb_tree *tree));
02250 BU_EXPORT BU_EXTERN(int bu_rb_uniq_off,
02251 (bu_rb_tree *tree,
02252 int order));
02253 #define bu_rb_uniq_off1(t) bu_rb_uniq_off((t), 0)
02254 BU_EXPORT BU_EXTERN(int bu_rb_uniq_on,
02255 (bu_rb_tree *tree,
02256 int order));
02257 #define bu_rb_uniq_on1(t) bu_rb_uniq_on((t), 0)
02258
02259
02260 BU_EXPORT BU_EXTERN(int bu_rb_rank,
02261 (bu_rb_tree *tree,
02262 int order));
02263 #define bu_rb_rank1(t) bu_rb_rank1((t), 0)
02264 BU_EXPORT BU_EXTERN(void *bu_rb_select,
02265 (bu_rb_tree *tree,
02266 int order,
02267 int k));
02268 #define bu_rb_select1(t,k) bu_rb_select((t), 0, (k))
02269
02270
02271 BU_EXPORT BU_EXTERN(void *bu_rb_search,
02272 (bu_rb_tree *tree,
02273 int order,
02274 void *data));
02275 #define bu_rb_search1(t,d) bu_rb_search((t), 0, (d))
02276
02277
02278 BU_EXPORT BU_EXTERN(void bu_rb_walk,
02279 (bu_rb_tree *tree,
02280 int order,
02281 void (*visit)(),
02282 int trav_type));
02283 #define bu_rb_walk1(t,v,d) bu_rb_walk((t), 0, (v), (d))
02284
02285
02286
02287
02288
02289
02290 BU_EXPORT BU_EXTERN(void bu_semaphore_init,
02291 (unsigned int nsemaphores));
02292 BU_EXPORT BU_EXTERN(void bu_semaphore_acquire,
02293 (unsigned int i));
02294 BU_EXPORT BU_EXTERN(void bu_semaphore_release,
02295 (unsigned int i));
02296
02297
02298
02299
02300
02301
02302 BU_EXPORT BU_EXTERN(void bu_vls_init,
02303 (struct bu_vls *vp));
02304 BU_EXPORT BU_EXTERN(void bu_vls_init_if_uninit,
02305 (struct bu_vls *vp));
02306 BU_EXPORT BU_EXTERN(struct bu_vls *bu_vls_vlsinit,
02307 ());
02308 BU_EXPORT BU_EXTERN(char *bu_vls_addr,
02309 (const struct bu_vls *vp));
02310 BU_EXPORT BU_EXTERN(char *bu_vls_strdup,
02311 (const struct bu_vls *vp));
02312 BU_EXPORT BU_EXTERN(char *bu_vls_strgrab,
02313 (struct bu_vls *vp));
02314 BU_EXPORT BU_EXTERN(void bu_vls_extend,
02315 (struct bu_vls *vp,
02316 unsigned int extra));
02317 BU_EXPORT BU_EXTERN(void bu_vls_setlen,
02318 (struct bu_vls *vp,
02319 int newlen));
02320 BU_EXPORT BU_EXTERN(int bu_vls_strlen,
02321 (const struct bu_vls *vp));
02322 BU_EXPORT BU_EXTERN(void bu_vls_trunc,
02323 (struct bu_vls *vp,
02324 int len));
02325 BU_EXPORT BU_EXTERN(void bu_vls_trunc2,
02326 (struct bu_vls *vp,
02327 int len));
02328 BU_EXPORT BU_EXTERN(void bu_vls_nibble,
02329 (struct bu_vls *vp,
02330 int len));
02331 BU_EXPORT BU_EXTERN(void bu_vls_free,
02332 (struct bu_vls *vp));
02333 BU_EXPORT BU_EXTERN(void bu_vls_vlsfree,
02334 (struct bu_vls *vp));
02335 BU_EXPORT BU_EXTERN(void bu_vls_strcpy,
02336 (struct bu_vls *vp,
02337 const char *s));
02338 BU_EXPORT BU_EXTERN(void bu_vls_strncpy,
02339 (struct bu_vls *vp,
02340 const char *s,
02341 long n));
02342 BU_EXPORT BU_EXTERN(void bu_vls_strcat,
02343 (struct bu_vls *vp,
02344 const char *s));
02345 BU_EXPORT BU_EXTERN(void bu_vls_strncat,
02346 (struct bu_vls *vp,
02347 const char *s,
02348 long n));
02349 BU_EXPORT BU_EXTERN(void bu_vls_vlscat,
02350 (struct bu_vls *dest,
02351 const struct bu_vls *src));
02352 BU_EXPORT BU_EXTERN(void bu_vls_vlscatzap,
02353 (struct bu_vls *dest,
02354 struct bu_vls *src));
02355 BU_EXPORT BU_EXTERN(void bu_vls_from_argv,
02356 (struct bu_vls *vp,
02357 int argc,
02358 const char *argv[]));
02359 BU_EXPORT BU_EXTERN(int bu_argv_from_string,
02360 (char **argv,
02361 int lim,
02362 char *lp));
02363 BU_EXPORT BU_EXTERN(void bu_vls_fwrite,
02364 (FILE *fp,
02365 const struct bu_vls *vp));
02366 BU_EXPORT BU_EXTERN(void bu_vls_write,
02367 (int fd,
02368 const struct bu_vls *vp));
02369 BU_EXPORT BU_EXTERN(int bu_vls_read,
02370 (struct bu_vls *vp,
02371 int fd));
02372 BU_EXPORT BU_EXTERN(int bu_vls_gets,
02373 (struct bu_vls *vp,
02374 FILE *fp));
02375 BU_EXPORT BU_EXTERN(void bu_vls_putc,
02376 (struct bu_vls *vp,
02377 int c));
02378 BU_EXPORT BU_EXTERN(void bu_vls_trimspace,
02379 (struct bu_vls *vp));
02380 #if 0
02381 BU_EXPORT BU_EXTERN(void bu_vls_vprintf,
02382 (struct bu_vls *vls,
02383 const char *fmt,
02384 va_list ap));
02385 #endif
02386 BU_EXPORT BU_EXTERN(void bu_vls_printf,
02387 (struct bu_vls *vls,
02388 char *fmt, ...));
02389 BU_EXPORT BU_EXTERN(void bu_vls_sprintf,
02390 (struct bu_vls *vls,
02391 char *fmt, ...));
02392 BU_EXPORT BU_EXTERN(void bu_vls_spaces,
02393 (struct bu_vls *vp,
02394 int cnt));
02395 BU_EXPORT BU_EXTERN(int bu_vls_print_positions_used,
02396 (const struct bu_vls *vp));
02397 BU_EXPORT BU_EXTERN(void bu_vls_detab,
02398 (struct bu_vls *vp));
02399
02400 #if 0
02401 BU_EXPORT BU_EXTERN(void bu_vls_blkset,
02402 (struct bu_vls *vp,
02403 int len,
02404 int ch));
02405 #endif
02406
02407 BU_EXPORT BU_EXTERN(void bu_vls_prepend,
02408 (struct bu_vls *vp,
02409 char *str));
02410
02411
02412
02413
02414
02415 BU_EXPORT extern const char bu_version[];
02416
02417
02418
02419
02420 BU_EXPORT BU_EXTERN(double bu_units_conversion,
02421 (const char *str));
02422 BU_EXPORT BU_EXTERN(const char *bu_units_string,
02423 (const double mm));
02424 BU_EXPORT BU_EXTERN(double bu_mm_value,
02425 (const char *s));
02426 BU_EXPORT BU_EXTERN(void bu_mm_cvt,
02427 (register const struct bu_structparse *sdp,
02428 register const char *name,
02429 char *base,
02430 const char *value));
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441 #define BU_GLONGLONG(_cp) \
02442 ((((long)((_cp)[0])) << 56) | \
02443 (((long)((_cp)[1])) << 48) | \
02444 (((long)((_cp)[2])) << 40) | \
02445 (((long)((_cp)[3])) << 32) | \
02446 (((long)((_cp)[4])) << 24) | \
02447 (((long)((_cp)[5])) << 16) | \
02448 (((long)((_cp)[6])) << 8) | \
02449 ((long)((_cp)[7])) )
02450 #define BU_GLONG(_cp) \
02451 ((((long)((_cp)[0])) << 24) | \
02452 (((long)((_cp)[1])) << 16) | \
02453 (((long)((_cp)[2])) << 8) | \
02454 ((long)((_cp)[3])) )
02455 #define BU_GSHORT(_cp) \
02456 ((((short)((_cp)[0])) << 8) | \
02457 (_cp)[1] )
02458
02459 BU_EXPORT BU_EXTERN(unsigned short bu_gshort,
02460 (const unsigned char *msgp));
02461 BU_EXPORT BU_EXTERN(unsigned long bu_glong,
02462 (const unsigned char *msgp));
02463 BU_EXPORT BU_EXTERN(unsigned char *bu_pshort,
02464 (register unsigned char *msgp,
02465 register int s));
02466 BU_EXPORT BU_EXTERN(unsigned char *bu_plong,
02467 (register unsigned char *msgp,
02468 register unsigned long l));
02469
02470
02471
02472
02473
02474
02475
02476
02477 BU_EXPORT BU_EXTERN(struct bu_vls *bu_association,
02478 (const char *fname,
02479 const char *value,
02480 int field_sep));
02481
02482
02483
02484
02485
02486
02487
02488 BU_EXPORT extern struct bu_cmdtab bu_observer_cmds[];
02489 BU_EXPORT BU_EXTERN(void bu_observer_notify,
02490 ());
02491 BU_EXPORT BU_EXTERN(void bu_observer_free,
02492 (struct bu_observer *));
02493
02494
02495
02496 BU_EXPORT BU_EXTERN(void bu_badmagic_tcl,
02497 (Tcl_Interp *interp,
02498 const long *ptr,
02499 unsigned long magic,
02500 const char *str,
02501 const char *file,
02502 int line));
02503
02504 BU_EXPORT BU_EXTERN(void bu_structparse_get_terse_form,
02505 (Tcl_Interp *interp,
02506 const struct bu_structparse *sp));
02507
02508 BU_EXPORT BU_EXTERN(int bu_structparse_argv,
02509 (Tcl_Interp *interp,
02510 int argc,
02511 char **argv,
02512 const struct bu_structparse *desc,
02513 char *base));
02514
02515 BU_EXPORT BU_EXTERN(int bu_tcl_mem_barriercheck,
02516 (ClientData clientData,
02517 Tcl_Interp *interp,
02518 int argc,
02519 char **argv));
02520
02521 BU_EXPORT BU_EXTERN(int bu_tcl_ck_malloc_ptr,
02522 (ClientData clientData,
02523 Tcl_Interp *interp,
02524 int argc,
02525 char **argv));
02526
02527 BU_EXPORT BU_EXTERN(int bu_tcl_malloc_len_roundup,
02528 (ClientData clientData,
02529 Tcl_Interp *interp,
02530 int argc,
02531 char **argv));
02532
02533 BU_EXPORT BU_EXTERN(int bu_tcl_prmem,
02534 (ClientData clientData,
02535 Tcl_Interp *interp,
02536 int argc,
02537 char **argv));
02538
02539 BU_EXPORT BU_EXTERN(int bu_tcl_printb,
02540 (ClientData clientData,
02541 Tcl_Interp *interp,
02542 int argc,
02543 char **argv));
02544
02545 BU_EXPORT BU_EXTERN(int bu_get_value_by_keyword,
02546 (ClientData clientData,
02547 Tcl_Interp *interp,
02548 int argc,
02549 char **argv));
02550
02551 BU_EXPORT BU_EXTERN(int bu_get_all_keyword_values,
02552 (ClientData clientData,
02553 Tcl_Interp *interp,
02554 int argc,
02555 char **argv));
02556
02557 BU_EXPORT BU_EXTERN(int bu_tcl_rgb_to_hsv,
02558 (ClientData clientData,
02559 Tcl_Interp *interp,
02560 int argc,
02561 char **argv));
02562
02563 BU_EXPORT BU_EXTERN(int bu_tcl_hsv_to_rgb,
02564 (ClientData clientData,
02565 Tcl_Interp *interp,
02566 int argc,
02567 char **argv));
02568
02569 BU_EXPORT BU_EXTERN(int bu_tcl_key_eq_to_key_val,
02570 (ClientData clientData,
02571 Tcl_Interp *interp,
02572 int argc,
02573 char **argv));
02574
02575 BU_EXPORT BU_EXTERN(int bu_tcl_shader_to_key_val,
02576 (ClientData clientData,
02577 Tcl_Interp *interp,
02578 int argc,
02579 char **argv));
02580
02581 BU_EXPORT BU_EXTERN(int bu_tcl_key_val_to_key_eq,
02582 (ClientData clientData,
02583 Tcl_Interp *interp,
02584 int argc,
02585 char **argv));
02586
02587 BU_EXPORT BU_EXTERN(int bu_tcl_shader_to_key_eq,
02588 (ClientData clientData,
02589 Tcl_Interp *interp,
02590 int argc,
02591 char **argv));
02592
02593 BU_EXPORT BU_EXTERN(int bu_tcl_brlcad_root,
02594 (ClientData clientData,
02595 Tcl_Interp *interp,
02596 int argc,
02597 char **argv));
02598
02599 BU_EXPORT BU_EXTERN(int bu_tcl_brlcad_data,
02600 (ClientData clientData,
02601 Tcl_Interp *interp,
02602 int argc,
02603 char **argv));
02604
02605
02606 BU_EXPORT BU_EXTERN(int bu_tcl_brlcad_path,
02607 (ClientData clientData,
02608 Tcl_Interp *interp,
02609 int argc,
02610 char **argv));
02611
02612 BU_EXPORT BU_EXTERN(int bu_tcl_units_conversion,
02613 (ClientData clientData,
02614 Tcl_Interp *interp,
02615 int argc,
02616 char **argv));
02617
02618 BU_EXPORT BU_EXTERN(void bu_tcl_setup,
02619 (Tcl_Interp *interp));
02620
02621 #ifdef BRLCAD_DEBUG
02622 BU_EXPORT BU_EXTERN(int Bu_d_Init,
02623 (Tcl_Interp *interp));
02624 #else
02625 BU_EXPORT BU_EXTERN(int Bu_Init,
02626 (Tcl_Interp *interp));
02627 #endif
02628
02629
02630
02631
02632
02633
02634
02635 #define BU_LEX_ANY 0
02636 struct bu_lex_t_int {
02637 int type;
02638 int value;
02639 };
02640 #define BU_LEX_INT 1
02641 struct bu_lex_t_dbl {
02642 int type;
02643 double value;
02644 };
02645 #define BU_LEX_DOUBLE 2
02646 struct bu_lex_t_key {
02647 int type;
02648 int value;
02649 };
02650 #define BU_LEX_SYMBOL 3
02651 #define BU_LEX_KEYWORD 4
02652 struct bu_lex_t_id {
02653 int type;
02654 char *value;
02655 };
02656 #define BU_LEX_IDENT 5
02657 #define BU_LEX_NUMBER 6
02658 union bu_lex_token {
02659 int type;
02660 struct bu_lex_t_int t_int;
02661 struct bu_lex_t_dbl t_dbl;
02662 struct bu_lex_t_key t_key;
02663 struct bu_lex_t_id t_id;
02664 };
02665 struct bu_lex_key {
02666 int tok_val;
02667 char *string;
02668 };
02669 #define BU_LEX_NEED_MORE 0
02670
02671 BU_EXPORT BU_EXTERN(int bu_lex,
02672 (union bu_lex_token *token,
02673 struct bu_vls *rtstr,
02674 struct bu_lex_key *keywords,
02675 struct bu_lex_key *symbols));
02676
02677
02678
02679 BU_EXPORT BU_EXTERN(long int bu_mread,
02680 (int fd, void *bufp, long int n));
02681
02682
02683 BU_EXPORT BU_EXTERN(void bu_mro_init_with_string,
02684 (struct bu_mro *mrop, const char *string));
02685 BU_EXPORT BU_EXTERN(void bu_mro_set,
02686 (struct bu_mro *mrop,
02687 const char *string));
02688 BU_EXPORT BU_EXTERN(void bu_mro_init,
02689 (struct bu_mro *mrop));
02690 BU_EXPORT BU_EXTERN(void bu_mro_free,
02691 (struct bu_mro *mrop));
02692
02693
02694
02695
02696
02697
02698
02699
02700 struct bu_hash_entry {
02701 long magic;
02702 unsigned char *key;
02703 unsigned char *value;
02704 int key_len;
02705 struct bu_hash_entry *next;
02706 };
02707
02708 struct bu_hash_tbl {
02709 long magic;
02710 unsigned long mask;
02711 unsigned long num_lists;
02712 unsigned long num_entries;
02713 struct bu_hash_entry **lists;
02714 };
02715
02716 struct bu_hash_record {
02717 long magic;
02718 struct bu_hash_tbl *tbl;
02719 unsigned long index;
02720 struct bu_hash_entry *hsh_entry;
02721 };
02722
02723 #define BU_HASH_TBL_MAGIC 0x48415348
02724 #define BU_HASH_RECORD_MAGIC 0x68617368
02725 #define BU_HASH_ENTRY_MAGIC 0x48454E54
02726 #define BU_CK_HASH_TBL(_hp) BU_CKMAG( _hp, BU_HASH_TBL_MAGIC, "bu_hash_tbl" )
02727 #define BU_CK_HASH_RECORD(_rp) BU_CKMAG( _rp, BU_HASH_RECORD_MAGIC, "bu_hash_record" )
02728 #define BU_CK_HASH_ENTRY(_ep) BU_CKMAG( _ep, BU_HASH_ENTRY_MAGIC, "bu_hash_entry" )
02729
02730 BU_EXPORT BU_EXTERN(unsigned long bu_hash,
02731 (unsigned char *str,
02732 int len));
02733 BU_EXPORT BU_EXTERN(struct bu_hash_tbl *bu_create_hash_tbl,
02734 (unsigned long tbl_size));
02735 BU_EXPORT BU_EXTERN(struct bu_hash_entry *bu_find_hash_entry,
02736 (struct bu_hash_tbl *hsh_tbl,
02737 unsigned char *key,
02738 int key_len,
02739 struct bu_hash_entry **prev,
02740 unsigned long *index2));
02741 BU_EXPORT BU_EXTERN(void bu_set_hash_value,
02742 (struct bu_hash_entry *hsh_entry,
02743 unsigned char *value));
02744 BU_EXPORT BU_EXTERN(unsigned char *bu_get_hash_value,
02745 (struct bu_hash_entry *hsh_entry));
02746 BU_EXPORT BU_EXTERN(unsigned char *bu_get_hash_key,
02747 (struct bu_hash_entry *hsh_entry));
02748 BU_EXPORT BU_EXTERN(struct bu_hash_entry *bu_hash_add_entry,
02749 (struct bu_hash_tbl *hsh_tbl,
02750 unsigned char *key,
02751 int key_len,
02752 int *new_entry));
02753 BU_EXPORT BU_EXTERN(void bu_hash_tbl_pr,
02754 (struct bu_hash_tbl *hsh_tbl,
02755 char *str));
02756 BU_EXPORT BU_EXTERN(void bu_hash_tbl_free,
02757 (struct bu_hash_tbl *hsh_tbl));
02758 BU_EXPORT BU_EXTERN(struct bu_hash_entry *bu_hash_tbl_first,
02759 (struct bu_hash_tbl *hsh_tbl,
02760 struct bu_hash_record *rec));
02761 BU_EXPORT BU_EXTERN(struct bu_hash_entry *bu_hash_tbl_next,
02762 (struct bu_hash_record *rec));
02763
02764 __END_DECLS
02765
02766 #endif
02767
02768
02769
02770
02771
02772
02773
02774
02775
02776
02777