#include "libut/ut.h" int UT_shl_hdr(char *cols[]);
This is a convenience function for appending a hyphen-underlined array of strings (intended as column headers) to the result buffer of the currently executing control port command.
This function is used only within a callback that implements a control port
command. (See the COMMAND CALLBACK in UT_shl_cmd_create(3)
for background
information).
The cols argument is an array of strings. The last array element must be NULL. Each string represents an individual column header. The strings are written to the result buffer sequentially, separated by spaces. Then another line is written to the result buffer consisting of stretches of hyphens to underline each header.
This function always returns 0.
Suppose that a function called ascii_cmd() is defined as shown below.
int ascii_cmd(int argc, char *argv[]) { char *cols[] = { "dec", "hex", "char", NULL }; int i; UT_shl_hdr( cols ); for(i=97;i<123;i++) UT_shlf("%3d %3x %4c\n",i,i,i); return SHL_OK; }
Then suppose that after UT_init(3)
it is made into a control port command
using:
UT_shl_cmd_create("ascii", "show a-z ascii values", ascii_cmd, NULL);
Then when a user of the control port runs the ascii command, they see:
dec hex char --- --- ---- 97 61 a 98 62 b 99 63 c 100 64 d 101 65 e 102 66 f 103 67 g 104 68 h 105 69 i 106 6a j 107 6b k 108 6c l 109 6d m 110 6e n 111 6f o 112 70 p 113 71 q 114 72 r 115 73 s 116 74 t 117 75 u 118 76 v 119 77 w 120 78 x 121 79 y 122 7a z
UT_shl_cmd_create(3), UT_shlf(3), UT_shle(3)
Troy D. Hanson <thanson@users.sourceforge.net>