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