formatting

This commit is contained in:
Thomas Bernard 2015-10-08 17:48:04 +02:00
parent d4af610c51
commit f407d5a7ee
3 changed files with 10 additions and 8 deletions

View File

@ -52,8 +52,8 @@ simpleUPnPcommand(int, const char *, const char *,
* If multicastif is not NULL, it will be used instead of the default
* multicast interface for sending SSDP discover packets.
* If localport is set to UPNP_LOCAL_PORT_SAME(1) SSDP packets will be sent
* from the source port 1900 (same as destination port), if set to
* UPNP_LOCAL_PORT_ANY(0) system assign a source port, any other value will
* from the source port 1900 (same as destination port), if set to
* UPNP_LOCAL_PORT_ANY(0) system assign a source port, any other value will
* be attempted as the source port.
* "searchalltypes" parameter is useful when searching several types,
* if 0, the discovery will stop with the first type returning results.

View File

@ -80,16 +80,16 @@ static int UPnP_init(UPnPObject *self, PyObject *args, PyObject *kwds)
char* multicastif = NULL;
char* minissdpdsocket = NULL;
static char *kwlist[] = {
"multicastif", "minissdpdsocket", "discoverdelay",
"multicastif", "minissdpdsocket", "discoverdelay",
"localport", NULL
};
if(!PyArg_ParseTupleAndKeywords(args, kwds, "|zzII", kwlist,
if(!PyArg_ParseTupleAndKeywords(args, kwds, "|zzII", kwlist,
&multicastif,
&minissdpdsocket,
&self->discoverdelay,
&self->localport))
return -1;
return -1;
if(self->localport>1 &&
(self->localport>65534||self->localport<1024)) {

View File

@ -577,11 +577,13 @@ int main(int argc, char ** argv)
rootdescurl = argv[++i];
else if(argv[i][1] == 'm')
multicastif = argv[++i];
else if(argv[i][1] == 'z'){
else if(argv[i][1] == 'z')
{
char junk;
if(sscanf(argv[++i], "%d%c", &localport, &junk)!=1 ||
localport<0 || localport>65535 ||
(localport >1 && localport < 1024)){
localport<0 || localport>65535 ||
(localport >1 && localport < 1024))
{
fprintf(stderr, "Invalid localport '%s'\n", argv[i]);
localport = UPNP_LOCAL_PORT_ANY;
break;