OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [iconv/] [lib/] [nullconv.c] - Blame information for rev 517

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (c) 2003-2004, Artem B. Bityuckiy
3
 * Copyright (c) 1999,2000, Konstantin Chuguev. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 */
26
#include <_ansi.h>
27
#include <reent.h>
28
#include <sys/types.h>
29
#include <errno.h>
30
#include <stdlib.h>
31
#include <string.h>
32
#include "local.h"
33
#include "conv.h"
34
 
35
static int null_conversion_dummy_data;
36
 
37
 
38
static _VOID_PTR
39
_DEFUN(null_conversion_open, (rptr, to, from),
40
                             struct _reent *rptr _AND
41
                             _CONST char *to     _AND
42
                             _CONST char *from)
43
{
44
  return (_VOID_PTR)&null_conversion_dummy_data;
45
}
46
 
47
 
48
static size_t
49
_DEFUN(null_conversion_close, (rptr, data),
50
                              struct _reent *rptr _AND
51
                              _VOID_PTR data)
52
{
53
  return 0;
54
}
55
 
56
 
57
static size_t
58
_DEFUN(null_conversion_convert,
59
                     (rptr, data, inbuf, inbytesleft, outbuf, outbytesleft),
60
                     struct _reent *rptr          _AND
61
                     _VOID_PTR data               _AND
62
                     _CONST unsigned char **inbuf _AND
63
                     size_t *inbytesleft          _AND
64
                     unsigned char **outbuf       _AND
65
                     size_t *outbytesleft         _AND
66
                     int flags)
67
{
68
  size_t result;
69
  size_t len;
70
 
71
  if (*inbytesleft < *outbytesleft)
72
    {
73
      result = 0;
74
      len = *inbytesleft;
75
    }
76
  else
77
    {
78
      result = (size_t)-1;
79
      len = *outbytesleft;
80
      __errno_r (rptr) = E2BIG;
81
    }
82
 
83
  if ((flags & 1) == 0)
84
    memcpy (*outbuf, *inbuf, len);
85
 
86
  *inbuf        += len;
87
  *outbuf       += len;
88
  *inbytesleft  -= len;
89
  *outbytesleft -= len;
90
 
91
  return result;
92
}
93
 
94
 
95
static int
96
_DEFUN(null_conversion_get_mb_cur_max, (data, direction),
97
                                       _VOID_PTR data     _AND
98
                                       int direction)
99
{
100
  return ICONV_MB_LEN_MAX;
101
}
102
 
103
 
104
static _VOID
105
_DEFUN(null_conversion_get_state, (data, state, size),
106
                                  _VOID_PTR data   _AND
107
                                  mbstate_t *state _AND
108
                                  int direction)
109
{
110
  return;
111
}
112
 
113
 
114
static int
115
_DEFUN(null_conversion_set_state, (data, state, direction),
116
                                  _VOID_PTR data   _AND
117
                                  mbstate_t *state _AND
118
                                  int direction)
119
{
120
  return 0;
121
}
122
 
123
static int
124
_DEFUN(null_conversion_is_stateful, (data, direction),
125
                                    _VOID_PTR data _AND
126
                                    int direction)
127
{
128
  return 0;
129
}
130
 
131
/* Null conversion definition object */
132
_CONST iconv_conversion_handlers_t
133
_iconv_null_conversion_handlers =
134
{
135
  null_conversion_open,
136
  null_conversion_close,
137
  null_conversion_convert,
138
  null_conversion_get_state,
139
  null_conversion_set_state,
140
  null_conversion_get_mb_cur_max,
141
  null_conversion_is_stateful
142
};
143
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.