static char * matcher_get_col_cast( const p_mcol col, const char *s_type ) { char * res; size_t idx; uint32_t len = string_measure ( col->name, NULL ) + 4; len += string_measure ( s_type, NULL ); res = malloc( len ); if ( res == NULL ) return res; res[ 0 ] = '('; idx = string_copy_measure ( &(res[ 1 ]), len-1, s_type ); res[ idx + 1 ] = ')'; string_copy_measure ( &(res[ idx + 2 ]), len-(idx+2), col->name ); return res; }
/* Config * configure an existing path manager */ static rc_t SRAPathConfigValue ( const KConfig *kfg, const char *node_path, char *value, size_t value_size, const char *dflt ) { const KConfigNode *node; rc_t rc = KConfigOpenNodeRead ( kfg, & node, node_path ); if ( rc == 0 ) { size_t num_read, remaining; rc = KConfigNodeRead ( node, 0, value, value_size - 1, & num_read, & remaining ); if ( rc == 0 ) { if ( remaining != 0 ) rc = RC ( rcSRA, rcMgr, rcConstructing, rcString, rcExcessive ); else value [ num_read ] = 0; } KConfigNodeRelease ( node ); } if ( rc != 0 ) { if ( dflt != NULL && dflt [ 0 ] != 0 ) { size_t num_read = string_copy_measure ( value, value_size, dflt ); rc = 0; if ( num_read == value_size ) rc = RC ( rcSRA, rcMgr, rcConstructing, rcString, rcExcessive ); } else value[0] = 0; } return rc; }
static void check_env ( const KConfig *self, char *path, size_t path_size ) { size_t num_read; const char *home; const KConfigNode *home_node; /* Check to see if home node exists */ rc_t rc = KConfigOpenNodeRead ( self, &home_node, "HOME" ); if ( home_node == NULL ) { /* just grab the HOME env variable */ home = getenv ( "HOME" ); if ( home != NULL ) { num_read = string_copy_measure ( path, path_size, home ); if ( num_read >= path_size ) path [ 0 ] = 0; } } else { /* if it exists check for a path */ rc = KConfigNodeRead ( home_node, 0, path, path_size, &num_read, NULL ); if ( rc != 0 ) { home = getenv ( "HOME" ); if ( home != NULL ) { num_read = string_copy_measure ( path, path_size, home ); if ( num_read >= path_size ) path [ 0 ] = 0; } } rc = KConfigNodeRelease ( home_node ); } }
void rna_splice_log_enter_ref( struct rna_splice_log * sl, const char * ref_name, struct ReferenceObj const * ref_obj ) { if ( sl != NULL ) { if ( ref_name != NULL ) string_copy_measure ( sl->ref_name, sizeof( sl->ref_name ), ref_name ); else sl->ref_name[ 0 ] = 0; sl->ref_obj = ref_obj; } }
static rc_t CC XFS_ReadCEverything_ZHR ( const char * Url, char * Buffer, size_t BufferSize, const char * Filler, XFS_ReadV_ZHR Reader ) { rc_t RCt; size_t NR; const char * DefaultFiller = "NULL"; struct VPath * Path; RCt = 0; NR = 0; Path = NULL; if ( Buffer == NULL || BufferSize <= 0 ) { return XFS_RC ( rcNull ); } * Buffer = 0; if ( Url == NULL ) { RCt = XFS_RC ( rcNull ); string_copy_measure ( Buffer, sizeof ( Buffer ), ( Filler == NULL ? DefaultFiller : Filler ) ); } else { RCt = VFSManagerMakePath ( XFS_VfsManager (), & Path, Url ); if ( RCt == 0 ) { RCt = Reader ( Path, Buffer, BufferSize, & NR ); VPathRelease ( Path ); } } return RCt; } /* XFS_ReadCEverything_ZHR () */
rc_t col_defs_as_string( col_defs* defs, char ** dst, bool only_requested ) { uint32_t idx, count, total = 0, dst_idx = 0; if ( defs == NULL ) return RC( rcExe, rcNoTarg, rcResolving, rcSelf, rcNull ); if ( dst == NULL ) return RC( rcExe, rcNoTarg, rcResolving, rcParam, rcNull ); *dst = NULL; count = VectorLength( &(defs->cols) ); for ( idx = 0; idx < count; ++idx ) { p_col_def col = (p_col_def) VectorGet ( &(defs->cols), idx ); if ( col != NULL ) { bool use_this = ( only_requested ) ? col->requested : true; if ( use_this ) total += ( string_measure ( col->name, NULL ) + 1 ); } } *dst = malloc( total + 1 ); if ( *dst == NULL ) return RC( rcVDB, rcNoTarg, rcResolving, rcMemory, rcExhausted ); *dst[0] = 0; for ( idx = 0; idx < count; ++idx ) { p_col_def col = (p_col_def) VectorGet ( &(defs->cols), idx ); if ( col != NULL ) { bool use_this = ( only_requested ) ? col->requested : true; if ( use_this ) { dst_idx += string_copy_measure ( &((*dst)[dst_idx]), total-dst_idx, col->name ); (*dst)[dst_idx++] = ','; } } } if ( dst_idx > 0 ) (*dst)[dst_idx-1] = 0; return 0; }
LIB_EXPORT rc_t CC XFSTreeDepotResource ( const struct XFSTreeDepot * self, char * Buffer, size_t BufferSize ) { rc_t RCt; const struct XFSTree * Tree; RCt = 0; Tree = NULL; if ( self == NULL || Buffer == NULL || BufferSize == 0 ) { return XFS_RC ( rcNull ); } * Buffer = 0; RCt = XFSTreeDepotGet ( self, & Tree ); if ( RCt == 0 ) { if ( Tree != NULL ) { if ( Tree -> Resource != NULL ) { string_copy_measure ( Buffer, BufferSize, Tree -> Resource ); } XFSTreeRelease ( Tree ); } else { RCt = XFS_RC ( rcNotFound ); } } return RCt; } /* XFSTreeDepotResource () */
static rc_t CC XFS_ReadVEverything_ZHR ( const struct VPath * Path, char * Buffer, size_t BufferSize, const char * Filler, XFS_ReadV_ZHR Reader ) { rc_t RCt; size_t NR; const char * DefaultFiller = "NULL"; RCt = 0; if ( Buffer == NULL || BufferSize <= 0 ) { return XFS_RC ( rcNull ); } * Buffer = 0; if ( Path != NULL ) { RCt = Reader ( Path, Buffer, BufferSize, & NR ); } else { RCt = XFS_RC ( rcNull ); string_copy_measure ( Buffer, sizeof ( Buffer ), ( Filler == NULL ? DefaultFiller : Filler ) ); } return RCt; } /* XFS_ReadVEverything_ZHR () */