Git init
[external/curl.git] / lib / strerror.c
1 /***************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 2004 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at http://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  ***************************************************************************/
22
23 #include "setup.h"
24
25 #ifdef HAVE_STRERROR_R
26 #  if (!defined(HAVE_POSIX_STRERROR_R) && \
27        !defined(HAVE_GLIBC_STRERROR_R) && \
28        !defined(HAVE_VXWORKS_STRERROR_R)) || \
29       (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
30       (defined(HAVE_GLIBC_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
31       (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R))
32 #    error "strerror_r MUST be either POSIX-style, glibc-style or vxworks-style"
33 #  endif
34 #endif
35
36 #include <curl/curl.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <errno.h>
40
41 #ifdef USE_LIBIDN
42 #include <idna.h>
43 #endif
44
45 #include "strerror.h"
46
47 #define _MPRINTF_REPLACE /* use our functions only */
48 #include <curl/mprintf.h>
49
50
51 const char *
52 curl_easy_strerror(CURLcode error)
53 {
54 #ifndef CURL_DISABLE_VERBOSE_STRINGS
55   switch (error) {
56   case CURLE_OK:
57     return "No error";
58
59   case CURLE_UNSUPPORTED_PROTOCOL:
60     return "Unsupported protocol";
61
62   case CURLE_FAILED_INIT:
63     return "Failed initialization";
64
65   case CURLE_URL_MALFORMAT:
66     return "URL using bad/illegal format or missing URL";
67
68   case CURLE_COULDNT_RESOLVE_PROXY:
69     return "Couldn't resolve proxy name";
70
71   case CURLE_COULDNT_RESOLVE_HOST:
72     return "Couldn't resolve host name";
73
74   case CURLE_COULDNT_CONNECT:
75     return "Couldn't connect to server";
76
77   case CURLE_FTP_WEIRD_SERVER_REPLY:
78     return "FTP: weird server reply";
79
80   case CURLE_REMOTE_ACCESS_DENIED:
81     return "Access denied to remote resource";
82
83   case CURLE_FTP_PRET_FAILED:
84     return "FTP: The server did not accept the PRET command.";
85
86   case CURLE_FTP_WEIRD_PASS_REPLY:
87     return "FTP: unknown PASS reply";
88
89   case CURLE_FTP_WEIRD_PASV_REPLY:
90     return "FTP: unknown PASV reply";
91
92   case CURLE_FTP_WEIRD_227_FORMAT:
93     return "FTP: unknown 227 response format";
94
95   case CURLE_FTP_CANT_GET_HOST:
96     return "FTP: can't figure out the host in the PASV response";
97
98   case CURLE_FTP_COULDNT_SET_TYPE:
99     return "FTP: couldn't set file type";
100
101   case CURLE_PARTIAL_FILE:
102     return "Transferred a partial file";
103
104   case CURLE_FTP_COULDNT_RETR_FILE:
105     return "FTP: couldn't retrieve (RETR failed) the specified file";
106
107   case CURLE_QUOTE_ERROR:
108     return "Quote command returned error";
109
110   case CURLE_HTTP_RETURNED_ERROR:
111     return "HTTP response code said error";
112
113   case CURLE_WRITE_ERROR:
114     return "Failed writing received data to disk/application";
115
116   case CURLE_UPLOAD_FAILED:
117     return "Upload failed (at start/before it took off)";
118
119   case CURLE_READ_ERROR:
120     return "Failed to open/read local data from file/application";
121
122   case CURLE_OUT_OF_MEMORY:
123     return "Out of memory";
124
125   case CURLE_OPERATION_TIMEDOUT:
126     return "Timeout was reached";
127
128   case CURLE_FTP_PORT_FAILED:
129     return "FTP: command PORT failed";
130
131   case CURLE_FTP_COULDNT_USE_REST:
132     return "FTP: command REST failed";
133
134   case CURLE_RANGE_ERROR:
135     return "Requested range was not delivered by the server";
136
137   case CURLE_HTTP_POST_ERROR:
138     return "Internal problem setting up the POST";
139
140   case CURLE_SSL_CONNECT_ERROR:
141     return "SSL connect error";
142
143   case CURLE_BAD_DOWNLOAD_RESUME:
144     return "Couldn't resume download";
145
146   case CURLE_FILE_COULDNT_READ_FILE:
147     return "Couldn't read a file:// file";
148
149   case CURLE_LDAP_CANNOT_BIND:
150     return "LDAP: cannot bind";
151
152   case CURLE_LDAP_SEARCH_FAILED:
153     return "LDAP: search failed";
154
155   case CURLE_FUNCTION_NOT_FOUND:
156     return "A required function in the library was not found";
157
158   case CURLE_ABORTED_BY_CALLBACK:
159     return "Operation was aborted by an application callback";
160
161   case CURLE_BAD_FUNCTION_ARGUMENT:
162     return "A libcurl function was given a bad argument";
163
164   case CURLE_INTERFACE_FAILED:
165     return "Failed binding local connection end";
166
167   case CURLE_TOO_MANY_REDIRECTS :
168     return "Number of redirects hit maximum amount";
169
170   case CURLE_UNKNOWN_TELNET_OPTION:
171     return "User specified an unknown telnet option";
172
173   case CURLE_TELNET_OPTION_SYNTAX :
174     return "Malformed telnet option";
175
176   case CURLE_PEER_FAILED_VERIFICATION:
177     return "SSL peer certificate or SSH remote key was not OK";
178
179   case CURLE_GOT_NOTHING:
180     return "Server returned nothing (no headers, no data)";
181
182   case CURLE_SSL_ENGINE_NOTFOUND:
183     return "SSL crypto engine not found";
184
185   case CURLE_SSL_ENGINE_SETFAILED:
186     return "Can not set SSL crypto engine as default";
187
188   case CURLE_SSL_ENGINE_INITFAILED:
189     return "Failed to initialise SSL crypto engine";
190
191   case CURLE_SEND_ERROR:
192     return "Failed sending data to the peer";
193
194   case CURLE_RECV_ERROR:
195     return "Failure when receiving data from the peer";
196
197   case CURLE_SSL_CERTPROBLEM:
198     return "Problem with the local SSL certificate";
199
200   case CURLE_SSL_CIPHER:
201     return "Couldn't use specified SSL cipher";
202
203   case CURLE_SSL_CACERT:
204     return "Peer certificate cannot be authenticated with known CA certificates";
205
206   case CURLE_SSL_CACERT_BADFILE:
207     return "Problem with the SSL CA cert (path? access rights?)";
208
209   case CURLE_BAD_CONTENT_ENCODING:
210     return "Unrecognized HTTP Content-Encoding";
211
212   case CURLE_LDAP_INVALID_URL:
213     return "Invalid LDAP URL";
214
215   case CURLE_FILESIZE_EXCEEDED:
216     return "Maximum file size exceeded";
217
218   case CURLE_USE_SSL_FAILED:
219     return "Requested SSL level failed";
220
221   case CURLE_SSL_SHUTDOWN_FAILED:
222     return "Failed to shut down the SSL connection";
223
224   case CURLE_SSL_CRL_BADFILE:
225     return "Failed to load CRL file (path? access rights?, format?)";
226
227   case CURLE_SSL_ISSUER_ERROR:
228     return "Issuer check against peer certificate failed";
229
230   case CURLE_SEND_FAIL_REWIND:
231     return "Send failed since rewinding of the data stream failed";
232
233   case CURLE_LOGIN_DENIED:
234     return "Login denied";
235
236   case CURLE_TFTP_NOTFOUND:
237     return "TFTP: File Not Found";
238
239   case CURLE_TFTP_PERM:
240     return "TFTP: Access Violation";
241
242   case CURLE_REMOTE_DISK_FULL:
243     return "Disk full or allocation exceeded";
244
245   case CURLE_TFTP_ILLEGAL:
246     return "TFTP: Illegal operation";
247
248   case CURLE_TFTP_UNKNOWNID:
249     return "TFTP: Unknown transfer ID";
250
251   case CURLE_REMOTE_FILE_EXISTS:
252     return "Remote file already exists";
253
254   case CURLE_TFTP_NOSUCHUSER:
255     return "TFTP: No such user";
256
257   case CURLE_CONV_FAILED:
258     return "Conversion failed";
259
260   case CURLE_CONV_REQD:
261     return "Caller must register CURLOPT_CONV_ callback options";
262
263   case CURLE_REMOTE_FILE_NOT_FOUND:
264     return "Remote file not found";
265
266   case CURLE_SSH:
267     return "Error in the SSH layer";
268
269   case CURLE_AGAIN:
270     return "Socket not ready for send/recv";
271
272   case CURLE_RTSP_CSEQ_ERROR:
273     return "RTSP CSeq mismatch or invalid CSeq";
274
275   case CURLE_RTSP_SESSION_ERROR:
276     return "RTSP session error";
277
278   case CURLE_FTP_BAD_FILE_LIST:
279     return "Unable to parse FTP file list";
280
281   case CURLE_CHUNK_FAILED:
282     return "Chunk callback failed";
283
284     /* error codes not used by current libcurl */
285   case CURLE_OBSOLETE4:
286   case CURLE_OBSOLETE10:
287   case CURLE_OBSOLETE12:
288   case CURLE_OBSOLETE16:
289   case CURLE_OBSOLETE20:
290   case CURLE_OBSOLETE24:
291   case CURLE_OBSOLETE29:
292   case CURLE_OBSOLETE32:
293   case CURLE_OBSOLETE40:
294   case CURLE_OBSOLETE44:
295   case CURLE_OBSOLETE46:
296   case CURLE_OBSOLETE50:
297   case CURLE_OBSOLETE57:
298   case CURL_LAST:
299     break;
300   }
301   /*
302    * By using a switch, gcc -Wall will complain about enum values
303    * which do not appear, helping keep this function up-to-date.
304    * By using gcc -Wall -Werror, you can't forget.
305    *
306    * A table would not have the same benefit.  Most compilers will
307    * generate code very similar to a table in any case, so there
308    * is little performance gain from a table.  And something is broken
309    * for the user's application, anyways, so does it matter how fast
310    * it _doesn't_ work?
311    *
312    * The line number for the error will be near this comment, which
313    * is why it is here, and not at the start of the switch.
314    */
315   return "Unknown error";
316 #else
317   if(error == CURLE_OK)
318     return "No error";
319   else
320     return "Error";
321 #endif
322 }
323
324 const char *
325 curl_multi_strerror(CURLMcode error)
326 {
327 #ifndef CURL_DISABLE_VERBOSE_STRINGS
328   switch (error) {
329   case CURLM_CALL_MULTI_PERFORM:
330     return "Please call curl_multi_perform() soon";
331
332   case CURLM_OK:
333     return "No error";
334
335   case CURLM_BAD_HANDLE:
336     return "Invalid multi handle";
337
338   case CURLM_BAD_EASY_HANDLE:
339     return "Invalid easy handle";
340
341   case CURLM_OUT_OF_MEMORY:
342     return "Out of memory";
343
344   case CURLM_INTERNAL_ERROR:
345     return "Internal error";
346
347   case CURLM_BAD_SOCKET:
348     return "Invalid socket argument";
349
350   case CURLM_UNKNOWN_OPTION:
351     return "Unknown option";
352
353   case CURLM_LAST:
354     break;
355   }
356
357   return "Unknown error";
358 #else
359   if(error == CURLM_OK)
360     return "No error";
361   else
362     return "Error";
363 #endif
364 }
365
366 const char *
367 curl_share_strerror(CURLSHcode error)
368 {
369 #ifndef CURL_DISABLE_VERBOSE_STRINGS
370   switch (error) {
371   case CURLSHE_OK:
372     return "No error";
373
374   case CURLSHE_BAD_OPTION:
375     return "Unknown share option";
376
377   case CURLSHE_IN_USE:
378     return "Share currently in use";
379
380   case CURLSHE_INVALID:
381     return "Invalid share handle";
382
383   case CURLSHE_NOMEM:
384     return "Out of memory";
385
386   case CURLSHE_LAST:
387     break;
388   }
389
390   return "CURLSHcode unknown";
391 #else
392   if(error == CURLSHE_OK)
393     return "No error";
394   else
395     return "Error";
396 #endif
397 }
398
399 #ifdef USE_WINSOCK
400
401 /* This function handles most / all (?) Winsock errors cURL is able to produce.
402  */
403 static const char *
404 get_winsock_error (int err, char *buf, size_t len)
405 {
406   const char *p;
407
408 #ifndef CURL_DISABLE_VERBOSE_STRINGS
409   switch (err) {
410   case WSAEINTR:
411     p = "Call interrupted";
412     break;
413   case WSAEBADF:
414     p = "Bad file";
415     break;
416   case WSAEACCES:
417     p = "Bad access";
418     break;
419   case WSAEFAULT:
420     p = "Bad argument";
421     break;
422   case WSAEINVAL:
423     p = "Invalid arguments";
424     break;
425   case WSAEMFILE:
426     p = "Out of file descriptors";
427     break;
428   case WSAEWOULDBLOCK:
429     p = "Call would block";
430     break;
431   case WSAEINPROGRESS:
432   case WSAEALREADY:
433     p = "Blocking call in progress";
434     break;
435   case WSAENOTSOCK:
436     p = "Descriptor is not a socket";
437     break;
438   case WSAEDESTADDRREQ:
439     p = "Need destination address";
440     break;
441   case WSAEMSGSIZE:
442     p = "Bad message size";
443     break;
444   case WSAEPROTOTYPE:
445     p = "Bad protocol";
446     break;
447   case WSAENOPROTOOPT:
448     p = "Protocol option is unsupported";
449     break;
450   case WSAEPROTONOSUPPORT:
451     p = "Protocol is unsupported";
452     break;
453   case WSAESOCKTNOSUPPORT:
454     p = "Socket is unsupported";
455     break;
456   case WSAEOPNOTSUPP:
457     p = "Operation not supported";
458     break;
459   case WSAEAFNOSUPPORT:
460     p = "Address family not supported";
461     break;
462   case WSAEPFNOSUPPORT:
463     p = "Protocol family not supported";
464     break;
465   case WSAEADDRINUSE:
466     p = "Address already in use";
467     break;
468   case WSAEADDRNOTAVAIL:
469     p = "Address not available";
470     break;
471   case WSAENETDOWN:
472     p = "Network down";
473     break;
474   case WSAENETUNREACH:
475     p = "Network unreachable";
476     break;
477   case WSAENETRESET:
478     p = "Network has been reset";
479     break;
480   case WSAECONNABORTED:
481     p = "Connection was aborted";
482     break;
483   case WSAECONNRESET:
484     p = "Connection was reset";
485     break;
486   case WSAENOBUFS:
487     p = "No buffer space";
488     break;
489   case WSAEISCONN:
490     p = "Socket is already connected";
491     break;
492   case WSAENOTCONN:
493     p = "Socket is not connected";
494     break;
495   case WSAESHUTDOWN:
496     p = "Socket has been shut down";
497     break;
498   case WSAETOOMANYREFS:
499     p = "Too many references";
500     break;
501   case WSAETIMEDOUT:
502     p = "Timed out";
503     break;
504   case WSAECONNREFUSED:
505     p = "Connection refused";
506     break;
507   case WSAELOOP:
508     p = "Loop??";
509     break;
510   case WSAENAMETOOLONG:
511     p = "Name too long";
512     break;
513   case WSAEHOSTDOWN:
514     p = "Host down";
515     break;
516   case WSAEHOSTUNREACH:
517     p = "Host unreachable";
518     break;
519   case WSAENOTEMPTY:
520     p = "Not empty";
521     break;
522   case WSAEPROCLIM:
523     p = "Process limit reached";
524     break;
525   case WSAEUSERS:
526     p = "Too many users";
527     break;
528   case WSAEDQUOT:
529     p = "Bad quota";
530     break;
531   case WSAESTALE:
532     p = "Something is stale";
533     break;
534   case WSAEREMOTE:
535     p = "Remote error";
536     break;
537 #ifdef WSAEDISCON  /* missing in SalfordC! */
538   case WSAEDISCON:
539     p = "Disconnected";
540     break;
541 #endif
542     /* Extended Winsock errors */
543   case WSASYSNOTREADY:
544     p = "Winsock library is not ready";
545     break;
546   case WSANOTINITIALISED:
547     p = "Winsock library not initialised";
548     break;
549   case WSAVERNOTSUPPORTED:
550     p = "Winsock version not supported";
551     break;
552
553     /* getXbyY() errors (already handled in herrmsg):
554      * Authoritative Answer: Host not found */
555   case WSAHOST_NOT_FOUND:
556     p = "Host not found";
557     break;
558
559     /* Non-Authoritative: Host not found, or SERVERFAIL */
560   case WSATRY_AGAIN:
561     p = "Host not found, try again";
562     break;
563
564     /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
565   case WSANO_RECOVERY:
566     p = "Unrecoverable error in call to nameserver";
567     break;
568
569     /* Valid name, no data record of requested type */
570   case WSANO_DATA:
571     p = "No data record of requested type";
572     break;
573
574   default:
575     return NULL;
576   }
577 #else
578   if(err == CURLE_OK)
579     return NULL;
580   else
581     p = "error";
582 #endif
583   strncpy (buf, p, len);
584   buf [len-1] = '\0';
585   return buf;
586 }
587 #endif   /* USE_WINSOCK */
588
589 /*
590  * Our thread-safe and smart strerror() replacement.
591  *
592  * The 'err' argument passed in to this function MUST be a true errno number
593  * as reported on this system. We do no range checking on the number before
594  * we pass it to the "number-to-message" conversion function and there might
595  * be systems that don't do proper range checking in there themselves.
596  *
597  * We don't do range checking (on systems other than Windows) since there is
598  * no good reliable and portable way to do it.
599  */
600 const char *Curl_strerror(struct connectdata *conn, int err)
601 {
602   char *buf, *p;
603   size_t max;
604   int old_errno = ERRNO;
605
606   DEBUGASSERT(conn);
607   DEBUGASSERT(err >= 0);
608
609   buf = conn->syserr_buf;
610   max = sizeof(conn->syserr_buf)-1;
611   *buf = '\0';
612
613 #ifdef USE_WINSOCK
614
615 #ifdef _WIN32_WCE
616   {
617     wchar_t wbuf[256];
618     wbuf[0] = L'\0';
619
620     FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
621                   LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL);
622     wcstombs(buf,wbuf,max);
623   }
624 #else
625   /* 'sys_nerr' is the maximum errno number, it is not widely portable */
626   if(err >= 0 && err < sys_nerr)
627     strncpy(buf, strerror(err), max);
628   else {
629     if(!get_winsock_error(err, buf, max) &&
630         !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
631                        LANG_NEUTRAL, buf, (DWORD)max, NULL))
632       snprintf(buf, max, "Unknown error %d (%#x)", err, err);
633   }
634 #endif
635
636 #else /* not USE_WINSOCK coming up */
637
638 #if defined(HAVE_STRERROR_R) && defined(HAVE_POSIX_STRERROR_R)
639  /*
640   * The POSIX-style strerror_r() may set errno to ERANGE if insufficient
641   * storage is supplied via 'strerrbuf' and 'buflen' to hold the generated
642   * message string, or EINVAL if 'errnum' is not a valid error number.
643   */
644   if(0 != strerror_r(err, buf, max)) {
645     if('\0' == buf[0])
646       snprintf(buf, max, "Unknown error %d", err);
647   }
648 #elif defined(HAVE_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)
649  /*
650   * The glibc-style strerror_r() only *might* use the buffer we pass to
651   * the function, but it always returns the error message as a pointer,
652   * so we must copy that string unconditionally (if non-NULL).
653   */
654   {
655     char buffer[256];
656     char *msg = strerror_r(err, buffer, sizeof(buffer));
657     if(msg)
658       strncpy(buf, msg, max);
659     else
660       snprintf(buf, max, "Unknown error %d", err);
661   }
662 #elif defined(HAVE_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)
663  /*
664   * The vxworks-style strerror_r() does use the buffer we pass to the function.
665   * The buffer size should be at least MAXERRSTR_SIZE (150) defined in rtsold.h
666   */
667   {
668     char buffer[256];
669     if(OK == strerror_r(err, buffer))
670       strncpy(buf, buffer, max);
671     else
672       snprintf(buf, max, "Unknown error %d", err);
673   }
674 #else
675   {
676     char *msg = strerror(err);
677     if(msg)
678       strncpy(buf, msg, max);
679     else
680       snprintf(buf, max, "Unknown error %d", err);
681   }
682 #endif
683
684 #endif /* end of ! USE_WINSOCK */
685
686   buf[max] = '\0'; /* make sure the string is zero terminated */
687
688   /* strip trailing '\r\n' or '\n'. */
689   if((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2)
690      *p = '\0';
691   if((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1)
692      *p = '\0';
693
694   if(old_errno != ERRNO)
695     SET_ERRNO(old_errno);
696
697   return buf;
698 }
699
700 #ifdef USE_LIBIDN
701 /*
702  * Return error-string for libidn status as returned from idna_to_ascii_lz().
703  */
704 const char *Curl_idn_strerror (struct connectdata *conn, int err)
705 {
706 #ifdef HAVE_IDNA_STRERROR
707   (void)conn;
708   return idna_strerror((Idna_rc) err);
709 #else
710   const char *str;
711   char *buf;
712   size_t max;
713
714   DEBUGASSERT(conn);
715
716   buf = conn->syserr_buf;
717   max = sizeof(conn->syserr_buf)-1;
718   *buf = '\0';
719
720 #ifndef CURL_DISABLE_VERBOSE_STRINGS
721   switch ((Idna_rc)err) {
722     case IDNA_SUCCESS:
723       str = "No error";
724       break;
725     case IDNA_STRINGPREP_ERROR:
726       str = "Error in string preparation";
727       break;
728     case IDNA_PUNYCODE_ERROR:
729       str = "Error in Punycode operation";
730       break;
731     case IDNA_CONTAINS_NON_LDH:
732       str = "Illegal ASCII characters";
733       break;
734     case IDNA_CONTAINS_MINUS:
735       str = "Contains minus";
736       break;
737     case IDNA_INVALID_LENGTH:
738       str = "Invalid output length";
739       break;
740     case IDNA_NO_ACE_PREFIX:
741       str = "No ACE prefix (\"xn--\")";
742       break;
743     case IDNA_ROUNDTRIP_VERIFY_ERROR:
744       str = "Round trip verify error";
745       break;
746     case IDNA_CONTAINS_ACE_PREFIX:
747       str = "Already have ACE prefix (\"xn--\")";
748       break;
749     case IDNA_ICONV_ERROR:
750       str = "Locale conversion failed";
751       break;
752     case IDNA_MALLOC_ERROR:
753       str = "Allocation failed";
754       break;
755     case IDNA_DLOPEN_ERROR:
756       str = "dlopen() error";
757       break;
758     default:
759       snprintf(buf, max, "error %d", err);
760       str = NULL;
761       break;
762   }
763 #else
764   if((Idna_rc)err == IDNA_SUCCESS)
765     str = "No error";
766   else
767     str = "Error";
768 #endif
769   if(str)
770     strncpy(buf, str, max);
771   buf[max] = '\0';
772   return (buf);
773 #endif
774 }
775 #endif  /* USE_LIBIDN */