LCOV - code coverage report
Current view: top level - lib - stringprep.c (source / functions) Hit Total Coverage
Test: GNU Libidn Lines: 133 158 84.2 %
Date: 2015-08-01 15:30:48 Functions: 6 8 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* stringprep.c --- Core stringprep implementation.
       2             :    Copyright (C) 2002-2015 Simon Josefsson
       3             : 
       4             :    This file is part of GNU Libidn.
       5             : 
       6             :    GNU Libidn is free software: you can redistribute it and/or
       7             :    modify it under the terms of either:
       8             : 
       9             :      * the GNU Lesser General Public License as published by the Free
      10             :        Software Foundation; either version 3 of the License, or (at
      11             :        your option) any later version.
      12             : 
      13             :    or
      14             : 
      15             :      * the GNU General Public License as published by the Free
      16             :        Software Foundation; either version 2 of the License, or (at
      17             :        your option) any later version.
      18             : 
      19             :    or both in parallel, as here.
      20             : 
      21             :    GNU Libidn is distributed in the hope that it will be useful,
      22             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      23             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24             :    General Public License for more details.
      25             : 
      26             :    You should have received copies of the GNU General Public License and
      27             :    the GNU Lesser General Public License along with this program.  If
      28             :    not, see <http://www.gnu.org/licenses/>. */
      29             : 
      30             : #ifdef HAVE_CONFIG_H
      31             : # include "config.h"
      32             : #endif
      33             : 
      34             : #include <stdlib.h>
      35             : #include <string.h>
      36             : 
      37             : #include "stringprep.h"
      38             : 
      39             : static ssize_t
      40       22583 : stringprep_find_character_in_table (uint32_t ucs4,
      41             :                                     const Stringprep_table_element * table)
      42             : {
      43             :   ssize_t i;
      44             : 
      45             :   /* This is where typical uses of Libidn spends very close to all CPU
      46             :      time and causes most cache misses.  One could easily do a binary
      47             :      search instead.  Before rewriting this, I want hard evidence this
      48             :      slowness is at all relevant in typical applications.  (I don't
      49             :      dispute optimization may improve matters significantly, I'm
      50             :      mostly interested in having someone give real-world benchmark on
      51             :      the impact of libidn.) */
      52             : 
      53     3858362 :   for (i = 0; table[i].start || table[i].end; i++)
      54     4556765 :     if (ucs4 >= table[i].start &&
      55      720628 :         ucs4 <= (table[i].end ? table[i].end : table[i].start))
      56         358 :       return i;
      57             : 
      58       22225 :   return -1;
      59             : }
      60             : 
      61             : static ssize_t
      62        3083 : stringprep_find_string_in_table (uint32_t * ucs4,
      63             :                                  size_t ucs4len,
      64             :                                  size_t * tablepos,
      65             :                                  const Stringprep_table_element * table)
      66             : {
      67             :   size_t j;
      68             :   ssize_t pos;
      69             : 
      70       25306 :   for (j = 0; j < ucs4len; j++)
      71       22563 :     if ((pos = stringprep_find_character_in_table (ucs4[j], table)) != -1)
      72             :       {
      73         340 :         if (tablepos)
      74         119 :           *tablepos = pos;
      75         340 :         return j;
      76             :       }
      77             : 
      78        2743 :   return -1;
      79             : }
      80             : 
      81             : static int
      82         447 : stringprep_apply_table_to_string (uint32_t * ucs4,
      83             :                                   size_t * ucs4len,
      84             :                                   size_t maxucs4len,
      85             :                                   const Stringprep_table_element * table)
      86             : {
      87             :   ssize_t pos;
      88             :   size_t i, maplen;
      89             : 
      90        1013 :   while ((pos = stringprep_find_string_in_table (ucs4, *ucs4len,
      91             :                                                  &i, table)) != -1)
      92             :     {
      93         565 :       for (maplen = STRINGPREP_MAX_MAP_CHARS;
      94         756 :            maplen > 0 && table[i].map[maplen - 1] == 0; maplen--)
      95             :         ;
      96             : 
      97         119 :       if (*ucs4len - 1 + maplen >= maxucs4len)
      98           0 :         return STRINGPREP_TOO_SMALL_BUFFER;
      99             : 
     100         119 :       memmove (&ucs4[pos + maplen], &ucs4[pos + 1],
     101         119 :                sizeof (uint32_t) * (*ucs4len - pos - 1));
     102         119 :       memcpy (&ucs4[pos], table[i].map, sizeof (uint32_t) * maplen);
     103         119 :       *ucs4len = *ucs4len - 1 + maplen;
     104             :     }
     105             : 
     106         447 :   return STRINGPREP_OK;
     107             : }
     108             : 
     109             : #define INVERTED(x) ((x) & ((~0UL) >> 1))
     110             : #define UNAPPLICAPLEFLAGS(flags, profileflags) \
     111             :   ((!INVERTED(profileflags) && !(profileflags & flags) && profileflags) || \
     112             :    ( INVERTED(profileflags) && (profileflags & flags)))
     113             : 
     114             : /**
     115             :  * stringprep_4i:
     116             :  * @ucs4: input/output array with string to prepare.
     117             :  * @len: on input, length of input array with Unicode code points,
     118             :  *   on exit, length of output array with Unicode code points.
     119             :  * @maxucs4len: maximum length of input/output array.
     120             :  * @flags: a #Stringprep_profile_flags value, or 0.
     121             :  * @profile: pointer to #Stringprep_profile to use.
     122             :  *
     123             :  * Prepare the input UCS-4 string according to the stringprep profile,
     124             :  * and write back the result to the input string.
     125             :  *
     126             :  * The input is not required to be zero terminated (@ucs4[@len] = 0).
     127             :  * The output will not be zero terminated unless @ucs4[@len] = 0.
     128             :  * Instead, see stringprep_4zi() if your input is zero terminated or
     129             :  * if you want the output to be.
     130             :  *
     131             :  * Since the stringprep operation can expand the string, @maxucs4len
     132             :  * indicate how large the buffer holding the string is.  This function
     133             :  * will not read or write to code points outside that size.
     134             :  *
     135             :  * The @flags are one of #Stringprep_profile_flags values, or 0.
     136             :  *
     137             :  * The @profile contain the #Stringprep_profile instructions to
     138             :  * perform.  Your application can define new profiles, possibly
     139             :  * re-using the generic stringprep tables that always will be part of
     140             :  * the library, or use one of the currently supported profiles.
     141             :  *
     142             :  * Return value: Returns %STRINGPREP_OK iff successful, or an
     143             :  *   #Stringprep_rc error code.
     144             :  **/
     145             : int
     146         225 : stringprep_4i (uint32_t * ucs4, size_t * len, size_t maxucs4len,
     147             :                Stringprep_profile_flags flags,
     148             :                const Stringprep_profile * profile)
     149             : {
     150             :   size_t i, j;
     151             :   ssize_t k;
     152         225 :   size_t ucs4len = *len;
     153             :   int rc;
     154             : 
     155        3647 :   for (i = 0; profile[i].operation; i++)
     156             :     {
     157        3471 :       switch (profile[i].operation)
     158             :         {
     159             :         case STRINGPREP_NFKC:
     160             :           {
     161         224 :             uint32_t *q = 0;
     162             : 
     163         224 :             if (UNAPPLICAPLEFLAGS (flags, profile[i].flags))
     164             :               break;
     165             : 
     166         224 :             if (flags & STRINGPREP_NO_NFKC && !profile[i].flags)
     167             :               /* Profile requires NFKC, but callee asked for no NFKC. */
     168           1 :               return STRINGPREP_FLAG_ERROR;
     169             : 
     170         223 :             q = stringprep_ucs4_nfkc_normalize (ucs4, ucs4len);
     171         223 :             if (!q)
     172           0 :               return STRINGPREP_NFKC_FAILED;
     173             : 
     174         223 :             for (ucs4len = 0; q[ucs4len]; ucs4len++)
     175             :               ;
     176             : 
     177         223 :             if (ucs4len >= maxucs4len)
     178             :               {
     179           0 :                 free (q);
     180           0 :                 return STRINGPREP_TOO_SMALL_BUFFER;
     181             :               }
     182             : 
     183         223 :             memcpy (ucs4, q, ucs4len * sizeof (ucs4[0]));
     184             : 
     185         223 :             free (q);
     186             :           }
     187         223 :           break;
     188             : 
     189             :         case STRINGPREP_PROHIBIT_TABLE:
     190        1895 :           k = stringprep_find_string_in_table (ucs4, ucs4len,
     191        1895 :                                                NULL, profile[i].table);
     192        1895 :           if (k != -1)
     193          34 :             return STRINGPREP_CONTAINS_PROHIBITED;
     194        1861 :           break;
     195             : 
     196             :         case STRINGPREP_UNASSIGNED_TABLE:
     197         178 :           if (UNAPPLICAPLEFLAGS (flags, profile[i].flags))
     198             :             break;
     199         178 :           if (flags & STRINGPREP_NO_UNASSIGNED)
     200             :             {
     201          52 :               k = stringprep_find_string_in_table
     202          52 :                 (ucs4, ucs4len, NULL, profile[i].table);
     203          52 :               if (k != -1)
     204           3 :                 return STRINGPREP_CONTAINS_UNASSIGNED;
     205             :             }
     206         175 :           break;
     207             : 
     208             :         case STRINGPREP_MAP_TABLE:
     209         447 :           if (UNAPPLICAPLEFLAGS (flags, profile[i].flags))
     210             :             break;
     211         447 :           rc = stringprep_apply_table_to_string
     212         447 :             (ucs4, &ucs4len, maxucs4len, profile[i].table);
     213         447 :           if (rc != STRINGPREP_OK)
     214           0 :             return rc;
     215         447 :           break;
     216             : 
     217             :         case STRINGPREP_BIDI_PROHIBIT_TABLE:
     218             :         case STRINGPREP_BIDI_RAL_TABLE:
     219             :         case STRINGPREP_BIDI_L_TABLE:
     220         537 :           break;
     221             : 
     222             :         case STRINGPREP_BIDI:
     223             :           {
     224         190 :             int done_prohibited = 0;
     225         190 :             int done_ral = 0;
     226         190 :             int done_l = 0;
     227         190 :             size_t contains_ral = SIZE_MAX;
     228         190 :             size_t contains_l = SIZE_MAX;
     229             : 
     230        3427 :             for (j = 0; profile[j].operation; j++)
     231        3237 :               if (profile[j].operation == STRINGPREP_BIDI_PROHIBIT_TABLE)
     232             :                 {
     233         190 :                   done_prohibited = 1;
     234         190 :                   k = stringprep_find_string_in_table (ucs4, ucs4len,
     235             :                                                        NULL,
     236         190 :                                                        profile[j].table);
     237         190 :                   if (k != -1)
     238           0 :                     return STRINGPREP_BIDI_CONTAINS_PROHIBITED;
     239             :                 }
     240        3047 :               else if (profile[j].operation == STRINGPREP_BIDI_RAL_TABLE)
     241             :                 {
     242         190 :                   done_ral = 1;
     243         190 :                   if (stringprep_find_string_in_table
     244         190 :                       (ucs4, ucs4len, NULL, profile[j].table) != -1)
     245          19 :                     contains_ral = j;
     246             :                 }
     247        2857 :               else if (profile[j].operation == STRINGPREP_BIDI_L_TABLE)
     248             :                 {
     249         190 :                   done_l = 1;
     250         190 :                   if (stringprep_find_string_in_table
     251         190 :                       (ucs4, ucs4len, NULL, profile[j].table) != -1)
     252         165 :                     contains_l = j;
     253             :                 }
     254             : 
     255         190 :             if (!done_prohibited || !done_ral || !done_l)
     256           0 :               return STRINGPREP_PROFILE_ERROR;
     257             : 
     258         190 :             if (contains_ral != SIZE_MAX && contains_l != SIZE_MAX)
     259           9 :               return STRINGPREP_BIDI_BOTH_L_AND_RAL;
     260             : 
     261         181 :             if (contains_ral != SIZE_MAX)
     262             :               {
     263          20 :                 if (!(stringprep_find_character_in_table
     264          10 :                       (ucs4[0], profile[contains_ral].table) != -1 &&
     265          20 :                       stringprep_find_character_in_table
     266          20 :                       (ucs4[ucs4len - 1], profile[contains_ral].table) != -1))
     267           2 :                   return STRINGPREP_BIDI_LEADTRAIL_NOT_RAL;
     268             :               }
     269             :           }
     270         179 :           break;
     271             : 
     272             :         default:
     273           0 :           return STRINGPREP_PROFILE_ERROR;
     274             :           break;
     275             :         }
     276             :     }
     277             : 
     278         176 :   *len = ucs4len;
     279             : 
     280         176 :   return STRINGPREP_OK;
     281             : }
     282             : 
     283             : static int
     284           0 : stringprep_4zi_1 (uint32_t * ucs4, size_t ucs4len, size_t maxucs4len,
     285             :                   Stringprep_profile_flags flags,
     286             :                   const Stringprep_profile * profile)
     287             : {
     288             :   int rc;
     289             : 
     290           0 :   rc = stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
     291           0 :   if (rc != STRINGPREP_OK)
     292           0 :     return rc;
     293             : 
     294           0 :   if (ucs4len >= maxucs4len)
     295           0 :     return STRINGPREP_TOO_SMALL_BUFFER;
     296             : 
     297           0 :   ucs4[ucs4len] = 0;
     298             : 
     299           0 :   return STRINGPREP_OK;
     300             : }
     301             : 
     302             : /**
     303             :  * stringprep_4zi:
     304             :  * @ucs4: input/output array with zero terminated string to prepare.
     305             :  * @maxucs4len: maximum length of input/output array.
     306             :  * @flags: a #Stringprep_profile_flags value, or 0.
     307             :  * @profile: pointer to #Stringprep_profile to use.
     308             :  *
     309             :  * Prepare the input zero terminated UCS-4 string according to the
     310             :  * stringprep profile, and write back the result to the input string.
     311             :  *
     312             :  * Since the stringprep operation can expand the string, @maxucs4len
     313             :  * indicate how large the buffer holding the string is.  This function
     314             :  * will not read or write to code points outside that size.
     315             :  *
     316             :  * The @flags are one of #Stringprep_profile_flags values, or 0.
     317             :  *
     318             :  * The @profile contain the #Stringprep_profile instructions to
     319             :  * perform.  Your application can define new profiles, possibly
     320             :  * re-using the generic stringprep tables that always will be part of
     321             :  * the library, or use one of the currently supported profiles.
     322             :  *
     323             :  * Return value: Returns %STRINGPREP_OK iff successful, or an
     324             :  *   #Stringprep_rc error code.
     325             :  **/
     326             : int
     327           0 : stringprep_4zi (uint32_t * ucs4, size_t maxucs4len,
     328             :                 Stringprep_profile_flags flags,
     329             :                 const Stringprep_profile * profile)
     330             : {
     331             :   size_t ucs4len;
     332             : 
     333           0 :   for (ucs4len = 0; ucs4len < maxucs4len && ucs4[ucs4len] != 0; ucs4len++)
     334             :     ;
     335             : 
     336           0 :   return stringprep_4zi_1 (ucs4, ucs4len, maxucs4len, flags, profile);
     337             : }
     338             : 
     339             : /**
     340             :  * stringprep:
     341             :  * @in: input/ouput array with string to prepare.
     342             :  * @maxlen: maximum length of input/output array.
     343             :  * @flags: a #Stringprep_profile_flags value, or 0.
     344             :  * @profile: pointer to #Stringprep_profile to use.
     345             :  *
     346             :  * Prepare the input zero terminated UTF-8 string according to the
     347             :  * stringprep profile, and write back the result to the input string.
     348             :  *
     349             :  * Note that you must convert strings entered in the systems locale
     350             :  * into UTF-8 before using this function, see
     351             :  * stringprep_locale_to_utf8().
     352             :  *
     353             :  * Since the stringprep operation can expand the string, @maxlen
     354             :  * indicate how large the buffer holding the string is.  This function
     355             :  * will not read or write to characters outside that size.
     356             :  *
     357             :  * The @flags are one of #Stringprep_profile_flags values, or 0.
     358             :  *
     359             :  * The @profile contain the #Stringprep_profile instructions to
     360             :  * perform.  Your application can define new profiles, possibly
     361             :  * re-using the generic stringprep tables that always will be part of
     362             :  * the library, or use one of the currently supported profiles.
     363             :  *
     364             :  * Return value: Returns %STRINGPREP_OK iff successful, or an error code.
     365             :  **/
     366             : int
     367         225 : stringprep (char *in,
     368             :             size_t maxlen,
     369             :             Stringprep_profile_flags flags,
     370             :             const Stringprep_profile * profile)
     371             : {
     372             :   int rc;
     373         225 :   char *utf8 = NULL;
     374         225 :   uint32_t *ucs4 = NULL;
     375         225 :   size_t ucs4len, maxucs4len, adducs4len = 50;
     376             : 
     377             :   do
     378             :     {
     379             :       uint32_t *newp;
     380             : 
     381         225 :       free (ucs4);
     382         225 :       ucs4 = stringprep_utf8_to_ucs4 (in, -1, &ucs4len);
     383         225 :       if (ucs4 == NULL)
     384           0 :         return STRINGPREP_ICONV_ERROR;
     385         225 :       maxucs4len = ucs4len + adducs4len;
     386         225 :       newp = realloc (ucs4, maxucs4len * sizeof (uint32_t));
     387         225 :       if (!newp)
     388             :         {
     389           0 :           free (ucs4);
     390           0 :           return STRINGPREP_MALLOC_ERROR;
     391             :         }
     392         225 :       ucs4 = newp;
     393             : 
     394         225 :       rc = stringprep_4i (ucs4, &ucs4len, maxucs4len, flags, profile);
     395         225 :       adducs4len += 50;
     396             :     }
     397         225 :   while (rc == STRINGPREP_TOO_SMALL_BUFFER);
     398         225 :   if (rc != STRINGPREP_OK)
     399             :     {
     400          49 :       free (ucs4);
     401          49 :       return rc;
     402             :     }
     403             : 
     404         176 :   utf8 = stringprep_ucs4_to_utf8 (ucs4, ucs4len, 0, 0);
     405         176 :   free (ucs4);
     406         176 :   if (!utf8)
     407           0 :     return STRINGPREP_ICONV_ERROR;
     408             : 
     409         176 :   if (strlen (utf8) >= maxlen)
     410             :     {
     411           5 :       free (utf8);
     412           5 :       return STRINGPREP_TOO_SMALL_BUFFER;
     413             :     }
     414             : 
     415         171 :   strcpy (in, utf8);            /* flawfinder: ignore */
     416             : 
     417         171 :   free (utf8);
     418             : 
     419         171 :   return STRINGPREP_OK;
     420             : }
     421             : 
     422             : /**
     423             :  * stringprep_profile:
     424             :  * @in: input array with UTF-8 string to prepare.
     425             :  * @out: output variable with pointer to newly allocate string.
     426             :  * @profile: name of stringprep profile to use.
     427             :  * @flags: a #Stringprep_profile_flags value, or 0.
     428             :  *
     429             :  * Prepare the input zero terminated UTF-8 string according to the
     430             :  * stringprep profile, and return the result in a newly allocated
     431             :  * variable.
     432             :  *
     433             :  * Note that you must convert strings entered in the systems locale
     434             :  * into UTF-8 before using this function, see
     435             :  * stringprep_locale_to_utf8().
     436             :  *
     437             :  * The output @out variable must be deallocated by the caller.
     438             :  *
     439             :  * The @flags are one of #Stringprep_profile_flags values, or 0.
     440             :  *
     441             :  * The @profile specifies the name of the stringprep profile to use.
     442             :  * It must be one of the internally supported stringprep profiles.
     443             :  *
     444             :  * Return value: Returns %STRINGPREP_OK iff successful, or an error code.
     445             :  **/
     446             : int
     447          73 : stringprep_profile (const char *in,
     448             :                     char **out,
     449             :                     const char *profile, Stringprep_profile_flags flags)
     450             : {
     451             :   const Stringprep_profiles *p;
     452          73 :   char *str = NULL;
     453          73 :   size_t len = strlen (in) + 1;
     454             :   int rc;
     455             : 
     456         186 :   for (p = &stringprep_profiles[0]; p->name; p++)
     457         186 :     if (strcmp (p->name, profile) == 0)
     458          73 :       break;
     459             : 
     460          73 :   if (!p || !p->name || !p->tables)
     461           0 :     return STRINGPREP_UNKNOWN_PROFILE;
     462             : 
     463             :   do
     464             :     {
     465          78 :       free (str);
     466          78 :       str = (char *) malloc (len);
     467          78 :       if (str == NULL)
     468           0 :         return STRINGPREP_MALLOC_ERROR;
     469             : 
     470          78 :       strcpy (str, in);
     471             : 
     472          78 :       rc = stringprep (str, len, flags, p->tables);
     473          78 :       len += 50;
     474             :     }
     475          78 :   while (rc == STRINGPREP_TOO_SMALL_BUFFER);
     476             : 
     477          73 :   if (rc == STRINGPREP_OK)
     478          41 :     *out = str;
     479             :   else
     480          32 :     free (str);
     481             : 
     482          73 :   return rc;
     483             : }
     484             : 
     485             : /*! \mainpage GNU Internationalized Domain Name Library
     486             :  *
     487             :  * \section intro Introduction
     488             :  *
     489             :  * GNU Libidn is an implementation of the Stringprep, Punycode and IDNA
     490             :  * specifications defined by the IETF Internationalized Domain Names
     491             :  * (IDN) working group, used for internationalized domain names.  The
     492             :  * package is available under the GNU Lesser General Public License.
     493             :  *
     494             :  * The library contains a generic Stringprep implementation that does
     495             :  * Unicode 3.2 NFKC normalization, mapping and prohibitation of
     496             :  * characters, and bidirectional character handling.  Profiles for
     497             :  * Nameprep, iSCSI, SASL and XMPP are included.  Punycode and ASCII
     498             :  * Compatible Encoding (ACE) via IDNA are supported.  A mechanism to
     499             :  * define Top-Level Domain (TLD) specific validation tables, and to
     500             :  * compare strings against those tables, is included.  Default tables
     501             :  * for some TLDs are also included.
     502             :  *
     503             :  * The Stringprep API consists of two main functions, one for
     504             :  * converting data from the system's native representation into UTF-8,
     505             :  * and one function to perform the Stringprep processing.  Adding a
     506             :  * new Stringprep profile for your application within the API is
     507             :  * straightforward.  The Punycode API consists of one encoding
     508             :  * function and one decoding function.  The IDNA API consists of the
     509             :  * ToASCII and ToUnicode functions, as well as an high-level interface
     510             :  * for converting entire domain names to and from the ACE encoded
     511             :  * form.  The TLD API consists of one set of functions to extract the
     512             :  * TLD name from a domain string, one set of functions to locate the
     513             :  * proper TLD table to use based on the TLD name, and core functions
     514             :  * to validate a string against a TLD table, and some utility wrappers
     515             :  * to perform all the steps in one call.
     516             :  *
     517             :  * The library is used by, e.g., GNU SASL and Shishi to process user
     518             :  * names and passwords.  Libidn can be built into GNU Libc to enable a
     519             :  * new system-wide getaddrinfo() flag for IDN processing.
     520             :  *
     521             :  * Libidn is developed for the GNU/Linux system, but runs on over 20 Unix
     522             :  * platforms (including Solaris, IRIX, AIX, and Tru64) and Windows.
     523             :  * Libidn is written in C and (parts of) the API is accessible from C,
     524             :  * C++, Emacs Lisp, Python and Java.
     525             :  *
     526             :  * The project web page:\n
     527             :  * http://www.gnu.org/software/libidn/
     528             :  *
     529             :  * The software archive:\n
     530             :  * ftp://alpha.gnu.org/pub/gnu/libidn/
     531             :  *
     532             :  * For more information see:\n
     533             :  * http://www.ietf.org/html.charters/idn-charter.html\n
     534             :  * http://www.ietf.org/rfc/rfc3454.txt (stringprep specification)\n
     535             :  * http://www.ietf.org/rfc/rfc3490.txt (idna specification)\n
     536             :  * http://www.ietf.org/rfc/rfc3491.txt (nameprep specification)\n
     537             :  * http://www.ietf.org/rfc/rfc3492.txt (punycode specification)\n
     538             :  * http://www.ietf.org/internet-drafts/draft-ietf-ips-iscsi-string-prep-04.txt\n
     539             :  * http://www.ietf.org/internet-drafts/draft-ietf-krb-wg-utf8-profile-01.txt\n
     540             :  * http://www.ietf.org/internet-drafts/draft-ietf-sasl-anon-00.txt\n
     541             :  * http://www.ietf.org/internet-drafts/draft-ietf-sasl-saslprep-00.txt\n
     542             :  * http://www.ietf.org/internet-drafts/draft-ietf-xmpp-nodeprep-01.txt\n
     543             :  * http://www.ietf.org/internet-drafts/draft-ietf-xmpp-resourceprep-01.txt\n
     544             :  *
     545             :  * Further information and paid contract development:\n
     546             :  * Simon Josefsson <simon@josefsson.org>
     547             :  *
     548             :  * \section examples Examples
     549             :  *
     550             :  * \include example.c
     551             :  * \include example3.c
     552             :  * \include example4.c
     553             :  * \include example5.c
     554             :  */
     555             : 
     556             : /**
     557             :  * STRINGPREP_VERSION
     558             :  *
     559             :  * String defined via CPP denoting the header file version number.
     560             :  * Used together with stringprep_check_version() to verify header file
     561             :  * and run-time library consistency.
     562             :  */
     563             : 
     564             : /**
     565             :  * STRINGPREP_MAX_MAP_CHARS
     566             :  *
     567             :  * Maximum number of code points that can replace a single code point,
     568             :  * during stringprep mapping.
     569             :  */
     570             : 
     571             : /**
     572             :  * Stringprep_rc:
     573             :  * @STRINGPREP_OK: Successful operation.  This value is guaranteed to
     574             :  *   always be zero, the remaining ones are only guaranteed to hold
     575             :  *   non-zero values, for logical comparison purposes.
     576             :  * @STRINGPREP_CONTAINS_UNASSIGNED: String contain unassigned Unicode
     577             :  *   code points, which is forbidden by the profile.
     578             :  * @STRINGPREP_CONTAINS_PROHIBITED: String contain code points
     579             :  *   prohibited by the profile.
     580             :  * @STRINGPREP_BIDI_BOTH_L_AND_RAL: String contain code points with
     581             :  *   conflicting bidirection category.
     582             :  * @STRINGPREP_BIDI_LEADTRAIL_NOT_RAL: Leading and trailing character
     583             :  *   in string not of proper bidirectional category.
     584             :  * @STRINGPREP_BIDI_CONTAINS_PROHIBITED: Contains prohibited code
     585             :  *   points detected by bidirectional code.
     586             :  * @STRINGPREP_TOO_SMALL_BUFFER: Buffer handed to function was too
     587             :  *   small.  This usually indicate a problem in the calling
     588             :  *   application.
     589             :  * @STRINGPREP_PROFILE_ERROR: The stringprep profile was inconsistent.
     590             :  *   This usually indicate an internal error in the library.
     591             :  * @STRINGPREP_FLAG_ERROR: The supplied flag conflicted with profile.
     592             :  *   This usually indicate a problem in the calling application.
     593             :  * @STRINGPREP_UNKNOWN_PROFILE: The supplied profile name was not
     594             :  *   known to the library.
     595             :  * @STRINGPREP_ICONV_ERROR: Could not convert string in locale encoding.
     596             :  * @STRINGPREP_NFKC_FAILED: The Unicode NFKC operation failed.  This
     597             :  *   usually indicate an internal error in the library.
     598             :  * @STRINGPREP_MALLOC_ERROR: The malloc() was out of memory.  This is
     599             :  *   usually a fatal error.
     600             :  *
     601             :  * Enumerated return codes of stringprep(), stringprep_profile()
     602             :  * functions (and macros using those functions).  The value 0 is
     603             :  * guaranteed to always correspond to success.
     604             :  */
     605             : 
     606             : /**
     607             :  * Stringprep_profile_flags:
     608             :  * @STRINGPREP_NO_NFKC: Disable the NFKC normalization, as well as
     609             :  *   selecting the non-NFKC case folding tables.  Usually the profile
     610             :  *   specifies BIDI and NFKC settings, and applications should not
     611             :  *   override it unless in special situations.
     612             :  * @STRINGPREP_NO_BIDI: Disable the BIDI step.  Usually the profile
     613             :  *   specifies BIDI and NFKC settings, and applications should not
     614             :  *   override it unless in special situations.
     615             :  * @STRINGPREP_NO_UNASSIGNED: Make the library return with an error if
     616             :  *   string contains unassigned characters according to profile.
     617             :  *
     618             :  * Stringprep profile flags.
     619             :  */
     620             : 
     621             : /**
     622             :  * Stringprep_profile_steps:
     623             :  * @STRINGPREP_NFKC: The NFKC step.
     624             :  * @STRINGPREP_BIDI: The BIDI step.
     625             :  * @STRINGPREP_MAP_TABLE: The MAP step.
     626             :  * @STRINGPREP_UNASSIGNED_TABLE: The Unassigned step.
     627             :  * @STRINGPREP_PROHIBIT_TABLE: The Prohibited step.
     628             :  * @STRINGPREP_BIDI_PROHIBIT_TABLE: The BIDI-Prohibited step.
     629             :  * @STRINGPREP_BIDI_RAL_TABLE: The BIDI-RAL step.
     630             :  * @STRINGPREP_BIDI_L_TABLE: The BIDI-L step.
     631             :  *
     632             :  * Various steps in the stringprep algorithm.  You really want to
     633             :  * study the source code to understand this one.  Only useful if you
     634             :  * want to add another profile.
     635             :  */
     636             : 
     637             : /**
     638             :  * stringprep_nameprep:
     639             :  * @in: input/ouput array with string to prepare.
     640             :  * @maxlen: maximum length of input/output array.
     641             :  *
     642             :  * Prepare the input UTF-8 string according to the nameprep profile.
     643             :  * The AllowUnassigned flag is true, use
     644             :  * stringprep_nameprep_no_unassigned() if you want a false
     645             :  * AllowUnassigned.  Returns 0 iff successful, or an error code.
     646             :  **/
     647             : 
     648             : /**
     649             :  * stringprep_nameprep_no_unassigned:
     650             :  * @in: input/ouput array with string to prepare.
     651             :  * @maxlen: maximum length of input/output array.
     652             :  *
     653             :  * Prepare the input UTF-8 string according to the nameprep profile.
     654             :  * The AllowUnassigned flag is false, use stringprep_nameprep() for
     655             :  * true AllowUnassigned.  Returns 0 iff successful, or an error code.
     656             :  **/
     657             : 
     658             : /**
     659             :  * stringprep_iscsi:
     660             :  * @in: input/ouput array with string to prepare.
     661             :  * @maxlen: maximum length of input/output array.
     662             :  *
     663             :  * Prepare the input UTF-8 string according to the draft iSCSI
     664             :  * stringprep profile.  Returns 0 iff successful, or an error code.
     665             :  **/
     666             : 
     667             : /**
     668             :  * stringprep_plain:
     669             :  * @in: input/ouput array with string to prepare.
     670             :  * @maxlen: maximum length of input/output array.
     671             :  *
     672             :  * Prepare the input UTF-8 string according to the draft SASL
     673             :  * ANONYMOUS profile.  Returns 0 iff successful, or an error code.
     674             :  **/
     675             : 
     676             : /**
     677             :  * stringprep_xmpp_nodeprep:
     678             :  * @in: input/ouput array with string to prepare.
     679             :  * @maxlen: maximum length of input/output array.
     680             :  *
     681             :  * Prepare the input UTF-8 string according to the draft XMPP node
     682             :  * identifier profile.  Returns 0 iff successful, or an error code.
     683             :  **/
     684             : 
     685             : /**
     686             :  * stringprep_xmpp_resourceprep:
     687             :  * @in: input/ouput array with string to prepare.
     688             :  * @maxlen: maximum length of input/output array.
     689             :  *
     690             :  * Prepare the input UTF-8 string according to the draft XMPP resource
     691             :  * identifier profile.  Returns 0 iff successful, or an error code.
     692             :  **/

Generated by: LCOV version 1.11