Cygwin: access: Fix X_OK behaviour for backup operators and admins
[newlib-cygwin.git] / newlib / libc / iconv / lib / nullconv.c
blobcc4229181f56debd50c214badc69c99d25030d29
1 /*
2 * Copyright (c) 2003-2004, Artem B. Bityuckiy
3 * Copyright (c) 1999,2000, Konstantin Chuguev. All rights reserved.
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.
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.
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"
35 static int null_conversion_dummy_data;
38 static void *
39 null_conversion_open (struct _reent *rptr,
40 const char *to,
41 const char *from)
43 return (void *)&null_conversion_dummy_data;
47 static size_t
48 null_conversion_close (struct _reent *rptr,
49 void *data)
51 return 0;
55 static size_t
56 null_conversion_convert (struct _reent *rptr,
57 void *data,
58 const unsigned char **inbuf,
59 size_t *inbytesleft,
60 unsigned char **outbuf,
61 size_t *outbytesleft,
62 int flags)
64 size_t result;
65 size_t len;
67 if (*inbytesleft < *outbytesleft)
69 result = 0;
70 len = *inbytesleft;
72 else
74 result = (size_t)-1;
75 len = *outbytesleft;
76 _REENT_ERRNO (rptr) = E2BIG;
79 if ((flags & 1) == 0)
80 memcpy (*outbuf, *inbuf, len);
82 *inbuf += len;
83 *outbuf += len;
84 *inbytesleft -= len;
85 *outbytesleft -= len;
87 return result;
91 static int
92 null_conversion_get_mb_cur_max (void *data,
93 int direction)
95 return ICONV_MB_LEN_MAX;
99 static void
100 null_conversion_get_state (void *data,
101 mbstate_t *state,
102 int direction)
104 return;
108 static int
109 null_conversion_set_state (void *data,
110 mbstate_t *state,
111 int direction)
113 return 0;
116 static int
117 null_conversion_is_stateful (void *data,
118 int direction)
120 return 0;
123 /* Null conversion definition object */
124 const iconv_conversion_handlers_t
125 _iconv_null_conversion_handlers =
127 null_conversion_open,
128 null_conversion_close,
129 null_conversion_convert,
130 null_conversion_get_state,
131 null_conversion_set_state,
132 null_conversion_get_mb_cur_max,
133 null_conversion_is_stateful