]> git.ipfire.org Git - thirdparty/git.git/blame - compat/precompose_utf8.h
Merge branch 'jk/escaped-wildcard-dwim'
[thirdparty/git.git] / compat / precompose_utf8.h
CommitLineData
76759c7d 1#ifndef PRECOMPOSE_UNICODE_H
f790d812
EN
2#define PRECOMPOSE_UNICODE_H
3
76759c7d
TB
4#include <sys/stat.h>
5#include <sys/types.h>
6#include <dirent.h>
7#include <iconv.h>
8
9
10typedef struct dirent_prec_psx {
11 ino_t d_ino; /* Posix */
12 size_t max_name_len; /* See below */
13 unsigned char d_type; /* available on all systems git runs on */
14
15 /*
16 * See http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html
17 * NAME_MAX + 1 should be enough, but some systems have
18 * NAME_MAX=255 and strlen(d_name) may return 508 or 510
19 * Solution: allocate more when needed, see precompose_utf8_readdir()
20 */
21 char d_name[NAME_MAX+1];
22} dirent_prec_psx;
23
24
25typedef struct {
26 iconv_t ic_precompose;
27 DIR *dirp;
28 struct dirent_prec_psx *dirent_nfc;
29} PREC_DIR;
30
31void precompose_argv(int argc, const char **argv);
fdf72966 32void probe_utf8_pathname_composition(void);
76759c7d
TB
33
34PREC_DIR *precompose_utf8_opendir(const char *dirname);
35struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *dirp);
36int precompose_utf8_closedir(PREC_DIR *dirp);
37
38#ifndef PRECOMPOSE_UNICODE_C
39#define dirent dirent_prec_psx
40#define opendir(n) precompose_utf8_opendir(n)
41#define readdir(d) precompose_utf8_readdir(d)
42#define closedir(d) precompose_utf8_closedir(d)
43#define DIR PREC_DIR
44#endif /* PRECOMPOSE_UNICODE_C */
45
76759c7d 46#endif /* PRECOMPOSE_UNICODE_H */