libxputty 0.1
Loading...
Searching...
No Matches
Typedefs | Functions | Variables
xdgmimeint.h File Reference

Go to the source code of this file.

Typedefs

typedef unsigned int xdg_unichar_t
 
typedef unsigned char xdg_uchar8_t
 
typedef unsigned short xdg_uint16_t
 
typedef unsigned int xdg_uint32_t
 

Functions

xdg_unichar_t _xdg_utf8_to_ucs4 (const char *source)
 
xdg_unichar_t _xdg_ucs4_to_lower (xdg_unichar_t source)
 
int _xdg_utf8_validate (const char *source)
 
xdg_unichar_t_xdg_convert_to_ucs4 (const char *source, int *len)
 
void _xdg_reverse_ucs4 (xdg_unichar_t *source, int len)
 
const char * _xdg_get_base_name (const char *file_name)
 
const char * _xdg_binary_or_text_fallback (const void *data, size_t len)
 

Variables

const char *const _xdg_utf8_skip
 

Typedef Documentation

◆ xdg_uchar8_t

typedef unsigned char xdg_uchar8_t

Definition at line 44 of file xdgmimeint.h.

◆ xdg_uint16_t

typedef unsigned short xdg_uint16_t

Definition at line 45 of file xdgmimeint.h.

◆ xdg_uint32_t

typedef unsigned int xdg_uint32_t

Definition at line 46 of file xdgmimeint.h.

◆ xdg_unichar_t

typedef unsigned int xdg_unichar_t

Definition at line 43 of file xdgmimeint.h.

Function Documentation

◆ _xdg_binary_or_text_fallback()

const char * _xdg_binary_or_text_fallback ( const void *  data,
size_t  len 
)

Definition at line 193 of file xdgmimeint.c.

194{
195 unsigned char *chardata;
196 int i;
197
198 chardata = (unsigned char *) data;
199 for (i = 0; i < 128 && i < len; ++i)
200 {
201 if (chardata[i] < 32 && chardata[i] != 9 && chardata[i] != 10 && chardata[i] != 13)
202 return XDG_MIME_TYPE_UNKNOWN; /* binary data */
203 }
204
205 return XDG_MIME_TYPE_TEXTPLAIN;
206}

Referenced by _xdg_mime_cache_get_mime_type_for_file(), xdg_mime_get_mime_type_for_data(), and xdg_mime_get_mime_type_for_file().

◆ _xdg_convert_to_ucs4()

xdg_unichar_t * _xdg_convert_to_ucs4 ( const char *  source,
int *  len 
)

Definition at line 157 of file xdgmimeint.c.

158{
159 xdg_unichar_t *out;
160 int i;
161 const char *p;
162
163 out = malloc (sizeof (xdg_unichar_t) * (strlen (source) + 1));
164
165 p = source;
166 i = 0;
167 while (*p)
168 {
169 out[i++] = _xdg_utf8_to_ucs4 (p);
170 p = _xdg_utf8_next_char (p);
171 }
172 out[i] = 0;
173 *len = i;
174
175 return out;
176}
xdg_unichar_t _xdg_utf8_to_ucs4(const char *source)
Definition xdgmimeint.c:61
unsigned int xdg_unichar_t
Definition xdgmimeint.h:43

References _xdg_utf8_to_ucs4().

◆ _xdg_get_base_name()

const char * _xdg_get_base_name ( const char *  file_name)

Definition at line 141 of file xdgmimeint.c.

142{
143 const char *base_name;
144
145 if (file_name == NULL)
146 return NULL;
147
148 base_name = strrchr (file_name, '/');
149
150 if (base_name == NULL)
151 return file_name;
152 else
153 return base_name + 1;
154}

Referenced by _xdg_mime_cache_get_mime_type_for_file(), and xdg_mime_get_mime_type_for_file().

◆ _xdg_reverse_ucs4()

void _xdg_reverse_ucs4 ( xdg_unichar_t source,
int  len 
)

Definition at line 179 of file xdgmimeint.c.

180{
182 int i;
183
184 for (i = 0; i < len - i - 1; i++)
185 {
186 c = source[i];
187 source[i] = source[len - i - 1];
188 source[len - i - 1] = c;
189 }
190}

◆ _xdg_ucs4_to_lower()

xdg_unichar_t _xdg_ucs4_to_lower ( xdg_unichar_t  source)

Definition at line 124 of file xdgmimeint.c.

125{
126 /* FIXME: Do a real to_upper sometime */
127 /* CaseFolding-3.2.0.txt has a table of rules. */
128 if ((source & 0xFF) == source)
129 return (xdg_unichar_t) tolower ((unsigned char) source);
130 return source;
131}

◆ _xdg_utf8_to_ucs4()

xdg_unichar_t _xdg_utf8_to_ucs4 ( const char *  source)

Definition at line 61 of file xdgmimeint.c.

62{
63 xdg_unichar_t ucs32;
64 if( ! ( *source & 0x80 ) )
65 {
66 ucs32 = *source;
67 }
68 else
69 {
70 int bytelength = 0;
71 xdg_unichar_t result;
72 if ( ! (*source & 0x40) )
73 {
74 ucs32 = *source;
75 }
76 else
77 {
78 if ( ! (*source & 0x20) )
79 {
80 result = *source++ & 0x1F;
81 bytelength = 2;
82 }
83 else if ( ! (*source & 0x10) )
84 {
85 result = *source++ & 0x0F;
86 bytelength = 3;
87 }
88 else if ( ! (*source & 0x08) )
89 {
90 result = *source++ & 0x07;
91 bytelength = 4;
92 }
93 else if ( ! (*source & 0x04) )
94 {
95 result = *source++ & 0x03;
96 bytelength = 5;
97 }
98 else if ( ! (*source & 0x02) )
99 {
100 result = *source++ & 0x01;
101 bytelength = 6;
102 }
103 else
104 {
105 result = *source++;
106 bytelength = 1;
107 }
108
109 for ( bytelength --; bytelength > 0; bytelength -- )
110 {
111 result <<= 6;
112 result |= *source++ & 0x3F;
113 }
114 ucs32 = result;
115 }
116 }
117 return ucs32;
118}

Referenced by _xdg_convert_to_ucs4().

◆ _xdg_utf8_validate()

int _xdg_utf8_validate ( const char *  source)

Definition at line 134 of file xdgmimeint.c.

135{
136 /* FIXME: actually write */
137 return TRUE;
138}

Referenced by _xdg_mime_cache_get_mime_type_for_file(), xdg_mime_get_mime_type_for_file(), and xdg_mime_is_valid_mime_type().

Variable Documentation

◆ _xdg_utf8_skip

const char* const _xdg_utf8_skip
extern

Definition at line 55 of file xdgmimeint.c.