diff options
Diffstat (limited to 'lib/roken/rtbl.cat3')
| -rw-r--r-- | lib/roken/rtbl.cat3 | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/lib/roken/rtbl.cat3 b/lib/roken/rtbl.cat3 new file mode 100644 index 0000000000000..3862cd5936e63 --- /dev/null +++ b/lib/roken/rtbl.cat3 @@ -0,0 +1,151 @@ + +RTBL(3) BSD Library Functions Manual RTBL(3) + +NNAAMMEE + rrttbbll__ccrreeaattee, rrttbbll__ddeessttrrooyy, rrttbbll__sseett__ffllaaggss, rrttbbll__ggeett__ffllaaggss, + rrttbbll__sseett__pprreeffiixx, rrttbbll__sseett__sseeppaarraattoorr, rrttbbll__sseett__ccoolluummnn__pprreeffiixx, + rrttbbll__sseett__ccoolluummnn__aaffffiixx__bbyy__iidd, rrttbbll__aadddd__ccoolluummnn, rrttbbll__aadddd__ccoolluummnn__bbyy__iidd, + rrttbbll__aadddd__ccoolluummnn__eennttrryy, rrttbbll__aadddd__ccoolluummnn__eennttrryy__bbyy__iidd, rrttbbll__nneeww__rrooww, + rrttbbll__ffoorrmmaatt -- format data in simple tables + +LLIIBBRRAARRYY + The roken library (libroken, -lroken) + +SSYYNNOOPPSSIISS + ##iinncclluuddee <<rrttbbll..hh>> + + _i_n_t + rrttbbll__aadddd__ccoolluummnn(_r_t_b_l___t _t_a_b_l_e, _c_o_n_s_t _c_h_a_r _*_c_o_l_u_m_n___n_a_m_e, + _u_n_s_i_g_n_e_d _i_n_t _f_l_a_g_s); + + _i_n_t + rrttbbll__aadddd__ccoolluummnn__bbyy__iidd(_r_t_b_l___t _t_a_b_l_e, _u_n_s_i_g_n_e_d _i_n_t _c_o_l_u_m_n___i_d, + _c_o_n_s_t _c_h_a_r _*_c_o_l_u_m_n___h_e_a_d_e_r, _u_n_s_i_g_n_e_d _i_n_t _f_l_a_g_s); + + _i_n_t + rrttbbll__aadddd__ccoolluummnn__eennttrryy(_r_t_b_l___t _t_a_b_l_e, _c_o_n_s_t _c_h_a_r _*_c_o_l_u_m_n___n_a_m_e, + _c_o_n_s_t _c_h_a_r _*_c_e_l_l___e_n_t_r_y); + + _i_n_t + rrttbbll__aadddd__ccoolluummnn__eennttrryy__bbyy__iidd(_r_t_b_l___t _t_a_b_l_e, _u_n_s_i_g_n_e_d _i_n_t _c_o_l_u_m_n___i_d, + _c_o_n_s_t _c_h_a_r _*_c_e_l_l___e_n_t_r_y); + + _r_t_b_l___t + rrttbbll__ccrreeaattee(_v_o_i_d); + + _v_o_i_d + rrttbbll__ddeessttrrooyy(_r_t_b_l___t _t_a_b_l_e); + + _i_n_t + rrttbbll__nneeww__rrooww(_r_t_b_l___t _t_a_b_l_e); + + _i_n_t + rrttbbll__sseett__ccoolluummnn__aaffffiixx__bbyy__iidd(_r_t_b_l___t _t_a_b_l_e, _u_n_s_i_g_n_e_d _i_n_t _c_o_l_u_m_n___i_d, _c_o_n_s_t, + _c_h_a_r, _*_p_r_e_f_i_x_", _c_o_n_s_t _c_h_a_r _*_s_u_f_f_i_x); + + _i_n_t + rrttbbll__sseett__ccoolluummnn__pprreeffiixx(_r_t_b_l___t _t_a_b_l_e, _c_o_n_s_t _c_h_a_r _*_c_o_l_u_m_n___n_a_m_e, + _c_o_n_s_t _c_h_a_r _*_p_r_e_f_i_x); + + _u_n_s_i_g_n_e_d _i_n_t + rrttbbll__ggeett__ffllaaggss(_r_t_b_l___t _t_a_b_l_e); + + _v_o_i_d + rrttbbll__sseett__ffllaaggss(_r_t_b_l___t _t_a_b_l_e, _u_n_s_i_g_n_e_d _i_n_t _f_l_a_g_s); + + _i_n_t + rrttbbll__sseett__pprreeffiixx(_r_t_b_l___t _t_a_b_l_e, _c_o_n_s_t _c_h_a_r _*_p_r_e_f_i_x); + + _i_n_t + rrttbbll__sseett__sseeppaarraattoorr(_r_t_b_l___t _t_a_b_l_e, _c_o_n_s_t _c_h_a_r _*_s_e_p_a_r_a_t_o_r); + + _i_n_t + rrttbbll__ffoorrmmaatt(_r_t_b_l___t _t_a_b_l_e, _F_I_L_E, _*_f_i_l_e_"); + +DDEESSCCRRIIPPTTIIOONN + This set of functions assemble a simple table consisting of rows and col- + umns, allowing it to be printed with certain options. Typical use would + be output from tools such as ls(1) or netstat(1), where you have a fixed + number of columns, but don't know the column widths before hand. + + A table is created with rrttbbll__ccrreeaattee() and destroyed with rrttbbll__ddeessttrrooyy(). + + Global flags on the table are set with _r_t_b_l___s_e_t___f_l_a_g_s and retrieved with + _r_t_b_l___g_e_t___f_l_a_g_s. At present the only defined flag is + RTBL_HEADER_STYLE_NONE which suppresses printing the header. + + Before adding data to the table, one or more columns need to be created. + This would normally be done with rrttbbll__aadddd__ccoolluummnn__bbyy__iidd(), _c_o_l_u_m_n___i_d is + any number of your choice (it's used only to identify columns), + _c_o_l_u_m_n___h_e_a_d_e_r is the header to print at the top of the column, and _f_l_a_g_s + are flags specific to this column. Currently the only defined flag is + RTBL_ALIGN_RIGHT, aligning column entries to the right. Columns are + printed in the order they are added. + + There's also a way to add columns by column name with rrttbbll__aadddd__ccoolluummnn(), + but this is less flexible (you need unique header names), and is consid- + ered deprecated. + + To add data to a column you use rrttbbll__aadddd__ccoolluummnn__eennttrryy__bbyy__iidd(), where the + _c_o_l_u_m_n___i_d is the same as when the column was added (adding data to a non- + existent column is undefined), and _c_e_l_l___e_n_t_r_y is whatever string you wish + to include in that cell. It should not include newlines. For columns + added with rrttbbll__aadddd__ccoolluummnn() you must use rrttbbll__aadddd__ccoolluummnn__eennttrryy() + instead. + + rrttbbll__nneeww__rrooww() fills all columns with blank entries until they all have + the same number of rows. + + Each column can have a separate prefix and suffix, set with + _r_t_b_l___s_e_t___c_o_l_u_m_n___a_f_f_i_x___b_y___i_d; _r_t_b_l___s_e_t___c_o_l_u_m_n___p_r_e_f_i_x allows setting the + prefix only by column name. In addition to this, columns may be separated + by a string set with _r_t_b_l___s_e_t___s_e_p_a_r_a_t_o_r (by default columns are not + seprated by anything). + + The finished table is printed to _f_i_l_e with _r_t_b_l___f_o_r_m_a_t. + +EEXXAAMMPPLLEESS + This program: + + #include <stdio.h> + #include <rtbl.h> + int + main(int argc, char **argv) + { + rtbl_t table; + table = rtbl_create(); + rtbl_set_separator(table, " "); + rtbl_add_column_by_id(table, 0, "Column A", 0); + rtbl_add_column_by_id(table, 1, "Column B", RTBL_ALIGN_RIGHT); + rtbl_add_column_by_id(table, 2, "Column C", 0); + rtbl_add_column_entry_by_id(table, 0, "A-1"); + rtbl_add_column_entry_by_id(table, 0, "A-2"); + rtbl_add_column_entry_by_id(table, 0, "A-3"); + rtbl_add_column_entry_by_id(table, 1, "B-1"); + rtbl_add_column_entry_by_id(table, 2, "C-1"); + rtbl_add_column_entry_by_id(table, 2, "C-2"); + rtbl_add_column_entry_by_id(table, 1, "B-2"); + rtbl_add_column_entry_by_id(table, 1, "B-3"); + rtbl_add_column_entry_by_id(table, 2, "C-3"); + rtbl_add_column_entry_by_id(table, 0, "A-4"); + rtbl_new_row(table); + rtbl_add_column_entry_by_id(table, 1, "B-4"); + rtbl_new_row(table); + rtbl_add_column_entry_by_id(table, 2, "C-4"); + rtbl_new_row(table); + rtbl_format(table, stdout); + rtbl_destroy(table); + return 0; + } + + will output the following: + + Column A Column B Column C + A-1 B-1 C-1 + A-2 B-2 C-2 + A-3 B-3 C-3 + A-4 + B-4 + C-4 + +HEIMDAL June 26, 2004 HEIMDAL |
