]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/mbsalign.h
libmount: fix comment referring to passno field
[thirdparty/util-linux.git] / include / mbsalign.h
CommitLineData
104b92f8
PB
1/* Align/Truncate a string in a given screen width
2 Copyright (C) 2009-2010 Free Software Foundation, Inc.
1b1f66e4 3 Copyright (C) 2010-2013 Karel Zak <kzak@redhat.com>
104b92f8
PB
4
5 This program is free software: you can redistribute it and/or modify
36c7f785
PB
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 2.1 of the License, or
104b92f8
PB
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1b1f66e4
KZ
17#ifndef UTIL_LINUX_MBSALIGN_H
18# define UTIL_LINUX_MBSALIGN_H
19# include <stddef.h>
104b92f8
PB
20
21typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
22
23enum {
24 /* Use unibyte mode for invalid multibyte strings or
25 or when heap memory is exhausted. */
26 MBA_UNIBYTE_FALLBACK = 0x0001,
27
28#if 0 /* Other possible options. */
29 /* Skip invalid multibyte chars rather than failing */
30 MBA_IGNORE_INVALID = 0x0002,
31
32 /* Align multibyte strings using "figure space" (\u2007) */
33 MBA_USE_FIGURE_SPACE = 0x0004,
34
35 /* Don't add any padding */
36 MBA_TRUNCATE_ONLY = 0x0008,
37
38 /* Don't truncate */
39 MBA_PAD_ONLY = 0x0010,
40#endif
41};
42
5f94ca33
KZ
43extern size_t mbs_truncate(char *str, size_t *width);
44
45extern size_t mbsalign (const char *src, char *dest,
46 size_t dest_size, size_t *width,
47 mbs_align_t align, int flags);
1b1f66e4 48
57867795
KZ
49extern size_t mbsalign_with_padding (const char *src, char *dest, size_t dest_size,
50 size_t *width, mbs_align_t align, int flags,
51 int padchar);
52
0c33fcbf 53extern size_t mbs_safe_nwidth(const char *buf, size_t bufsz, size_t *sz);
1b1f66e4 54extern size_t mbs_safe_width(const char *s);
c426f70f 55
1b1f66e4 56extern char *mbs_safe_encode(const char *s, size_t *width);
ff471d89 57extern char *mbs_safe_encode_to_buffer(const char *s, size_t *width, char *buf, const char *safechars);
c426f70f 58extern size_t mbs_safe_encode_size(size_t bytes);
1b1f66e4 59
365ed9f6
KZ
60extern char *mbs_invalid_encode(const char *s, size_t *width);
61extern char *mbs_invalid_encode_to_buffer(const char *s, size_t *width, char *buf);
62
1b1f66e4 63#endif /* UTIL_LINUX_MBSALIGN_H */