Adding listdevice program

This commit is contained in:
Thomas Bernard 2013-02-16 10:25:10 +01:00
parent 01ec54aec3
commit d06140277b
3 changed files with 40 additions and 2 deletions

View File

@ -20,3 +20,4 @@ _jnaerator.*
out.errors.txt out.errors.txt
jnaerator-*.jar jnaerator-*.jar
miniupnpc.h.bak miniupnpc.h.bak
listdevices

View File

@ -54,7 +54,8 @@ SRCS = igd_desc_parse.c miniupnpc.c minixml.c minisoap.c miniwget.c \
upnpc.c upnpcommands.c upnpreplyparse.c testminixml.c \ upnpc.c upnpcommands.c upnpreplyparse.c testminixml.c \
minixmlvalid.c testupnpreplyparse.c minissdpc.c \ minixmlvalid.c testupnpreplyparse.c minissdpc.c \
upnperrors.c testigddescparse.c testminiwget.c \ upnperrors.c testigddescparse.c testminiwget.c \
connecthostport.c portlistingparse.c receivedata.c connecthostport.c portlistingparse.c receivedata.c \
listdevices.c
LIBOBJS = miniwget.o minixml.o igd_desc_parse.o minisoap.o \ LIBOBJS = miniwget.o minixml.o igd_desc_parse.o minisoap.o \
miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \ miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \
@ -89,7 +90,7 @@ ifeq ($(JARSUFFIX), win32)
endif endif
endif endif
EXECUTABLES = upnpc-static EXECUTABLES = upnpc-static listdevices
EXECUTABLES_ADDTESTS = testminixml minixmlvalid testupnpreplyparse \ EXECUTABLES_ADDTESTS = testminixml minixmlvalid testupnpreplyparse \
testigddescparse testminiwget testigddescparse testminiwget
@ -226,6 +227,9 @@ upnpc-static: upnpc.o $(LIBRARY) $(LDLIBS)
upnpc-shared: upnpc.o $(SHAREDLIBRARY) $(LDLIBS) upnpc-shared: upnpc.o $(SHAREDLIBRARY) $(LDLIBS)
$(CC) $(LDFLAGS) -o $@ $^ $(CC) $(LDFLAGS) -o $@ $^
listdevices: listdevices.o $(LIBRARY) $(LDLIBS)
$(CC) $(LDFLAGS) -o $@ $^
testminixml: $(TESTMINIXMLOBJS) testminixml: $(TESTMINIXMLOBJS)
testminiwget: $(TESTMINIWGETOBJS) testminiwget: $(TESTMINIWGETOBJS)

33
miniupnpc/listdevices.c Normal file
View File

@ -0,0 +1,33 @@
/* $Id$ */
/* Project : miniupnp
* Author : Thomas Bernard
* Copyright (c) 2013 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution. */
#include <stdio.h>
#include "miniupnpc.h"
int main(int argc, char * * argv)
{
const char * multicastif = 0;
const char * minissdpdpath = 0;
int ipv6 = 0;
int error = 0;
struct UPNPDev * devlist = 0;
struct UPNPDev * dev;
devlist = upnpDiscover(2000, multicastif, minissdpdpath,
0/*sameport*/, ipv6, &error);
if(devlist) {
for(dev = devlist; dev != NULL; dev = dev->pNext) {
printf("%s\t%s\n", dev->st, dev->descURL);
}
freeUPNPDevlist(devlist);
} else {
printf("no device found.\n");
}
return 0;
}