aboutsummaryrefslogtreecommitdiffhomepage
path: root/wutil.h
blob: 0f35017319c1820368690eb1b44e4aeb1da0f94a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/** \file wutil.h

  Prototypes for wide character equivalents of various standard unix
  functions. 
*/
#ifndef FISH_WUTIL_H
#define FISH_WUTIL_H

#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdarg.h>

/**
   Wide version of the dirent data structure
*/
struct wdirent
{
	/**
	   The name of the current directory
	*/
	wchar_t *d_name;
}
	;


/**
   Call this function on startup to create internal wutil
   resources. This function doesn't do anything.
*/
void wutil_init();

/**
   Call this function on exit to free internal wutil resources
*/
void wutil_destroy();

/**
   Wide character version of fopen().
*/
FILE *wfopen(const wchar_t *path, const char *mode);

/**
   Wide character version of freopen().
*/
FILE *wfreopen(const wchar_t *path, const char *mode, FILE *stream);

/**
   Wide character version of open().
*/
int wopen(const wchar_t *pathname, int flags, ...);

/**
   Wide character version of creat().
*/
int wcreat(const wchar_t *pathname, mode_t mode);


/**
   Wide character version of opendir().
*/
DIR *wopendir(const wchar_t *name);

/**
   Wide character version of stat().
*/
int wstat(const wchar_t *file_name, struct stat *buf);

/**
   Wide character version of lstat().
*/
int lwstat(const wchar_t *file_name, struct stat *buf);

/**
   Wide character version of access().
*/
int waccess(const wchar_t *pathname, int mode);

/**
   Wide character version of perror().
*/
void wperror(const wchar_t *s);

/**
   Wide character version of getcwd().
*/
wchar_t *wgetcwd( wchar_t *buff, size_t sz );

/**
   Wide character version of chdir()
*/
int wchdir( const wchar_t * dir );

/** 
	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.
*/
wchar_t *wrealpath(const wchar_t *pathname, wchar_t *resolved_path);

/**
   Wide character version of readdir()
*/
struct wdirent *wreaddir(DIR *dir );

/**
   Wide character version of dirname()
*/
wchar_t *wdirname( wchar_t *path );

/**
   Wide character version of basename()
*/
wchar_t *wbasename( const wchar_t *path );

/**
   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.
*/
const wchar_t *wgettext( const wchar_t *in );

/**
   Wide character version of getenv
*/
wchar_t *wgetenv( const wchar_t *name );

/**
   Wide character version of mkdir
*/
int wmkdir( const wchar_t *dir, int mode );

#endif