library/src/utility/BP-StringFormattingSessions.cc
// attempt to add a row group to a string formatting session
attempt to add a row group to a string formatting session
attempt to add a row group to a string formatting session
BP_ERROR_T BP_AddRowGroupToSFSession
(
	P_BP_SF_SESSION sfs,
	char * new_row_group_identifier,
	P_BP_STRING_ROW_BORDER_SET border_set
)
{
	if(!sfs)
		return ERR_FAILURE;
	if(!sfs->tq)
		return ERR_FAILURE;
	P_BP_SFS_STRING_ROW_GROUP new_row_group = (P_BP_SFS_STRING_ROW_GROUP) tq_calloc
	(
			sfs->tq,
			sizeof(BP_SFS_STRING_ROW_GROUP),
			1,
			BPLN
	);
	if(!new_row_group)
		return ERR_FAILURE;
	if(border_set)
	{
		new_row_group->border_set.border_left  = tq_strdup(sfs->tq, border_set->border_left, BPLN);
		new_row_group->border_set.border_right = tq_strdup(sfs->tq, border_set->border_right, BPLN);
		new_row_group->border_set.border_top_enabled           = border_set->border_top_enabled;
		new_row_group->border_set.border_top_char              = tq_strdup(sfs->tq, border_set->border_top_char,   BPLN);
		new_row_group->border_set.border_top_left_corner       = tq_strdup(sfs->tq, border_set->border_top_left_corner, BPLN);
		new_row_group->border_set.border_top_right_corner      = tq_strdup(sfs->tq, border_set->border_top_right_corner, BPLN);
		new_row_group->border_set.border_bottom_enabled        = border_set->border_bottom_enabled;
		new_row_group->border_set.border_bottom_char           = tq_strdup(sfs->tq, border_set->border_bottom_char,         BPLN);
		new_row_group->border_set.border_bottom_left_corner    = tq_strdup(sfs->tq, border_set->border_bottom_left_corner,  BPLN);
		new_row_group->border_set.border_bottom_right_corner   = tq_strdup(sfs->tq, border_set->border_bottom_right_corner, BPLN);
	}
	else
	{
		new_row_group->border_set.border_left  = tq_strdup(sfs->tq, "", BPLN);
		new_row_group->border_set.border_right = tq_strdup(sfs->tq, "", BPLN);
		  (disabled by default)
		new_row_group->border_set.border_top_enabled           = BP_FALSE;
		new_row_group->border_set.border_top_char              = tq_strdup(sfs->tq, " ",   BPLN);
		new_row_group->border_set.border_top_left_corner       = tq_strdup(sfs->tq, "   ", BPLN);
		new_row_group->border_set.border_top_right_corner      = tq_strdup(sfs->tq, "   ", BPLN);
		  (disabled by default)
		new_row_group->border_set.border_bottom_enabled        = BP_FALSE;
		new_row_group->border_set.border_bottom_char           = tq_strdup(sfs->tq, " ",   BPLN);
		new_row_group->border_set.border_bottom_left_corner    = tq_strdup(sfs->tq, "   ", BPLN);
		new_row_group->border_set.border_bottom_right_corner   = tq_strdup(sfs->tq, "   ", BPLN);
	}
	sfs->row_group_n++;
	sfs->row_groups = (P_BP_SFS_STRING_ROW_GROUP *) tq_realloc
	(
			sfs->tq,
			(void *) sfs->row_groups,
			sizeof(P_BP_SFS_STRING_ROW_GROUP) * (sfs->row_group_n+1),
			BPLN
	);
	if(!sfs->row_groups)
	{
		sfs->row_group_n--;
		return ERR_FAILURE;
	}
	sfs->row_groups[sfs->row_group_n-1] = new_row_group;
	new_row_group->session = sfs;
	if(new_row_group_identifier)
	{
		new_row_group->row_group_identifier = tq_strdup(sfs->tq, new_row_group_identifier, BPLN);
		if(!new_row_group->row_group_identifier)
			return ERR_FAILURE;
		new_row_group->row_group_identifier_len = strnlen(new_row_group->row_group_identifier, BP_KILOBYTE);
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_AddRowGroupToSFSession ( P_BP_SF_SESSION sfs , char * new_row_group_identifier , P_BP_STRING_ROW_BORDER_SET border_set ) { if ( ! sfs ) return ERR_FAILURE ; if ( ! sfs -> tq ) return ERR_FAILURE ; P_BP_SFS_STRING_ROW_GROUP new_row_group = ( P_BP_SFS_STRING_ROW_GROUP ) tq_calloc ( sfs -> tq , sizeof ( BP_SFS_STRING_ROW_GROUP ) , 1 , BPLN ) ; if ( ! new_row_group ) return ERR_FAILURE ; if ( border_set ) { new_row_group -> border_set . border_left = tq_strdup ( sfs -> tq , border_set -> border_left , BPLN ) ; new_row_group -> border_set . border_right = tq_strdup ( sfs -> tq , border_set -> border_right , BPLN ) ; new_row_group -> border_set . border_top_enabled = border_set -> border_top_enabled ; new_row_group -> border_set . border_top_char = tq_strdup ( sfs -> tq , border_set -> border_top_char , BPLN ) ; new_row_group -> border_set . border_top_left_corner = tq_strdup ( sfs -> tq , border_set -> border_top_left_corner , BPLN ) ; new_row_group -> border_set . border_top_right_corner = tq_strdup ( sfs -> tq , border_set -> border_top_right_corner , BPLN ) ; new_row_group -> border_set . border_bottom_enabled = border_set -> border_bottom_enabled ; new_row_group -> border_set . border_bottom_char = tq_strdup ( sfs -> tq , border_set -> border_bottom_char , BPLN ) ; new_row_group -> border_set . border_bottom_left_corner = tq_strdup ( sfs -> tq , border_set -> border_bottom_left_corner , BPLN ) ; new_row_group -> border_set . border_bottom_right_corner = tq_strdup ( sfs -> tq , border_set -> border_bottom_right_corner , BPLN ) ; } else { new_row_group -> border_set . border_left = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row_group -> border_set . border_right = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row_group -> border_set . border_top_enabled = BP_FALSE ; new_row_group -> border_set . border_top_char = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row_group -> border_set . border_top_left_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row_group -> border_set . border_top_right_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row_group -> border_set . border_bottom_enabled = BP_FALSE ; new_row_group -> border_set . border_bottom_char = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row_group -> border_set . border_bottom_left_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row_group -> border_set . border_bottom_right_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; } sfs -> row_group_n ++ ; sfs -> row_groups = ( P_BP_SFS_STRING_ROW_GROUP * ) tq_realloc ( sfs -> tq , ( void * ) sfs -> row_groups , sizeof ( P_BP_SFS_STRING_ROW_GROUP ) * ( sfs -> row_group_n + 1 ) , BPLN ) ; if ( ! sfs -> row_groups ) { sfs -> row_group_n -- ; return ERR_FAILURE ; } sfs -> row_groups [ sfs -> row_group_n - 1 ] = new_row_group ; new_row_group -> session = sfs ; if ( new_row_group_identifier ) { new_row_group -> row_group_identifier = tq_strdup ( sfs -> tq , new_row_group_identifier , BPLN ) ; if ( ! new_row_group -> row_group_identifier ) return ERR_FAILURE ; new_row_group -> row_group_identifier_len = strnlen ( new_row_group -> row_group_identifier , BP_KILOBYTE ) ; } return ERR_SUCCESS ; }
attempt to add a row group to a string formatting session
attempt to add a row group to a string formatting session
// ensure we have a session // ensure we have a tail queue allocator // create new row structure // ensure we can create a new row group // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add Border Info %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set left and right borders // border top items // border bottom items // default border is just spaces/padding // set left and right borders // border top items (disabled by default) // border bottom items (disabled by default) // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add Row Group Items in Place %%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // increment row count // now add memory for the new pointer // if we couldn't create space for the new group pointer, // return indicating failure. // set the group as the new row group // set session // only set identifier if the user has indicated they want to set one // add identifier // set row group identifier length // return indicating success