* Improved type output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34439 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+32
-8
@@ -67,6 +67,34 @@ dumpRawData(const char *buffer, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char*
|
||||||
|
type_to_string(uint32 type)
|
||||||
|
{
|
||||||
|
if (type == B_RAW_TYPE)
|
||||||
|
return "raw_data";
|
||||||
|
|
||||||
|
static char buffer[32];
|
||||||
|
|
||||||
|
int32 missed = 0, shift = 24;
|
||||||
|
uint8 value[4];
|
||||||
|
for (int32 i = 0; i < 4; i++, shift -= 8) {
|
||||||
|
value[i] = uint8(type >> shift);
|
||||||
|
if (value[i] < ' ' || value[i] > 127) {
|
||||||
|
value[i] = '.';
|
||||||
|
missed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missed < 2) {
|
||||||
|
sprintf(buffer, "'%c%c%c%c'", value[0], value[1], value[2],
|
||||||
|
value[3]);
|
||||||
|
} else
|
||||||
|
sprintf(buffer, "0x%08lx", type);
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
catAttr(const char *attribute, const char *fileName, bool keepRaw = false)
|
catAttr(const char *attribute, const char *fileName, bool keepRaw = false)
|
||||||
{
|
{
|
||||||
@@ -188,10 +216,7 @@ catAttr(const char *attribute, const char *fileName, bool keepRaw = false)
|
|||||||
case 'MSIG':
|
case 'MSIG':
|
||||||
case 'MSDC':
|
case 'MSDC':
|
||||||
case 'MPTH':
|
case 'MPTH':
|
||||||
printf("%s : '%c%c%c%c' : %s\n", fileName,
|
printf("%s : %s : %s\n", fileName, type_to_string(info.type),
|
||||||
(int)((info.type >> 24) & 0xff),
|
|
||||||
(int)((info.type >> 16) & 0xff),
|
|
||||||
(int)((info.type >> 8) & 0xff), (int)(info.type & 0xff),
|
|
||||||
buffer);
|
buffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -208,7 +233,7 @@ catAttr(const char *attribute, const char *fileName, bool keepRaw = false)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// The rest of the attributes types are displayed as raw data
|
// The rest of the attributes types are displayed as raw data
|
||||||
printf("%s : raw_data : \n", fileName);
|
printf("%s : %s : \n", fileName, type_to_string(info.type));
|
||||||
dumpRawData(buffer, size);
|
dumpRawData(buffer, size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -248,7 +273,8 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Issue usage message
|
// Issue usage message
|
||||||
fprintf(stderr, "usage: %s [--raw|-r] attr_name file1 [file2...]\n", program);
|
fprintf(stderr, "usage: %s [--raw|-r] <attribute-name> <file1> "
|
||||||
|
"[<file2>...]\n", program);
|
||||||
// Be's original version -only- returned 1 if the
|
// Be's original version -only- returned 1 if the
|
||||||
// amount of parameters was wrong, not if the file
|
// amount of parameters was wrong, not if the file
|
||||||
// or attribute couldn't be found (!)
|
// or attribute couldn't be found (!)
|
||||||
@@ -258,5 +284,3 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user