MCPcopy Create free account
hub / github.com/RsyncProject/rsync / maxColumnWidth

Function maxColumnWidth

popt/popthelp.c:96–111  ·  view source on GitHub ↗

* Return no. of columns in output window. * @param fp FILE * @return no. of columns */

Source from the content-addressed store, hash-verified

94 * @return no. of columns
95 */
96static size_t maxColumnWidth(FILE *fp)
97{
98 size_t maxcols = _POPTHELP_MAXLINE;
99#if defined(TIOCGWINSZ)
100 struct winsize ws;
101 int fdno = fileno(fp ? fp : stdout);
102
103 memset(&ws, 0, sizeof(ws));
104 if (fdno >= 0 && !ioctl(fdno, (unsigned long)TIOCGWINSZ, &ws)) {
105 size_t ws_col = (size_t)ws.ws_col;
106 if (ws_col > maxcols && ws_col < (size_t)256)
107 maxcols = ws_col - 1;
108 }
109#endif
110 return maxcols;
111}
112
113/**
114 * Determine number of display characters in a string.

Callers 2

poptPrintHelpFunction · 0.85
poptPrintUsageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected