xref: /freebsd-src/crypto/openssl/apps/lib/columns.c (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
3*b077aed3SPierre Pronchery  *
4*b077aed3SPierre Pronchery  * Licensed under the Apache License 2.0 (the "License").  You may not use
5*b077aed3SPierre Pronchery  * this file except in compliance with the License.  You can obtain a copy
6*b077aed3SPierre Pronchery  * in the file LICENSE in the source distribution or at
7*b077aed3SPierre Pronchery  * https://www.openssl.org/source/license.html
8*b077aed3SPierre Pronchery  */
9*b077aed3SPierre Pronchery 
10*b077aed3SPierre Pronchery #include <string.h>
11*b077aed3SPierre Pronchery #include "apps.h"
12*b077aed3SPierre Pronchery #include "function.h"
13*b077aed3SPierre Pronchery 
calculate_columns(FUNCTION * functions,DISPLAY_COLUMNS * dc)14*b077aed3SPierre Pronchery void calculate_columns(FUNCTION *functions, DISPLAY_COLUMNS *dc)
15*b077aed3SPierre Pronchery {
16*b077aed3SPierre Pronchery     FUNCTION *f;
17*b077aed3SPierre Pronchery     int len, maxlen = 0;
18*b077aed3SPierre Pronchery 
19*b077aed3SPierre Pronchery     for (f = functions; f->name != NULL; ++f)
20*b077aed3SPierre Pronchery         if (f->type == FT_general || f->type == FT_md || f->type == FT_cipher)
21*b077aed3SPierre Pronchery             if ((len = strlen(f->name)) > maxlen)
22*b077aed3SPierre Pronchery                 maxlen = len;
23*b077aed3SPierre Pronchery 
24*b077aed3SPierre Pronchery     dc->width = maxlen + 2;
25*b077aed3SPierre Pronchery     dc->columns = (80 - 1) / dc->width;
26*b077aed3SPierre Pronchery }
27*b077aed3SPierre Pronchery 
28