Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 1 | |
| 2 | /* pngwio.c - functions for data output |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 3 | * |
Glenn Randers-Pehrson | 668af4e | 2009-06-24 06:35:59 -0500 | [diff] [blame] | 4 | * Last changed in libpng 1.4.0 [June 24, 2009] |
Glenn Randers-Pehrson | 79134c6 | 2009-02-14 10:32:18 -0600 | [diff] [blame] | 5 | * Copyright (c) 1998-2009 Glenn Randers-Pehrson |
Glenn Randers-Pehrson | d436672 | 2000-06-04 14:29:29 -0500 | [diff] [blame] | 6 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
| 7 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 8 | * |
Glenn Randers-Pehrson | 3e61d79 | 2009-06-24 09:31:28 -0500 | [diff] [blame^] | 9 | * This code is released under the zlib-libpng license. |
| 10 | * For conditions of distribution and use, see copyright notice in png.h |
| 11 | * |
Glenn Randers-Pehrson | 8686fff | 1998-05-21 09:27:50 -0500 | [diff] [blame] | 12 | * This file provides a location for all output. Users who need |
| 13 | * special handling are expected to write functions that have the same |
| 14 | * arguments as these and perform similar functions, but that possibly |
| 15 | * use different output methods. Note that you shouldn't change these |
Glenn Randers-Pehrson | b6ce43d | 1998-01-01 07:13:13 -0600 | [diff] [blame] | 16 | * functions, but rather write replacement functions and then change |
| 17 | * them at run time with png_set_write_fn(...). |
| 18 | */ |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 19 | |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 20 | #include "png.h" |
Glenn Randers-Pehrson | 3097f61 | 2001-05-07 14:52:45 -0500 | [diff] [blame] | 21 | #ifdef PNG_WRITE_SUPPORTED |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 22 | #include "pngpriv.h" |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 23 | |
| 24 | /* Write the data to whatever output you are using. The default routine |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 25 | * writes to a file pointer. Note that this routine sometimes gets called |
| 26 | * with very small lengths, so you should implement some kind of simple |
| 27 | * buffering if you are using unbuffered writes. This should never be asked |
| 28 | * to write more than 64K on a 16 bit machine. |
| 29 | */ |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 30 | |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 31 | void /* PRIVATE */ |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 32 | png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 33 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 34 | if (png_ptr->write_data_fn != NULL ) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 35 | (*(png_ptr->write_data_fn))(png_ptr, data, length); |
| 36 | else |
| 37 | png_error(png_ptr, "Call to NULL write function"); |
| 38 | } |
| 39 | |
Glenn Randers-Pehrson | 70e3f54 | 1998-01-03 22:40:55 -0600 | [diff] [blame] | 40 | #if !defined(PNG_NO_STDIO) |
Glenn Randers-Pehrson | 8686fff | 1998-05-21 09:27:50 -0500 | [diff] [blame] | 41 | /* This is the function that does the actual writing of data. If you are |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 42 | * not writing to a standard C stream, you should create a replacement |
| 43 | * write_data function and use it at run time with png_set_write_fn(), rather |
| 44 | * than changing the library. |
| 45 | */ |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 46 | #ifndef USE_FAR_KEYWORD |
Glenn Randers-Pehrson | 25d8224 | 2002-05-01 11:51:26 -0500 | [diff] [blame] | 47 | void PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 48 | png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 49 | { |
| 50 | png_uint_32 check; |
| 51 | |
Glenn Randers-Pehrson | d8eb62f | 2009-05-30 20:19:20 -0500 | [diff] [blame] | 52 | if (png_ptr == NULL) |
| 53 | return; |
Glenn Randers-Pehrson | 316f97a | 2000-07-08 13:19:41 -0500 | [diff] [blame] | 54 | check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 55 | if (check != length) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 56 | png_error(png_ptr, "Write Error"); |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 57 | } |
| 58 | #else |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 59 | /* This is the model-independent version. Since the standard I/O library |
| 60 | * can't handle far buffers in the medium and small models, we have to copy |
| 61 | * the data. |
| 62 | */ |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 63 | |
| 64 | #define NEAR_BUF_SIZE 1024 |
| 65 | #define MIN(a,b) (a <= b ? a : b) |
| 66 | |
Glenn Randers-Pehrson | 25d8224 | 2002-05-01 11:51:26 -0500 | [diff] [blame] | 67 | void PNGAPI |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 68 | png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 69 | { |
| 70 | png_uint_32 check; |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 71 | png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ |
Glenn Randers-Pehrson | 316f97a | 2000-07-08 13:19:41 -0500 | [diff] [blame] | 72 | png_FILE_p io_ptr; |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 73 | |
Glenn Randers-Pehrson | d8eb62f | 2009-05-30 20:19:20 -0500 | [diff] [blame] | 74 | if (png_ptr == NULL) |
| 75 | return; |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 76 | /* Check if data really is near. If so, use usual code. */ |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 77 | near_data = (png_byte *)CVT_PTR_NOCHECK(data); |
Glenn Randers-Pehrson | 316f97a | 2000-07-08 13:19:41 -0500 | [diff] [blame] | 78 | io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 79 | if ((png_bytep)near_data == data) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 80 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 81 | check = fwrite(near_data, 1, length, io_ptr); |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 82 | } |
| 83 | else |
| 84 | { |
| 85 | png_byte buf[NEAR_BUF_SIZE]; |
| 86 | png_size_t written, remaining, err; |
| 87 | check = 0; |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 88 | remaining = length; |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 89 | do |
| 90 | { |
| 91 | written = MIN(NEAR_BUF_SIZE, remaining); |
Glenn Randers-Pehrson | 4bb4d01 | 2009-05-20 12:45:29 -0500 | [diff] [blame] | 92 | png_memcpy(buf, data, written); /* Copy far buffer to near buffer */ |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 93 | err = fwrite(buf, 1, written, io_ptr); |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 94 | if (err != written) |
| 95 | break; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 96 | |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 97 | else |
| 98 | check += err; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 99 | |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 100 | data += written; |
| 101 | remaining -= written; |
| 102 | } |
| 103 | while (remaining != 0); |
| 104 | } |
| 105 | if (check != length) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 106 | png_error(png_ptr, "Write Error"); |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | #endif |
Glenn Randers-Pehrson | 70e3f54 | 1998-01-03 22:40:55 -0600 | [diff] [blame] | 110 | #endif |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 111 | |
| 112 | /* This function is called to output any data pending writing (normally |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 113 | * to disk). After png_flush is called, there should be no data pending |
| 114 | * writing in any buffers. |
| 115 | */ |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 116 | #if defined(PNG_WRITE_FLUSH_SUPPORTED) |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 117 | void /* PRIVATE */ |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 118 | png_flush(png_structp png_ptr) |
| 119 | { |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 120 | if (png_ptr->output_flush_fn != NULL) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 121 | (*(png_ptr->output_flush_fn))(png_ptr); |
| 122 | } |
| 123 | |
Glenn Randers-Pehrson | 70e3f54 | 1998-01-03 22:40:55 -0600 | [diff] [blame] | 124 | #if !defined(PNG_NO_STDIO) |
Glenn Randers-Pehrson | 25d8224 | 2002-05-01 11:51:26 -0500 | [diff] [blame] | 125 | void PNGAPI |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 126 | png_default_flush(png_structp png_ptr) |
| 127 | { |
Glenn Randers-Pehrson | 316f97a | 2000-07-08 13:19:41 -0500 | [diff] [blame] | 128 | png_FILE_p io_ptr; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 129 | if (png_ptr == NULL) |
| 130 | return; |
Glenn Randers-Pehrson | 316f97a | 2000-07-08 13:19:41 -0500 | [diff] [blame] | 131 | io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 132 | fflush(io_ptr); |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 133 | } |
| 134 | #endif |
Glenn Randers-Pehrson | 70e3f54 | 1998-01-03 22:40:55 -0600 | [diff] [blame] | 135 | #endif |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 136 | |
| 137 | /* This function allows the application to supply new output functions for |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 138 | * libpng if standard C streams aren't being used. |
| 139 | * |
| 140 | * This function takes as its arguments: |
| 141 | * png_ptr - pointer to a png output data structure |
| 142 | * io_ptr - pointer to user supplied structure containing info about |
| 143 | * the output functions. May be NULL. |
| 144 | * write_data_fn - pointer to a new output function that takes as its |
| 145 | * arguments a pointer to a png_struct, a pointer to |
| 146 | * data to be written, and a 32-bit unsigned int that is |
| 147 | * the number of bytes to be written. The new write |
| 148 | * function should call png_error(png_ptr, "Error msg") |
| 149 | * to exit and output any fatal error messages. May be |
| 150 | * NULL, in which case libpng's default function will |
| 151 | * be used. |
| 152 | * flush_data_fn - pointer to a new flush function that takes as its |
| 153 | * arguments a pointer to a png_struct. After a call to |
| 154 | * the flush function, there should be no data in any buffers |
| 155 | * or pending transmission. If the output method doesn't do |
| 156 | * any buffering of ouput, a function prototype must still be |
| 157 | * supplied although it doesn't have to do anything. If |
| 158 | * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile |
| 159 | * time, output_flush_fn will be ignored, although it must be |
| 160 | * supplied for compatibility. May be NULL, in which case |
| 161 | * libpng's default function will be used, if |
| 162 | * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not |
| 163 | * a good idea if io_ptr does not point to a standard |
| 164 | * *FILE structure. |
| 165 | */ |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 166 | void PNGAPI |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 167 | png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, |
| 168 | png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) |
| 169 | { |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 170 | if (png_ptr == NULL) |
| 171 | return; |
| 172 | |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 173 | png_ptr->io_ptr = io_ptr; |
| 174 | |
Glenn Randers-Pehrson | 70e3f54 | 1998-01-03 22:40:55 -0600 | [diff] [blame] | 175 | #if !defined(PNG_NO_STDIO) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 176 | if (write_data_fn != NULL) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 177 | png_ptr->write_data_fn = write_data_fn; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 178 | |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 179 | else |
Glenn Randers-Pehrson | 25d8224 | 2002-05-01 11:51:26 -0500 | [diff] [blame] | 180 | png_ptr->write_data_fn = png_default_write_data; |
Glenn Randers-Pehrson | 70e3f54 | 1998-01-03 22:40:55 -0600 | [diff] [blame] | 181 | #else |
| 182 | png_ptr->write_data_fn = write_data_fn; |
| 183 | #endif |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 184 | |
| 185 | #if defined(PNG_WRITE_FLUSH_SUPPORTED) |
Glenn Randers-Pehrson | 70e3f54 | 1998-01-03 22:40:55 -0600 | [diff] [blame] | 186 | #if !defined(PNG_NO_STDIO) |
Andreas Dilger | 47a0c42 | 1997-05-16 02:46:07 -0500 | [diff] [blame] | 187 | if (output_flush_fn != NULL) |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 188 | png_ptr->output_flush_fn = output_flush_fn; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 189 | |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 190 | else |
Glenn Randers-Pehrson | 25d8224 | 2002-05-01 11:51:26 -0500 | [diff] [blame] | 191 | png_ptr->output_flush_fn = png_default_flush; |
Glenn Randers-Pehrson | 70e3f54 | 1998-01-03 22:40:55 -0600 | [diff] [blame] | 192 | #else |
| 193 | png_ptr->output_flush_fn = output_flush_fn; |
| 194 | #endif |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 195 | #endif /* PNG_WRITE_FLUSH_SUPPORTED */ |
| 196 | |
| 197 | /* It is an error to read while writing a png file */ |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 198 | if (png_ptr->read_data_fn != NULL) |
| 199 | { |
| 200 | png_ptr->read_data_fn = NULL; |
| 201 | png_warning(png_ptr, |
| 202 | "Attempted to set both read_data_fn and write_data_fn in"); |
| 203 | png_warning(png_ptr, |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 204 | "the same structure. Resetting read_data_fn to NULL"); |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 205 | } |
Guy Schalnat | e5a3779 | 1996-06-05 15:50:50 -0500 | [diff] [blame] | 206 | } |
| 207 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 208 | #if defined(USE_FAR_KEYWORD) |
| 209 | #if defined(_MSC_VER) |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 210 | void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 211 | { |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 212 | void *near_ptr; |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 213 | void FAR *far_ptr; |
| 214 | FP_OFF(near_ptr) = FP_OFF(ptr); |
| 215 | far_ptr = (void FAR *)near_ptr; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 216 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 217 | if (check != 0) |
| 218 | if (FP_SEG(ptr) != FP_SEG(far_ptr)) |
| 219 | png_error(png_ptr, "segment lost in conversion"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 220 | |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 221 | return(near_ptr); |
| 222 | } |
| 223 | # else |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 224 | void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 225 | { |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 226 | void *near_ptr; |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 227 | void FAR *far_ptr; |
| 228 | near_ptr = (void FAR *)ptr; |
| 229 | far_ptr = (void FAR *)near_ptr; |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 230 | |
Glenn Randers-Pehrson | 145f5c8 | 2008-07-10 09:13:13 -0500 | [diff] [blame] | 231 | if (check != 0) |
| 232 | if (far_ptr != ptr) |
| 233 | png_error(png_ptr, "segment lost in conversion"); |
Glenn Randers-Pehrson glennrp@comcast.net | b1c0d33 | 2009-05-15 20:39:34 -0500 | [diff] [blame] | 234 | |
Andreas Dilger | 02ad0ef | 1997-01-17 01:34:35 -0600 | [diff] [blame] | 235 | return(near_ptr); |
| 236 | } |
| 237 | # endif |
| 238 | # endif |
Glenn Randers-Pehrson | 3097f61 | 2001-05-07 14:52:45 -0500 | [diff] [blame] | 239 | #endif /* PNG_WRITE_SUPPORTED */ |