OLD | NEW |
1 /* -*- mode: C; c-file-style: "gnu" -*- */ | 1 /* -*- mode: C; c-file-style: "gnu" -*- */ |
2 /* xdgmimeint.c: Internal defines and functions. | 2 /* xdgmimeint.c: Internal defines and functions. |
3 * | 3 * |
4 * More info can be found at http://www.freedesktop.org/standards/ | 4 * More info can be found at http://www.freedesktop.org/standards/ |
5 * | 5 * |
6 * Copyright (C) 2003 Red Hat, Inc. | 6 * Copyright (C) 2003 Red Hat, Inc. |
7 * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu> | 7 * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu> |
8 * | 8 * |
9 * Licensed under the Academic Free License version 2.0 | 9 * Licensed under the Academic Free License version 2.0 |
10 * Or under the following terms: | 10 * Or under the following terms: |
11 * | 11 * |
12 * This library is free software; you can redistribute it and/or | 12 * This library is free software; you can redistribute it and/or |
13 * modify it under the terms of the GNU Lesser General Public | 13 * modify it under the terms of the GNU Lesser General Public |
14 * License as published by the Free Software Foundation; either | 14 * License as published by the Free Software Foundation; either |
15 * version 2 of the License, or (at your option) any later version. | 15 * version 2 of the License, or (at your option) any later version. |
16 * | 16 * |
17 * This library is distributed in the hope that it will be useful, | 17 * This library is distributed in the hope that it will be useful, |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 * Lesser General Public License for more details. | 20 * Lesser General Public License for more details. |
21 * | 21 * |
22 * You should have received a copy of the GNU Lesser General Public | 22 * You should have received a copy of the GNU Lesser General Public |
23 * License along with this library; if not, write to the | 23 * License along with this library; if not, write to the |
24 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 24 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
25 * Boston, MA 02111-1307, USA. | 25 * Boston, MA 02111-1307, USA. |
26 */ | 26 */ |
27 | 27 |
28 #ifdef HAVE_CONFIG_H | 28 #ifdef HAVE_CONFIG_H |
29 #include "config.h" | 29 #include <config.h> |
30 #endif | 30 #endif |
31 | 31 |
32 #include "xdgmimeint.h" | 32 #include "xdgmimeint.h" |
33 #include <ctype.h> | 33 #include <ctype.h> |
34 #include <string.h> | 34 #include <string.h> |
35 | 35 |
36 #ifndef FALSE | 36 #ifndef FALSE |
37 #define FALSE (0) | 37 #define FALSE (0) |
38 #endif | 38 #endif |
39 | 39 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 int i; | 182 int i; |
183 | 183 |
184 for (i = 0; i < len - i - 1; i++) | 184 for (i = 0; i < len - i - 1; i++) |
185 { | 185 { |
186 c = source[i]; | 186 c = source[i]; |
187 source[i] = source[len - i - 1]; | 187 source[i] = source[len - i - 1]; |
188 source[len - i - 1] = c; | 188 source[len - i - 1] = c; |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
| 192 const char * |
| 193 _xdg_binary_or_text_fallback(const void *data, size_t len) |
| 194 { |
| 195 unsigned char *chardata; |
| 196 int i; |
| 197 |
| 198 chardata = (unsigned char *) data; |
| 199 for (i = 0; i < 32 && 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 } |
OLD | NEW |