static int ping_camera(const char *url) { const char *cp; char *url2, *p; static const char *uuid; static size_t uuid_len; static const char path[] = "/desc_iml/MobileConnectedCamera.xml?uuid="; size_t base_len, len; char *outbuf, contenttype[LINE_SIZE]; int err; /* Find the http://host:port part of the url */ cp = strstr(url, "://"); if (!cp) { fprintf(stderr, "Invalid device URL: %s\n", url); abort(); return -1; } cp += 3; cp = strchr(cp, '/'); if (!cp) cp = url + strlen(url); base_len = cp - url; if (base_len > 1024) { fprintf(stderr, "Device URL too long: %s\n", url); return -1; } if (!uuid) { uuid = get_uuid(); uuid_len = strlen(uuid); } /* paste baseurl + path + uuid */ len = base_len + sizeof(path) - 1 + uuid_len; url2 = malloc(len + 1); if (!url2) { perror("Memory allocation failure"); return -1; } url2[len] = '\0'; memcpy(url2, url, cp - url); p = url2 + (cp - url); memcpy(p, path, sizeof(path) - 1); p += sizeof(path) - 1; memcpy(p, uuid, uuid_len); fprintf(stderr, "url2: \"%s\"\n", url2); outbuf = NULL; err = UpnpDownloadUrlItem(url2, &outbuf, contenttype); /* FIXME: Check that the XML contains what we expect */ free(outbuf); if (err) upnp_perror("UpnpDownloadUrlItem", err); return err; }
ERROR_TYPE IUpnp::DownloadUrlItem(IN const char *url,OUT char **outBuf,OUT char *contentType) { return (ERROR_TYPE)UpnpDownloadUrlItem(url,outBuf,contentType); }