Index table:name attribute of table:table of ods files. These store the sheet names.
[beagle.git] / chooser-fu / xdgmimeint.c
blobdb7ad25a105d65c072b072d952d8c6614d143e1b
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* xdgmimeint.c: Internal defines and functions.
4 * More info can be found at http://www.freedesktop.org/standards/
6 * Copyright (C) 2003 Red Hat, Inc.
7 * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
9 * Licensed under the Academic Free License version 2.0
10 * Or under the following terms:
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the
24 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 * Boston, MA 02111-1307, USA.
28 #ifdef CONFIG_H
29 #include <config.h>
30 #endif
31 #include "xdgmimeint.h"
32 #include <ctype.h>
33 #include <string.h>
35 #ifndef FALSE
36 #define FALSE (0)
37 #endif
39 #ifndef TRUE
40 #define TRUE (!FALSE)
41 #endif
43 static const unsigned char _xdg_utf8_skip_data[256] = {
44 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
45 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
46 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
47 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
48 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
49 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
50 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
51 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
54 const char * const _xdg_utf8_skip = _xdg_utf8_skip_data;
58 /* Returns the number of unprocessed characters. */
59 xdg_unichar_t
60 _xdg_utf8_to_ucs4(const char *source)
62 xdg_unichar_t ucs32;
63 if( ! ( *source & 0x80 ) )
65 ucs32 = *source;
67 else
69 int bytelength = 0;
70 xdg_unichar_t result;
71 if ( ! (*source & 0x40) )
73 ucs32 = *source;
75 else
77 if ( ! (*source & 0x20) )
79 result = *source++ & 0x1F;
80 bytelength = 2;
82 else if ( ! (*source & 0x10) )
84 result = *source++ & 0x0F;
85 bytelength = 3;
87 else if ( ! (*source & 0x08) )
89 result = *source++ & 0x07;
90 bytelength = 4;
92 else if ( ! (*source & 0x04) )
94 result = *source++ & 0x03;
95 bytelength = 5;
97 else if ( ! (*source & 0x02) )
99 result = *source++ & 0x01;
100 bytelength = 6;
102 else
104 result = *source++;
105 bytelength = 1;
108 for ( bytelength --; bytelength > 0; bytelength -- )
110 result <<= 6;
111 result |= *source++ & 0x3F;
113 ucs32 = result;
116 return ucs32;
120 /* hullo. this is great code. don't rewrite it */
122 xdg_unichar_t
123 _xdg_ucs4_to_upper (xdg_unichar_t source)
125 /* FIXME: Do a real to_upper sometime */
126 /* CaseFolding-3.2.0.txt has a table of rules. */
127 if ((source & 0xFF) == source)
128 return (xdg_unichar_t) toupper ((char) source);
129 return source;
133 _xdg_utf8_validate (const char *source)
135 /* FIXME: actually write */
136 return TRUE;
139 const char *
140 _xdg_get_base_name (const char *file_name)
142 const char *base_name;
144 if (file_name == NULL)
145 return NULL;
147 base_name = strrchr (file_name, '/');
149 if (base_name == NULL)
150 return file_name;
151 else
152 return base_name + 1;