home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue6 / SDL.ZIP / !gcc / include / unixlib / h / iconv < prev    next >
Encoding:
Text File  |  2006-09-17  |  3.3 KB  |  90 lines

  1.  
  2.  
  3. #ifndef __ICONV_H
  4. #define __ICONV_H 1
  5.  
  6. #ifndef __UNIXLIB_FEATURES_H
  7. #include <features.h>
  8. #endif
  9.  
  10. #define __need_size_t
  11. #include <stddef.h>
  12.  
  13. __BEGIN_DECLS
  14.  
  15. typedef void *iconv_t;
  16.  
  17. /*
  18.  * Allocate a conversion descriptor suitable for converting byte sequences
  19.  * from encoding from code to encoding tocode.
  20.  * The resulting conversion descriptor may be used any number of times and
  21.  * remains valid until deallocated with iconv_close.
  22.  * A conversion descriptor contains a conversion state. After creation,
  23.  * the state is in the initial state. Using iconv modifies the descriptor's
  24.  * conversion state. The state may be reset by calling iconv with NULL
  25.  * as the inbuf argument.
  26.  *
  27.  * Returns the conversion descriptor on success. On error, (iconv_t)(-1) is
  28.  * returned and errno is set. If errno is set to EINVAL, the implementation
  29.  * does not provide support for conversion between fromcode and tocode.
  30.  */
  31.  
  32. /* This function is a cancellation point.  */
  33. extern iconv_t iconv_open (const char *__tocode, const char *__fromcode);
  34.  
  35. /* Perform character set conversion
  36.  * cd must be a conversion descriptor as allocated by iconv_open.
  37.  *
  38.  * If inbuf is not NULL and *inbuf is not NULL, the multibyte sequence
  39.  * starting at *inbuf is converted into a multibyte sequence starting at
  40.  * *outbuf. At most *inbytesleft bytes, starting at *inbuf, will be read.
  41.  * At most *outbytesleft bytes, starting at *outbuf, will be written.
  42.  *
  43.  * One multibyte character is converted at a time.  For each conversion,
  44.  * *inbuf is incremented and *inbytesleft is decremented by the number of
  45.  * converted input bytes. Similarly, *outbuf is incremented and
  46.  * *outbytesleft is decremented by the number of converted output bytes.
  47.  *
  48.  * Conversion can stop for four reasons:
  49.  *
  50.  * 1. An invalid multibyte input sequence is encountered. In this case,
  51.  *    errno is set to EILSEQ and (size_t)(-1) is returned. *inbuf points
  52.  *    to the start of the illegal sequence.
  53.  *
  54.  * 2. The input sequence has been entirely converted. In this case, the
  55.  *    number of non-reversible conversions performed is returned.
  56.  *
  57.  * 3. An incomplete multibyte sequence is encountered in the input and
  58.  *    the input terminates after it. In this case, errno is set to EINVAL
  59.  *    and (size_t)(-1) is returned.
  60.  *
  61.  * 4. The output buffer has no room for the next converted character.
  62.  *    In this case, errno is set to E2BIG and (size_t)(-1) is returned.
  63.  *
  64.  * If inbuf is NULL or *inbuf is NULL but outbuf is not NULL and *outbuf is
  65.  * not NULL, the function attempts to set cd's conversion state to the
  66.  * initial state and store a corresponding shift sequence in *outbuf.
  67.  * At most *outbytesleft will be written. If the output buffer is too small
  68.  * for this reset sequence, errno is set to E2BIG and (size_t)(-1) is
  69.  * returned. Otherwise *outbuf is incremented and *outbytesleft is
  70.  * decremented by the number of bytes written.
  71.  *
  72.  * If inbuf or *inbuf and outbuf or *outbuf are NULL, cd is reset to the
  73.  * initial conversion state.
  74.  */
  75. extern size_t iconv (iconv_t __cd,
  76.              char **__restrict __inbuf,
  77.              size_t *__restrict __inbytesleft,
  78.              char **__restrict __outbuf,
  79.              size_t *__restrict __outbytesleft);
  80.  
  81. /* Deallocate a conversion descriptor cd.
  82.  * Returns 0 on success, -1 on error and sets errno
  83.  
  84.  This function is a possible cancellation point.  */
  85. extern int iconv_close (iconv_t __cd);
  86.  
  87. __END_DECLS
  88.  
  89. #endif
  90.