BRL-CAD
Loading...
Searching...
No Matches
db_io.h
Go to the documentation of this file.
1/* D B _ I O . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1993-2025 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @file rt/db_io.h
21 *
22 */
23
24#ifndef RT_DB_IO_H
25#define RT_DB_IO_H
26
27#include "common.h"
28
29/* system headers */
30#include <stdio.h> /* for FILE */
31
32/* interface headers */
33#include "vmath.h"
34#include "bu/avs.h"
35#include "rt/db5.h"
36#include "rt/defines.h"
37
39
40
41struct rt_db_internal; /* forward declaration */
42
43
44/* db_open.c */
45/**
46 * Ensure that the on-disk database has been completely written out of
47 * the operating system's cache.
48 */
49RT_EXPORT extern void db_sync(struct db_i *dbip);
50
51
52
53/* close a model database */
54/**
55 * De-register a client of this database instance, if provided, and
56 * close out the instance.
57 */
58RT_EXPORT extern void db_close_client(struct db_i *dbip,
59 long *client);
60
61/**
62 * Check if a specified path is a .g database file, based on identification (or
63 * not) of a valid .g file header. Returns the dbi_version if the file has a
64 * valid header, and -1 otherwise.
65 *
66 * Note that this routine does NOT do the endian-flipping tests to spot
67 * big-endian v4 .g files in the case where a valid header is not found - files
68 * are assumed to be either v5 or little endian v4 formatted. Codes willing to
69 * take the performance vs robustness tradeoff of the endian flipping check
70 * (which will do more file reading than this basic check) should use db_open.
71 */
72RT_EXPORT extern int db_filetype(const char *file_path);
73
74/* dump a full copy of a database */
75/**
76 * Dump a full copy of one database into another. This is a good way
77 * of committing a ".inmem" database to a ".g" file. The input is a
78 * database instance, the output is a LIBWDB object, which could be a
79 * disk file or another database instance.
80 *
81 * Returns -
82 * -1 error
83 * 0 success
84 */
85RT_EXPORT extern int db_dump(struct rt_wdb *wdbp,
86 struct db_i *dbip);
87
88/**
89 * Obtain an additional instance of this same database. A new client
90 * is registered at the same time if one is specified.
91 */
92RT_EXPORT extern struct db_i *db_clone_dbi(struct db_i *dbip,
93 long *client);
94
95
96/**
97 * Create a v5 database "free" object of the specified size, and place
98 * it at the indicated location in the database.
99 *
100 * There are two interesting cases:
101 * - The free object is "small". Just write it all at once.
102 * - The free object is "large". Write header and trailer
103 * separately
104 *
105 * @return 0 OK
106 * @return -1 Fail. This is a horrible error.
107 */
108RT_EXPORT extern int db5_write_free(struct db_i *dbip,
109 struct directory *dp,
110 size_t length);
111
112
113/**
114 * Change the size of a v5 database object.
115 *
116 * If the object is getting smaller, break it into two pieces, and
117 * write out free objects for both. The caller is expected to
118 * re-write new data on the first one.
119 *
120 * If the object is getting larger, seek a suitable "hole" large
121 * enough to hold it, throwing back any surplus, properly marked.
122 *
123 * If the object is getting larger and there is no suitable "hole" in
124 * the database, extend the file, write a free object in the new
125 * space, and write a free object in the old space.
126 *
127 * There is no point to trying to extend in place, that would require
128 * two searches through the memory map, and doesn't save any disk I/O.
129 *
130 * Returns -
131 * 0 OK
132 * -1 Failure
133 */
134RT_EXPORT extern int db5_realloc(struct db_i *dbip,
135 struct directory *dp,
136 struct bu_external *ep);
137
138
139/**
140 * A routine for merging together the three optional parts of an
141 * object into the final on-disk format. Results in extra data
142 * copies, but serves as a starting point for testing. Any of name,
143 * attrib, and body may be null.
144 */
146 int dli,
147 const char *name,
148 const unsigned char hidden,
149 const struct bu_external *attrib,
150 const struct bu_external *body,
151 int major,
152 int minor,
153 int a_zzz,
154 int b_zzz);
155
156
157/**
158 * The attributes are taken from ip->idb_avs
159 *
160 * If present, convert attributes to on-disk format. This must happen
161 * after exporting the body, in case the ft_export5() method happened
162 * to extend the attribute set. Combinations are one "solid" which
163 * does this.
164 *
165 * The internal representation is NOT freed, that's the caller's job.
166 *
167 * The 'ext' pointer is accepted in uninitialized form, and an
168 * initialized structure is always returned, so that the caller may
169 * free it even when an error return is given.
170 *
171 * Returns -
172 * 0 OK
173 * -1 FAIL
174 */
176 const char *name,
177 const struct rt_db_internal *ip,
178 double conv2mm,
179 struct db_i *dbip,
180 struct resource *resp,
181 const int major);
182
183
184/*
185 * Modify name of external object, if necessary.
186 */
188 const char *name);
189
190
191/**
192 * Given an external representation of a database object, convert
193 * it into its internal representation.
194 *
195 * Returns -
196 * <0 On error
197 * id On success.
198 */
199RT_EXPORT extern int
201 struct rt_db_internal *ip,
202 const struct bu_external *ep,
203 const char *name,
204 const struct db_i *dbip,
205 const mat_t mat,
206 struct resource *resp);
207
208/**
209 * Get an object from the database, and convert it into its internal
210 * representation.
211 *
212 * Applications and middleware shouldn't call this directly, they
213 * should use the generic interface "rt_db_get_internal()".
214 *
215 * Returns -
216 * <0 On error
217 * id On success.
218 */
220 const struct directory *dp,
221 const struct db_i *dbip,
222 const mat_t mat,
223 struct resource *resp);
224
225
226/**
227 * Convert the internal representation of a solid to the external one,
228 * and write it into the database.
229 *
230 * Applications and middleware shouldn't call this directly, they
231 * should use the version-generic interface "rt_db_put_internal()".
232 *
233 * The internal representation is always freed. (Not the pointer,
234 * just the contents).
235 *
236 * Returns -
237 * <0 error
238 * 0 success
239 */
241 struct db_i *dbip,
242 struct rt_db_internal *ip,
243 struct resource *resp,
244 const int major);
245
246
247/**
248 * Make only the front (header) portion of a free object. This is
249 * used when operating on very large contiguous free objects in the
250 * database (e.g. 50 MBytes).
251 */
253 size_t length);
254
255
256/**
257 * Make a complete, zero-filled, free object. Note that free objects
258 * can sometimes get quite large.
259 */
261 size_t length);
262
263
264/**
265 * Given a variable-width length field character pointer (cp) in
266 * network order (XDR), store it in *lenp.
267 *
268 * Format is typically expected to be one of:
269 * DB5HDR_WIDTHCODE_8BIT
270 * DB5HDR_WIDTHCODE_16BIT
271 * DB5HDR_WIDTHCODE_32BIT
272 * DB5HDR_WIDTHCODE_64BIT
273 *
274 * Returns -
275 * The number of bytes of input that were decoded.
276 */
277RT_EXPORT extern size_t db5_decode_signed(size_t *lenp,
278 const unsigned char *cp,
279 int format);
280
281/**
282 * Given a variable-width length field in network order (XDR), store
283 * it in *lenp.
284 *
285 * This routine processes unsigned values.
286 *
287 * Returns -
288 * The number of bytes of input that were decoded.
289 */
290RT_EXPORT extern size_t db5_decode_length(size_t *lenp,
291 const unsigned char *cp,
292 int format);
293#if defined(USE_BINARY_ATTRIBUTES)
294/**
295 * Given a pointer to a binary attribute, determine its length.
296 */
297RT_EXPORT extern void decode_binary_attribute(const size_t len,
298 const unsigned char *cp);
299#endif
300
301/**
302 * Given a number to encode, decide which is the smallest encoding
303 * format which will contain it.
304 */
306
307
309
310/**
311 * Given a value and a variable-width format spec, store it in network
312 * order.
313 *
314 * Returns -
315 * pointer to next available byte.
316 */
317RT_EXPORT extern unsigned char *db5_encode_length(unsigned char *cp,
318 size_t val,
319 int format);
320
321/**
322 * Given a pointer to the memory for a serialized database object, get
323 * a raw internal representation.
324 *
325 * Returns -
326 * on success, pointer to next unused byte in 'ip' after object got;
327 * NULL, on error.
328 */
329RT_EXPORT extern const unsigned char *db5_get_raw_internal_ptr(struct db5_raw_internal *rip,
330 const unsigned char *ip);
331
332
333/**
334 * Given a file pointer to an open geometry database positioned on a
335 * serialized object, get a raw internal representation.
336 *
337 * Returns -
338 * 0 on success
339 * -1 on EOF
340 * -2 on error
341 */
343 FILE *fp);
344
345
346/**
347 * Verify that this is a valid header for a BRL-CAD v5 database.
348 *
349 * Returns -
350 * 0 Not valid v5 header
351 * 1 Valid v5 header
352 */
353RT_EXPORT extern int db5_header_is_valid(const unsigned char *hp);
354
355
356/**
357 * write an ident header (title and units) to the provided file
358 * pointer.
359 *
360 * Returns -
361 * 0 Success
362 * -1 Error
363 */
364RT_EXPORT extern int db5_fwrite_ident(FILE *,
365 const char *,
366 double);
367
368
369/**
370 *
371 * Given that caller already has an external representation of the
372 * database object, update it to have a new name (taken from
373 * dp->d_namep) in that external representation, and write the new
374 * object into the database, obtaining different storage if the size
375 * has changed.
376 *
377 * Changing the name on a v5 object is a relatively expensive
378 * operation.
379 *
380 * Caller is responsible for freeing memory of external
381 * representation, using bu_free_external().
382 *
383 * This routine is used to efficiently support MGED's "cp" and "keep"
384 * commands, which don't need to import and decompress objects just to
385 * rename and copy them.
386 *
387 * Returns -
388 * -1 error
389 * 0 success
390 */
392 struct directory *dp,
393 struct db_i *dbip);
394
395/**
396 * As the v4 database does not really have the notion of "wrapping",
397 * this function writes the object name into the proper place (a
398 * standard location in all granules).
399 */
401 const char *name);
402
403
404/* db_io.c */
405RT_EXPORT extern int db_write(struct db_i *dbip,
406 const void * addr,
407 size_t count,
408 b_off_t offset);
409
410/**
411 * Add name from dp->d_namep to external representation of solid, and
412 * write it into a file.
413 *
414 * Caller is responsible for freeing memory of external
415 * representation, using bu_free_external().
416 *
417 * The 'name' field of the external representation is modified to
418 * contain the desired name. The 'ep' parameter cannot be const.
419 *
420 * THIS ROUTINE ONLY SUPPORTS WRITING V4 GEOMETRY.
421 *
422 * Returns -
423 * <0 error
424 * 0 OK
425 *
426 * NOTE: Callers of this should be using wdb_export_external()
427 * instead.
428 */
429RT_EXPORT extern int db_fwrite_external(FILE *fp,
430 const char *name,
431 struct bu_external *ep);
432
433/* malloc & read records */
434
435/**
436 * Retrieve all records in the database pertaining to an object, and
437 * place them in malloc()'ed storage, which the caller is responsible
438 * for free()'ing.
439 *
440 * This loads the combination into a local record buffer. This is in
441 * external v4 format.
442 *
443 * Returns -
444 * union record * - OK
445 * (union record *)0 - FAILURE
446 */
447RT_EXPORT extern union record *db_getmrec(const struct db_i *,
448 const struct directory *dp);
449/* get several records from db */
450
451/**
452 * Retrieve 'len' records from the database, "offset" granules into
453 * this entry.
454 *
455 * Returns -
456 * 0 OK
457 * -1 FAILURE
458 */
459RT_EXPORT extern int db_get(const struct db_i *,
460 const struct directory *dp,
461 union record *where,
462 b_off_t offset,
463 size_t len);
464/* put several records into db */
465
466/**
467 * Store 'len' records to the database, "offset" granules into this
468 * entry.
469 *
470 * Returns:
471 * 0 OK
472 * non-0 FAILURE
473 */
474RT_EXPORT extern int db_put(struct db_i *,
475 const struct directory *dp,
476 union record *where,
477 b_off_t offset, size_t len);
478
479/**
480 * Obtains a object from the database, leaving it in external
481 * (on-disk) format.
482 *
483 * The bu_external structure represented by 'ep' is initialized here,
484 * the caller need not pre-initialize it. On error, 'ep' is left
485 * un-initialized and need not be freed, to simplify error recovery.
486 * On success, the caller is responsible for calling
487 * bu_free_external(ep);
488 *
489 * Returns -
490 * -1 error
491 * 0 success
492 */
494 const struct directory *dp,
495 const struct db_i *dbip);
496
497/**
498 * Given that caller already has an external representation of the
499 * database object, update it to have a new name (taken from
500 * dp->d_namep) in that external representation, and write the new
501 * object into the database, obtaining different storage if the size
502 * has changed.
503 *
504 * Caller is responsible for freeing memory of external
505 * representation, using bu_free_external().
506 *
507 * This routine is used to efficiently support MGED's "cp" and "keep"
508 * commands, which don't need to import objects just to rename and
509 * copy them.
510 *
511 * Returns -
512 * <0 error
513 * 0 success
514 */
516 struct directory *dp,
517 struct db_i *dbip);
518
519/* db_scan.c */
520/* read db (to build directory) */
521RT_EXPORT extern int db_scan(struct db_i *,
522 int (*handler)(struct db_i *,
523 const char *name,
525 size_t nrec,
526 int flags,
527 void *client_data),
528 int do_old_matter,
529 void *client_data);
530/* update db unit conversions */
531#define db_ident(a, b, c) +++error+++
532
533/**
534 * Update the _GLOBAL object, which in v5 serves the place of the
535 * "ident" header record in v4 as the place to stash global
536 * information. Since every database will have one of these things,
537 * it's no problem to update it.
538 *
539 * Returns -
540 * 0 Success
541 * -1 Fatal Error
542 */
543RT_EXPORT extern int db_update_ident(struct db_i *dbip,
544 const char *title,
545 double local2mm);
546
547/**
548 * Create a header for a v5 database.
549 *
550 * This routine has the same calling sequence as db_fwrite_ident()
551 * which makes a v4 database header.
552 *
553 * In the v5 database, two database objects must be created to match
554 * the semantics of what was in the v4 header:
555 *
556 * First, a database header object.
557 *
558 * Second, create a specially named attribute-only object which
559 * contains the attributes "title=" and "units=" with the values of
560 * title and local2mm respectively.
561 *
562 * Note that the current working units are specified as a conversion
563 * factor to millimeters because database dimensional values are
564 * always stored as millimeters (mm). The units conversion factor
565 * only affects the display and conversion of input values. This
566 * helps prevent error accumulation and improves numerical stability
567 * when calculations are made.
568 *
569 * This routine should only be used by db_create(). Everyone else
570 * should use db5_update_ident().
571 *
572 * Returns -
573 * 0 Success
574 * -1 Fatal Error
575 */
576RT_EXPORT extern int db_fwrite_ident(FILE *fp,
577 const char *title,
578 double local2mm);
579
580/**
581 * Initialize conversion factors given the v4 database unit
582 */
583RT_EXPORT extern void db_conversions(struct db_i *,
584 int units);
585
586/**
587 * Given a string, return the V4 database code representing the user's
588 * preferred editing units. The v4 database format does not have many
589 * choices.
590 *
591 * Returns -
592 * -1 Not a legal V4 database code
593 * # The V4 database code number
594 */
595RT_EXPORT extern int db_v4_get_units_code(const char *str);
596
597/* db5_scan.c */
598
599/**
600 * A generic routine to determine the type of the database, (v4 or v5)
601 * and to invoke the appropriate db_scan()-like routine to build the
602 * in-memory directory.
603 *
604 * It is the caller's responsibility to close the database in case of
605 * error.
606 *
607 * Called from rt_dirbuild() and other places directly where a
608 * raytrace instance is not required.
609 *
610 * Returns -
611 * 0 OK
612 * -1 failure
613 */
614RT_EXPORT extern int db_dirbuild(struct db_i *dbip);
615RT_EXPORT extern int db_dirbuild_inmem(struct db_i *dbip, const void *data, b_off_t data_size);
616RT_EXPORT extern struct directory *db5_diradd(struct db_i *dbip,
617 const struct db5_raw_internal *rip,
619 void *client_data);
620
621/**
622 * Scan a v5 database, sending each object off to a handler.
623 *
624 * Returns -
625 * 0 Success
626 * -1 Fatal Error
627 */
628RT_EXPORT extern int db5_scan(struct db_i *dbip,
629 void (*handler)(struct db_i *,
630 const struct db5_raw_internal *,
632 void *client_data),
633 void *client_data);
634RT_EXPORT extern int db5_scan_inmem(struct db_i *dbip,
635 void (*handler)(struct db_i *,
636 const struct db5_raw_internal *,
638 void *client_data),
639 void *client_data,
640 const void *data,
642
643/**
644 * Obtain the database version for a given database instance.
645 *
646 * Returns 4 or 5 accordingly for v4 or v5 geometry database files.
647 * Returns -1 if dbip is invalid.
648 */
649RT_EXPORT extern int db_version(const struct db_i *dbip);
650RT_EXPORT extern int db_version_inmem(const struct db_i *dbip, const void *data, b_off_t data_size);
651
652
653/* db_corrupt.c */
654
655/**
656 * Detect whether a given geometry database file seems to be corrupt
657 * or invalid due to flipped endianness. Only relevant for v4
658 * geometry files that are binary-incompatible with the runtime
659 * platform.
660 *
661 * Returns true if flipping the endian type fixes all combination
662 * member matrices.
663 */
664RT_EXPORT extern int rt_db_flip_endian(struct db_i *dbip);
665
666
667/**
668 * Transmogrify an existing directory entry to be an in-memory-only
669 * one, stealing the external representation from 'ext'.
670 */
671RT_EXPORT extern void db_inmem(struct directory *dp,
672 struct bu_external *ext,
673 int flags,
674 struct db_i *dbip);
675
676/* db_lookup.c */
677
678/**
679 * Return the number of "struct directory" nodes in the given
680 * database.
681 */
682RT_EXPORT extern size_t db_directory_size(const struct db_i *dbip);
683
684/**
685 * For debugging, ensure that all the linked-lists for the directory
686 * structure are intact.
687 */
688RT_EXPORT extern void db_ck_directory(const struct db_i *dbip);
689
690/**
691 * Returns -
692 * 0 if the in-memory directory is empty
693 * 1 if the in-memory directory has entries,
694 * which implies that a db_scan() has already been performed.
695 */
696RT_EXPORT extern int db_is_directory_non_empty(const struct db_i *dbip);
697
698/**
699 * Returns a hash index for a given string that corresponds with the
700 * head of that string's hash chain.
701 */
702RT_EXPORT extern int db_dirhash(const char *str);
703
704/**
705 * This routine ensures that ret_name is not already in the
706 * directory. If it is, it tries a fixed number of times to modify
707 * ret_name before giving up. Note - most of the time, the hash for
708 * ret_name is computed once.
709 *
710 * Inputs -
711 * dbip database instance pointer
712 * ret_name the original name
713 * noisy to blather or not
714 *
715 * Outputs -
716 * ret_name the name to use
717 * headp pointer to the first (struct directory *) in the bucket
718 *
719 * Returns -
720 * 0 success
721 * <0 fail
722 */
723RT_EXPORT extern int db_dircheck(struct db_i *dbip,
724 struct bu_vls *ret_name,
725 int noisy,
726 struct directory ***headp);
727/* convert name to directory ptr */
728
729/**
730 * This routine takes a path or a name and returns the current directory
731 * pointer (if any) associated with the object.
732 *
733 * If given an object name, it will look up the object name in the directory
734 * table. If the name is present, a pointer to the directory struct element is
735 * returned, otherwise NULL is returned.
736 *
737 * If given a path, it will validate that the path is a valid path in the
738 * current database. If it is, a pointer to the current directory in the path
739 * (i.e. the leaf object on the path) is returned, otherwise NULL is returned.
740 *
741 * If noisy is non-zero, a print occurs, else only the return code indicates
742 * failure.
743 *
744 * Returns -
745 * struct directory if name is found
746 * RT_DIR_NULL on failure
747 */
748RT_EXPORT extern struct directory *db_lookup(const struct db_i *,
749 const char *name,
750 int noisy);
751
752/* add entry to directory */
753
754/**
755 * Add an entry to the directory. Try to make the regular path
756 * through the code as fast as possible, to speed up building the
757 * table of contents.
758 *
759 * dbip is a pointer to a valid/opened database instance
760 *
761 * name is the string name of the object being added
762 *
763 * laddr is the offset into the file to the object
764 *
765 * len is the length of the object, number of db granules used
766 *
767 * flags are defined in raytrace.h (RT_DIR_SOLID, RT_DIR_COMB, RT_DIR_REGION,
768 * RT_DIR_INMEM, etc.) for db version 5, ptr is the minor_type
769 * (non-null pointer to valid unsigned char code)
770 *
771 * an laddr of RT_DIR_PHONY_ADDR means that database storage has not
772 * been allocated yet.
773 */
774RT_EXPORT extern struct directory *db_diradd(struct db_i *,
775 const char *name,
777 size_t len,
778 int flags,
779 void *ptr);
780RT_EXPORT extern struct directory *db_diradd5(struct db_i *dbip,
781 const char *name,
783 unsigned char major_type,
784 unsigned char minor_type,
785 unsigned char name_hidden,
786 size_t object_length,
788
789/* delete entry from directory */
790
791/**
792 * Given a pointer to a directory entry, remove it from the linked
793 * list, and free the associated memory.
794 *
795 * It is the responsibility of the caller to have released whatever
796 * structures have been hung on the d_use_hd bu_list, first.
797 *
798 * Returns -
799 * 0 on success
800 * non-0 on failure
801 */
802RT_EXPORT extern int db_dirdelete(struct db_i *,
803 struct directory *dp);
804RT_EXPORT extern int db_fwrite_ident(FILE *,
805 const char *,
806 double);
807
808/**
809 * For debugging, print the entire contents of the database directory.
810 */
811RT_EXPORT extern void db_pr_dir(const struct db_i *dbip);
812
813/**
814 * Change the name string of a directory entry. Because of the
815 * hashing function, this takes some extra work.
816 *
817 * Returns -
818 * 0 on success
819 * non-0 on failure
820 */
821RT_EXPORT extern int db_rename(struct db_i *,
822 struct directory *,
823 const char *newname);
824
825
826/**
827 * Updates the d_nref fields (which count the number of times a given
828 * entry is referenced by a COMBination in the database).
829 *
830 */
831RT_EXPORT extern void db_update_nref(struct db_i *dbip,
832 struct resource *resp);
833
834
835/* db_flags.c */
836/**
837 * Given the internal form of a database object, return the
838 * appropriate 'flags' word for stashing in the in-memory directory of
839 * objects.
840 */
842
843
844/* XXX - should use in db5_diradd() */
845/**
846 * Given a database object in "raw" internal form, return the
847 * appropriate 'flags' word for stashing in the in-memory directory of
848 * objects.
849 */
851
852/* db_alloc.c */
853
854/* allocate "count" granules */
855RT_EXPORT extern int db_alloc(struct db_i *,
856 struct directory *dp,
857 size_t count);
858/* delete "recnum" from entry */
859RT_EXPORT extern int db_delrec(struct db_i *,
860 struct directory *dp,
861 int recnum);
862/* delete all granules assigned dp */
863RT_EXPORT extern int db_delete(struct db_i *,
864 struct directory *dp);
865/* write FREE records from 'start' */
866RT_EXPORT extern int db_zapper(struct db_i *,
867 struct directory *dp,
868 size_t start);
869
870/**
871 * This routine is called by the RT_GET_DIRECTORY macro when the
872 * freelist is exhausted. Rather than simply getting one additional
873 * structure, we get a whole batch, saving overhead.
874 */
876
877/**
878 * This routine is called by the GET_SEG macro when the freelist is
879 * exhausted. Rather than simply getting one additional structure, we
880 * get a whole batch, saving overhead. When this routine is called,
881 * the seg resource must already be locked. malloc() locking is done
882 * in bu_malloc.
883 */
884RT_EXPORT extern void rt_alloc_seg_block(struct resource *res);
885
886
887/**
888 * Read named MGED db, build toc.
889 */
890RT_EXPORT extern struct rt_i *rt_dirbuild(const char *filename, char *buf, int len);
891RT_EXPORT extern struct rt_i *rt_dirbuild_inmem(const void *data, b_off_t data_size, char *buf, int len);
892
893
894/* db5_types.c */
896 const int major);
897
899 const int major);
900
902 const int major,
903 const int minor);
904
906 const int major,
907 const int minor);
908
910 int *minor,
911 const char *tag);
912
914 int *minor,
915 const char *descrip);
916
917RT_EXPORT extern size_t db5_type_sizeof_h_binu(const int minor);
918
919RT_EXPORT extern size_t db5_type_sizeof_n_binu(const int minor);
920
922
923#endif /* RT_DB_IO_H */
924
925/*
926 * Local Variables:
927 * tab-width: 8
928 * mode: C
929 * indent-tabs-mode: t
930 * c-file-style: "stroustrup"
931 * End:
932 * ex: shiftwidth=4 tabstop=8
933 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
Definition of the BRL-CAD "v5" database format used for new ".g" files.
void db5_make_free_object_hdr(struct bu_external *ep, size_t length)
int db_put_external(struct bu_external *ep, struct directory *dp, struct db_i *dbip)
void db5_import_color_table(char *cp)
int db_get_external(struct bu_external *ep, const struct directory *dp, const struct db_i *dbip)
void db5_make_free_object(struct bu_external *ep, size_t length)
int db_wrap_v5_external(struct bu_external *ep, const char *name)
int db5_write_free(struct db_i *dbip, struct directory *dp, size_t length)
void db_close_client(struct db_i *dbip, long *client)
struct directory * db5_diradd(struct db_i *dbip, const struct db5_raw_internal *rip, b_off_t laddr, void *client_data)
int db_update_ident(struct db_i *dbip, const char *title, double local2mm)
struct rt_i * rt_dirbuild_inmem(const void *data, b_off_t data_size, char *buf, int len)
int db_scan(struct db_i *, int(*handler)(struct db_i *, const char *name, b_off_t addr, size_t nrec, int flags, void *client_data), int do_old_matter, void *client_data)
int db5_type_descrip_from_major(char **descrip, const int major)
int db_rename(struct db_i *, struct directory *, const char *newname)
size_t db5_decode_length(size_t *lenp, const unsigned char *cp, int format)
int db_dirbuild(struct db_i *dbip)
int db5_type_tag_from_major(char **tag, const int major)
int db5_type_tag_from_codes(char **tag, const int major, const int minor)
size_t db5_type_sizeof_h_binu(const int minor)
int db_filetype(const char *file_path)
int rt_db_put_internal5(struct directory *dp, struct db_i *dbip, struct rt_db_internal *ip, struct resource *resp, const int major)
int db_flags_raw_internal(const struct db5_raw_internal *intern)
struct directory * db_lookup(const struct db_i *, const char *name, int noisy)
int db_delete(struct db_i *, struct directory *dp)
int db_dirhash(const char *str)
struct rt_i * rt_dirbuild(const char *filename, char *buf, int len)
int db_write(struct db_i *dbip, const void *addr, size_t count, b_off_t offset)
struct directory * db_diradd5(struct db_i *dbip, const char *name, b_off_t laddr, unsigned char major_type, unsigned char minor_type, unsigned char name_hidden, size_t object_length, struct bu_attribute_value_set *avs)
int rt_db_external5_to_internal5(struct rt_db_internal *ip, const struct bu_external *ep, const char *name, const struct db_i *dbip, const mat_t mat, struct resource *resp)
void rt_alloc_seg_block(struct resource *res)
int db_dirbuild_inmem(struct db_i *dbip, const void *data, b_off_t data_size)
int db_version(const struct db_i *dbip)
int db_v4_get_units_code(const char *str)
int db_alloc(struct db_i *, struct directory *dp, size_t count)
union record * db_getmrec(const struct db_i *, const struct directory *dp)
int db_dirdelete(struct db_i *, struct directory *dp)
int db_put(struct db_i *, const struct directory *dp, union record *where, b_off_t offset, size_t len)
int db5_scan_inmem(struct db_i *dbip, void(*handler)(struct db_i *, const struct db5_raw_internal *, b_off_t addr, void *client_data), void *client_data, const void *data, b_off_t data_size)
int db5_realloc(struct db_i *dbip, struct directory *dp, struct bu_external *ep)
int db5_fwrite_ident(FILE *, const char *, double)
const unsigned char * db5_get_raw_internal_ptr(struct db5_raw_internal *rip, const unsigned char *ip)
struct directory * db_diradd(struct db_i *, const char *name, b_off_t laddr, size_t len, int flags, void *ptr)
int db_put_external5(struct bu_external *ep, struct directory *dp, struct db_i *dbip)
int db_fwrite_external(FILE *fp, const char *name, struct bu_external *ep)
int db5_select_length_encoding(size_t len)
int rt_db_flip_endian(struct db_i *dbip)
void db_sync(struct db_i *dbip)
int db_zapper(struct db_i *, struct directory *dp, size_t start)
int rt_db_cvt_to_external5(struct bu_external *ext, const char *name, const struct rt_db_internal *ip, double conv2mm, struct db_i *dbip, struct resource *resp, const int major)
int db_get(const struct db_i *, const struct directory *dp, union record *where, b_off_t offset, size_t len)
void db_update_nref(struct db_i *dbip, struct resource *resp)
int db_dump(struct rt_wdb *wdbp, struct db_i *dbip)
int db_flags_internal(const struct rt_db_internal *intern)
void db_ck_directory(const struct db_i *dbip)
size_t db5_decode_signed(size_t *lenp, const unsigned char *cp, int format)
int db5_type_codes_from_tag(int *major, int *minor, const char *tag)
int db5_type_codes_from_descrip(int *major, int *minor, const char *descrip)
void db_pr_dir(const struct db_i *dbip)
int db5_get_raw_internal_fp(struct db5_raw_internal *rip, FILE *fp)
int db_delrec(struct db_i *, struct directory *dp, int recnum)
void db_conversions(struct db_i *, int units)
void db_inmem(struct directory *dp, struct bu_external *ext, int flags, struct db_i *dbip)
int rt_db_get_internal5(struct rt_db_internal *ip, const struct directory *dp, const struct db_i *dbip, const mat_t mat, struct resource *resp)
int db_is_directory_non_empty(const struct db_i *dbip)
struct db_i * db_clone_dbi(struct db_i *dbip, long *client)
int db5_header_is_valid(const unsigned char *hp)
void db_alloc_directory_block(struct resource *resp)
unsigned char * db5_encode_length(unsigned char *cp, size_t val, int format)
int db_dircheck(struct db_i *dbip, struct bu_vls *ret_name, int noisy, struct directory ***headp)
int db5_type_descrip_from_codes(char **descrip, const int major, const int minor)
void db5_export_object3(struct bu_external *out, int dli, const char *name, const unsigned char hidden, const struct bu_external *attrib, const struct bu_external *body, int major, int minor, int a_zzz, int b_zzz)
int db_version_inmem(const struct db_i *dbip, const void *data, b_off_t data_size)
int db5_scan(struct db_i *dbip, void(*handler)(struct db_i *, const struct db5_raw_internal *, b_off_t addr, void *client_data), void *client_data)
size_t db5_type_sizeof_n_binu(const int minor)
size_t db_directory_size(const struct db_i *dbip)
int db_fwrite_ident(FILE *fp, const char *title, double local2mm)
void db_wrap_v4_external(struct bu_external *op, const char *name)
void int char int * length
Definition tig.h:180
#define b_off_t
Definition common.h:223
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition vmath.h:370
Definition vls.h:53
void * ptr
ptr to in-memory-only obj
Definition directory.h:67
Definition wdb.h:62
Definition db4.h:411
fundamental vector, matrix, quaternion math macros