Annotation of embedaddon/miniupnpd/miniupnpc-libuv/example.c, revision 1.1

1.1     ! misho       1: #include <stdio.h>
        !             2: #include <string.h>
        !             3: #include <stdlib.h>
        !             4: #include "minissdpc-libuv.h"
        !             5: #include <uv.h>
        !             6: 
        !             7: void requestFinish2(void* session, void* userdata, struct UPNPDev* upnpdev)
        !             8: {
        !             9:   struct UPNPDev* it;
        !            10:   (void)userdata;
        !            11: 
        !            12:   for(it = upnpdev; it != NULL; it = it->pNext) {
        !            13:     printf("url = %s\n", it->descURL);
        !            14:     printf("st = %s\n", it->st);
        !            15:     printf("usn = %s\n", it->usn);
        !            16:     printf("\n");
        !            17:   }
        !            18:   disconnectFromMiniSSDPD((uv_stream_t*)session);
        !            19: }
        !            20: 
        !            21: void requestFinish(void* session, int success, void* userdata)
        !            22: {
        !            23:   (void)userdata;
        !            24:   if (success == 0)
        !            25:   {
        !            26:     printf("Error while requesting results.\n");
        !            27:     return;
        !            28:   }
        !            29:   receiveDevicesFromMiniSSDPD(session, &requestFinish2, NULL);
        !            30: }
        !            31: 
        !            32: void connect_cb(void* session, void* userdata)
        !            33: {
        !            34:   if (session == 0) {
        !            35:     printf("Error while connecting\n");
        !            36:     return;
        !            37:   }
        !            38: 
        !            39:   char* search = userdata;
        !            40: 
        !            41:   int ret;
        !            42:   if ((ret = requestDevicesFromMiniSSDPD(session, search, &requestFinish, NULL)) != MINISSDPC_SUCCESS) {
        !            43:     printf("Error while requesting devices\n");
        !            44:     if (ret == MINISSDPC_INVALID_INPUT)
        !            45:       printf("Invalid input!!\n");
        !            46:     else if (ret == MINISSDPC_MEMORY_ERROR)
        !            47:       printf("Can't malloc?\n");
        !            48:   }
        !            49: }
        !            50: 
        !            51: int main(int argc, char *argv[])
        !            52: {
        !            53:   char* pipeName;
        !            54:   char* search;
        !            55: 
        !            56:   if (argc < 3) {
        !            57:     printf("Usage: %s </path/to/minissdpd.socket> <device>\n", argv[0]);
        !            58:     printf("       ssdp:all for all devices\n");
        !            59:     return 1;
        !            60:   }
        !            61:   pipeName = argv[1];
        !            62:   search = argv[2];
        !            63:   connectToMiniSSDPD(pipeName, &connect_cb, search);
        !            64:   uv_run(uv_default_loop(), UV_RUN_DEFAULT);
        !            65:   return 0;
        !            66: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>