Check command line, clean warnings.
This commit is contained in:
parent
b4938b278d
commit
619a386006
|
@ -1,6 +1,7 @@
|
|||
# tested with GNU Make
|
||||
PKG_CONFIG ?= pkg-config
|
||||
|
||||
CFLAGS += -g
|
||||
CFLAGS += -Wall -Wextra
|
||||
CFLAGS += $(shell $(PKG_CONFIG) libuv --cflags)
|
||||
LDFLAGS += $(shell $(PKG_CONFIG) libuv --libs-only-L)
|
||||
|
|
|
@ -6,19 +6,21 @@
|
|||
|
||||
void requestFinish2(void* session, void* userdata, struct UPNPDev* upnpdev)
|
||||
{
|
||||
struct UPNPDev* it = upnpdev;
|
||||
while(it != NULL) {
|
||||
struct UPNPDev* it;
|
||||
(void)userdata;
|
||||
|
||||
for(it = upnpdev; it != NULL; it = it->pNext) {
|
||||
printf("url = %s\n", it->descURL);
|
||||
printf("st = %s\n", it->st);
|
||||
printf("usn = %s\n", it->usn);
|
||||
printf("\n");
|
||||
it = it->pNext;
|
||||
}
|
||||
disconnectFromMiniSSDPD((uv_stream_t*)session);
|
||||
}
|
||||
|
||||
void requestFinish(void* session, int success, void* userdata)
|
||||
{
|
||||
(void)userdata;
|
||||
if (success == 0)
|
||||
{
|
||||
printf("Error while requesting results.\n");
|
||||
|
@ -48,8 +50,17 @@ void connect_cb(void* session, void* userdata)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char* pipeName = argv[1];
|
||||
char* search = argv[2];
|
||||
char* pipeName;
|
||||
char* search;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("Usage: %s </path/to/minissdpd.socket> <device>\n", argv[0]);
|
||||
printf(" ssdp:all for all devices\n");
|
||||
return 1;
|
||||
}
|
||||
pipeName = argv[1];
|
||||
search = argv[2];
|
||||
connectToMiniSSDPD(pipeName, &connect_cb, search);
|
||||
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -88,15 +88,22 @@ static void write_cb(uv_write_t* req, int status)
|
|||
MINIUPNP_LIBSPEC int
|
||||
requestDevicesFromMiniSSDPD(void *session, const char * devtype, void(*requestFinish)(void *connect, int success, void* userdata), void* userdata)
|
||||
{
|
||||
char *buffer = malloc(256);
|
||||
char *buffer;
|
||||
char *p;
|
||||
unsigned int stsize;
|
||||
|
||||
if (devtype == NULL)
|
||||
{
|
||||
return MINISSDPC_UNKNOWN_ERROR;
|
||||
}
|
||||
stsize = strlen(devtype);
|
||||
|
||||
buffer = malloc(256);
|
||||
if(buffer == NULL)
|
||||
{
|
||||
return MINISSDPC_MEMORY_ERROR;
|
||||
}
|
||||
|
||||
char *p = buffer;
|
||||
unsigned int stsize = strlen(devtype);
|
||||
p = buffer;
|
||||
|
||||
if(stsize == 8 && 0 == memcmp(devtype, "ssdp:all", 8))
|
||||
{
|
||||
|
@ -155,6 +162,7 @@ requestDevicesFromMiniSSDPD(void *session, const char * devtype, void(*requestFi
|
|||
|
||||
static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf)
|
||||
{
|
||||
(void)handle;
|
||||
buf->base = malloc(size);
|
||||
buf->len = size;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue