示例#1
0
int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num)
{
	struct ex_chunk_dir excd;
	int index = 16;
	int useld = 0;

	if (!ec->cid.cd)
		return 0;

	while(1) {
		ecard_readbytes(&excd, ec, index, 8, useld);
		index += 8;
		if (c_id(&excd) == 0) {
			if (!useld && ec->loader) {
				useld = 1;
				index = 0;
				continue;
			}
			return 0;
		}
		if (c_id(&excd) == 0xf0) { /* link */
			index = c_start(&excd);
			continue;
		}
		if (c_id(&excd) == 0x80) { /* loader */
			if (!ec->loader) {
				ec->loader = (loader_t)kmalloc(c_len(&excd),
							       GFP_KERNEL);
				if (ec->loader)
					ecard_readbytes(ec->loader, ec,
							(int)c_start(&excd),
							c_len(&excd), useld);
				else
					return 0;
			}
			continue;
		}
		if (c_id(&excd) == id && num-- == 0)
			break;
	}

	if (c_id(&excd) & 0x80) {
		switch (c_id(&excd) & 0x70) {
		case 0x70:
			ecard_readbytes((unsigned char *)excd.d.string, ec,
					(int)c_start(&excd), c_len(&excd),
					useld);
			break;
		case 0x00:
			break;
		}
	}
	cd->start_offset = c_start(&excd);
	memcpy(cd->d.string, excd.d.string, 256);
	return 1;
}
示例#2
0
int McpServlet::get_grab_info_by_c_id(const idl::mcp_get_grab_info_by_c_id_params& in, idl::mcp_get_grab_info_by_c_id_response& out)
{
    UB_LOG_TRACE( "get_grab_info_by_c_id start" );
    string c_id(in.c_id());
    vector<grab_t> grab_list;
    int count=0;
    ContentInfo c_info(c_id);
    int res=c_info.getGrabList(count, grab_list);
    if(res!=0){
        UB_LOG_FATAL( "getGrabList failed, [%s:%d]", __FILE__, __LINE__ );
        count = res;
        goto end;
    }
end:
    out.m_result_params()->set_result(count);
    vector<grab_t>::const_iterator iter=grab_list.begin();
    for(int i=0; iter!=grab_list.end(); ++i, ++iter){
        setGrabInfoResult(out.m_result_params()->mutable_grab_list(i), *iter);
    }
    UB_LOG_TRACE( "get_grab_info_by_c_id start" );
    return 0;
}