void upnp_renderer_dump_control_scpd(void) { char *buf; buf = upnp_get_scpd(upnp_control_get_service()); assert(buf != NULL); fputs(buf, stdout); }
struct upnp_device *upnp_device_init(struct upnp_device_descriptor *device_def, const char *ip_address, unsigned short port) { int rc; char *buf; struct service *srv; struct icon *icon_entry; assert(device_def != NULL); if (device_def->init_function) { rc = device_def->init_function(); if (rc != 0) { return NULL; } } struct upnp_device *result_device = malloc(sizeof(*result_device)); result_device->upnp_device_descriptor = device_def; ithread_mutex_init(&(result_device->device_mutex), NULL); /* register icons in web server */ for (int i = 0; (icon_entry = device_def->icons[i]); i++) { webserver_register_file(icon_entry->url, "image/png"); } /* generate and register service schemas in web server */ for (int i = 0; (srv = device_def->services[i]); i++) { buf = upnp_get_scpd(srv); assert(buf != NULL); webserver_register_buf(srv->scpd_url, buf, "text/xml"); } if (!initialize_device(device_def, result_device, ip_address, port)) { UpnpFinish(); free(result_device); return NULL; } return result_device; }
void upnp_renderer_dump_transport_scpd(void) { fputs(upnp_get_scpd(&transport_service), stdout); }
void upnp_renderer_dump_control_scpd(void) { fputs(upnp_get_scpd(&control_service), stdout); }
struct device_private *upnp_device_init(struct device *device_def, const char *ip_address) { int rc; #ifdef HAVE_LIBUPNP short int port = 0; #endif struct service *srv; struct icon *icon_entry; char *buf; struct device_private *priv = NULL; int i; assert(device_def != NULL); if (device_def->init_function) { rc = device_def->init_function(); if (rc != 0) { goto out; } } priv = malloc(sizeof(*priv)); priv->upnp_device = device_def; #ifdef HAVE_LIBUPNP ithread_mutex_init(&(priv->device_mutex), NULL); #endif //upnp_device = device_def; /* register icons in web server */ for (i=0; (icon_entry = device_def->icons[i]); i++) { webserver_register_file(icon_entry->url, "image/png"); } /* generate and register service schemas in web server */ for (i=0; (srv = device_def->services[i]); i++) { buf = upnp_get_scpd(srv); assert(buf != NULL); printf("registering '%s'\n", srv->scpd_url); webserver_register_buf(srv->scpd_url,buf,"text/xml"); } #ifdef HAVE_LIBUPNP rc = UpnpInit(ip_address, port); if (UPNP_E_SUCCESS != rc) { printf("UpnpInit() Error: %d\n", rc); goto upnp_err_out; } rc = UpnpEnableWebserver(TRUE); if (UPNP_E_SUCCESS != rc) { printf("UpnpEnableWebServer() Error: %d\n", rc); goto upnp_err_out; } rc = UpnpSetVirtualDirCallbacks(&virtual_dir_callbacks); if (UPNP_E_SUCCESS != rc) { printf("UpnpSetVirtualDirCallbacks() Error: %d\n", rc); goto upnp_err_out; } rc = UpnpAddVirtualDir("/upnp"); if (UPNP_E_SUCCESS != rc) { printf("UpnpAddVirtualDir() Error: %d\n", rc); goto upnp_err_out; } buf = upnp_get_device_desc(device_def); rc = UpnpRegisterRootDevice2(UPNPREG_BUF_DESC, buf, strlen(buf), 1, &event_handler, priv, &(priv->device_handle)); if (UPNP_E_SUCCESS != rc) { printf("UpnpRegisterRootDevice2() Error: %d\n", rc); goto upnp_err_out; } rc = UpnpSendAdvertisement(priv->device_handle, 100); if (UPNP_E_SUCCESS != rc) { fprintf(stderr, "Error sending advertisements: %d\n", rc); goto upnp_err_out; } #endif goto out; #ifdef HAVE_LIBUPNP upnp_err_out: UpnpFinish(); #endif out: return priv; }
int upnp_device_init(struct device *device_def, char *ip_address) { int rc; int result = -1; short int port = 0; struct service *srv; struct icon *icon_entry; char *buf; int i; if (device_def->init_function) { rc = device_def->init_function(); if (rc != 0) { goto out; } } upnp_device = device_def; /* register icons in web server */ for (i=0; (icon_entry = upnp_device->icons[i]); i++) { webserver_register_file(icon_entry->url, "image/png"); } /* generate and register service schemas in web server */ for (i=0; (srv = upnp_device->services[i]); i++) { buf = upnp_get_scpd(srv); debug_printf(MSG_INFO, "registering '%s'\n", srv->scpd_url); webserver_register_buf(srv->scpd_url,buf,"text/xml"); } rc = UpnpInit(ip_address, port); if (UPNP_E_SUCCESS != rc) { debug_printf(MSG_ERROR, "UpnpInit() Error: %d\n", rc); goto upnp_err_out; } rc = UpnpEnableWebserver(TRUE); if (UPNP_E_SUCCESS != rc) { debug_printf(MSG_ERROR, "UpnpEnableWebServer() Error: %d\n", rc); goto upnp_err_out; } rc = UpnpSetVirtualDirCallbacks(&virtual_dir_callbacks); if (UPNP_E_SUCCESS != rc) { debug_printf(MSG_ERROR, "UpnpSetVirtualDirCallbacks() Error: %d\n", rc); goto upnp_err_out; } rc = UpnpAddVirtualDir("/upnp"); if (UPNP_E_SUCCESS != rc) { debug_printf(MSG_ERROR, "UpnpAddVirtualDir() Error: %d\n", rc); goto upnp_err_out; } buf = upnp_get_device_desc(device_def); rc = UpnpRegisterRootDevice2(UPNPREG_BUF_DESC, buf, strlen(buf), 1, &event_handler, &device_def, &device_handle); if (UPNP_E_SUCCESS != rc) { debug_printf(MSG_ERROR, "UpnpRegisterRootDevice2() Error: %d\n", rc); goto upnp_err_out; } rc = UpnpSendAdvertisement(device_handle, 100); if (UPNP_E_SUCCESS != rc) { debug_printf(MSG_ERROR, "Error sending advertisements: %d\n", rc); goto upnp_err_out; } result = 0; goto out; upnp_err_out: UpnpFinish(); out: return result; }