13781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/* -*- mode: C; c-file-style: "gnu" -*- */ 23781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/* xdgmimeint.h: Internal defines and functions. 33781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 43781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * More info can be found at http://www.freedesktop.org/standards/ 53781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 63781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Copyright (C) 2003 Red Hat, Inc. 73781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu> 83781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 93781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Licensed under the Academic Free License version 2.0 103781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Or under the following terms: 113781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 123781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * This library is free software; you can redistribute it and/or 133781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * modify it under the terms of the GNU Lesser General Public 143781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * License as published by the Free Software Foundation; either 153781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * version 2 of the License, or (at your option) any later version. 163781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 173781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * This library is distributed in the hope that it will be useful, 183781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * but WITHOUT ANY WARRANTY; without even the implied warranty of 193781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 203781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Lesser General Public License for more details. 213781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 223781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * You should have received a copy of the GNU Lesser General Public 233781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * License along with this library; if not, write to the 243781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 253781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Boston, MA 02111-1307, USA. 263781343738de4abddf56982325a77bd70a98cd26Alexander Larsson */ 273781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 283781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#ifndef __XDG_MIME_INT_H__ 293781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#define __XDG_MIME_INT_H__ 303781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 313781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#include "xdgmime.h" 323781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 333781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 343781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#ifndef FALSE 353781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#define FALSE (0) 363781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#endif 373781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 383781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#ifndef TRUE 393781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#define TRUE (!FALSE) 403781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#endif 413781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 423781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/* FIXME: Needs to be configure check */ 433781343738de4abddf56982325a77bd70a98cd26Alexander Larssontypedef unsigned int xdg_unichar_t; 443781343738de4abddf56982325a77bd70a98cd26Alexander Larssontypedef unsigned char xdg_uchar8_t; 453781343738de4abddf56982325a77bd70a98cd26Alexander Larssontypedef unsigned short xdg_uint16_t; 463781343738de4abddf56982325a77bd70a98cd26Alexander Larssontypedef unsigned int xdg_uint32_t; 473781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 483781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#ifdef XDG_PREFIX 492bd31c9e6c6159a5ef0a92ea567b48649256ab43Matthias Clasen#define _xdg_utf8_skip XDG_RESERVED_ENTRY(utf8_skip) 502bd31c9e6c6159a5ef0a92ea567b48649256ab43Matthias Clasen#define _xdg_utf8_to_ucs4 XDG_RESERVED_ENTRY(utf8_to_ucs4) 512bd31c9e6c6159a5ef0a92ea567b48649256ab43Matthias Clasen#define _xdg_ucs4_to_lower XDG_RESERVED_ENTRY(ucs4_to_lower) 522bd31c9e6c6159a5ef0a92ea567b48649256ab43Matthias Clasen#define _xdg_utf8_validate XDG_RESERVED_ENTRY(utf8_validate) 532bd31c9e6c6159a5ef0a92ea567b48649256ab43Matthias Clasen#define _xdg_get_base_name XDG_RESERVED_ENTRY(get_base_name) 542bd31c9e6c6159a5ef0a92ea567b48649256ab43Matthias Clasen#define _xdg_convert_to_ucs4 XDG_RESERVED_ENTRY(convert_to_ucs4) 552bd31c9e6c6159a5ef0a92ea567b48649256ab43Matthias Clasen#define _xdg_reverse_ucs4 XDG_RESERVED_ENTRY(reverse_ucs4) 563781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#endif 573781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 583781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#define SWAP_BE16_TO_LE16(val) (xdg_uint16_t)(((xdg_uint16_t)(val) << 8)|((xdg_uint16_t)(val) >> 8)) 593781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 603781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#define SWAP_BE32_TO_LE32(val) (xdg_uint32_t)((((xdg_uint32_t)(val) & 0xFF000000U) >> 24) | \ 613781343738de4abddf56982325a77bd70a98cd26Alexander Larsson (((xdg_uint32_t)(val) & 0x00FF0000U) >> 8) | \ 623781343738de4abddf56982325a77bd70a98cd26Alexander Larsson (((xdg_uint32_t)(val) & 0x0000FF00U) << 8) | \ 633781343738de4abddf56982325a77bd70a98cd26Alexander Larsson (((xdg_uint32_t)(val) & 0x000000FFU) << 24)) 643781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/* UTF-8 utils 653781343738de4abddf56982325a77bd70a98cd26Alexander Larsson */ 663781343738de4abddf56982325a77bd70a98cd26Alexander Larssonextern const char *const _xdg_utf8_skip; 673781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#define _xdg_utf8_next_char(p) (char *)((p) + _xdg_utf8_skip[*(unsigned char *)(p)]) 683781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#define _xdg_utf8_char_size(p) (int) (_xdg_utf8_skip[*(unsigned char *)(p)]) 693781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 703781343738de4abddf56982325a77bd70a98cd26Alexander Larssonxdg_unichar_t _xdg_utf8_to_ucs4 (const char *source); 713781343738de4abddf56982325a77bd70a98cd26Alexander Larssonxdg_unichar_t _xdg_ucs4_to_lower (xdg_unichar_t source); 723781343738de4abddf56982325a77bd70a98cd26Alexander Larssonint _xdg_utf8_validate (const char *source); 732bd31c9e6c6159a5ef0a92ea567b48649256ab43Matthias Clasenxdg_unichar_t *_xdg_convert_to_ucs4 (const char *source, int *len); 742bd31c9e6c6159a5ef0a92ea567b48649256ab43Matthias Clasenvoid _xdg_reverse_ucs4 (xdg_unichar_t *source, int len); 753781343738de4abddf56982325a77bd70a98cd26Alexander Larssonconst char *_xdg_get_base_name (const char *file_name); 763781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 773781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#endif /* __XDG_MIME_INT_H__ */ 78