bsd_iconv.c (252547) | bsd_iconv.c (254273) |
---|---|
1/* $FreeBSD: head/lib/libc/iconv/iconv.c 252547 2013-07-03 07:03:19Z peter $ */ | 1/* $FreeBSD: head/lib/libc/iconv/iconv.c 254273 2013-08-13 07:15:01Z peter $ */ |
2/* $NetBSD: iconv.c,v 1.11 2009/03/03 16:22:33 explorer Exp $ */ 3 4/*- 5 * Copyright (c) 2003 Citrus Project, 6 * Copyright (c) 2009, 2010 Gabor Kovesdan <gabor@FreeBSD.org>, 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 32 unchanged lines hidden (view full) --- 42#include <string.h> 43 44#include "citrus_types.h" 45#include "citrus_module.h" 46#include "citrus_esdb.h" 47#include "citrus_hash.h" 48#include "citrus_iconv.h" 49 | 2/* $NetBSD: iconv.c,v 1.11 2009/03/03 16:22:33 explorer Exp $ */ 3 4/*- 5 * Copyright (c) 2003 Citrus Project, 6 * Copyright (c) 2009, 2010 Gabor Kovesdan <gabor@FreeBSD.org>, 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 32 unchanged lines hidden (view full) --- 42#include <string.h> 43 44#include "citrus_types.h" 45#include "citrus_module.h" 46#include "citrus_esdb.h" 47#include "citrus_hash.h" 48#include "citrus_iconv.h" 49 |
50__weak_reference(libiconv, iconv); 51__weak_reference(libiconv_open, iconv_open); 52__weak_reference(libiconv_open_into, iconv_open_into); 53__weak_reference(libiconv_close, iconv_close); 54__weak_reference(libiconvlist, iconvlist); 55__weak_reference(libiconvctl, iconvctl); 56__weak_reference(libiconv_set_relocation_prefix, iconv_set_relocation_prefix); | 50#include <_libiconv_compat.h> 51#ifdef __LIBICONV_COMPAT 52__weak_reference(iconv, libiconv); 53__weak_reference(iconv_open, libiconv_open); 54__weak_reference(iconv_open_into, libiconv_open_into); 55__weak_reference(iconv_close, libiconv_close); 56__weak_reference(iconvlist, libiconvlist); 57__weak_reference(iconvctl, libiconvctl); 58__weak_reference(iconv_set_relocation_prefix, libiconv_set_relocation_prefix); 59__weak_reference(_iconv_version, _libiconv_version); 60#endif |
57 58#define ISBADF(_h_) (!(_h_) || (_h_) == (iconv_t)-1) 59 | 61 62#define ISBADF(_h_) (!(_h_) || (_h_) == (iconv_t)-1) 63 |
60int _libiconv_version = _LIBICONV_VERSION; | 64int _iconv_version = _ICONV_VERSION; |
61 62iconv_t _iconv_open(const char *out, const char *in, 63 struct _citrus_iconv *prealloc); 64 65iconv_t 66_iconv_open(const char *out, const char *in, struct _citrus_iconv *handle) 67{ 68 const char *out_slashes; --- 26 unchanged lines hidden (view full) --- 95 96 handle->cv_shared->ci_discard_ilseq = strcasestr(out, "//IGNORE"); 97 handle->cv_shared->ci_hooks = NULL; 98 99 return ((iconv_t)(void *)handle); 100} 101 102iconv_t | 65 66iconv_t _iconv_open(const char *out, const char *in, 67 struct _citrus_iconv *prealloc); 68 69iconv_t 70_iconv_open(const char *out, const char *in, struct _citrus_iconv *handle) 71{ 72 const char *out_slashes; --- 26 unchanged lines hidden (view full) --- 99 100 handle->cv_shared->ci_discard_ilseq = strcasestr(out, "//IGNORE"); 101 handle->cv_shared->ci_hooks = NULL; 102 103 return ((iconv_t)(void *)handle); 104} 105 106iconv_t |
103libiconv_open(const char *out, const char *in) | 107iconv_open(const char *out, const char *in) |
104{ 105 106 return (_iconv_open(out, in, NULL)); 107} 108 109int | 108{ 109 110 return (_iconv_open(out, in, NULL)); 111} 112 113int |
110libiconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr) | 114iconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr) |
111{ 112 struct _citrus_iconv *handle; 113 114 handle = (struct _citrus_iconv *)ptr; 115 return ((_iconv_open(out, in, handle) == (iconv_t)-1) ? -1 : 0); 116} 117 118int | 115{ 116 struct _citrus_iconv *handle; 117 118 handle = (struct _citrus_iconv *)ptr; 119 return ((_iconv_open(out, in, handle) == (iconv_t)-1) ? -1 : 0); 120} 121 122int |
119libiconv_close(iconv_t handle) | 123iconv_close(iconv_t handle) |
120{ 121 122 if (ISBADF(handle)) { 123 errno = EBADF; 124 return (-1); 125 } 126 127 _citrus_iconv_close((struct _citrus_iconv *)(void *)handle); 128 129 return (0); 130} 131 132size_t | 124{ 125 126 if (ISBADF(handle)) { 127 errno = EBADF; 128 return (-1); 129 } 130 131 _citrus_iconv_close((struct _citrus_iconv *)(void *)handle); 132 133 return (0); 134} 135 136size_t |
133libiconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *szout) | 137iconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *szout) |
134{ 135 size_t ret; 136 int err; 137 138 if (ISBADF(handle)) { 139 errno = EBADF; 140 return ((size_t)-1); 141 } --- 63 unchanged lines hidden (view full) --- 205 const char * const *s2; 206 207 s1 = first; 208 s2 = second; 209 return (strcmp(*s1, *s2)); 210} 211 212void | 138{ 139 size_t ret; 140 int err; 141 142 if (ISBADF(handle)) { 143 errno = EBADF; 144 return ((size_t)-1); 145 } --- 63 unchanged lines hidden (view full) --- 209 const char * const *s2; 210 211 s1 = first; 212 s2 = second; 213 return (strcmp(*s1, *s2)); 214} 215 216void |
213libiconvlist(int (*do_one) (unsigned int, const char * const *, | 217iconvlist(int (*do_one) (unsigned int, const char * const *, |
214 void *), void *data) 215{ 216 char **list, **names; 217 const char * const *np; 218 char *curitem, *curkey, *slashpos; 219 size_t sz; 220 unsigned int i, j; 221 --- 37 unchanged lines hidden (view full) --- 259__inline const char 260*iconv_canonicalize(const char *name) 261{ 262 263 return (_citrus_iconv_canonicalize(name)); 264} 265 266int | 218 void *), void *data) 219{ 220 char **list, **names; 221 const char * const *np; 222 char *curitem, *curkey, *slashpos; 223 size_t sz; 224 unsigned int i, j; 225 --- 37 unchanged lines hidden (view full) --- 263__inline const char 264*iconv_canonicalize(const char *name) 265{ 266 267 return (_citrus_iconv_canonicalize(name)); 268} 269 270int |
267libiconvctl(iconv_t cd, int request, void *argument) | 271iconvctl(iconv_t cd, int request, void *argument) |
268{ 269 struct _citrus_iconv *cv; 270 struct iconv_hooks *hooks; 271 const char *convname; 272 char src[PATH_MAX], *dst; 273 int *i; 274 275 cv = (struct _citrus_iconv *)(void *)cd; --- 35 unchanged lines hidden (view full) --- 311 return (-1); 312 default: 313 errno = EINVAL; 314 return (-1); 315 } 316} 317 318void | 272{ 273 struct _citrus_iconv *cv; 274 struct iconv_hooks *hooks; 275 const char *convname; 276 char src[PATH_MAX], *dst; 277 int *i; 278 279 cv = (struct _citrus_iconv *)(void *)cd; --- 35 unchanged lines hidden (view full) --- 315 return (-1); 316 default: 317 errno = EINVAL; 318 return (-1); 319 } 320} 321 322void |
319libiconv_set_relocation_prefix(const char *orig_prefix __unused, | 323iconv_set_relocation_prefix(const char *orig_prefix __unused, |
320 const char *curr_prefix __unused) 321{ 322 323} | 324 const char *curr_prefix __unused) 325{ 326 327} |