miniupnpc.c: simpleUPnPcommand2() C++ => C comments

also reindentation, move declaration of soapbodylen up
vim stuff :)
This commit is contained in:
Thomas Bernard 2015-10-26 11:44:40 +01:00
parent 899ccb9575
commit 06417600f8
1 changed files with 13 additions and 13 deletions

View File

@ -1,4 +1,5 @@
/* $Id: miniupnpc.c,v 1.135 2015/07/23 20:40:08 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab */
/* Project : miniupnp
* Web : http://miniupnp.free.fr/
* Author : Thomas BERNARD
@ -103,6 +104,7 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
char * path;
char soapact[128];
char soapbody[2048];
int soapbodylen;
char * buf;
int n;
@ -110,7 +112,6 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
snprintf(soapact, sizeof(soapact), "%s#%s", service, action);
if(args==NULL)
{
int soapbodylen;
soapbodylen = snprintf(soapbody, sizeof(soapbody),
"<?xml version=\"1.0\"?>\r\n"
"<" SOAPPREFIX ":Envelope "
@ -128,7 +129,6 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
{
char * p;
const char * pe, * pv;
int soapbodylen;
const char * const pend = soapbody + sizeof(soapbody);
soapbodylen = snprintf(soapbody, sizeof(soapbody),
"<?xml version=\"1.0\"?>\r\n"
@ -143,7 +143,7 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
p = soapbody + soapbodylen;
while(args->elt)
{
if((p+1) > pend) // check for space to write next byte
if(p >= pend) /* check for space to write next byte */
return NULL;
*(p++) = '<';
@ -151,7 +151,7 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
while(p < pend && *pe)
*(p++) = *(pe++);
if((p+1) > pend) // check for space to write next byte
if(p >= pend) /* check for space to write next byte */
return NULL;
*(p++) = '>';
@ -161,7 +161,7 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
*(p++) = *(pv++);
}
if((p+2) > pend) // check for space to write next 2 bytes
if((p+2) > pend) /* check for space to write next 2 bytes */
return NULL;
*(p++) = '<';
*(p++) = '/';
@ -170,13 +170,13 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
while(p < pend && *pe)
*(p++) = *(pe++);
if((p+1) > pend) // check for space to write next byte
if(p >= pend) /* check for space to write next byte */
return NULL;
*(p++) = '>';
args++;
}
if((p+4) > pend) // check for space to write next 4 bytes
if((p+4) > pend) /* check for space to write next 4 bytes */
return NULL;
*(p++) = '<';
*(p++) = '/';
@ -189,7 +189,7 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
strncpy(p, "></" SOAPPREFIX ":Body></" SOAPPREFIX ":Envelope>\r\n",
pend - p);
if(soapbody[sizeof(soapbody)-1]) // strncpy pads buffer with 0s, so if it doesn't end in 0, could not fit full string
if(soapbody[sizeof(soapbody)-1]) /* strncpy pads buffer with 0s, so if it doesn't end in 0, could not fit full string */
return NULL;
}
if(!parseURL(url, hostname, &port, &path, NULL)) return NULL;