#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <wchar.h>
#include <wctype.h>
#include <string.h>
#include <dirent.h>
#include <stdarg.h>
#include <limits.h>
#include <libgen.h>
#include <libintl.h>
#include "fallback.h"
#include "util.h"
#include "common.h"
#include "wutil.h"
#include "halloc.h"
#include "halloc_util.h"
Defines | |
| #define | TMP_LEN_MIN 256 |
| Minimum length of the internal covnersion buffers. | |
| #define | PATH_MAX 4096 |
| Fallback length of MAXPATHLEN. | |
| #define | BUFF_COUNT 4 |
| For wgettext: Number of string_buffer_t in the ring of buffers. | |
Functions | |
| void | wutil_init () |
| Call this function on startup to create internal wutil resources. | |
| void | wutil_destroy () |
| Call this function on exit to free internal wutil resources. | |
| static char * | wutil_wcs2str (const wchar_t *in) |
| Convert the specified wide aharacter string to a narrow character string. | |
| static wchar_t * | wutil_str2wcs (const char *in) |
| Convert the specified wide character string to a narrow character string. | |
| wdirent * | wreaddir (DIR *dir) |
| Wide character version of readdir(). | |
| wchar_t * | wgetcwd (wchar_t *buff, size_t sz) |
| Wide character version of getcwd(). | |
| int | wchdir (const wchar_t *dir) |
| Wide character version of chdir(). | |
| FILE * | wfopen (const wchar_t *path, const char *mode) |
| Wide character version of fopen(). | |
| FILE * | wfreopen (const wchar_t *path, const char *mode, FILE *stream) |
| Wide character version of freopen(). | |
| int | wopen (const wchar_t *pathname, int flags,...) |
| Wide character version of open(). | |
| int | wcreat (const wchar_t *pathname, mode_t mode) |
| Wide character version of creat(). | |
| DIR * | wopendir (const wchar_t *name) |
| Wide character version of opendir(). | |
| int | wstat (const wchar_t *file_name, struct stat *buf) |
| Wide character version of stat(). | |
| int | lwstat (const wchar_t *file_name, struct stat *buf) |
| Wide character version of lstat(). | |
| int | waccess (const wchar_t *file_name, int mode) |
| Wide character version of access(). | |
| void | wperror (const wchar_t *s) |
| Wide character version of perror(). | |
| wchar_t * | wrealpath (const wchar_t *pathname, wchar_t *resolved_path) |
| Wide character version of realpath function. | |
| wchar_t * | wdirname (wchar_t *path) |
| Wide character version of dirname(). | |
| wchar_t * | wbasename (const wchar_t *path) |
| Wide character version of basename(). | |
| static void | wgettext_destroy () |
| For wgettext: Internal shutdown function. | |
| static void | wgettext_init () |
| For wgettext: Internal init function. | |
| static char * | wgettext_wcs2str (const wchar_t *in) |
| For wgettext: Wide to narrow character conversion. | |
| const wchar_t * | wgettext (const wchar_t *in) |
| Wide character wrapper around the gettext function. | |
| wchar_t * | wgetenv (const wchar_t *name) |
| Wide character version of getenv. | |
| int | wmkdir (const wchar_t *name, int mode) |
| Wide character version of mkdir. | |
| int | wrename (const wchar_t *old, const wchar_t *new) |
| Wide character version of rename. | |
Variables | |
| static char * | tmp = 0 |
Buffer for converting wide arguments to narrow arguments, used by the wutil_wcs2str() function. | |
| static wchar_t * | tmp2 |
Buffer for converting narrow results to wide ones, used by the wutil_str2wcs() function. | |
| static size_t | tmp_len = 0 |
Length of the tmp buffer. | |
| static size_t | tmp2_len |
Length of the tmp2 buffer. | |
| static int | wutil_calls = 0 |
| Counts the number of calls to the wutil wrapper functions. | |
| static struct wdirent | my_wdirent |
| Storage for the wreaddir function. | |
| static string_buffer_t | buff [BUFF_COUNT] |
| For wgettext: The ring of string_buffer_t. | |
| static int | curr_buff = 0 |
| For wgettext: Current position in the ring. | |
| static char * | wcs2str_buff = 0 |
| For wgettext: Buffer used by translate_wcs2str. | |
| static size_t | wcs2str_buff_count = 0 |
| For wgettext: Size of buffer used by translate_wcs2str. | |
| static int | wgettext_is_init = 0 |
| For wgettext: Flag to tell whether the translation library has been initialized. | |
|
|
Fallback length of MAXPATHLEN. Just a hopefully sane value... |
|
|
Wide character wrapper around the gettext function. For historic reasons, unlike the real gettext function, wgettext takes care of setting the correct domain, etc. using the textdomain and bindtextdomain functions. This should probably be moved out of wgettext, so that wgettext will be nothing more than a wrapper around gettext, like all other functions in this file. |
|
|
For wgettext: Internal shutdown function. Automatically called on shutdown if the library has been initialized. |
|
|
For wgettext: Internal init function. Automatically called when a translation is first requested. |
|
|
For wgettext: Wide to narrow character conversion. Internal implementation that avoids exessive calls to malloc |
|
||||||||||||
|
Wide character version of realpath function. Just like the GNU version of realpath, wrealpath will accept 0 as the value for the second argument, in which case the result will be allocated using malloc, and must be free'd by the user. |
|
|
Call this function on startup to create internal wutil resources. This function doesn't do anything. |
|
|
Convert the specified wide character string to a narrow character string. This function uses an internal temporary buffer for storing the result so subsequent results will overwrite previous results. |
|
|
Convert the specified wide aharacter string to a narrow character string. This function uses an internal temporary buffer for storing the result so subsequent results will overwrite previous results. |
|
|
Buffer for converting narrow results to wide ones, used by the Avoid usign this without thinking about it, since subsequent calls will overwrite previous values. |
1.4.4