Exemplo n.º 1
0
bool dsp_entry_v2::show_config_popup(dsp_preset & p_data,HWND p_parent) {
	PFC_ASSERT(p_data.get_owner() == get_guid());
	dsp_preset_impl temp(p_data);
	show_config_popup_v2(p_data,p_parent,dsp_preset_edit_callback_impl(temp));
	PFC_ASSERT(temp.get_owner() == get_guid());
	if (temp == p_data) return false;
	p_data = temp;
	return true;
}
	ui_element_instance::ptr instantiate(HWND parent,ui_element_config::ptr cfg,ui_element_instance_callback::ptr callback) 
	{
		PFC_ASSERT( cfg->get_guid() == get_guid() );
		service_nnptr_t<ui_element_instance_impl_helper> item = new service_impl_t<ui_element_instance_impl_helper>(cfg, callback);
		item->initialize_window(parent);
		return item;
	}
Exemplo n.º 3
0
ui_element_config::ptr UIElement::get_default_configuration()
{
	BYTE temp[sizeof(UIPreference) + 8] = {0,};
	UIPreference *settemp = (UIPreference *)&temp[4];
	*((DWORD *)&temp[0]) = ('A' << 24 | 'L' << 16 | 'S' << 8 | 'O');
	settemp->SetDefault();

	return ui_element_config::g_create(get_guid(), temp, sizeof(temp));
}
bool preferences_page::get_help_url(pfc::string_base & p_out)
{
	p_out = "http://help.foobar2000.org/";
	p_out += core_version_info::g_get_version_string();
	p_out += "/preferences/";
	p_out += (const char*) pfc::print_guid(get_guid());
	p_out += "/";
	p_out += get_name();
	return true;
}
Exemplo n.º 5
0
void rss_parser::fill_feed_items(std::tr1::shared_ptr<rss_feed> feed) {
	/*
	 * we iterate over all items of a feed, create an rss_item object for
	 * each item, and fill it with the appropriate values from the data structure.
	 */
	for (std::vector<rsspp::item>::iterator item=f.items.begin();item!=f.items.end();item++) {
		std::tr1::shared_ptr<rss_item> x(new rss_item(ch));

		set_item_title(feed, x, *item);

		if (item->link != "") {
			x->set_link(utils::absolute_url(feed->link(), item->link));
		}

		set_item_author(x, *item);

		x->set_feedurl(feed->rssurl());

		if (f.rss_version == rsspp::ATOM_1_0 && item->labels.size() > 0) {
			std::vector<std::string>::const_iterator start, finish;
			start = item->labels.begin();
			finish = item->labels.end();
			if (std::find(start, finish, "fresh") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			} 
			if (std::find(start, finish, "kept-unread") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "read") != finish) {
				x->set_unread_nowrite(false);
				x->set_override_unread(true);
			}
		}

		set_item_content(x, *item);

		if (item->pubDate != "") 
			x->set_pubDate(parse_date(item->pubDate));
		else
			x->set_pubDate(::time(NULL));
			
		x->set_guid(get_guid(*item));

		x->set_base(item->base);

		set_item_enclosure(x, *item);

		LOG(LOG_DEBUG, "rss_parser::parse: item title = `%s' link = `%s' pubDate = `%s' (%d) description = `%s'", x->title().c_str(), 
			x->link().c_str(), x->pubDate().c_str(), x->pubDate_timestamp(), x->description().c_str());

		add_item_to_feed(feed, x);
	}
}
	///=============================================================================================
	void GlobalInfo_i::GetGlobalInfoW(GlobalInfo * Info) const
	{
		LogTrace();
		Info->StructSize = sizeof(*Info);
		Info->MinFarVersion = get_min_version();
		Info->Version = get_version();
		Info->Author = get_author();
		Info->Description = get_description();
		Info->Guid = *get_guid();
		Info->Title = get_title();
	}
bool dsp_rate_entry::instantiate(service_ptr_t<dsp>& p_out, const dsp_preset& p_preset)
{
	bool ret = false;
	if (p_preset.get_owner() == get_guid())
	{
		t_dsp_rate_params params;
		params.set_data(p_preset);
		p_out = reinterpret_cast<dsp*>(new service_impl_t<dsp_rate>(params));
		ret = p_out.is_valid();
	}
	return ret;
}
Exemplo n.º 8
0
int		make_it_happen(struct stat file, char *eof)
{
  stat(eof, &file);
  get_rights(&file);
  my_printf(" %d", file.st_nlink);
  get_uid(&file);
  get_guid(&file);
  my_printf(" %d", file.st_size);
  my_put_time(ctime(&(file).st_mtime));
  my_put_file_name(eof, &file);
  my_printf("\n");
}
Exemplo n.º 9
0
static gboolean
guid_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
{
     e_guid_t guid;

    if (!get_guid(s, &guid)) {
        logfunc("\"%s\" is not a valid GUID.", s);
        return FALSE;
    }

    fv->value.guid = guid;
    return TRUE;
}
Exemplo n.º 10
0
static gboolean
guid_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, gchar **err_msg)
{
     e_guid_t guid;

    if (!get_guid(s, &guid)) {
        if (err_msg != NULL)
            *err_msg = g_strdup_printf("\"%s\" is not a valid GUID.", s);
        return FALSE;
    }

    fv->value.guid = guid;
    return TRUE;
}
Exemplo n.º 11
0
ui_element_config::ptr UIElement::get_configuration()
{
	if(m_config->get_data_size() == sizeof(m_Setting) + m_Script.get_length() + 8)
	{
		memcpy(((BYTE *)m_config->get_data() + 4), &m_Setting, sizeof(m_Setting));
	}
	else
	{
		BYTE temp[sizeof(UIPreference) + 8] = {0,};
		memcpy(temp + 4, &m_Setting, sizeof(m_Setting));
		memset(temp, 0, sizeof(temp));
		*((DWORD *)&temp[0]) = ('A' << 24 | 'L' << 16 | 'S' << 8 | 'O');
		return ui_element_config::g_create(get_guid(), temp, sizeof(temp));
	}
	return m_config;
}
Exemplo n.º 12
0
int scan_inode_table(int fd, long long start, long long end,
	long long root_inode_start, int root_inode_offset,
	struct squashfs_super_block *sBlk, union squashfs_inode_header
	*dir_inode, unsigned char **inode_table, unsigned int *root_inode_block,
	unsigned int *root_inode_size, long long *uncompressed_file,
	unsigned int *uncompressed_directory, int *file_count, int *sym_count,
	int *dev_count, int *dir_count, int *fifo_count, int *sock_count,
	unsigned int *id_table)
{
	unsigned char *cur_ptr;
	int byte, files = 0;
	unsigned int directory_start_block, bytes = 0, size = 0;
	struct squashfs_base_inode_header base;

	TRACE("scan_inode_table: start 0x%llx, end 0x%llx, root_inode_start "
		"0x%llx\n", start, end, root_inode_start);

	*root_inode_block = UINT_MAX;
	while(start < end) {
		if(start == root_inode_start) {
			TRACE("scan_inode_table: read compressed block 0x%llx "
				"containing root inode\n", start);
			*root_inode_block = bytes;
		}
		if(size - bytes < SQUASHFS_METADATA_SIZE) {
			*inode_table = realloc(*inode_table, size
				+= SQUASHFS_METADATA_SIZE);
			if(*inode_table == NULL)
				MEM_ERROR();
		}
		TRACE("scan_inode_table: reading block 0x%llx\n", start);
		byte = read_block(fd, start, &start, 0, *inode_table + bytes);
		if(byte == 0)
			goto corrupted;

		bytes += byte;

		/* If this is not the last metadata block in the inode table
		 * then it should be SQUASHFS_METADATA_SIZE in size.
		 * Note, we can't use expected in read_block() above for this
		 * because we don't know if this is the last block until
		 * after reading.
		 */
		if(start != end && byte != SQUASHFS_METADATA_SIZE)
			goto corrupted;
	}

	/*
	 * We expect to have found the metadata block containing the
	 * root inode in the above inode_table metadata block scan.  If it
	 * hasn't been found then the filesystem is corrupted
	 */
	if(*root_inode_block == UINT_MAX)
		goto corrupted;

	/*
	 * The number of bytes available after the root inode medata block
	 * should be at least the root inode offset + the size of a
	 * regular directory inode, if not the filesystem is corrupted
	 *
	 *	+-----------------------+-----------------------+
	 *	| 			|        directory	|
	 *	|			|          inode	|
	 *	+-----------------------+-----------------------+
	 *	^			^			^
	 *	*root_inode_block	root_inode_offset	bytes
	 */
	if((bytes - *root_inode_block) < (root_inode_offset +
			sizeof(struct squashfs_dir_inode_header)))
		goto corrupted;

	/*
	 * Read last inode entry which is the root directory inode, and obtain
	 * the last directory start block index.  This is used when calculating
	 * the total uncompressed directory size.  The directory bytes in the
	 * last * block will be counted as normal.
	 *
	 * Note, the previous check ensures the following calculation won't
	 * underflow, and we won't access beyond the buffer
	 */
	*root_inode_size = bytes - (*root_inode_block + root_inode_offset);
	bytes = *root_inode_block + root_inode_offset;
	SQUASHFS_SWAP_DIR_INODE_HEADER(*inode_table + bytes, &dir_inode->dir);
	
	if(dir_inode->base.inode_type == SQUASHFS_DIR_TYPE)
		directory_start_block = dir_inode->dir.start_block;
	else if(dir_inode->base.inode_type == SQUASHFS_LDIR_TYPE) {
		if(*root_inode_size < sizeof(struct squashfs_ldir_inode_header))
			/* corrupted filesystem */
			goto corrupted;
		SQUASHFS_SWAP_LDIR_INODE_HEADER(*inode_table + bytes,
			&dir_inode->ldir);
		directory_start_block = dir_inode->ldir.start_block;
	} else
		/* bad type, corrupted filesystem */
		goto corrupted;

	get_uid(id_table[dir_inode->base.uid]);
	get_guid(id_table[dir_inode->base.guid]);

	/* allocate fragment to file mapping table */
	file_mapping = calloc(sBlk->fragments, sizeof(struct append_file *));
	if(file_mapping == NULL)
		MEM_ERROR();

	for(cur_ptr = *inode_table; cur_ptr < *inode_table + bytes; files ++) {
		if(NO_INODE_BYTES(squashfs_base_inode_header))
			/* corrupted filesystem */
			goto corrupted;

		SQUASHFS_SWAP_BASE_INODE_HEADER(cur_ptr, &base);

		TRACE("scan_inode_table: processing inode @ byte position "
			"0x%x, type 0x%x\n",
			(unsigned int) (cur_ptr - *inode_table),
			base.inode_type);

		get_uid(id_table[base.uid]);
		get_guid(id_table[base.guid]);

		switch(base.inode_type) {
		case SQUASHFS_FILE_TYPE: {
			struct squashfs_reg_inode_header inode;
			int frag_bytes, blocks, i;
			long long start, file_bytes = 0;
			unsigned int *block_list;

			if(NO_INODE_BYTES(squashfs_reg_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			SQUASHFS_SWAP_REG_INODE_HEADER(cur_ptr, &inode);

			frag_bytes = inode.fragment == SQUASHFS_INVALID_FRAG ?
				0 : inode.file_size % sBlk->block_size;
			blocks = inode.fragment == SQUASHFS_INVALID_FRAG ?
				(inode.file_size + sBlk->block_size - 1) >>
				sBlk->block_log : inode.file_size >>
				sBlk->block_log;
			start = inode.start_block;

			TRACE("scan_inode_table: regular file, file_size %d, "
				"blocks %d\n", inode.file_size, blocks);

			if(NO_BYTES(blocks * sizeof(unsigned int)))
				/* corrupted filesystem */
				goto corrupted;

			block_list = malloc(blocks * sizeof(unsigned int));
			if(block_list == NULL)
				MEM_ERROR();

			cur_ptr += sizeof(inode);
			SQUASHFS_SWAP_INTS(cur_ptr, block_list, blocks);

			*uncompressed_file += inode.file_size;
			(*file_count) ++;

			for(i = 0; i < blocks; i++)
				file_bytes +=
					SQUASHFS_COMPRESSED_SIZE_BLOCK
								(block_list[i]);

			if(inode.fragment != SQUASHFS_INVALID_FRAG &&
					inode.fragment >= sBlk->fragments) {
				free(block_list);
				goto corrupted;
			}

			add_file(start, inode.file_size, file_bytes,
				block_list, blocks, inode.fragment,
				inode.offset, frag_bytes);
				
			cur_ptr += blocks * sizeof(unsigned int);
			break;
		}	
		case SQUASHFS_LREG_TYPE: {
			struct squashfs_lreg_inode_header inode;
			int frag_bytes, blocks, i;
			long long start, file_bytes = 0;
			unsigned int *block_list;

			if(NO_INODE_BYTES(squashfs_lreg_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			SQUASHFS_SWAP_LREG_INODE_HEADER(cur_ptr, &inode);

			frag_bytes = inode.fragment == SQUASHFS_INVALID_FRAG ?
				0 : inode.file_size % sBlk->block_size;
			blocks = inode.fragment == SQUASHFS_INVALID_FRAG ?
				(inode.file_size + sBlk->block_size - 1) >>
				sBlk->block_log : inode.file_size >>
				sBlk->block_log;
			start = inode.start_block;

			TRACE("scan_inode_table: extended regular "
				"file, file_size %lld, blocks %d\n",
				inode.file_size, blocks);

			if(NO_BYTES(blocks * sizeof(unsigned int)))
				/* corrupted filesystem */
				goto corrupted;

			block_list = malloc(blocks * sizeof(unsigned int));
			if(block_list == NULL)
				MEM_ERROR();

			cur_ptr += sizeof(inode);
			SQUASHFS_SWAP_INTS(cur_ptr, block_list, blocks);

			*uncompressed_file += inode.file_size;
			(*file_count) ++;

			for(i = 0; i < blocks; i++)
				file_bytes +=
					SQUASHFS_COMPRESSED_SIZE_BLOCK
								(block_list[i]);

			if(inode.fragment != SQUASHFS_INVALID_FRAG &&
					inode.fragment >= sBlk->fragments) {
				free(block_list);
				goto corrupted;
			}

			add_file(start, inode.file_size, file_bytes,
				block_list, blocks, inode.fragment,
				inode.offset, frag_bytes);

			cur_ptr += blocks * sizeof(unsigned int);
			break;
		}	
		case SQUASHFS_SYMLINK_TYPE:
		case SQUASHFS_LSYMLINK_TYPE: {
			struct squashfs_symlink_inode_header inode;

			if(NO_INODE_BYTES(squashfs_symlink_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			SQUASHFS_SWAP_SYMLINK_INODE_HEADER(cur_ptr, &inode);

			(*sym_count) ++;

			if (inode.inode_type == SQUASHFS_LSYMLINK_TYPE) {
				if(NO_BYTES(inode.symlink_size +
							sizeof(unsigned int)))
					/* corrupted filesystem */
					goto corrupted;
				cur_ptr += sizeof(inode) + inode.symlink_size +
							sizeof(unsigned int);
			} else {
				if(NO_BYTES(inode.symlink_size))
					/* corrupted filesystem */
					goto corrupted;
				cur_ptr += sizeof(inode) + inode.symlink_size;
			}
			break;
		}
		case SQUASHFS_DIR_TYPE: {
			struct squashfs_dir_inode_header dir_inode;

			if(NO_INODE_BYTES(squashfs_dir_inode_header))
				/* corrupted filesystem */
				goto corrupted;
				
			SQUASHFS_SWAP_DIR_INODE_HEADER(cur_ptr, &dir_inode);

			if(dir_inode.start_block < directory_start_block)
				*uncompressed_directory += dir_inode.file_size;

			(*dir_count) ++;
			cur_ptr += sizeof(struct squashfs_dir_inode_header);
			break;
		}
		case SQUASHFS_LDIR_TYPE: {
			struct squashfs_ldir_inode_header dir_inode;
			int i;

			if(NO_INODE_BYTES(squashfs_ldir_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			SQUASHFS_SWAP_LDIR_INODE_HEADER(cur_ptr, &dir_inode);

			if(dir_inode.start_block < directory_start_block)
				*uncompressed_directory += dir_inode.file_size;

			(*dir_count) ++;
			cur_ptr += sizeof(struct squashfs_ldir_inode_header);

			for(i = 0; i < dir_inode.i_count; i++) {
				struct squashfs_dir_index index;

				if(NO_BYTES(sizeof(index)))
					/* corrupted filesystem */
					goto corrupted;
			
				SQUASHFS_SWAP_DIR_INDEX(cur_ptr, &index);

				if(NO_BYTES(index.size + 1))
					/* corrupted filesystem */
					goto corrupted;

				cur_ptr += sizeof(index) + index.size + 1;
			}
			break;
		}
	 	case SQUASHFS_BLKDEV_TYPE:
	 	case SQUASHFS_CHRDEV_TYPE:
			if(NO_INODE_BYTES(squashfs_dev_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			(*dev_count) ++;
			cur_ptr += sizeof(struct squashfs_dev_inode_header);
			break;
	 	case SQUASHFS_LBLKDEV_TYPE:
	 	case SQUASHFS_LCHRDEV_TYPE:
			if(NO_INODE_BYTES(squashfs_ldev_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			(*dev_count) ++;
			cur_ptr += sizeof(struct squashfs_ldev_inode_header);
			break;
		case SQUASHFS_FIFO_TYPE:
			if(NO_INODE_BYTES(squashfs_ipc_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			(*fifo_count) ++;
			cur_ptr += sizeof(struct squashfs_ipc_inode_header);
			break;
		case SQUASHFS_LFIFO_TYPE:
			if(NO_INODE_BYTES(squashfs_lipc_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			(*fifo_count) ++;
			cur_ptr += sizeof(struct squashfs_lipc_inode_header);
			break;
		case SQUASHFS_SOCKET_TYPE:
			if(NO_INODE_BYTES(squashfs_ipc_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			(*sock_count) ++;
			cur_ptr += sizeof(struct squashfs_ipc_inode_header);
			break;
		case SQUASHFS_LSOCKET_TYPE:
			if(NO_INODE_BYTES(squashfs_lipc_inode_header))
				/* corrupted filesystem */
				goto corrupted;

			(*sock_count) ++;
			cur_ptr += sizeof(struct squashfs_lipc_inode_header);
			break;
	 	default:
			ERROR("Unknown inode type %d in scan_inode_table!\n",
					base.inode_type);
			goto corrupted;
		}
	}
	
	printf("Read existing filesystem, %d inodes scanned\n", files);
	return TRUE;

corrupted:
	ERROR("scan_inode_table: filesystem corruption detected in "
		"scanning metadata\n");
	free(*inode_table);
	return FALSE;
}
Exemplo n.º 13
0
void scan_winlnk(const class scanner_params &sp,const recursion_control_block &rcb)
{
    assert(sp.sp_version==scanner_params::CURRENT_SP_VERSION);
    if(sp.phase==scanner_params::PHASE_STARTUP){
        assert(sp.info->si_version==scanner_info::CURRENT_SI_VERSION);
        sp.info->name		= "winlnk";
        sp.info->author		= "Simson Garfinkel";
        sp.info->description	= "Search for Windows LNK files";
        sp.info->feature_names.insert("winlnk");
        debug = sp.info->config->debug;
        return;
    }
    if(sp.phase==scanner_params::PHASE_SCAN){
	
	// phase 1: set up the feature recorder and search for winlnk features
	const sbuf_t &sbuf = sp.sbuf;
	feature_recorder *winlnk_recorder = sp.fs.get_name("winlnk");

	// make sure that potential LNK file is large enough and has the correct signature
	if (sbuf.pagesize <= SMALLEST_LNK_FILE){
            return;
        }

        for (size_t p=0;(p < sbuf.pagesize) &&  (p < sbuf.bufsize - SMALLEST_LNK_FILE); p++){
            if ( sbuf.get32u(p+0x00) == 0x0000004c &&
                 sbuf.get32u(p+0x04) == 0x00021401 &&
                 sbuf.get32u(p+0x08) == 0x00000000 &&
                 sbuf.get32u(p+0x0c) == 0x000000c0 &&
                 sbuf.get32u(p+0x10) == 0x46000000 ){

		dfxml_writer::strstrmap_t lnkmap;
                
                uint32_t LinkFlags      = sbuf.get32u(p+0x0014);
                bool     HasLinkTargetIDList = LinkFlags & (1 << 0);
                bool     HasLinkInfo        = LinkFlags  & (1 << 1);
                //bool     HasName            = LinkFlags  & (1 << 2);
                //bool     HasRelativePath    = LinkFlags  & (1 << 3);
                //bool     HasWorkingDir      = LinkFlags  & (1 << 4);
                //uint32_t FileAttributes = sbuf.get32u(p+0x0018);
                uint64_t CreationTime   = sbuf.get64u(p+0x001c);
                uint64_t AccessTime     = sbuf.get64u(p+0x0024);
                uint64_t WriteTime      = sbuf.get64u(p+0x002c);

                size_t loc = 0x004c;    // location of next section
                
                lnkmap["ctime"] = microsoftDateToISODate(CreationTime);
                lnkmap["atime"] = microsoftDateToISODate(AccessTime);
                lnkmap["wtime"] = microsoftDateToISODate(WriteTime);

                if (HasLinkTargetIDList ){
                    uint16_t IDListSize = sbuf.get16u(p+loc);
                    loc += IDListSize + 2;
                }

                std::string path("NOLINKINFO");
                if (HasLinkInfo ){
                    uint32_t LinkInfoSize       = sbuf.get32u(p+loc);
                    //uint32_t LinkInfoHeaderSize = sbuf.get32u(p+loc+4);
                    //uint32_t LinkInfoFlags      = sbuf.get32u(p+loc+8);
                    //uint32_t VolumeIDOffset      = sbuf.get32u(p+loc+12);
                    uint32_t LocalBasePathOffset = sbuf.get32u(p+loc+16);
                    //uint32_t CommonNetworkRelativeLinkOffset = sbuf.get32u(p+loc+20);
                    //uint32_t CommonPathSuffixOffset = sbuf.get32u(p+loc+20);

                    /* copy out the pathname */
                    path = "";
                    for(size_t i = p+loc+LocalBasePathOffset; i<sbuf.bufsize && sbuf[i]; i++){
                        path += sbuf[i];
                    }
                    lnkmap["path"] = path;
                    loc += LinkInfoSize;
                }
                winlnk_recorder->write(sbuf.pos0+p,path,dfxml_writer::xmlmap(lnkmap,"lnk",""));
                p += loc;
            } else
            /**
             * At present we don't entirely support LNK parsing, and
             * some blocks need to be carved because of this.
             */
            if ( sbuf.get32u(p+0x00) == 0x00000060 &&
                 sbuf.get32u(p+0x04) == 0xa0000003 &&
                 sbuf.get32u(p+0x08) == 0x00000058 &&
                 sbuf.get32u(p+0x0c) == 0x00000000){
		dfxml_writer::strstrmap_t lnkguid;
                std::string dvolid = get_guid(sbuf, p+32);
                lnkguid["droid_volumeid"] = dvolid;
                lnkguid["droid_fileid"] = get_guid(sbuf, p+48);
                lnkguid["birth_volumeid"] = get_guid(sbuf, p+64);
                lnkguid["birth_fileid"] = get_guid(sbuf, p+80);
                winlnk_recorder->write(sbuf.pos0+p,dvolid,dfxml_writer::xmlmap(lnkguid,"lnk-guid",""));
                p += 96;
            }
        }
    }
}
Exemplo n.º 14
0
/* 
 * Convert ip related info in hmsg from utf16 to utf8 and store in umsg
 */
static int 
ipinfo_utf16_utf8(hv_kvp_bsd_msg *hmsg, hv_kvp_bsd_msg *umsg)
{
        int err_ip, err_subnet, err_gway, err_dns, err_adap;
	struct guid_extract *id;
	int unit = 0;
	char if_name[4];
	char* guid_data = NULL;
	char buf[38]; 
	int len=16;
	/* Trying to find GUID of Network Device */
	guid_data = get_guid(unit); /* get_guid returns a golabl varaiable */
	id = (struct guid_extract *)guid_data;
	snprintf(buf, sizeof(buf), "%.2s%.2s%.2s%.2s-%.2s%.2s-%.2s%.2s-%.4s-%.12s",
           id->a4,id->a3,id->a2,id->a1,
             id->b2, id->b1, id->c2, id->c1,id->d,id->e);
	guid_data = NULL;
	sprintf(if_name,"%s%d","hn",unit);
#ifdef DEBUG
	int i;
	printf("GUID KVP: %s\nif_name: %s  \n",buf,if_name);
	/* buf holds GUID Instance */
	printf("ipinfo_utf16_utf8:adapterId\n");
	for (i=0; i<=len; i++) 
		printf("%x:", hmsg->body.kvp_ip_val.adapter_id[i]);
	printf("\naddr_family:%x dhcp_enabled:%x:", 
		hmsg->body.kvp_ip_val.addr_family,
		hmsg->body.kvp_ip_val.dhcp_enabled);
	printf("ipinfo_utf16_utf8:ip_address\n");
	for (i=0; i<=len; i++) 
		printf("%x:", hmsg->body.kvp_ip_val.ip_addr[i]);
	printf("\nipinfo_utf16_utf8:sub_net\n");
	for (i=0; i<=len; i++) 
		printf("%x:", hmsg->body.kvp_ip_val.sub_net[i]);
	printf("\nipinfo_utf16_utf8:gate_way\n");
	for (i=0; i<=len; i++) 
		printf("%x:", hmsg->body.kvp_ip_val.gate_way[i]);
	printf("\nipinfo_utf16_utf8:dns_addr\n");
	for (i=0; i<=len; i++) 
		printf("%x:", hmsg->body.kvp_ip_val.dns_addr[i]);
#endif
	/* IP Address */
    len = utf16_to_utf8((char *)umsg->body.kvp_ip_val.ip_addr, MAX_IP_ADDR_SIZE,
                        (uint16_t *)hmsg->body.kvp_ip_val.ip_addr,
                        MAX_IP_ADDR_SIZE, UNUSED_FLAG, &err_ip);
	/* Adapter ID : GUID */
	len = utf16_to_utf8((char *)umsg->body.kvp_ip_val.adapter_id,
                        MAX_ADAPTER_ID_SIZE,
                        (uint16_t *)hmsg->body.kvp_ip_val.adapter_id,
                        MAX_ADAPTER_ID_SIZE, UNUSED_FLAG, &err_adap);
	/* Need to implemnet multiple network adapter handler */
	if (strncmp(buf,(char *)umsg->body.kvp_ip_val.adapter_id,16) == 0)
	{
		/* Pass inteface Name */
		printf("GUID Found\n");
		
		strcpy((char *)umsg->body.kvp_ip_val.adapter_id,if_name);
	}
	else
	{
		/* Need to Implment Safe Exit */  
		printf("GUID Not Found\n");
	}
	/* Address Family , DHCP , SUBNET, Gateway, DNS */ 
	umsg->body.kvp_ip_val.addr_family = hmsg->body.kvp_ip_val.addr_family;
        umsg->body.kvp_ip_val.dhcp_enabled = hmsg->body.kvp_ip_val.dhcp_enabled;
        utf16_to_utf8((char *)umsg->body.kvp_ip_val.sub_net, MAX_IP_ADDR_SIZE,
                        (uint16_t *)hmsg->body.kvp_ip_val.sub_net,
                        MAX_IP_ADDR_SIZE, UNUSED_FLAG, &err_subnet);


        utf16_to_utf8((char *)umsg->body.kvp_ip_val.gate_way, MAX_GATEWAY_SIZE,
                        (uint16_t *)hmsg->body.kvp_ip_val.gate_way,
                        MAX_GATEWAY_SIZE, UNUSED_FLAG, &err_gway);

        utf16_to_utf8((char *)umsg->body.kvp_ip_val.dns_addr, MAX_IP_ADDR_SIZE,
                        (uint16_t *)hmsg->body.kvp_ip_val.dns_addr,
                        MAX_IP_ADDR_SIZE, UNUSED_FLAG, &err_dns);

#ifdef DEBUG
	printf("dhcp_enabled:%d \naddr_family:%d\n", 
	umsg->body.kvp_ip_val.dhcp_enabled, umsg->body.kvp_ip_val.addr_family);
	printf("adapter_id=%s\n",(char *)umsg->body.kvp_ip_val.adapter_id);
	printf("ip_addr=%s\n", (char *)umsg->body.kvp_ip_val.ip_addr);
	printf("sub_net=%s\n", (char *)umsg->body.kvp_ip_val.sub_net);
	printf("gate_way=%s\n", (char *)umsg->body.kvp_ip_val.gate_way);
	printf("dns_addr=%s\n", (char *)umsg->body.kvp_ip_val.dns_addr);
#endif
        return (err_ip | err_subnet | err_gway | err_dns | err_adap);
//	return err_adap;
}
Exemplo n.º 15
0
void rss_parser::fill_feed_items(std::shared_ptr<rss_feed> feed) {
	/*
	 * we iterate over all items of a feed, create an rss_item object for
	 * each item, and fill it with the appropriate values from the data structure.
	 */
	for (auto item : f.items) {
		std::shared_ptr<rss_item> x(new rss_item(ch));

		set_item_title(feed, x, item);

		if (item.link != "") {
			x->set_link(utils::absolute_url(feed->link(), item.link));
		}

		if (x->link().empty() && item.guid_isPermaLink) {
			x->set_link(item.guid);
		}

		set_item_author(x, item);

		x->set_feedurl(feed->rssurl());
		x->set_feedptr(feed);

		if ((f.rss_version == rsspp::ATOM_1_0 || f.rss_version == rsspp::TTRSS_JSON || f.rss_version == rsspp::NEWSBLUR_JSON || f.rss_version == rsspp::OCNEWS_JSON) && item.labels.size() > 0) {
			auto start = item.labels.begin();
			auto finish = item.labels.end();

			if (std::find(start, finish, "fresh") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "kept-unread") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "read") != finish) {
				x->set_unread_nowrite(false);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "ttrss:unread") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "ttrss:read") != finish) {
				x->set_unread_nowrite(false);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "newsblur:unread") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "newsblur:read") != finish) {
				x->set_unread_nowrite(false);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "ocnews:unread") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "ocnews:read") != finish) {
				x->set_unread_nowrite(false);
				x->set_override_unread(true);
			}
		}

		set_item_content(x, item);

		if (item.pubDate != "")
			x->set_pubDate(parse_date(item.pubDate));
		else
			x->set_pubDate(::time(nullptr));

		x->set_guid(get_guid(item));

		x->set_base(item.base);

		set_item_enclosure(x, item);

		LOG(LOG_DEBUG, "rss_parser::parse: item title = `%s' link = `%s' pubDate = `%s' (%d) description = `%s'", x->title().c_str(),
		    x->link().c_str(), x->pubDate().c_str(), x->pubDate_timestamp(), x->description().c_str());

		add_item_to_feed(feed, x);
	}
}
Exemplo n.º 16
0
int WMA_File::asfReadHeader()
{
	int noEndlessLoop = 0;

//  ASFContext asf;
	TAGGER_GUID g;
//  int size, i;
	int64_t gsize;

	get_guid(this, &g);
	if (memcmp(&g, &asf_header, sizeof(TAGGER_GUID)))
		goto fail;
	get_le64(this);
	get_le32(this);
	get_byte(this);
	get_byte(this);
	//  memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid));
	for(;;) {


		noEndlessLoop++;
		if( noEndlessLoop > 256 )
		{
			goto fail;
		}

		get_guid(this, &g);
		gsize = get_le64(this);
// #ifdef DEBUG
//     printf("%08Lx: ", url_ftell(f) - 24);
//     print_guid(&g);
//     printf("  size=0x%Lx\n", gsize);
// #endif
		if (gsize < 24)
			goto fail;
		if (!memcmp(&g, &file_header, sizeof(TAGGER_GUID))) {
			get_guid(this, &g);
			// asf.hdr.file_size      =
			get_le64(this);
			// asf.hdr.create_time    =
			get_le64(this);
			// asf.hdr.packets_count  =
			get_le64(this);
			// asf.hdr.play_time
			int64_t play_time = get_le64(this);
			// play_time is in 100ns = 10^-7s units
			if (wmaProperties)
				wmaProperties->m_length = (play_time / 10000000L);
			// asf.hdr.send_time      =
			get_le64(this);
			// asf.hdr.preroll        =
			get_le32(this);
			// asf.hdr.ignore     =
			get_le32(this);
			// asf.hdr.flags      =
			get_le32(this);
			// asf.hdr.min_pktsize    =
			get_le32(this);
			// asf.hdr.max_pktsize    =
			get_le32(this);
			// asf.hdr.max_bitrate    =
			get_le32(this);
			// asf.packet_size = asf.hdr.max_pktsize;
			// asf.nb_packets = asf.hdr.packets_count;
		} else if (!memcmp(&g, &stream_header, sizeof(TAGGER_GUID))) {
			//int type;
			int type_specific_size;
			//unsigned int tag1;
			int64_t pos1, pos2;

			pos1 = Tell();

			get_guid(this, &g);
			if (!memcmp(&g, &audio_stream, sizeof(TAGGER_GUID))) {
				//        type = CODEC_TYPE_AUDIO;
			} else {
				wxLogDebug(wxT("Tagger: WMA file contains non-audio streams."));
				return false;
			}

			get_guid(this, &g);
			get_le64(this); // total size
			type_specific_size = get_le32(this);
			get_le32(this);
			get_le16(this) /*& 0x7f*/; /* stream id */

			get_le32(this);
//       st->codec.codec_type = type;
//       /* 1 fps default (XXX: put 0 fps instead) */
//       st->codec.frame_rate = 1000;
//       st->codec.frame_rate_base = 1;

			//      if (type == CODEC_TYPE_AUDIO) {
			getWavHeader(type_specific_size);
			//        st->need_parsing = 1;
			/* We have to init the frame size at some point .... */
			pos2 = Tell();
			if (gsize > (pos2 + 8 - pos1 + 24)) {
				/* asf_st.ds_span = */ get_byte(this);
				/* asf_st.ds_packet_size = */ get_le16(this);
				// asf_st.ds_chunk_size =
				get_le16(this);
				//  asf_st.ds_data_size =
				get_le16(this);
				// asf_st.ds_silence_data =
				get_byte(this);
			}

			pos2 = Tell();
			Seek(gsize - (pos2 - pos1 + 24), SJ_SEEK_CUR);
		} else if (!memcmp(&g, &data_header, sizeof(TAGGER_GUID))) {
			break;
		} else if (!memcmp(&g, &comment_header, sizeof(TAGGER_GUID))) {
			int len1, len2, len3, len4, len5;

			len1 = get_le16(this);
			len2 = get_le16(this);
			len3 = get_le16(this);
			len4 = get_le16(this);
			len5 = get_le16(this);

			if (wmaTag) {
				wxString s;
				//char buf[1];

				get_str16_nolen(this, len1, s);
				wmaTag->setTitle(s);

				get_str16_nolen(this, len2, s);
				wmaTag->setLeadArtist(s);

				get_str16_nolen(this, len3, s); // Copyright notice

				get_str16_nolen(this, len4, s);
				wmaTag->setComment(s);

				Seek(len5, SJ_SEEK_CUR);
			} else {
				Seek(len1+len2+len3+len4+len5, SJ_SEEK_CUR);
			}
		} else if (!memcmp(&g, &extended_content_header, sizeof(TAGGER_GUID))) {
			int desc_count, i;

			desc_count = get_le16(this);
			for(i=0; i<desc_count; i++)
			{
				int name_len,value_type,value_len = 0;
				int64_t value_num = 0;
				wxString name, value;

				name_len = get_le16(this);
				get_str16_nolen(this, name_len, name);
				value_type = get_le16(this);
				value_len = get_le16(this);

				//debug (name);
				//                printf ("value_type is %d; name_len is %d\n", value_type, name_len);

				if ((value_type == 0) || (value_type == 1)) // unicode or byte
				{
					get_str16_nolen(this, value_len, value);
					//debug ("string value:");
					//debug(value);
					if ( wmaTag ) {
						if (name == wxT("WM/AlbumTitle"))
						{ wmaTag->setAlbum(value); }

						if (name == wxT("WM/Genre"))
						{ wmaTag->setGenre(value); }

						if (name == wxT("WM/Year"))
						{ long l; if(!value.ToLong(&l)){l=0;} wmaTag->setYear(l); }

						if (name==wxT("WM/TrackNumber"))
						{ long l; if(!value.ToLong(&l)){l=0;} wmaTag->setTrack(l, 0); }
					}
				}
				if ((value_type >= 2) && (value_type <= 5)) // boolean or DWORD or QWORD or WORD
				{
					if (value_type==2) value_num = get_le32(this);
					if (value_type==3) value_num = get_le32(this);
					if (value_type==4) value_num = get_le64(this);
					if (value_type==5) value_num = get_le16(this);

					//printf("numerical value: %d\n", value_num);
					if (wmaTag) {
						if (name==wxT("WM/Track"))
						{ wmaTag->setTrack(value_num + 1, 0); }

						if (name==wxT("WM/TrackNumber"))
						{ wmaTag->setTrack(value_num, 0); }
					}
				}
			}
#if 0
		} else if (!memcmp(&g, &head1_guid, sizeof(TAGGER_GUID))) {
			int v1, v2;
			get_guid(f, &g);
			v1 = get_le32(this);
			v2 = get_le16(this);
		} else if (!memcmp(&g, &codec_comment_header, sizeof(TAGGER_GUID))) {
			int len, v1, n, num;
			char str[256], *q;
			char tag[16];

			get_guid(this, &g);
			print_guid(&g);

			n = get_le32(this);
			for(i=0; i<n; i++) {
				num = get_le16(this); /* stream number */
				get_str16(this, str, sizeof(str));
				get_str16(this, str, sizeof(str));
				len = get_le16(this);
				q = tag;
				while (len > 0) {
					v1 = get_byte(this);
					if ((q - tag) < sizeof(tag) - 1)
						*q++ = v1;
					len--;
				}
				*q = '\0';
			}
#endif
			// FIXME: Can we eliminate all further reads?

			// FIXME: implement EOF check
//     } else if (url_feof(f)) {
//       goto fail;
		} else {
			Seek(gsize - 24, SJ_SEEK_CUR);
		}
	}
	get_guid(this, &g);
	get_le64(this);
	get_byte(this);
	get_byte(this);
	// FIXME: implement EOF check
//   if (url_feof(f))
//           goto fail;
//   asf->data_offset = url_ftell(f);
//   asf->packet_size_left = 0;

	return true;

fail:
	return false;
//   for(i=0;i<s->nb_streams;i++) {
//     AVStream *st = s->streams[i];
//     if (st) {
//       av_free(st->priv_data);
//       av_free(st->codec.extradata);
//     }
//     av_free(st);
//   }
//   return -1;
}