示例#1
0
/** Class constructor */
TxFrameZB::TxFrameZB(uint64_t addr, uint16_t addr16, uint8_t source_ep, uint8_t dest_ep,
                  uint16_t cluster_id, uint16_t profile_id, uint8_t broadcast_rad,
                  uint8_t tx_opt, const uint8_t *const data, uint16_t len)
{
    uint8_t frame_data[EXP_ADDR_OVERHEAD + len];

    _frame_id = get_next_frame_id();

    /* copy the frame id, the 64bit remote address, the 16bit network address,
     * the end point source and destination addresses, the cluster and profile IDs,
     * the broad cast radious, the options byte and the frame data */

    frame_data[0] = _frame_id;
    rmemcpy(&frame_data[1], (const uint8_t *)&addr, sizeof addr);
    frame_data[9] = (uint8_t)(addr16 >> 8);
    frame_data[10] = (uint8_t)addr16;
    frame_data[11] = source_ep;
    frame_data[12] = dest_ep;
    frame_data[13] = (uint8_t)(cluster_id >> 8);
    frame_data[14] = (uint8_t)cluster_id;
    frame_data[15] = (uint8_t)(profile_id >> 8);
    frame_data[16] = (uint8_t)profile_id;
    frame_data[17] = broadcast_rad;
    frame_data[18] = tx_opt;

    if (len) {
        memcpy(&frame_data[19], data, len);
    }

    set_api_frame(ExpAddrCmd, frame_data, EXP_ADDR_OVERHEAD + len);
}
示例#2
0
文件: video.c 项目: 8l/FUZIX
void scroll_down(void)
{
	map_for_video();
	rmemcpy(curpty->base + VT_WIDTH*2, curpty->base,
	       VT_WIDTH*2 * VT_BOTTOM);
	map_for_kernel();
}
示例#3
0
/** Class constructor */
TxFrameZB::TxFrameZB(uint64_t addr, uint16_t addr16, uint8_t broadcast_rad, uint8_t tx_opt,
                const uint8_t *const data, uint16_t len)
{
    uint8_t frame_data[TX_REQUEST_OVERHEAD + len];

    _frame_id = get_next_frame_id();

    /* copy the frame id, the 64bit remote address, the 16bit network address,
     * the broad cast radious, the options byte and the frame data */

    frame_data[0] = _frame_id;
    rmemcpy(&frame_data[1], (const uint8_t *)&addr, sizeof addr);
    frame_data[9] = (uint8_t)(addr16 >> 8);
    frame_data[10] = (uint8_t)addr16;
    frame_data[11] = broadcast_rad;
    frame_data[12] = tx_opt;

    if (len) {
        memcpy(&frame_data[13], data, len);
    }

    set_api_frame(TxReqZB, frame_data, TX_REQUEST_OVERHEAD + len);
}
示例#4
0
void inspect_flac_file (char *filename) {

	int fd;
	int ret;
	//char *filename;
	
	unsigned char bytes[4];
	unsigned char flac_header_magic_bytes[4];
	
	unsigned char channels_char;
	unsigned char sample_rate_char[3];
	unsigned char bit_depth_char;
	
	unsigned short int min_blocksize;
	unsigned short int max_blocksize;
	
	unsigned int channels;
	unsigned int sample_rate;
	unsigned int bit_depth;
	
	channels_char = 0;
	memset(sample_rate_char, 0, 3);
	bit_depth_char = 0;

	min_blocksize = 0;
	max_blocksize = 0;	
	channels = 0;
	sample_rate = 0;
	bit_depth = 0;
	
	memcpy (flac_header_magic_bytes, "fLaC", 4);

	fd = open ( filename, O_RDONLY );
	
	if (fd <= 0) {
		printf("Could not open file %s\n", filename);
		exit(1);
	}
	
	
	ret = read (fd, bytes, 4);
	
	if (ret != 4) {
		printf("Could not read file %s\n", filename);
		close (fd);
		exit(1);
	}
	
	if (memcmp(flac_header_magic_bytes, bytes, 4) == 0) {
	
	
		ret = lseek(fd, 8, SEEK_SET);
	
		if (ret != 8) {
			printf("Could not seek file %s\n", filename);
			close (fd);
			exit(1);
		}
	
		ret = read (fd, bytes, 2);

		if (ret != 2) {
			printf("Could not read file %s\n", filename);
			close (fd);
			exit(1);
		}
	
		rmemcpy(&min_blocksize, bytes, 2);	
	
		ret = read (fd, bytes, 2);

		if (ret != 2) {
			printf("Could not read file %s\n", filename);
			close (fd);
			exit(1);
		}
		
		rmemcpy(&max_blocksize, bytes, 2);	
	
		//printf("blocksize min: %u max: %u\n", min_blocksize, max_blocksize);
		
	
		ret = lseek(fd, 18, SEEK_SET);
	
		if (ret != 18) {
			printf("Could not seek file %s\n", filename);
			close (fd);
			exit(1);
		}
	
		ret = read (fd, bytes, 4);

		if (ret != 4) {
			printf("Could not read file %s\n", filename);
			close (fd);
			exit(1);
		}

		
		channels_char |= bytes[2] & 0x08;
		channels_char |= bytes[2] & 0x04;
		channels_char |= bytes[2] & 0x02;
		channels_char >>= 1;
		
		channels = channels_char;
		channels++;
		
		//printf("Channels bytes is %x\n", channels_char);
		//printf("Channels is %u\n", channels);
		
		bit_depth_char |= bytes[3] & 0x80;
		bit_depth_char |= bytes[3] & 0x40;
		bit_depth_char |= bytes[3] & 0x20;
		bit_depth_char |= bytes[3] & 0x10;
		bit_depth_char >>= 4;
		
		if (bytes[2] & 0x01) {
			bit_depth_char |= 0x10;
		}
		
		bit_depth = bit_depth_char;
		bit_depth++;
		
		//printf("bit_depth bytes is %x\n", bit_depth_char);
		//printf("bit depth is %u\n", bit_depth);
		
		sample_rate_char[0] |= bytes[2] & 0x80;
		sample_rate_char[0] |= bytes[2] & 0x40;
		sample_rate_char[0] |= bytes[2] & 0x20;
		sample_rate_char[0] |= bytes[2] & 0x10;

		sample_rate_char[2] = bytes[0];
		sample_rate_char[1] = bytes[1];
		
		memcpy((unsigned char *)&sample_rate, sample_rate_char, 3);
		
		sample_rate >>= 4;
		
		//printf("sample rate is %u\n", sample_rate);
		
		
		///if ((min_blocksize == 0) || (max_blocksize == 0) || (min_blocksize != max_blocksize) || (sample_rate != 44100) || (bit_depth != 16)
		//	|| (channels != 2)) {
		
			printf("File: %s\t\tR: %u B: %u C: %u BS: %u-%u\n", filename, sample_rate, bit_depth, channels, min_blocksize, max_blocksize);
		
		//} 
	
	} else {
示例#5
0
void
exec_connect()
{
	int	version;
	char	hostname[MAXHOSTNAMELEN];
	char	username[MAXLOGNAME];
	char	progname[MAXPATHLEN];
	WorkArea *wp;
	sj3_ugid ugid;

	version = get_int();
	get_nstring(hostname, sizeof(hostname));
	get_nstring(username, sizeof(username));
	get_nstring(progname, sizeof(progname));

	if (cur_cli -> work)
		longjmp(error_ret, SJ3_AlreadyConnected);

	if (version < 0)
		longjmp(error_ret, SJ3_DifferentVersion);

	if (hostname[0] == '\0')
		longjmp(error_ret, SJ3_NoHostName);

	if (username[0] == '\0')
		longjmp(error_ret, SJ3_NoUserName);

	if (!check_user(username, hostname))
		longjmp(error_ret, SJ3_NotAllowedUser);

	if (!(wp = alloc_workarea()))
		longjmp(error_ret, SJ3_NotEnoughMemory);

	if (priv_getugid(username, &ugid)) {
		struct sockaddr addr;
		uid_t euid;
		gid_t egid;
		int len = sizeof(addr);

		if (getsockname(cur_client->fd, &addr, &len) < 0)
			perror("getsockname");

		if (strict_auth_enable) {
			getpeereid(cur_client->fd, &euid, &egid);
			if (ugid.uid != euid || ugid.gid != egid) {
				longjmp(error_ret, SJ3_NotAllowedUser);
			}
		}
		cur_cli -> uid = ugid.uid;
	} else
		longjmp(error_ret, SJ3_NotAllowedUser);

        cur_cli -> version = version;
	strlcpy(cur_cli -> host, hostname, sizeof(cur_cli -> host));
	strlcpy(cur_cli -> user, username, sizeof(cur_cli -> user));
	strlcpy(cur_cli -> prog, progname, sizeof(cur_cli -> prog));
        rmemcpy(cur_cli -> def_char, defaultchar, 2);
	cur_cli -> work = wp;

        if (version == 1)
	        put_int(SJ3_NormalEnd);
        else
                put_int((-SJ3SERV_VERSION_NO));

	logging_out("connection established on %d (%s, %s, %s)",
			cur_cli -> fd, hostname, username, progname);
}