maint: update all copyright year number ranges
[coreutils.git] / gl / lib / mbsalign.h
blobd2208009d637c32e9b02143e5c2d5d88edcffb6e
1 /* Align/Truncate a string in a given screen width
2 Copyright (C) 2009-2017 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #include <stddef.h>
19 typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
21 enum {
22 /* Use unibyte mode for invalid multibyte strings
23 or when heap memory is exhausted. */
24 MBA_UNIBYTE_FALLBACK = 0x0001,
26 /* As an optimization, don't do multibyte processing
27 when we know no multibyte characters are present. */
28 MBA_UNIBYTE_ONLY = 0x0002,
30 /* Don't add leading padding. */
31 MBA_NO_LEFT_PAD = 0x0004,
33 /* Don't add trailing padding. */
34 MBA_NO_RIGHT_PAD = 0x0008
36 #if 0 /* Other possible options. */
37 /* Skip invalid multibyte chars rather than failing. */
38 MBA_IGNORE_INVALID
40 /* Align multibyte strings using "figure space" (\u2007). */
41 MBA_USE_FIGURE_SPACE
43 /* Don't truncate. */
44 MBA_NO_TRUNCATE
46 /* Ensure no leading whitespace. */
47 MBA_LSTRIP
49 /* Ensure no trailing whitespace. */
50 MBA_RSTRIP
51 #endif
54 size_t
55 mbsalign (const char *src, char *dest, size_t dest_size,
56 size_t *width, mbs_align_t align, int flags);
58 char *
59 ambsalign (const char *src, size_t *width, mbs_align_t align, int flags);