[xml] clean use of HAVE_SNPRINTF

Date view Thread view Subject view Author view

From: Lutz Behnke (behnke@trustcenter.de)
Date: Thu Feb 10 2000 - 09:24:54 EST


Hi there,

libxml-1.8.6 fails to link properly to the example prgs, and will generaly fail
to link on Solaris 2.5.1, since this backwater OS does not support 'snprintf'
as the glorious glibcs does B-)

I have included a small patch to add the missing code mainly to nanohttp.c

I have looked into the archive wether somebody allready submitted this, but
could not find any mention. But since I also failed to make the connection from
i18n to encode B-) I might be in repetition on this as well.

mfg lutz

-- 
Lutz Behnke, TC TrustCenter GmbH
Sonninstrasse 24-28, D-20097 Hamburg, Germany
Tel:040/80 80 26-0  Fax:040/80 80 26-1 26   http://www.trustcenter.de
-----BEGIN GEEK CODE BLOCK-----
 Version: 3.1  
GCS/IT d- s+:+ a C++ ULS+++$ P+++ L+++ E+++ W++ !N o? k? !w@++ !O
!M !V PS+ PE Y+ PGP t+ 5+ X R+ tv+ b+++ DI+++ D G++ e++ h* r y+  
------END GEEK CODE BLOCK------

diff -Naur libxml-1.8.6/nanoftp.c libxml-1.8.6_clean_snprintf/nanoftp.c --- libxml-1.8.6/nanoftp.c Mon Jan 31 13:46:07 2000 +++ libxml-1.8.6_clean_snprintf/nanoftp.c Thu Feb 10 14:34:00 2000 @@ -648,10 +648,17 @@ int len; int res; +#ifdef HAVE_SNPRINTF if (ctxt->user == NULL) len = snprintf(buf, sizeof(buf), "USER anonymous\r\n"); else len = snprintf(buf, sizeof(buf), "USER %s\r\n", ctxt->user); +#else + if (ctxt->user == NULL) + len = sprintf(buf, "USER anonymous\r\n"); + else + len = sprintf(buf, "USER %s\r\n", ctxt->user); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -671,10 +678,17 @@ int len; int res; +#ifdef HAVE_SNPRINTF if (ctxt->passwd == NULL) len = snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n", hostname); else len = snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd); +#else + if (ctxt->passwd == NULL) + len = sprintf(buf, "PASS libxml@%s\r\n", hostname); + else + len = sprintf(buf, "PASS %s\r\n", ctxt->passwd); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -700,7 +714,11 @@ int len; int res; +#ifdef HAVE_SNPRINTF len = snprintf(buf, sizeof(buf), "QUIT\r\n"); +#else + len = sprintf(buf, "QUIT\r\n"); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -820,7 +838,11 @@ /* * We need proxy auth */ - len = snprintf(buf, sizeof(buf), "USER %s\r\n", proxyUser); +#ifdef HAVE_SNPRINTF + len = snprintf(buf, sizeof(buf), "USER %s\r\n", proxyUser); +#else + len = sprintf(buf, "USER %s\r\n", proxyUser); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -836,11 +858,19 @@ if (proxyPasswd == NULL) break; case 3: +#ifdef HAVE_SNPRINTF if (proxyPasswd != NULL) len = snprintf(buf, sizeof(buf), "PASS %s\r\n", proxyPasswd); else len = snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n", hostname); +#else + if (proxyPasswd != NULL) + len = sprintf(buf, "PASS %s\r\n", proxyPasswd); + else + len = sprintf(buf, "PASS libxml@%s\r\n", + hostname); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -878,7 +908,11 @@ /* we will try in seqence */ case 1: /* Using SITE command */ +#ifdef HAVE_SNPRINTF len = snprintf(buf, sizeof(buf), "SITE %s\r\n", ctxt->hostname); +#else + len = sprintf(buf, "SITE %s\r\n", ctxt->hostname); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -901,12 +935,21 @@ } case 2: /* USER user@host command */ +#ifdef HAVE_SNPRINTF if (ctxt->user == NULL) len = snprintf(buf, sizeof(buf), "USER anonymous@%s\r\n", ctxt->hostname); else len = snprintf(buf, sizeof(buf), "USER %s@%s\r\n", ctxt->user, ctxt->hostname); +#else + if (ctxt->user == NULL) + len = sprintf(buf, "USER anonymous@%s\r\n", + ctxt->hostname); + else + len = sprintf(buf, "USER %s@%s\r\n", + ctxt->user, ctxt->hostname); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -922,10 +965,17 @@ proxyType = 2; return(0); } +#ifdef HAVE_SNPRINTF if (ctxt->passwd == NULL) len = snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n", hostname); else len = snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd); +#else + if (ctxt->passwd == NULL) + len = sprintf(buf, "PASS libxml@%s\r\n", hostname); + else + len = sprintf(buf, "PASS %s\r\n", ctxt->passwd); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -1061,7 +1111,11 @@ * 250 * 500, 501, 502, 421, 530, 550 */ +#ifdef HAVE_SNPRINTF len = snprintf(buf, sizeof(buf), "CWD %s\r\n", directory); +#else + len = sprintf(buf, "CWD %s\r\n", directory); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -1108,7 +1162,11 @@ dataAddr.sin_family = AF_INET; if (ctxt->passive) { +#ifdef HAVE_SNPRINTF len = snprintf(buf, sizeof(buf), "PASV\r\n"); +#else + len = sprintf(buf, "PASV\r\n"); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -1164,9 +1222,15 @@ } adp = (unsigned char *) &dataAddr.sin_addr; portp = (unsigned char *) &dataAddr.sin_port; +#ifdef HAVE_SNPRINTF len = snprintf(buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n", adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff, portp[0] & 0xff, portp[1] & 0xff); +#else + len = sprintf(buf, "PORT %d,%d,%d,%d,%d,%d\r\n", + adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff, + portp[0] & 0xff, portp[1] & 0xff); +#endif buf[sizeof(buf) - 1] = 0; #ifdef DEBUG_FTP printf(buf); @@ -1363,14 +1427,22 @@ if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1) return(-1); ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); +#ifdef HAVE_SNPRINTF len = snprintf(buf, sizeof(buf), "LIST -L\r\n"); +#else + len = sprintf(buf, "LIST -L\r\n"); +#endif } else { if (filename[0] != '/') { if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1) return(-1); } ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); +#ifdef HAVE_SNPRINTF len = snprintf(buf, sizeof(buf), "LIST -L %s\r\n", filename); +#else + len = sprintf(buf, "LIST -L %s\r\n", filename); +#endif } #ifdef DEBUG_FTP printf(buf); @@ -1462,7 +1534,11 @@ return(-1); ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); +#ifdef HAVE_SNPRINTF len = snprintf(buf, sizeof(buf), "TYPE I\r\n"); +#else + len = sprintf(buf, "TYPE I\r\n"); +#endif #ifdef DEBUG_FTP printf(buf); #endif @@ -1476,10 +1552,17 @@ close(ctxt->dataFd); ctxt->dataFd = -1; return(-res); } +#ifdef HAVE_SNPRINTF if (filename == NULL) len = snprintf(buf, sizeof(buf), "RETR %s\r\n", ctxt->path); else len = snprintf(buf, sizeof(buf), "RETR %s\r\n", filename); +#else + if (filename == NULL) + len = sprintf(buf, "RETR %s\r\n", ctxt->path); + else + len = sprintf(buf, "RETR %s\r\n", filename); +#endif #ifdef DEBUG_FTP printf(buf); #endif diff -Naur libxml-1.8.6/nanohttp.c libxml-1.8.6_clean_snprintf/nanohttp.c --- libxml-1.8.6/nanohttp.c Mon Jan 31 09:38:16 2000 +++ libxml-1.8.6_clean_snprintf/nanohttp.c Thu Feb 10 14:22:40 2000 @@ -752,7 +752,7 @@ } ctxt->fd = ret; if (proxy) { -#ifdef have_snprintf +#ifdef HAVE_SNPRINTF if (ctxt->port != 80) snprintf(buf, sizeof(buf), "GET http://%s:%d%s HTTP/1.0\r\nHost: %s\r\n\r\n",


----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:30:02 EDT