Database4
[Database IO]

Collaboration diagram for Database4:


Files

file  db.h
 GED Database Format v4.
file  db_alloc.c
file  db_comb.c
file  db_flags.c
file  db_io.c
file  db_scan.c

Data Structures

union  record

Defines

#define DB_H   seen
#define NAMESIZE   16
#define NAMEMOVE(from, to)   (void)strncpy(to, from, NAMESIZE)
#define DB_MINREC   128
#define RECORD_DEFINED
#define DB_RECORD_NULL   ((union record *)0)
#define DB_ARGS(args)   ()
#define STAT_ROT   1
#define STAT_XLATE   2
#define STAT_PERSP   4
#define STAT_SCALE   8
#define DEBUG_PR(aaa, rrr)

Typedefs

typedef float dbfloat_t

Functions

void rt_fastf_float DB_ARGS ((fastf_t *ff, const dbfloat_t *fp, int n))
void rt_mat_dbmat DB_ARGS ((fastf_t *ff, const dbfloat_t *dbp))
void rt_dbmat_mat DB_ARGS ((dbfloat_t *dbp, const fastf_t *ff))
int db_alloc (register struct db_i *dbip, register struct directory *dp, int count)
int db_delrec (struct db_i *dbip, register struct directory *dp, int recnum)
int db_delete (struct db_i *dbip, struct directory *dp)
int db_zapper (struct db_i *dbip, struct directory *dp, int start)
int db_tree_nleaves (const union tree *tp)
rt_tree_arraydb_flatten_tree (struct rt_tree_array *rt_tree_array, union tree *tp, int op, int free, struct resource *resp)
int rt_comb_import4 (struct rt_db_internal *ip, const struct bu_external *ep, const mat_t matrix, const struct db_i *dbip, struct resource *resp)
int rt_comb_export4 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip, struct resource *resp)
void db_tree_flatten_describe (struct bu_vls *vls, const union tree *tp, int indented, int lvl, double mm2local, struct resource *resp)
void db_tree_describe (struct bu_vls *vls, const union tree *tp, int indented, int lvl, double mm2local)
void db_comb_describe (struct bu_vls *str, const struct rt_comb_internal *comb, int verbose, double mm2local, struct resource *resp)
void rt_comb_ifree (struct rt_db_internal *ip, struct resource *resp)
int rt_comb_describe (struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local, struct resource *resp, struct db_i *db_i)
void db_wrap_v4_external (struct bu_external *op, const char *name)
int db_ck_left_heavy_tree (const union tree *tp, int no_unions)
int db_ck_v4gift_tree (const union tree *tp)
treedb_mkbool_tree (struct rt_tree_array *rt_tree_array, int howfar, struct resource *resp)
treedb_mkgift_tree (struct rt_tree_array *trees, int subtreecount, struct resource *resp)
int db_flags_internal (const struct rt_db_internal *intern)
int db_flags_raw_internal (const struct db5_raw_internal *raw)
int db_read (const struct db_i *dbip, genptr_t addr, long int count, long int offset)
recorddb_getmrec (const struct db_i *dbip, const struct directory *dp)
int db_get (const struct db_i *dbip, const struct directory *dp, union record *where, int offset, int len)
int db_write (struct db_i *dbip, const genptr_t addr, long int count, long int offset)
int db_put (struct db_i *dbip, const struct directory *dp, union record *where, int offset, int len)
int db_get_external (register struct bu_external *ep, const struct directory *dp, const struct db_i *dbip)
int db_put_external (struct bu_external *ep, struct directory *dp, struct db_i *dbip)
int db_fwrite_external (FILE *fp, const char *name, struct bu_external *ep)
void db_free_external (register struct bu_external *ep)
int db_scan (register struct db_i *dbip, int(*handler)(struct db_i *, const char *, long int, int, int, genptr_t), int do_old_matter, genptr_t client_data)
int db_update_ident (struct db_i *dbip, const char *new_title, double local2mm)
int db_fwrite_ident (FILE *fp, const char *title, double local2mm)
void db_conversions (struct db_i *dbip, int local)
int db_v4_get_units_code (const char *str)

Define Documentation

#define DB_H   seen
 

Definition at line 75 of file db.h.

#define NAMESIZE   16
 

Definition at line 77 of file db.h.

Referenced by db_diradd(), rt_comb_export4(), rt_dsp_export(), rt_ebm_export(), rt_hf_export(), rt_submodel_export(), rt_vol_export(), and wdb_move_all_cmd().

#define NAMEMOVE from,
to   )     (void)strncpy(to, from, NAMESIZE)
 

Definition at line 90 of file db.h.

Referenced by db_wrap_v4_external().

#define DB_MINREC   128
 

Definition at line 92 of file db.h.

#define RECORD_DEFINED
 

Definition at line 95 of file db.h.

#define DB_RECORD_NULL   ((union record *)0)
 

Definition at line 451 of file db.h.

#define DB_ARGS args   )     ()
 

Definition at line 462 of file db.h.

#define STAT_ROT   1
 

Definition at line 71 of file db_comb.c.

Referenced by db_tree_describe(), and db_tree_flatten_describe().

#define STAT_XLATE   2
 

Definition at line 72 of file db_comb.c.

Referenced by db_tree_describe(), and db_tree_flatten_describe().

#define STAT_PERSP   4
 

Definition at line 73 of file db_comb.c.

Referenced by db_tree_describe(), and db_tree_flatten_describe().

#define STAT_SCALE   8
 

Definition at line 74 of file db_comb.c.

Referenced by db_tree_describe(), and db_tree_flatten_describe().

#define DEBUG_PR aaa,
rrr   ) 
 

Value:

{\
        if(RT_G_DEBUG&DEBUG_DB) bu_log("db_scan x%x %c (0%o)\n", \
                aaa,rrr.u_id,rrr.u_id ); }

Definition at line 63 of file db_scan.c.

Referenced by db_scan().


Typedef Documentation

typedef float dbfloat_t
 

Definition at line 87 of file db.h.


Function Documentation

void rt_fastf_float DB_ARGS (fastf_t *ff, const dbfloat_t *fp, int n)   ) 
 

void rt_mat_dbmat DB_ARGS (fastf_t *ff, const dbfloat_t *dbp)   ) 
 

void rt_dbmat_mat DB_ARGS (dbfloat_t *dbp, const fastf_t *ff)   ) 
 

int db_alloc register struct db_i dbip,
register struct directory dp,
int  count
 

D B _ A L L O C

Find a block of database storage of "count" granules.

Returns - 0 OK -1 failure

Definition at line 75 of file db_alloc.c.

References bu_log(), bu_malloc(), bu_realloc(), db_get(), db_zapper(), DEBUG_DB, ID_FREE, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_G_DEBUG, rt_memalloc(), and record::u_id.

Here is the call graph for this function:

int db_delrec struct db_i dbip,
register struct directory dp,
int  recnum
 

D B _ D E L R E C

Delete a specific record from database entry No longer supported.

Definition at line 138 of file db_alloc.c.

References bu_log(), DEBUG_DB, RT_CK_DBI, RT_CK_DIR, and RT_G_DEBUG.

Here is the call graph for this function:

int db_delete struct db_i dbip,
struct directory dp
 

D B _ D E L E T E

Delete the indicated database record(s). Arrange to write "free storage" database markers in it's place, positively erasing what had been there before.

Definition at line 158 of file db_alloc.c.

References bu_bomb(), bu_free(), bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db5_write_free(), db_zapper(), db_i::dbi_freep, db_i::dbi_version, DEBUG_DB, record::i, NULL, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_G_DEBUG, and rt_memfree().

Referenced by db_put_external(), and wdb_kill_cmd().

Here is the call graph for this function:

int db_zapper struct db_i dbip,
struct directory dp,
int  start
 

D B _ Z A P P E R

Using a single call to db_put(), write multiple zeroed records out, all with u_id field set to ID_FREE. This will zap all records from "start" to the end of this entry.

Returns: -1 on error 0 on success (from db_put())

Definition at line 203 of file db_alloc.c.

References BU_ASSERT_LONG, bu_bomb(), bu_free(), bu_log(), bu_malloc(), bzero, directory::d_flags, directory::d_len, directory::d_namep, db_put(), db_i::dbi_read_only, db_i::dbi_version, DEBUG_DB, record::i, ID_FREE, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_G_DEBUG, and record::u_id.

Referenced by db_alloc(), and db_delete().

Here is the call graph for this function:

int db_tree_nleaves const union tree tp  ) 
 

D B _ T R E E _ N L E A V E S

Return count of number of leaf nodes in this tree.

Definition at line 113 of file db_comb.c.

References bu_log(), db_tree_nleaves(), OP_DB_LEAF, OP_GUARD, OP_INTERSECT, OP_NOP, OP_NOT, OP_REGION, OP_SOLID, OP_SUBTRACT, OP_UNION, OP_XNOP, OP_XOR, rt_bomb(), RT_CK_TREE, tree::tree_node::tb_left, tree::tree_node::tb_right, tree::tr_b, and TREE_NULL.

Referenced by db_tree_flatten_describe(), db_tree_nleaves(), rt_comb_export4(), and wdb_combadd().

Here is the call graph for this function:

struct rt_tree_array* db_flatten_tree struct rt_tree_array rt_tree_array,
union tree tp,
int  op,
int  free,
struct resource resp
 

D B _ F L A T T E N _ T R E E

Take a binary tree in "V4-ready" layout (non-unions pushed below unions, left-heavy), and flatten it into an array layout, ready for conversion back to the GIFT-inspired V4 database format.

This is done using the db_non_union_push() routine.

If argument 'free' is non-zero, then the non-leaf nodes are freed along the way, to prevent memory leaks. In this case, the caller's copy of 'tp' will be invalid upon return.

When invoked at the very top of the tree, the op argument must be OP_UNION.

Definition at line 166 of file db_comb.c.

References bu_bomb(), bu_log(), db_flatten_tree(), NULL, OP_DB_LEAF, OP_INTERSECT, OP_SUBTRACT, OP_UNION, RT_CK_RESOURCE, RT_CK_TREE, RT_FREE_TREE, tree::tree_node::tb_left, tree::tree_node::tb_right, rt_tree_array::tl_op, rt_tree_array::tl_tree, tree::tr_b, and TREE_NULL.

Referenced by db_flatten_tree(), db_tree_flatten_describe(), rt_comb_export4(), and wdb_combadd().

Here is the call graph for this function:

int rt_comb_import4 struct rt_db_internal ip,
const struct bu_external ep,
const mat_t  matrix,
const struct db_i dbip,
struct resource resp
 

R T _ C O M B _ I M P O R T 4

Import a combination record from a V4 database into internal form.

Definition at line 211 of file db_comb.c.

References bu_calloc(), BU_CK_EXTERNAL, bu_free(), bu_log(), bu_external::ext_buf, bu_external::ext_nbytes, ID_COMB, ID_MEMB, NULL, and record::u_id.

Here is the call graph for this function:

int rt_comb_export4 struct bu_external ep,
const struct rt_db_internal ip,
double  local2mm,
const struct db_i dbip,
struct resource resp
 

R T _ C O M B _ E X P O R T 4

Definition at line 421 of file db_comb.c.

References rt_comb_internal::aircode, bn_mat_identity, BU_ASSERT_LONG, bu_bomb(), bu_calloc(), bu_free(), BU_INIT_EXTERNAL, bu_log(), bu_shader_to_key_eq(), bu_vls_addr(), bu_vls_free(), bu_vls_init(), bu_vls_strlen(), record::c, record::combination::c_aircode, record::combination::c_flags, record::combination::c_inherit, record::combination::c_los, record::combination::c_material, record::combination::c_matname, record::combination::c_matparm, record::combination::c_override, record::combination::c_regionid, record::combination::c_rgb, db_ck_v4gift_tree(), db_flatten_tree(), db_free_tree(), db_non_union_push(), db_tree_nleaves(), DBV4_NON_REGION, DBV4_REGION, DBV4_REGION_FASTGEN_PLATE, DBV4_REGION_FASTGEN_VOLUME, bu_external::ext_buf, bu_external::ext_nbytes, rt_comb_internal::GIFTmater, ID_COMB, ID_COMBINATION, ID_MEMB, rt_db_internal::idb_ptr, rt_comb_internal::inherit, rt_comb_internal::is_fastgen, rt_comb_internal::los, M, record::M, record::member::m_relation, NAMESIZE, NULL, OP_DB_LEAF, OP_INTERSECT, OP_SUBTRACT, OP_UNION, REGION_FASTGEN_PLATE, REGION_FASTGEN_VOLUME, rt_comb_internal::region_flag, rt_comb_internal::region_id, REGION_NON_FASTGEN, rt_comb_internal::rgb, rt_comb_internal::rgb_valid, RT_CK_COMB, RT_CK_DB_INTERNAL, RT_CK_RESOURCE, RT_CK_TREE, rt_dbmat_mat(), rt_pr_tree(), rt_comb_internal::shader, tree::tree_db_leaf::tl_mat, tree::tree_db_leaf::tl_name, rt_tree_array::tl_tree, tree::tr_l, rt_comb_internal::tree, TREE_NULL, and record::u_id.

Here is the call graph for this function:

void db_tree_flatten_describe struct bu_vls vls,
const union tree tp,
int  indented,
int  lvl,
double  mm2local,
struct resource resp
 

D B _ T R E E _ F L A T T E N _ D E S C R I B E

Produce a GIFT-compatible listing, one "member" per line, regardless of the structure of the tree we've been given.

Definition at line 595 of file db_comb.c.

References bn_ae_vec(), bn_mat_identity, BU_ASSERT_LONG, BU_ASSERT_PTR, bu_bomb(), bu_calloc(), BU_CK_VLS, bu_vls_printf(), bu_vls_spaces(), bu_vls_strcat(), db_ck_v4gift_tree(), db_dup_subtree(), db_flatten_tree(), db_non_union_push(), db_tree_nleaves(), MDX, MDY, MDZ, NULL, OP_DB_LEAF, OP_INTERSECT, OP_NOP, OP_SUBTRACT, OP_UNION, RT_CK_RESOURCE, RT_CK_TREE, STAT_PERSP, STAT_ROT, STAT_SCALE, STAT_XLATE, status, rt_tree_array::tl_op, rt_tree_array::tl_tree, and void().

Referenced by db_comb_describe().

Here is the call graph for this function:

void db_tree_describe struct bu_vls vls,
const union tree tp,
int  indented,
int  lvl,
double  mm2local
 

D B _ T R E E _ D E S C R I B E

Definition at line 711 of file db_comb.c.

References bn_ae_vec(), bn_mat_identity, bu_bomb(), BU_CK_VLS, bu_log(), bu_vls_printf(), bu_vls_spaces(), bu_vls_strcat(), db_tree_describe(), MDX, MDY, MDZ, OP_DB_LEAF, OP_GUARD, OP_INTERSECT, OP_NOP, OP_NOT, OP_SUBTRACT, OP_UNION, OP_XNOP, OP_XOR, RT_CK_TREE, STAT_PERSP, STAT_ROT, STAT_SCALE, STAT_XLATE, status, tree::tree_node::tb_left, tree::tree_node::tb_right, tree::tree_db_leaf::tl_mat, tree::tree_db_leaf::tl_name, tree::tr_b, and tree::tr_l.

Referenced by db_tree_describe().

Here is the call graph for this function:

void db_comb_describe struct bu_vls str,
const struct rt_comb_internal comb,
int  verbose,
double  mm2local,
struct resource resp
 

D B _ C O M B _ D E S C R I B E

Definition at line 817 of file db_comb.c.

References rt_comb_internal::aircode, bu_vls_addr(), bu_vls_printf(), bu_vls_strcat(), bu_vls_strlen(), db_tree_flatten_describe(), rt_comb_internal::GIFTmater, rt_comb_internal::inherit, rt_comb_internal::is_fastgen, rt_comb_internal::los, REGION_FASTGEN_PLATE, REGION_FASTGEN_VOLUME, rt_comb_internal::region_flag, rt_comb_internal::region_id, rt_comb_internal::rgb, rt_comb_internal::rgb_valid, RT_CK_COMB, RT_CK_RESOURCE, rt_pr_tree_vls(), rt_comb_internal::shader, and rt_comb_internal::tree.

Referenced by rt_comb_describe().

Here is the call graph for this function:

void rt_comb_ifree struct rt_db_internal ip,
struct resource resp
 

R T _ C O M B _ I F R E E

Free the storage associated with the rt_db_internal version of this combination.

Definition at line 881 of file db_comb.c.

References bu_free(), bu_vls_free(), db_free_tree(), GENPTR_NULL, rt_db_internal::idb_ptr, rt_comb_internal::magic, rt_comb_internal::material, NULL, RT_CK_DB_INTERNAL, RT_CK_RESOURCE, rt_comb_internal::shader, and rt_comb_internal::tree.

Referenced by wdb_showmats_cmd(), and wdb_whatid_cmd().

Here is the call graph for this function:

int rt_comb_describe struct bu_vls str,
const struct rt_db_internal ip,
int  verbose,
double  mm2local,
struct resource resp,
struct db_i db_i
 

R T _ C O M B _ D E S C R I B E

rt_functab[ID_COMBINATION].ft_describe() method

Definition at line 910 of file db_comb.c.

References db_comb_describe(), rt_db_internal::idb_ptr, RT_CK_COMB, RT_CK_DB_INTERNAL, and RT_CK_RESOURCE.

Here is the call graph for this function:

void db_wrap_v4_external struct bu_external op,
const char *  name
 

D B _ W R A P _ V 4 _ E X T E R N A L

As the v4 database does not really have the notion of "wrapping", this function writes the object name into the proper place (a standard location in all granules).

Definition at line 940 of file db_comb.c.

References BU_CK_EXTERNAL, bu_external::ext_buf, NAMEMOVE, record::s, and record::solidrec::s_name.

Referenced by db_fwrite_external(), db_put_external(), nmg_stash_model_to_file(), wdb_export_external(), and wdb_put_internal().

int db_ck_left_heavy_tree const union tree tp,
int  no_unions
 

D B _ C K _ L E F T _ H E A V Y _ T R E E

Support routine for db_ck_v4gift_tree(). Ensure that the tree below 'tp' is left-heavy, i.e. that there are nothing but solids on the right side of any binary operations.

Returns - -1 ERROR 0 OK

Definition at line 964 of file db_comb.c.

References bu_bomb(), bu_log(), db_ck_left_heavy_tree(), OP_DB_LEAF, OP_INTERSECT, OP_SUBTRACT, OP_UNION, OP_XOR, RT_CK_TREE, tree::tree_node::tb_left, tree::tree_node::tb_right, and tree::tr_b.

Referenced by db_ck_left_heavy_tree(), and db_ck_v4gift_tree().

Here is the call graph for this function:

int db_ck_v4gift_tree const union tree tp  ) 
 

D B _ C K _ V 4 G I F T _ T R E E

Look a gift-tree in the mouth. Ensure that this boolean tree conforms to the GIFT convention that union operations must bind the loosest. There are two stages to this check: 1) Ensure that if unions are present they are all at the root of tree, 2) Ensure non-union children of union nodes are all left-heavy (nothing but solid nodes permitted on rhs of binary operators).

Returns - -1 ERROR 0 OK

Definition at line 1008 of file db_comb.c.

References bu_bomb(), bu_log(), db_ck_left_heavy_tree(), db_ck_v4gift_tree(), OP_DB_LEAF, OP_INTERSECT, OP_SUBTRACT, OP_UNION, OP_XOR, RT_CK_TREE, tree::tree_node::tb_left, tree::tree_node::tb_right, and tree::tr_b.

Referenced by db_ck_v4gift_tree(), db_tree_flatten_describe(), main(), rt_comb_export4(), and wdb_combadd().

Here is the call graph for this function:

union tree* db_mkbool_tree struct rt_tree_array rt_tree_array,
int  howfar,
struct resource resp
 

D B _ M K B O O L _ T R E E

Given a rt_tree_array array, build a tree of "union tree" nodes appropriately connected together. Every element of the rt_tree_array array used is replaced with a TREE_NULL. Elements which are already TREE_NULL are ignored. Returns a pointer to the top of the tree.

Definition at line 1044 of file db_comb.c.

References RT_CK_RESOURCE, rt_tree_array::tl_tree, and TREE_NULL.

Referenced by db_mkgift_tree().

union tree* db_mkgift_tree struct rt_tree_array trees,
int  subtreecount,
struct resource resp
 

D B _ M K G I F T _ T R E E

Definition at line 1109 of file db_comb.c.

References bu_log(), db_mkbool_tree(), DEBUG_TREEWALK, OP_UNION, RT_CK_RESOURCE, RT_G_DEBUG, rt_pr_tree(), rt_tree_array::tl_op, and rt_tree_array::tl_tree.

Referenced by wdb_combadd().

Here is the call graph for this function:

int db_flags_internal const struct rt_db_internal intern  ) 
 

D B _ F L A G S _ I N T E R N A L

Given the internal form of a database object, return the appropriate 'flags' word for stashing in the in-memory directory of objects.

Definition at line 64 of file db_flags.c.

References DIR_COMB, DIR_REGION, DIR_SOLID, ID_COMBINATION, rt_db_internal::idb_ptr, rt_comb_internal::region_flag, RT_CK_COMB, and RT_CK_DB_INTERNAL.

Referenced by nmg_stash_model_to_file(), and wdb_put_internal().

int db_flags_raw_internal const struct db5_raw_internal raw  ) 
 

d b _ f l a g s _ r a w _ i n t e r n a l

Given a database object in "raw" internal form, return the appropriate 'flags' word for stashing in the in-memory directory of objects.

Definition at line 91 of file db_flags.c.

References db5_raw_internal::attributes, bu_avs_get(), bu_avs_init_empty(), db5_import_attributes(), DB5_MAJORTYPE_BRLCAD, DB5_MINORTYPE_BRLCAD_COMBINATION, DIR_COMB, DIR_NON_GEOM, DIR_REGION, DIR_SOLID, bu_external::ext_buf, db5_raw_internal::major_type, db5_raw_internal::minor_type, and NULL.

Here is the call graph for this function:

int db_read const struct db_i dbip,
genptr_t  addr,
long int  count,
long int  offset
 

D B _ R E A D

Reads 'count' bytes at file offset 'offset' into buffer at 'addr'. A wrapper for the UNIX read() sys-call that takes into account syscall semaphores, stdio-only machines, and in-memory buffering.

Returns - 0 OK -1 failure

Definition at line 82 of file db_io.c.

References bu_bomb(), bu_log(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), db_i::dbi_eof, db_i::dbi_fd, db_i::dbi_filename, db_i::dbi_fp, db_i::dbi_inmem, DEBUG_DB, perror(), RT_CK_DBI, and RT_G_DEBUG.

Referenced by db_get(), db_get_external(), and db_getmrec().

Here is the call graph for this function:

union record* db_getmrec const struct db_i dbip,
const struct directory dp
 

D B _ G E T M R E C

Retrieve all records in the database pertaining to an object, and place them in malloc()'ed storage, which the caller is responsible for free()'ing.

This loads the combination into a local record buffer. This is in external v4 format.

Returns - union record * OK (union record *)0 failure

Definition at line 150 of file db_io.c.

References bcopy, bu_free(), bu_log(), bu_malloc(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_read(), db_i::dbi_version, DEBUG_DB, NULL, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, and RT_G_DEBUG.

Referenced by db_functree(), and db_preorder_traverse().

Here is the call graph for this function:

int db_get const struct db_i dbip,
const struct directory dp,
union record where,
int  offset,
int  len
 

D B _ G E T

Retrieve 'len' records from the database, "offset" granules into this entry.

Returns - 0 OK -1 failure

Definition at line 196 of file db_io.c.

References bcopy, bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_read(), DEBUG_DB, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_G_DEBUG, and record::u_id.

Here is the call graph for this function:

int db_write struct db_i dbip,
const genptr_t  addr,
long int  count,
long int  offset
 

D B _ W R I T E

Writes 'count' bytes into at file offset 'offset' from buffer at 'addr'. A wrapper for the UNIX write() sys-call that takes into account syscall semaphores, stdio-only machines, and in-memory buffering.

Returns - 0 OK -1 failure

Definition at line 243 of file db_io.c.

References bu_log(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), db_i::dbi_fd, db_i::dbi_filename, db_i::dbi_fp, db_i::dbi_inmem, db_i::dbi_read_only, DEBUG_DB, perror(), RT_CK_DBI, RT_G_DEBUG, and void().

Here is the call graph for this function:

int db_put struct db_i dbip,
const struct directory dp,
union record where,
int  offset,
int  len
 

D B _ P U T

Store 'len' records to the database, "offset" granules into this entry.

Returns - 0 OK -1 failure

Definition at line 295 of file db_io.c.

References bcopy, bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_write(), db_i::dbi_filename, db_i::dbi_read_only, DEBUG_DB, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, and RT_G_DEBUG.

Here is the call graph for this function:

int db_get_external register struct bu_external ep,
const struct directory dp,
const struct db_i dbip
 

D B _ G E T _ E X T E R N A L

Obtains a object from the database, leaving it in external (on-disk) format. The bu_external structure represented by 'ep' is initialized here, the caller need not pre-initialize it. On error, 'ep' is left un-initialized and need not be freed, to simplify error recovery. On success, the caller is responsible for calling bu_free_external(ep);

Returns - -1 error 0 success

Definition at line 346 of file db_io.c.

References bcopy, bu_free(), BU_INIT_EXTERNAL, bu_log(), bu_malloc(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_read(), db_i::dbi_version, DEBUG_DB, NULL, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, and RT_G_DEBUG.

Here is the call graph for this function:

int db_put_external struct bu_external ep,
struct directory dp,
struct db_i dbip
 

D B _ P U T _ E X T E R N A L

Given that caller already has an external representation of the database object, update it to have a new name (taken from dp->d_namep) in that external representation, and write the new object into the database, obtaining different storage if the size has changed.

Caller is responsible for freeing memory of external representation, using bu_free_external().

This routine is used to efficiently support MGED's "cp" and "keep" commands, which don't need to import objects just to rename and copy them.

Returns - -1 error 0 success

Definition at line 399 of file db_io.c.

References bcopy, bu_bomb(), BU_CK_EXTERNAL, bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_alloc(), db_delete(), db_put_external5(), db_wrap_v4_external(), db_write(), db_i::dbi_filename, db_i::dbi_read_only, db_i::dbi_version, DEBUG_DB, bu_external::ext_buf, bu_external::ext_nbytes, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, and RT_G_DEBUG.

Referenced by db5_update_ident(), rt_db_put_internal(), wdb_copy_cmd(), and wdb_export_external().

Here is the call graph for this function:

int db_fwrite_external FILE *  fp,
const char *  name,
struct bu_external ep
 

D B _ F W R I T E _ E X T E R N A L

Add name from dp->d_namep to external representation of solid, and write it into a file.

Caller is responsible for freeing memory of external representation, using bu_free_external().

The 'name' field of the external representation is modified to contain the desired name.

Returns - <0 error 0 OK

NOTE: Callers of this should be using wdb_export_external() instead.

Definition at line 474 of file db_io.c.

References BU_CK_EXTERNAL, bu_fwrite_external(), bu_log(), db_wrap_v4_external(), DEBUG_DB, and RT_G_DEBUG.

Here is the call graph for this function:

void db_free_external register struct bu_external ep  ) 
 

D B _ F R E E _ E X T E R N A L

XXX This is a leftover. You should call bu_free_external() instead.

Definition at line 496 of file db_io.c.

References BU_CK_EXTERNAL, and bu_free_external().

Here is the call graph for this function:

int db_scan register struct db_i dbip,
int(*)(struct db_i *, const char *, long int, int, int, genptr_t handler,
int  do_old_matter,
genptr_t  client_data
 

D B _ S C A N

This routine sequentially reads through the model database file and builds a directory of the object names, to allow rapid named access to objects.

Note that some multi-record database items include length fields. These length fields are not used here. Instead, the sizes of multi-record items are determined by reading ahead and computing the actual size. This prevents difficulties arising from external "adjustment" of the number of records without corresponding adjustment of the length fields. In the future, these length fields will be phased out.

The handler will be called with a variety of args. The handler is responsible for handling name strings of exactly NAMESIZE chars. The most common example of such a function is db_diradd().

Note that the handler may do I/O, including repositioning the file pointer, so this must be taken into account.

Returns - 0 Success -1 Fatal Error

Definition at line 95 of file db_scan.c.

References bu_glong(), bu_log(), bu_strdup, db_conversions(), DB_SS_NGRAN, DBID_ARBN, DBID_BOT, DBID_CLINE, DBID_EXTR, DBID_NMG, DBID_PARTICLE, DBID_PIPE, DBID_SKETCH, DBID_STRSOL, DBV4_NON_REGION, DBV4_REGION, DBV4_REGION_FASTGEN_PLATE, DBV4_REGION_FASTGEN_VOLUME, DEBUG_DB, DEBUG_PR, DIR_COMB, DIR_REGION, DIR_SOLID, ID_ARS_A, ID_ARS_B, ID_BSOLID, ID_BSURF, ID_COMB, ID_FREE, ID_IDENT, ID_MATERIAL, ID_MEMB, ID_P_DATA, ID_P_HEAD, ID_SOLID, ID_VERSION, RT_CK_DBI, rt_color_addrec(), RT_G_DEBUG, rt_memfree(), and void().

Here is the call graph for this function:

int db_update_ident struct db_i dbip,
const char *  new_title,
double  local2mm
 

D B _ U P D A T E _ I D E N T

Update the existing v4 IDENT record with new title and units. To permit using db_get and db_put, a custom directory entry is crafted.

Note: Special care is required, because the "title" arg may actually be passed in as dbip->dbi_title.

Definition at line 374 of file db_scan.c.

References BU_ASSERT_LONG, bu_free(), bu_log(), bu_strdup, bu_units_string(), directory::d_flags, directory::d_len, directory::d_magic, db5_update_ident(), db_get(), db_put(), db_v4_get_units_code(), db_i::dbi_read_only, db_i::dbi_title, db_i::dbi_version, DEBUG_DB, record::i, record::ident::i_title, record::ident::i_units, ID_IDENT, ID_MM_UNIT, RT_CK_DBI, RT_DIR_MAGIC, RT_DIR_SET_NAMEP, RT_G_DEBUG, record::u_id, and void().

Referenced by wdb_title_cmd(), and wdb_units_cmd().

Here is the call graph for this function:

int db_fwrite_ident FILE *  fp,
const char *  title,
double  local2mm
 

D B _ F W R I T E _ I D E N T

Fwrite an IDENT record with given title and editing scale. Attempts to map the editing scale into a v4 database unit as best it can. No harm done if it doesn't map.

This should be called by db_create() only. All others should call db_update_ident().

Returns - 0 Success -1 Fatal Error

Definition at line 443 of file db_scan.c.

References bu_log(), bu_units_string(), bzero, db_v4_get_units_code(), DEBUG_DB, ID_IDENT, ID_VERSION, RT_G_DEBUG, and void().

Referenced by db_create().

Here is the call graph for this function:

void db_conversions struct db_i dbip,
int  local
 

D B _ C O N V E R S I O N S

Initialize conversion factors given the v4 database unit

Definition at line 470 of file db_scan.c.

References db_i::dbi_base2local, db_i::dbi_local2base, ID_CM_UNIT, ID_FT_UNIT, ID_IN_UNIT, ID_KM_UNIT, ID_M_UNIT, ID_MI_UNIT, ID_MM_UNIT, ID_NO_UNIT, ID_UM_UNIT, ID_YD_UNIT, and RT_CK_DBI.

Referenced by db_scan().

int db_v4_get_units_code const char *  str  ) 
 

D B _ V 4 _ G E T _ U N I T S _ C O D E

Given a string, return the V4 database code representing the user's preferred editing units. The v4 database format does not have many choices.

Returns - -1 Not a legal V4 database code # The V4 database code number

Definition at line 548 of file db_scan.c.

References ID_CM_UNIT, ID_FT_UNIT, ID_IN_UNIT, ID_KM_UNIT, ID_M_UNIT, ID_MI_UNIT, ID_MM_UNIT, ID_NO_UNIT, ID_UM_UNIT, and ID_YD_UNIT.

Referenced by db_fwrite_ident(), and db_update_ident().


Generated on Mon Sep 18 01:25:42 2006 for BRL-CAD by  doxygen 1.4.6