The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netsmb/iconv.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: iconv.c,v 1.12 2006/11/16 01:33:51 christos Exp $      */
    2 
    3 /* Public domain */
    4 
    5 #include <sys/cdefs.h>
    6 __KERNEL_RCSID(0, "$NetBSD: iconv.c,v 1.12 2006/11/16 01:33:51 christos Exp $");
    7 
    8 #include <sys/param.h>
    9 #include <sys/kernel.h>
   10 #include <sys/systm.h>
   11 #include <sys/errno.h>
   12 #include <sys/malloc.h>
   13 
   14 #include <netsmb/iconv.h>
   15 
   16 int
   17 iconv_open(const char *to, const char *from,
   18     void **handle)
   19 {
   20         return 0;
   21 }
   22 
   23 int
   24 iconv_close(void *handle)
   25 {
   26         return 0;
   27 }
   28 
   29 int
   30 iconv_conv(void *handle, const char **inbuf,
   31     size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
   32 {
   33         if (*inbytesleft > *outbytesleft)
   34                 return(E2BIG);
   35 
   36         if (inbuf == NULL)
   37                 return(0); /* initial shift state */
   38 
   39         (void)memcpy(*outbuf, *inbuf, *inbytesleft);
   40 
   41         *outbytesleft -= *inbytesleft;
   42 
   43         *inbuf += *inbytesleft;
   44         *outbuf += *inbytesleft;
   45 
   46         *inbytesleft = 0;
   47 
   48         return 0;
   49 }
   50 
   51 char *
   52 iconv_convstr(void *handle, char *dst, const char *src, size_t l)
   53 {
   54         char *p = dst;
   55         size_t inlen, outlen;
   56         int error;
   57 
   58         if (handle == NULL) {
   59                 strlcpy(dst, src, l);
   60                 return dst;
   61         }
   62         inlen = outlen = strlen(src);
   63         error = iconv_conv(handle, NULL, NULL, &p, &outlen);
   64         if (error)
   65                 return NULL;
   66         error = iconv_conv(handle, &src, &inlen, &p, &outlen);
   67         if (error)
   68                 return NULL;
   69         *p = 0;
   70         return dst;
   71 }
   72 
   73 void *
   74 iconv_convmem(void *handle, void *dst, const void *src, int size)
   75 {
   76         const char *s = src;
   77         char *d = dst;
   78         size_t inlen, outlen;
   79         int error;
   80 
   81         if (size == 0)
   82                 return dst;
   83         if (handle == NULL) {
   84                 memcpy(dst, src, size);
   85                 return dst;
   86         }
   87         inlen = outlen = size;
   88         error = iconv_conv(handle, NULL, NULL, &d, &outlen);
   89         if (error)
   90                 return NULL;
   91         error = iconv_conv(handle, &s, &inlen, &d, &outlen);
   92         if (error)
   93                 return NULL;
   94         return dst;
   95 }
   96 
   97 int
   98 iconv_lookupcp(const char **cpp, const char *s)
   99 {
  100         for (; *cpp; cpp++)
  101                 if (strcmp(*cpp, s) == 0)
  102                         return 0;
  103         return ENOENT;
  104 }

Cache object: c1dc85dd96524c12bb5287dae2495d7c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.