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