Exemplo n.º 1
0
LOCAL void PROC do_mask (char *pathend) {
        static struct find_t fi;

        adds (pathend, mask);
        if (_dos_findfirst (path, findattr, &fi))
                return;

        do {    const char *p;
                p = fi.name-1; do p++; while (*p == '.');
                if (*p == '\0') continue;               /* name == dots */

                adds (pathend, fi.name); found++;
            {   ATTR attr = attr2str (OLD_ATTR, fi.attrib);

                if (*NEW_PART != '\0') {
                    attr = (attr & attr_keep) | attr_set;
                    if (_dos_setfileattr (path,
                                          attr2str (NEW_ATTR, attr)
                                          & (ATTR)~_A_SUBDIR)) {
                        sayerror (E_ACCESS, "access denied", path);
                        continue;
            }   }    }

                say (info, path);
        } while (_dos_findnext (&fi) == 0);
}
Exemplo n.º 2
0
static void avrcp_get_current_player_value_dump(int level, struct frame *frm,
						uint8_t ctype, uint16_t len)
{
	uint8_t num;

	p_indent(level, frm);

	if (len < 2) {
		printf("PDU Malformed\n");
		raw_dump(level, frm);
		return;
	}

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	num = get_u8(frm);
	printf("AttributeCount: 0x%02x\n", num);

	for (; num > 0; num--) {
		uint8_t attr;

		p_indent(level, frm);

		attr = get_u8(frm);
		printf("AttributeID: 0x%02x (%s)\n", attr, attr2str(attr));
	}

	return;

response:
	num = get_u8(frm);
	printf("ValueCount: 0x%02x\n", num);

	for (; num > 0; num--) {
		uint8_t attr, value;

		p_indent(level, frm);

		attr = get_u8(frm);
		printf("AttributeID: 0x%02x (%s)\n", attr, attr2str(attr));

		p_indent(level, frm);

		value = get_u8(frm);
		printf("ValueID: 0x%02x (%s)\n", value,
						value2str(attr, value));
	}
}
Exemplo n.º 3
0
static bool avrcp_get_current_player_value(struct avctp_frame *avctp_frame,
						uint8_t ctype, uint8_t len,
						uint8_t indent)
{
	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
	uint8_t num;

	if (!l2cap_frame_get_u8(frame, &num))
		return false;

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	print_field("%*cAttributeCount: 0x%02x", (indent - 8), ' ', num);

	for (; num > 0; num--) {
		uint8_t attr;

		if (!l2cap_frame_get_u8(frame, &attr))
			return false;

		print_field("%*cAttributeID: 0x%02x (%s)", (indent - 8),
						' ', attr, attr2str(attr));
	}

	return true;

response:
	print_field("%*cValueCount: 0x%02x", (indent - 8), ' ', num);

	for (; num > 0; num--) {
		uint8_t attr, value;

		if (!l2cap_frame_get_u8(frame, &attr))
			return false;

		print_field("%*cAttributeID: 0x%02x (%s)", (indent - 8),
						' ', attr, attr2str(attr));

		if (!l2cap_frame_get_u8(frame, &value))
			return false;

		print_field("%*cValueID: 0x%02x (%s)", (indent - 8),
					' ', value, value2str(attr, value));
	}

	return true;
}
Exemplo n.º 4
0
static bool avrcp_list_player_attributes(struct avctp_frame *avctp_frame,
						uint8_t ctype, uint8_t len,
						uint8_t indent)
{
	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
	uint8_t num;
	int i;

	if (len == 0)
		return true;

	if (!l2cap_frame_get_u8(frame, &num))
		return false;

	print_field("%*cAttributeCount: 0x%02x", (indent - 8), ' ', num);

	for (i = 0; num > 0; num--, i++) {
		uint8_t attr;

		if (!l2cap_frame_get_u8(frame, &attr))
			return false;

		print_field("%*cAttributeID: 0x%02x (%s)", (indent - 8), ' ',
							attr, attr2str(attr));
	}

	return true;
}
Exemplo n.º 5
0
int node2str(spConfigNode*node,str*string)
{
	int i;
	ENTRY;
	
	if(node->text)
		text2str(node->text,string);
	putStr(string,'<');
	for(i=0;i<(int)strlen(node->name);++i)
	{
		switch(node->name[i])
		{
			case '[':case '>': case '\\':
			case '"':case '/':
				putStr(string,'\\');
			default:
				putStr(string,node->name[i]);
		}
	}
	putStr(string,' ');
	for(i=0;i<node->numAttributes;++i)
	{
		attr2str(node->attributes[i],string);
	}
	if(node->numChildren)
	{
		putStr(string,'>');
		
		for(i=0;i<node->numChildren;++i)
		{
			node2str(node->children[i],string);
		}
		
		putStr(string,'<');
		putStr(string,'/');
		for(i=0;i<(int)strlen(node->name);++i)
		{
			switch(node->name[i])
			{
				case '[':case '>': case '\\':
				case '"':case '/':
					putStr(string,'\\');
				default:
					putStr(string,node->name[i]);
			}
		}		
		putStr(string,'>');
	}
	else
	{
		putStr(string,'/');
		putStr(string,'>');
	}
	
	return(0);
}
Exemplo n.º 6
0
static void avrcp_list_player_attributes_dump(int level, struct frame *frm,
								uint16_t len)
{
	uint8_t num;

	if (len == 0)
		return;

	p_indent(level, frm);

	num = get_u8(frm);
	printf("AttributeCount: 0x%02x\n", num);

	for (; num > 0; num--) {
		uint8_t attr;

		p_indent(level, frm);

		attr = get_u8(frm);
		printf("AttributeID: 0x%02x (%s)\n", attr, attr2str(attr));
	}
}
Exemplo n.º 7
0
static void avrcp_get_player_value_text_dump(int level, struct frame *frm,
						uint8_t ctype, uint16_t len)
{
	static uint8_t attr = 0; /* Remember attribute */
	uint8_t num;

	p_indent(level, frm);

	if (len < 1) {
		printf("PDU Malformed\n");
		raw_dump(level, frm);
		return;
	}

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	attr = get_u8(frm);
	printf("AttributeID: 0x%02x (%s)\n", attr, attr2str(attr));

	p_indent(level, frm);

	num = get_u8(frm);
	printf("ValueCount: 0x%02x\n", num);

	for (; num > 0; num--) {
		uint8_t value;

		p_indent(level, frm);

		value = get_u8(frm);
		printf("ValueID: 0x%02x (%s)\n", value,
						value2str(attr, value));
	}

	return;

response:
	num = get_u8(frm);
	printf("ValueCount: 0x%02x\n", num);

	for (; num > 0; num--) {
		uint8_t value, len;
		uint16_t charset;

		p_indent(level, frm);

		value = get_u8(frm);
		printf("ValueID: 0x%02x (%s)\n", value,
						value2str(attr, value));

		p_indent(level, frm);

		charset = get_u16(frm);
		printf("CharsetID: 0x%04x (%s)\n", charset,
							charset2str(charset));

		p_indent(level, frm);

		len = get_u8(frm);
		printf("StringLength: 0x%02x\n", len);

		p_indent(level, frm);

		printf("String: ");
		for (; len > 0; len--) {
			uint8_t c = get_u8(frm);
			printf("%1c", isprint(c) ? c : '.');
		}
		printf("\n");
	}
}
Exemplo n.º 8
0
static void avrcp_register_notification_dump(int level, struct frame *frm,
						uint8_t ctype, uint16_t len)
{
	uint8_t event, status;
	uint16_t uid;
	uint32_t interval;
	uint64_t id;

	p_indent(level, frm);

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	if (len < 5) {
		printf("PDU Malformed\n");
		raw_dump(level, frm);
		return;
	}

	event = get_u8(frm);
	printf("EventID: 0x%02x (%s)\n", event, event2str(event));

	p_indent(level, frm);

	interval = get_u32(frm);
	printf("Interval: 0x%08x (%u seconds)\n", interval, interval);

	return;

response:
	if (len < 1) {
		printf("PDU Malformed\n");
		raw_dump(level, frm);
		return;
	}

	event = get_u8(frm);
	printf("EventID: 0x%02x (%s)\n", event, event2str(event));

	p_indent(level, frm);

	switch (event) {
	case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED:
		status = get_u8(frm);
		printf("PlayStatus: 0x%02x (%s)\n", status,
						playstatus2str(status));
		break;
	case AVRCP_EVENT_TRACK_CHANGED:
		id = get_u64(frm);
		printf("Identifier: 0x%jx (%s)\n", id,
						id ? "Reserved" : "PLAYING");
		break;
	case AVRCP_EVENT_PLAYBACK_POS_CHANGED:
		interval = get_u32(frm);
		printf("Position: 0x%08x (%u miliseconds)\n", interval,
								interval);
		break;
	case AVRCP_EVENT_BATT_STATUS_CHANGED:
		status = get_u8(frm);
		printf("BatteryStatus: 0x%02x (%s)\n", status,
							status2str(status));
		break;
	case AVRCP_EVENT_SYSTEM_STATUS_CHANGED:
		status = get_u8(frm);
		printf("SystemStatus: 0x%02x ", status);
		switch (status) {
		case 0x00:
			printf("(POWER_ON)\n");
		case 0x01:
			printf("(POWER_OFF)\n");
		case 0x02:
			printf("(UNPLUGGED)\n");
		default:
			printf("(UNKOWN)\n");
		}
		break;
	case AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED:
		status = get_u8(frm);
		printf("AttributeCount: 0x%02x\n", status);

		for (; status > 0; status--) {
			uint8_t attr, value;

			p_indent(level, frm);

			attr = get_u8(frm);
			printf("AttributeID: 0x%02x (%s)\n", attr,
							attr2str(attr));

			p_indent(level, frm);

			value = get_u8(frm);
			printf("ValueID: 0x%02x (%s)\n", value,
						value2str(attr, value));
		}
		break;
	case AVRCP_EVENT_VOLUME_CHANGED:
		status = get_u8(frm) & 0x7F;
		printf("Volume: %.2f%% (%d/127)\n", status/1.27, status);
		break;
	case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED:
		uid = get_u16(frm);
		printf("PlayerID: 0x%04x (%u)\n", uid, uid);

		p_indent(level, frm);

		uid = get_u16(frm);
		printf("UIDCounter: 0x%04x (%u)\n", uid, uid);
		break;
	}
}
Exemplo n.º 9
0
int main(void)
{
    Display *dpy;
    Bool ret;
    int event_base, error_base, major, minor, screens, i;
    char *str;
        
    /*
     * open a connection to the X server indicated by the DISPLAY
     * environment variable
     */
    
    dpy = XOpenDisplay(NULL);
    if (!dpy) {
        fprintf(stderr, "Cannot open display '%s'.\n", XDisplayName(NULL));
        return 1;
    }
    
    /*
     * check if the NV-CONTROL X extension is present on this X server
     */

    ret = XNVCTRLQueryExtension(dpy, &event_base, &error_base);
    if (ret != True) {
        fprintf(stderr, "The NV-CONTROL X extension does not exist on '%s'.\n",
                XDisplayName(NULL));
        return 1;
    }

    /*
     * query the major and minor extension version
     */

    ret = XNVCTRLQueryVersion(dpy, &major, &minor);
    if (ret != True) {
        fprintf(stderr, "The NV-CONTROL X extension does not exist on '%s'.\n",
                XDisplayName(NULL));
        return 1;
    }

    /*
     * print statistics thus far
     */

    printf("NV-CONTROL X extension present\n");
    printf("  version        : %d.%d\n", major, minor);
    printf("  event base     : %d\n", event_base);
    printf("  error base     : %d\n", error_base);
    
    /*
     * loop over each screen, and determine if each screen is
     * controlled by the NVIDIA X driver (and thus supports the
     * NV-CONTROL X extension); then, query the string attributes on
     * the screen.
     */

    screens = ScreenCount(dpy);
    for (i = 0; i < screens; i++) {
        if (XNVCTRLIsNvScreen(dpy, i)) {
            printf("Screen %d supports the NV-CONTROL X extension\n", i);

            ret = XNVCTRLQueryStringAttribute(dpy, i,
                                              0, /* XXX not curently used */
                                              NV_CTRL_STRING_PRODUCT_NAME,
                                              &str);
            if (ret) {
                printf("  GPU            : %s\n", str);
                XFree(str);
            }
            
            ret = XNVCTRLQueryStringAttribute(dpy, i,
                                              0, /* XXX not curently used */
                                              NV_CTRL_STRING_VBIOS_VERSION,
                                              &str);
            
            if (ret) {
                printf("  VideoBIOS      : %s\n", str);
                XFree(str);
            }

            ret = XNVCTRLQueryStringAttribute(dpy, i,
                                              0, /* XXX not curently used */
                                              NV_CTRL_STRING_NVIDIA_DRIVER_VERSION,
                                              &str);

            if (ret) {
                printf("  Driver version : %s\n", str);
                XFree(str);
            }
        }
    }

    /*
     * print attribute permission and type information.
     */

    printf("Attributes (Integers):\n");
    for (i = 0; i < NV_CTRL_LAST_ATTRIBUTE; i++) {
        const char *name = attr2str(i, attr_int_table);
        if (name) {
            NVCTRLAttributePermissionsRec perms;

            printf("  (%3d) [Perms: ", i);

            memset(&perms, 0, sizeof(NVCTRLAttributePermissionsRec));

            XNVCTRLQueryAttributePermissions(dpy, i, &perms);
            print_perms(&perms);
            printf("] [ ");
            printf("%-32s", GetAttrTypeName(perms.type));
            printf("] - %s\n", name);
        }
    }

    printf("Attributes (Strings):\n");
    for (i = 0; i < NV_CTRL_STRING_LAST_ATTRIBUTE; i++) {
        const char *name = attr2str(i, attr_str_table);
        if (name) {
            NVCTRLAttributePermissionsRec perms;

            printf("  (%3d) [Perms: ", i);

            memset(&perms, 0, sizeof(NVCTRLAttributePermissionsRec));

            XNVCTRLQueryStringAttributePermissions(dpy, i, &perms);
            print_perms(&perms);
            printf("] [ ");
            printf("%-32s", GetAttrTypeName(perms.type));
            printf("] - %s\n", name);
        }
    }

    printf("Attributes (Binary Data):\n");
    for (i = 0; i < NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE; i++) {
        const char *name = attr2str(i, attr_bin_table);
        if (name) {
            NVCTRLAttributePermissionsRec perms;

            printf("  (%3d) [Perms: ", i);

            memset(&perms, 0, sizeof(NVCTRLAttributePermissionsRec));

            XNVCTRLQueryBinaryDataAttributePermissions(dpy, i, &perms);
            print_perms(&perms);
            printf("] [ ");
            printf("%-32s", GetAttrTypeName(perms.type));
            printf("] - %s\n", name);
        }
    }

    printf("Attributes (String Operations):\n");
    for (i = 0; i < NV_CTRL_STRING_OPERATION_LAST_ATTRIBUTE; i++) {
        const char *name = attr2str(i, attr_strop_table);
        if (name) {
            NVCTRLAttributePermissionsRec perms;

            printf("  (%3d) [Perms: ", i);

            memset(&perms, 0, sizeof(NVCTRLAttributePermissionsRec));

            XNVCTRLQueryStringOperationAttributePermissions(dpy, i, &perms);
            print_perms(&perms);
            printf("] [ ");
            printf("%-32s", GetAttrTypeName(perms.type));
            printf("] - %s\n", name);
        }
    }

    /*
     * close the display connection
     */

    XCloseDisplay(dpy);

    return 0;
}
Exemplo n.º 10
0
static bool avrcp_get_player_value_text(struct avctp_frame *avctp_frame,
					uint8_t ctype, uint8_t len,
					uint8_t indent)
{
	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
	static uint8_t attr = 0;
	uint8_t num;

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	if (!l2cap_frame_get_u8(frame, &attr))
		return false;

	print_field("%*cAttributeID: 0x%02x (%s)", (indent - 8), ' ',
						attr, attr2str(attr));

	if (!l2cap_frame_get_u8(frame, &num))
		return false;

	print_field("%*cValueCount: 0x%02x", (indent - 8), ' ', num);

	for (; num > 0; num--) {
		uint8_t value;

		if (!l2cap_frame_get_u8(frame, &value))
			return false;

		print_field("%*cValueID: 0x%02x (%s)", (indent - 8),
				' ', value, value2str(attr, value));
	}

	return true;

response:
	if (!l2cap_frame_get_u8(frame, &num))
		return false;

	print_field("%*cValueCount: 0x%02x", (indent - 8), ' ', num);

	for (; num > 0; num--) {
		uint8_t value, len;
		uint16_t charset;

		if (!l2cap_frame_get_u8(frame, &value))
			return false;

		print_field("%*cValueID: 0x%02x (%s)", (indent - 8), ' ',
						value, value2str(attr, value));

		if (!l2cap_frame_get_be16(frame, &charset))
			return false;

		print_field("%*cCharsetIDID: 0x%02x (%s)", (indent - 8), ' ',
						charset, charset2str(charset));

		if (!l2cap_frame_get_u8(frame, &len))
			return false;

		print_field("%*cStringLength: 0x%02x", (indent - 8), ' ', len);

		printf("String: ");
		for (; len > 0; len--) {
			uint8_t c;

			if (!l2cap_frame_get_u8(frame, &c))
				return false;

			printf("%1c", isprint(c) ? c : '.');
		}
		printf("\n");
	}

	return true;
}
Exemplo n.º 11
0
static bool avrcp_register_notification(struct avctp_frame *avctp_frame,
					uint8_t ctype, uint8_t len,
					uint8_t indent)
{
	struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
	uint8_t event, status;
	uint16_t uid;
	uint32_t interval;
	uint64_t id;

	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
		goto response;

	if (!l2cap_frame_get_u8(frame, &event))
		return false;

	print_field("%*cEventID: 0x%02x (%s)", (indent - 8),
						' ', event, event2str(event));

	if (!l2cap_frame_get_be32(frame, &interval))
		return false;

	print_field("%*cInterval: 0x%08x (%u seconds)",
					(indent - 8), ' ', interval, interval);

	return true;

response:
	if (!l2cap_frame_get_u8(frame, &event))
		return false;

	print_field("%*cEventID: 0x%02x (%s)", (indent - 8),
						' ', event, event2str(event));

	switch (event) {
	case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED:
		if (!l2cap_frame_get_u8(frame, &status))
			return false;

		print_field("%*cPlayStatus: 0x%02x (%s)", (indent - 8),
					' ', status, playstatus2str(status));
		break;
	case AVRCP_EVENT_TRACK_CHANGED:
		if (!l2cap_frame_get_be64(frame, &id))
			return false;

		print_field("%*cIdentifier: 0x%16" PRIx64 " (%" PRIu64 ")",
						(indent - 8), ' ', id, id);
		break;
	case AVRCP_EVENT_PLAYBACK_POS_CHANGED:
		if (!l2cap_frame_get_be32(frame, &interval))
			return false;

		print_field("%*cPosition: 0x%08x (%u miliseconds)",
					(indent - 8), ' ', interval, interval);
		break;
	case AVRCP_EVENT_BATT_STATUS_CHANGED:
		if (!l2cap_frame_get_u8(frame, &status))
			return false;

		print_field("%*cBatteryStatus: 0x%02x (%s)", (indent - 8),
					' ', status, status2str(status));

		break;
	case AVRCP_EVENT_SYSTEM_STATUS_CHANGED:
		if (!l2cap_frame_get_u8(frame, &status))
			return false;

		print_field("%*cSystemStatus: 0x%02x ", (indent - 8),
								' ', status);
		switch (status) {
		case 0x00:
			printf("(POWER_ON)\n");
			break;
		case 0x01:
			printf("(POWER_OFF)\n");
			break;
		case 0x02:
			printf("(UNPLUGGED)\n");
			break;
		default:
			printf("(UNKOWN)\n");
			break;
		}
		break;
	case AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED:
		if (!l2cap_frame_get_u8(frame, &status))
			return false;

		print_field("%*cAttributeCount: 0x%02x", (indent - 8),
								' ', status);

		for (; status > 0; status--) {
			uint8_t attr, value;

			if (!l2cap_frame_get_u8(frame, &attr))
				return false;

			print_field("%*cAttributeID: 0x%02x (%s)",
				(indent - 8), ' ', attr, attr2str(attr));

			if (!l2cap_frame_get_u8(frame, &value))
				return false;

			print_field("%*cValueID: 0x%02x (%s)", (indent - 8),
					' ', value, value2str(attr, value));
		}
		break;
	case AVRCP_EVENT_VOLUME_CHANGED:
		if (!l2cap_frame_get_u8(frame, &status))
			return false;

		status &= 0x7F;

		print_field("%*cVolume: %.2f%% (%d/127)", (indent - 8),
						' ', status/1.27, status);
		break;
	case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED:
		if (!l2cap_frame_get_be16(frame, &uid))
			return false;

		print_field("%*cPlayerID: 0x%04x (%u)", (indent - 8),
								' ', uid, uid);

		if (!l2cap_frame_get_be16(frame, &uid))
			return false;

		print_field("%*cUIDCounter: 0x%04x (%u)", (indent - 8),
								' ', uid, uid);
		break;
	case AVRCP_EVENT_UIDS_CHANGED:
		if (!l2cap_frame_get_be16(frame, &uid))
			return false;

		print_field("%*cUIDCounter: 0x%04x (%u)", (indent - 8),
								' ', uid, uid);
		break;
	}

	return true;
}