static UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode) { extern struct ushare_t *ut; struct upnp_entry_t *entry = NULL; struct web_file_t *file; int fd, upnp_id = 0; if (!filename) return NULL; log_verbose ("http_open, filename : %s\n", filename); if (mode != UPNP_READ) return NULL; if (!strcmp (filename, CDS_LOCATION)) return get_file_memory (CDS_LOCATION, CDS_DESCRIPTION, CDS_DESCRIPTION_LEN); if (!strcmp (filename, CMS_LOCATION)) return get_file_memory (CMS_LOCATION, CMS_DESCRIPTION, CMS_DESCRIPTION_LEN); if (!strcmp (filename, MSR_LOCATION)) return get_file_memory (MSR_LOCATION, MSR_DESCRIPTION, MSR_DESCRIPTION_LEN); if (ut->use_presentation && ( !strcmp (filename, USHARE_PRESENTATION_PAGE) || !strncmp (filename, USHARE_CGI, strlen (USHARE_CGI)))) return get_file_memory (USHARE_PRESENTATION_PAGE, ut->presentation->buf, ut->presentation->len); upnp_id = atoi (strrchr (filename, '/') + 1); entry = upnp_get_entry (ut, upnp_id); if (!entry) return NULL; if (!entry->fullpath) return NULL; log_verbose ("Fullpath : %s\n", entry->fullpath); fd = open (entry->fullpath, O_RDONLY | O_NONBLOCK | O_SYNC | O_NDELAY); if (fd < 0) return NULL; file = malloc (sizeof (struct web_file_t)); file->fullpath = strdup (entry->fullpath); file->pos = 0; file->type = FILE_LOCAL; file->detail.local.entry = entry; file->detail.local.fd = fd; return ((UpnpWebFileHandle) file); }
static UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode) { extern struct ushare_t *ut; struct upnp_entry_t *entry = NULL; struct web_file_t *file; int fd, upnp_id = 0; if (!filename) return NULL; log_verbose ("http_open, filename : %s mode=%d\n", filename, mode); if (mode == UPNP_READ) //return NULL; { if (!strcmp (filename, CDS_LOCATION)) return get_file_memory (CDS_LOCATION, CDS_DESCRIPTION, CDS_DESCRIPTION_LEN); if (!strcmp (filename, CMS_LOCATION)) return get_file_memory (CMS_LOCATION, CMS_DESCRIPTION, CMS_DESCRIPTION_LEN); if (!strcmp (filename, MSR_LOCATION)) return get_file_memory (MSR_LOCATION, MSR_DESCRIPTION, MSR_DESCRIPTION_LEN); if (ut->use_presentation && ( !strcmp (filename, USHARE_PRESENTATION_PAGE) || !strncmp (filename, USHARE_CGI, strlen (USHARE_CGI)))) return get_file_memory (USHARE_PRESENTATION_PAGE, ut->presentation->buf, ut->presentation->len); upnp_id = atoi (strrchr (filename, '/') + 1); if ( upnp_id == WebCamID )//for webcam { readcnt++; while( writecnt > 0 ) usleep(1000); } entry = upnp_get_entry (ut, upnp_id); if (!entry) return NULL; if (!entry->fullpath) return NULL; log_verbose ("Fullpath : %s\n", entry->fullpath); fd = open (entry->fullpath, O_RDONLY | O_NONBLOCK | O_SYNC | O_NDELAY); if (fd < 0) return NULL; if ( upnp_id == WebCamID )//for webcam webcamfd = fd; file = malloc (sizeof (struct web_file_t)); file->fullpath = strdup (entry->fullpath); file->pos = 0; file->type = FILE_LOCAL; file->detail.local.entry = entry; file->detail.local.fd = fd; return ((UpnpWebFileHandle) file); } else { /*fd = open ("TEST", O_WRONLY | O_NONBLOCK | O_SYNC | O_NDELAY| O_CREAT,0600); extern struct mime_type_t *MIME_Type_List; file = malloc (sizeof (struct web_file_t)); file->fullpath = strdup ("TEST"); file->pos = 0; file->type = FILE_LOCAL; file->detail.local.entry = NULL; file->detail.local.fd = fd; return ((UpnpWebFileHandle) file);*/ return NULL; } }