library/src/utility/BP-StringFormattingSessions.cc
// Creates a new string formatting session
Creates a new string formatting session
Creates a new string formatting session
P_BP_SF_SESSION BP_CreateStringFormattingSession( char * name, P_BP_STRING_ROW_BORDER_SET border_set )
{
	P_BP_SF_SESSION session = (P_BP_SF_SESSION) bpcalloc(sizeof(BP_SF_SESSION), 1);
	if(!session)
		return NULL;
	session->tq = BP_CreateLinkL("sfs", BP_FALSE);
	if(!session->tq)
	{
		bpfree(session);
		return NULL;
	}
	if(name)
		session->session_name = tq_strndup(session->tq, name, BP_KILOBYTE, BPLN);
	if(border_set)
	{
		session->border_set.border_left  = tq_strdup(session->tq, border_set->border_left, BPLN);
		session->border_set.border_right = tq_strdup(session->tq, border_set->border_right, BPLN);
		session->border_set.border_top_enabled           = border_set->border_top_enabled;
		session->border_set.border_top_char              = tq_strdup(session->tq, border_set->border_top_char,   BPLN);
		session->border_set.border_top_left_corner       = tq_strdup(session->tq, border_set->border_top_left_corner, BPLN);
		session->border_set.border_top_right_corner      = tq_strdup(session->tq, border_set->border_top_right_corner, BPLN);
		session->border_set.border_bottom_enabled        = border_set->border_bottom_enabled;
		session->border_set.border_bottom_char           = tq_strdup(session->tq, border_set->border_bottom_char,         BPLN);
		session->border_set.border_bottom_left_corner    = tq_strdup(session->tq, border_set->border_bottom_left_corner,  BPLN);
		session->border_set.border_bottom_right_corner   = tq_strdup(session->tq, border_set->border_bottom_right_corner, BPLN);
	}
	else
	{
		session->border_set.border_left  = tq_strdup(session->tq, " ", BPLN);
		session->border_set.border_right = tq_strdup(session->tq, " ", BPLN);
		session->border_set.border_top_enabled           = BP_FALSE;
		session->border_set.border_top_char              = tq_strdup(session->tq, " ",   BPLN);
		session->border_set.border_top_left_corner       = tq_strdup(session->tq, "   ", BPLN);
		session->border_set.border_top_right_corner      = tq_strdup(session->tq, "   ", BPLN);
		session->border_set.border_bottom_enabled        = BP_FALSE;
		session->border_set.border_bottom_char           = tq_strdup(session->tq, " ",   BPLN);
		session->border_set.border_bottom_left_corner    = tq_strdup(session->tq, "   ", BPLN);
		session->border_set.border_bottom_right_corner   = tq_strdup(session->tq, "   ", BPLN);
	}
	return session;
}
P_BP_SF_SESSION BP_CreateStringFormattingSession ( char * name , P_BP_STRING_ROW_BORDER_SET border_set ) { P_BP_SF_SESSION session = ( P_BP_SF_SESSION ) bpcalloc ( sizeof ( BP_SF_SESSION ) , 1 ) ; if ( ! session ) return NULL ; session -> tq = BP_CreateLinkL ( " " , BP_FALSE ) ; if ( ! session -> tq ) { bpfree ( session ) ; return NULL ; } if ( name ) session -> session_name = tq_strndup ( session -> tq , name , BP_KILOBYTE , BPLN ) ; if ( border_set ) { session -> border_set . border_left = tq_strdup ( session -> tq , border_set -> border_left , BPLN ) ; session -> border_set . border_right = tq_strdup ( session -> tq , border_set -> border_right , BPLN ) ; session -> border_set . border_top_enabled = border_set -> border_top_enabled ; session -> border_set . border_top_char = tq_strdup ( session -> tq , border_set -> border_top_char , BPLN ) ; session -> border_set . border_top_left_corner = tq_strdup ( session -> tq , border_set -> border_top_left_corner , BPLN ) ; session -> border_set . border_top_right_corner = tq_strdup ( session -> tq , border_set -> border_top_right_corner , BPLN ) ; session -> border_set . border_bottom_enabled = border_set -> border_bottom_enabled ; session -> border_set . border_bottom_char = tq_strdup ( session -> tq , border_set -> border_bottom_char , BPLN ) ; session -> border_set . border_bottom_left_corner = tq_strdup ( session -> tq , border_set -> border_bottom_left_corner , BPLN ) ; session -> border_set . border_bottom_right_corner = tq_strdup ( session -> tq , border_set -> border_bottom_right_corner , BPLN ) ; } else { session -> border_set . border_left = tq_strdup ( session -> tq , " " , BPLN ) ; session -> border_set . border_right = tq_strdup ( session -> tq , " " , BPLN ) ; session -> border_set . border_top_enabled = BP_FALSE ; session -> border_set . border_top_char = tq_strdup ( session -> tq , " " , BPLN ) ; session -> border_set . border_top_left_corner = tq_strdup ( session -> tq , " " , BPLN ) ; session -> border_set . border_top_right_corner = tq_strdup ( session -> tq , " " , BPLN ) ; session -> border_set . border_bottom_enabled = BP_FALSE ; session -> border_set . border_bottom_char = tq_strdup ( session -> tq , " " , BPLN ) ; session -> border_set . border_bottom_left_corner = tq_strdup ( session -> tq , " " , BPLN ) ; session -> border_set . border_bottom_right_corner = tq_strdup ( session -> tq , " " , BPLN ) ; } return session ; }
Creates a new string formatting session
Creates a new string formatting session
// allocate space for the session // create new string formatting session // set name if one was provided // 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 // border bottom items // return the allocated session