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 * Reads 'count' bytes at file offset 'offset' into buffer at 'addr'.
412 * A wrapper for the UNIX read() sys-call that takes into account
413 * syscall semaphores, stdio-only machines, and in-memory buffering.
414 *
415 * Returns -
416 * 0 OK
417 * -1 FAILURE
418 */
419RT_EXPORT extern int
420db_read(const struct db_i *dbip,
421 void *addr,
422 size_t count,
423 b_off_t offset);
424
425/**
426 * Add name from dp->d_namep to external representation of solid, and
427 * write it into a file.
428 *
429 * Caller is responsible for freeing memory of external
430 * representation, using bu_free_external().
431 *
432 * The 'name' field of the external representation is modified to
433 * contain the desired name. The 'ep' parameter cannot be const.
434 *
435 * THIS ROUTINE ONLY SUPPORTS WRITING V4 GEOMETRY.
436 *
437 * Returns -
438 * <0 error
439 * 0 OK
440 *
441 * NOTE: Callers of this should be using wdb_export_external()
442 * instead.
443 */
444RT_EXPORT extern int db_fwrite_external(FILE *fp,
445 const char *name,
446 struct bu_external *ep);
447
448/* malloc & read records */
449
450/**
451 * Retrieve all records in the database pertaining to an object, and
452 * place them in malloc()'ed storage, which the caller is responsible
453 * for free()'ing.
454 *
455 * This loads the combination into a local record buffer. This is in
456 * external v4 format.
457 *
458 * Returns -
459 * union record * - OK
460 * (union record *)0 - FAILURE
461 */
462RT_EXPORT extern union record *db_getmrec(const struct db_i *,
463 const struct directory *dp);
464/* get several records from db */
465
466/**
467 * Retrieve 'len' records from the database, "offset" granules into
468 * this entry.
469 *
470 * Returns -
471 * 0 OK
472 * -1 FAILURE
473 */
474RT_EXPORT extern int db_get(const struct db_i *,
475 const struct directory *dp,
476 union record *where,
477 b_off_t offset,
478 size_t len);
479/* put several records into db */
480
481/**
482 * Store 'len' records to the database, "offset" granules into this
483 * entry.
484 *
485 * Returns:
486 * 0 OK
487 * non-0 FAILURE
488 */
489RT_EXPORT extern int db_put(struct db_i *,
490 const struct directory *dp,
491 union record *where,
492 b_off_t offset, size_t len);
493
494/**
495 * Obtains a object from the database, leaving it in external
496 * (on-disk) format.
497 *
498 * The bu_external structure represented by 'ep' is initialized here,
499 * the caller need not pre-initialize it. On error, 'ep' is left
500 * un-initialized and need not be freed, to simplify error recovery.
501 * On success, the caller is responsible for calling
502 * bu_free_external(ep);
503 *
504 * Returns -
505 * -1 error
506 * 0 success
507 */
509 const struct directory *dp,
510 const struct db_i *dbip);
511
512/**
513 * Given that caller already has an external representation of the
514 * database object, update it to have a new name (taken from
515 * dp->d_namep) in that external representation, and write the new
516 * object into the database, obtaining different storage if the size
517 * has changed.
518 *
519 * Caller is responsible for freeing memory of external
520 * representation, using bu_free_external().
521 *
522 * This routine is used to efficiently support MGED's "cp" and "keep"
523 * commands, which don't need to import objects just to rename and
524 * copy them.
525 *
526 * Returns -
527 * <0 error
528 * 0 success
529 */
531 struct directory *dp,
532 struct db_i *dbip);
533
534/* db_scan.c */
535/* read db (to build directory) */
536RT_EXPORT extern int db_scan(struct db_i *,
537 int (*handler)(struct db_i *,
538 const char *name,
540 size_t nrec,
541 int flags,
542 void *client_data),
543 int do_old_matter,
544 void *client_data);
545/* update db unit conversions */
546#define db_ident(a, b, c) +++error+++
547
548/**
549 * Update the _GLOBAL object, which in v5 serves the place of the
550 * "ident" header record in v4 as the place to stash global
551 * information. Since every database will have one of these things,
552 * it's no problem to update it.
553 *
554 * Returns -
555 * 0 Success
556 * -1 Fatal Error
557 */
558RT_EXPORT extern int db_update_ident(struct db_i *dbip,
559 const char *title,
560 double local2mm);
561
562/**
563 * Create a header for a v5 database.
564 *
565 * This routine has the same calling sequence as db_fwrite_ident()
566 * which makes a v4 database header.
567 *
568 * In the v5 database, two database objects must be created to match
569 * the semantics of what was in the v4 header:
570 *
571 * First, a database header object.
572 *
573 * Second, create a specially named attribute-only object which
574 * contains the attributes "title=" and "units=" with the values of
575 * title and local2mm respectively.
576 *
577 * Note that the current working units are specified as a conversion
578 * factor to millimeters because database dimensional values are
579 * always stored as millimeters (mm). The units conversion factor
580 * only affects the display and conversion of input values. This
581 * helps prevent error accumulation and improves numerical stability
582 * when calculations are made.
583 *
584 * This routine should only be used by db_create(). Everyone else
585 * should use db5_update_ident().
586 *
587 * Returns -
588 * 0 Success
589 * -1 Fatal Error
590 */
591RT_EXPORT extern int db_fwrite_ident(FILE *fp,
592 const char *title,
593 double local2mm);
594
595/**
596 * Initialize conversion factors given the v4 database unit
597 */
598RT_EXPORT extern void db_conversions(struct db_i *,
599 int units);
600
601/**
602 * Given a string, return the V4 database code representing the user's
603 * preferred editing units. The v4 database format does not have many
604 * choices.
605 *
606 * Returns -
607 * -1 Not a legal V4 database code
608 * # The V4 database code number
609 */
610RT_EXPORT extern int db_v4_get_units_code(const char *str);
611
612/* db5_scan.c */
613
614/**
615 * A generic routine to determine the type of the database, (v4 or v5)
616 * and to invoke the appropriate db_scan()-like routine to build the
617 * in-memory directory.
618 *
619 * It is the caller's responsibility to close the database in case of
620 * error.
621 *
622 * Called from rt_dirbuild() and other places directly where a
623 * raytrace instance is not required.
624 *
625 * Returns -
626 * 0 OK
627 * -1 failure
628 */
629RT_EXPORT extern int db_dirbuild(struct db_i *dbip);
630RT_EXPORT extern int db_dirbuild_inmem(struct db_i *dbip, const void *data, b_off_t data_size);
631RT_EXPORT extern struct directory *db5_diradd(struct db_i *dbip,
632 const struct db5_raw_internal *rip,
634 void *client_data);
635
636/**
637 * Scan a v5 database, sending each object off to a handler.
638 *
639 * Returns -
640 * 0 Success
641 * -1 Fatal Error
642 */
643RT_EXPORT extern int db5_scan(struct db_i *dbip,
644 void (*handler)(struct db_i *,
645 const struct db5_raw_internal *,
647 void *client_data),
648 void *client_data);
649RT_EXPORT extern int db5_scan_inmem(struct db_i *dbip,
650 void (*handler)(struct db_i *,
651 const struct db5_raw_internal *,
653 void *client_data),
654 void *client_data,
655 const void *data,
657
658/**
659 * Obtain the database version for a given database instance.
660 *
661 * Returns 4 or 5 accordingly for v4 or v5 geometry database files.
662 * Returns -1 if dbip is invalid.
663 */
664RT_EXPORT extern int db_version(const struct db_i *dbip);
665RT_EXPORT extern int db_version_inmem(const struct db_i *dbip, const void *data, b_off_t data_size);
666
667
668/* db_corrupt.c */
669
670/**
671 * Detect whether a given geometry database file seems to be corrupt
672 * or invalid due to flipped endianness. Only relevant for v4
673 * geometry files that are binary-incompatible with the runtime
674 * platform.
675 *
676 * Returns true if flipping the endian type fixes all combination
677 * member matrices.
678 */
679RT_EXPORT extern int rt_db_flip_endian(struct db_i *dbip);
680
681
682/**
683 * Transmogrify an existing directory entry to be an in-memory-only
684 * one, stealing the external representation from 'ext'.
685 */
686RT_EXPORT extern void db_inmem(struct directory *dp,
687 struct bu_external *ext,
688 int flags,
689 struct db_i *dbip);
690
691/* db_lookup.c */
692
693/**
694 * Return the number of "struct directory" nodes in the given
695 * database.
696 */
697RT_EXPORT extern size_t db_directory_size(const struct db_i *dbip);
698
699/**
700 * For debugging, ensure that all the linked-lists for the directory
701 * structure are intact.
702 */
703RT_EXPORT extern void db_ck_directory(const struct db_i *dbip);
704
705/**
706 * Returns -
707 * 0 if the in-memory directory is empty
708 * 1 if the in-memory directory has entries,
709 * which implies that a db_scan() has already been performed.
710 */
711RT_EXPORT extern int db_is_directory_non_empty(const struct db_i *dbip);
712
713/**
714 * Returns a hash index for a given string that corresponds with the
715 * head of that string's hash chain.
716 */
717RT_EXPORT extern int db_dirhash(const char *str);
718
719/**
720 * This routine ensures that ret_name is not already in the
721 * directory. If it is, it tries a fixed number of times to modify
722 * ret_name before giving up. Note - most of the time, the hash for
723 * ret_name is computed once.
724 *
725 * Inputs -
726 * dbip database instance pointer
727 * ret_name the original name
728 * noisy to blather or not
729 *
730 * Outputs -
731 * ret_name the name to use
732 * headp pointer to the first (struct directory *) in the bucket
733 *
734 * Returns -
735 * 0 success
736 * <0 fail
737 */
738RT_EXPORT extern int db_dircheck(struct db_i *dbip,
739 struct bu_vls *ret_name,
740 int noisy,
741 struct directory ***headp);
742/* convert name to directory ptr */
743
744/**
745 * This routine takes a path or a name and returns the current directory
746 * pointer (if any) associated with the object.
747 *
748 * If given an object name, it will look up the object name in the directory
749 * table. If the name is present, a pointer to the directory struct element is
750 * returned, otherwise NULL is returned.
751 *
752 * If given a path, it will validate that the path is a valid path in the
753 * current database. If it is, a pointer to the current directory in the path
754 * (i.e. the leaf object on the path) is returned, otherwise NULL is returned.
755 *
756 * If noisy is non-zero, a print occurs, else only the return code indicates
757 * failure.
758 *
759 * Returns -
760 * struct directory if name is found
761 * RT_DIR_NULL on failure
762 */
763RT_EXPORT extern struct directory *db_lookup(const struct db_i *,
764 const char *name,
765 int noisy);
766
767/* add entry to directory */
768
769/**
770 * Add an entry to the directory. Try to make the regular path
771 * through the code as fast as possible, to speed up building the
772 * table of contents.
773 *
774 * dbip is a pointer to a valid/opened database instance
775 *
776 * name is the string name of the object being added
777 *
778 * laddr is the offset into the file to the object
779 *
780 * len is the length of the object, number of db granules used
781 *
782 * flags are defined in raytrace.h (RT_DIR_SOLID, RT_DIR_COMB, RT_DIR_REGION,
783 * RT_DIR_INMEM, etc.) for db version 5, ptr is the minor_type
784 * (non-null pointer to valid unsigned char code)
785 *
786 * an laddr of RT_DIR_PHONY_ADDR means that database storage has not
787 * been allocated yet.
788 */
789RT_EXPORT extern struct directory *db_diradd(struct db_i *,
790 const char *name,
792 size_t len,
793 int flags,
794 void *ptr);
795RT_EXPORT extern struct directory *db_diradd5(struct db_i *dbip,
796 const char *name,
798 unsigned char major_type,
799 unsigned char minor_type,
800 unsigned char name_hidden,
801 size_t object_length,
803
804/* delete entry from directory */
805
806/**
807 * Given a pointer to a directory entry, remove it from the linked
808 * list, and free the associated memory.
809 *
810 * It is the responsibility of the caller to have released whatever
811 * structures have been hung on the d_use_hd bu_list, first.
812 *
813 * Returns -
814 * 0 on success
815 * non-0 on failure
816 */
817RT_EXPORT extern int db_dirdelete(struct db_i *,
818 struct directory *dp);
819RT_EXPORT extern int db_fwrite_ident(FILE *,
820 const char *,
821 double);
822
823/**
824 * For debugging, print the entire contents of the database directory.
825 */
826RT_EXPORT extern void db_pr_dir(const struct db_i *dbip);
827
828/**
829 * Change the name string of a directory entry. Because of the
830 * hashing function, this takes some extra work.
831 *
832 * Returns -
833 * 0 on success
834 * non-0 on failure
835 */
836RT_EXPORT extern int db_rename(struct db_i *,
837 struct directory *,
838 const char *newname);
839
840
841/**
842 * Updates the d_nref fields (which count the number of times a given
843 * entry is referenced by a COMBination in the database).
844 *
845 */
846RT_EXPORT extern void db_update_nref(struct db_i *dbip,
847 struct resource *resp);
848
849
850/* db_flags.c */
851/**
852 * Given the internal form of a database object, return the
853 * appropriate 'flags' word for stashing in the in-memory directory of
854 * objects.
855 */
857
858
859/* XXX - should use in db5_diradd() */
860/**
861 * Given a database object in "raw" internal form, return the
862 * appropriate 'flags' word for stashing in the in-memory directory of
863 * objects.
864 */
866
867/* db_alloc.c */
868
869/* allocate "count" granules */
870RT_EXPORT extern int db_alloc(struct db_i *,
871 struct directory *dp,
872 size_t count);
873/* delete "recnum" from entry */
874RT_EXPORT extern int db_delrec(struct db_i *,
875 struct directory *dp,
876 int recnum);
877/* delete all granules assigned dp */
878RT_EXPORT extern int db_delete(struct db_i *,
879 struct directory *dp);
880/* write FREE records from 'start' */
881RT_EXPORT extern int db_zapper(struct db_i *,
882 struct directory *dp,
883 size_t start);
884
885/**
886 * This routine is called by the RT_GET_DIRECTORY macro when the
887 * freelist is exhausted. Rather than simply getting one additional
888 * structure, we get a whole batch, saving overhead.
889 */
891
892/**
893 * This routine is called by the GET_SEG macro when the freelist is
894 * exhausted. Rather than simply getting one additional structure, we
895 * get a whole batch, saving overhead. When this routine is called,
896 * the seg resource must already be locked. malloc() locking is done
897 * in bu_malloc.
898 */
899RT_EXPORT extern void rt_alloc_seg_block(struct resource *res);
900
901
902/**
903 * Read named MGED db, build toc.
904 */
905RT_EXPORT extern struct rt_i *rt_dirbuild(const char *filename, char *buf, int len);
906RT_EXPORT extern struct rt_i *rt_dirbuild_inmem(const void *data, b_off_t data_size, char *buf, int len);
907
908
909/* db5_types.c */
911 const int major);
912
914 const int major);
915
917 const int major,
918 const int minor);
919
921 const int major,
922 const int minor);
923
925 int *minor,
926 const char *tag);
927
929 int *minor,
930 const char *descrip);
931
932RT_EXPORT extern size_t db5_type_sizeof_h_binu(const int minor);
933
934RT_EXPORT extern size_t db5_type_sizeof_n_binu(const int minor);
935
937
938#endif /* RT_DB_IO_H */
939
940/*
941 * Local Variables:
942 * tab-width: 8
943 * mode: C
944 * indent-tabs-mode: t
945 * c-file-style: "stroustrup"
946 * End:
947 * ex: shiftwidth=4 tabstop=8
948 */
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_read(const struct db_i *dbip, void *addr, size_t count, b_off_t offset)
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:240
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