Hey: Style fixes, code clean up
No functional changes intended
This commit is contained in:
+112
-125
@@ -162,7 +162,8 @@ parse(BMessenger& the_application, int argc, char *argv[], int32 argapp)
|
|||||||
fprintf(stderr, "Error when sending message to %s!\n", argv[argapp]);
|
fprintf(stderr, "Error when sending message to %s!\n", argv[argapp]);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
} else {
|
} else {
|
||||||
if (the_reply.what == (uint32)B_MESSAGE_NOT_UNDERSTOOD || the_reply.what==(uint32)B_ERROR){ // I do it myself
|
if (the_reply.what == (uint32)B_MESSAGE_NOT_UNDERSTOOD
|
||||||
|
|| the_reply.what == (uint32)B_ERROR) { // I do it myself
|
||||||
if (the_reply.HasString("message")) {
|
if (the_reply.HasString("message")) {
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
printf("%s (error 0x%8" B_PRIx32 ")\n",
|
printf("%s (error 0x%8" B_PRIx32 ")\n",
|
||||||
@@ -221,10 +222,9 @@ parse(BMessenger& the_application, int argc, char *argv[], int32 argapp)
|
|||||||
bool v;
|
bool v;
|
||||||
the_reply.FindBool("result", &v);
|
the_reply.FindBool("result", &v);
|
||||||
printf("%s\n", v ? "true" : "false");
|
printf("%s\n", v ? "true" : "false");
|
||||||
} else {
|
} else
|
||||||
printf("Unsupported type\n");
|
printf("Unsupported type\n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
printf("Reply ");
|
printf("Reply ");
|
||||||
print_message(&the_reply);
|
print_message(&the_reply);
|
||||||
@@ -441,27 +441,27 @@ Hey(BMessenger* target, char* argv[], int32* argx, int32 argc, BMessage* reply)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strcasecmp(argv[*argx], "do")==0){ // added "do" -- [email protected] 1999-11-03
|
if (strcasecmp(argv[*argx], "do") == 0) // added "do" -- [email protected] 1999-11-03
|
||||||
the_message.what = B_EXECUTE_PROPERTY;
|
the_message.what = B_EXECUTE_PROPERTY;
|
||||||
} else if (strcasecmp(argv[*argx], "get")==0){
|
else if (strcasecmp(argv[*argx], "get") == 0)
|
||||||
the_message.what = B_GET_PROPERTY;
|
the_message.what = B_GET_PROPERTY;
|
||||||
} else if (strcasecmp(argv[*argx], "set")==0){
|
else if (strcasecmp(argv[*argx], "set") == 0)
|
||||||
the_message.what = B_SET_PROPERTY;
|
the_message.what = B_SET_PROPERTY;
|
||||||
} else if (strcasecmp(argv[*argx], "create")==0){
|
else if (strcasecmp(argv[*argx], "create") == 0)
|
||||||
the_message.what = B_CREATE_PROPERTY;
|
the_message.what = B_CREATE_PROPERTY;
|
||||||
} else if (strcasecmp(argv[*argx], "delete")==0){
|
else if (strcasecmp(argv[*argx], "delete") == 0)
|
||||||
the_message.what = B_DELETE_PROPERTY;
|
the_message.what = B_DELETE_PROPERTY;
|
||||||
} else if (strcasecmp(argv[*argx], "quit")==0){
|
else if (strcasecmp(argv[*argx], "quit") == 0)
|
||||||
the_message.what = B_QUIT_REQUESTED;
|
the_message.what = B_QUIT_REQUESTED;
|
||||||
} else if (strcasecmp(argv[*argx], "save")==0){
|
else if (strcasecmp(argv[*argx], "save") == 0)
|
||||||
the_message.what = B_SAVE_REQUESTED;
|
the_message.what = B_SAVE_REQUESTED;
|
||||||
} else if (strcasecmp(argv[*argx], "load")==0){
|
else if (strcasecmp(argv[*argx], "load") == 0)
|
||||||
the_message.what = B_REFS_RECEIVED;
|
the_message.what = B_REFS_RECEIVED;
|
||||||
} else if(strcasecmp(argv[*argx], "count")==0){
|
else if(strcasecmp(argv[*argx], "count") == 0)
|
||||||
the_message.what = B_COUNT_PROPERTIES;
|
the_message.what = B_COUNT_PROPERTIES;
|
||||||
} else if(strcasecmp(argv[*argx], "getsuites")==0){
|
else if(strcasecmp(argv[*argx], "getsuites") == 0)
|
||||||
the_message.what = B_GET_SUPPORTED_SUITES;
|
the_message.what = B_GET_SUPPORTED_SUITES;
|
||||||
} else {
|
else {
|
||||||
switch(strlen(argv[*argx])) { // can be a message constant if 1,2,3 or 4 chars
|
switch(strlen(argv[*argx])) { // can be a message constant if 1,2,3 or 4 chars
|
||||||
case 1:
|
case 1:
|
||||||
the_message.what = (int32)argv[*argx][0];
|
the_message.what = (int32)argv[*argx][0];
|
||||||
@@ -639,13 +639,11 @@ add_specifier(BMessage *to_message, char *argv[], int32 *argx, int32 argc)
|
|||||||
|
|
||||||
(*argx)++;
|
(*argx)++;
|
||||||
|
|
||||||
if (strcasecmp(property, "do")==0){ // Part of the "hey App let Specifier do Verb".
|
if (strcasecmp(property, "do") == 0) // Part of the "hey App let Specifier do Verb".
|
||||||
return B_ERROR; // no more specifiers
|
return B_ERROR; // no more specifiers
|
||||||
}
|
|
||||||
|
|
||||||
if (strcasecmp(property, "to")==0){ // it is the 'to' string!!!
|
if (strcasecmp(property, "to") == 0) // it is the 'to' string!!!
|
||||||
return B_ERROR; // no more specifiers
|
return B_ERROR; // no more specifiers
|
||||||
}
|
|
||||||
|
|
||||||
if (strcasecmp(property, "with") == 0) { // it is the 'with' string!!!
|
if (strcasecmp(property, "with") == 0) { // it is the 'with' string!!!
|
||||||
*argx -= 2;
|
*argx -= 2;
|
||||||
@@ -716,18 +714,16 @@ add_specifier(BMessage *to_message, char *argv[], int32 *argx, int32 argc)
|
|||||||
(*argx)++;
|
(*argx)++;
|
||||||
if (strcasecmp(specifier, "to") == 0) {
|
if (strcasecmp(specifier, "to") == 0) {
|
||||||
specifier = argv[*argx];
|
specifier = argv[*argx];
|
||||||
if (specifier==NULL){
|
if (specifier == NULL)
|
||||||
return B_BAD_SCRIPT_SYNTAX; // wrong syntax
|
return B_BAD_SCRIPT_SYNTAX; // wrong syntax
|
||||||
}
|
|
||||||
(*argx)++;
|
(*argx)++;
|
||||||
ix2 = strtoul(specifier, &end, 10);
|
ix2 = strtoul(specifier, &end, 10);
|
||||||
to_message->AddSpecifier(property, ix1, ix2 - ix1 > 0 ? ix2 - ix1 : 1);
|
to_message->AddSpecifier(property, ix1, ix2 - ix1 > 0 ? ix2 - ix1 : 1);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} else {
|
} else
|
||||||
return B_BAD_SCRIPT_SYNTAX; // wrong syntax
|
return B_BAD_SCRIPT_SYNTAX; // wrong syntax
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else { // name specifier
|
} else { // name specifier
|
||||||
// if it contains only digits, it will be an index...
|
// if it contains only digits, it will be an index...
|
||||||
bool index_spec = true;
|
bool index_spec = true;
|
||||||
@@ -748,8 +744,7 @@ add_specifier(BMessage *to_message, char *argv[], int32 *argx, int32 argc)
|
|||||||
revspec.AddString("property", property);
|
revspec.AddString("property", property);
|
||||||
revspec.AddInt32("index", atol(specifier + 1));
|
revspec.AddInt32("index", atol(specifier + 1));
|
||||||
to_message->AddSpecifier(&revspec);
|
to_message->AddSpecifier(&revspec);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
to_message->AddSpecifier(property, atol(specifier));
|
to_message->AddSpecifier(property, atol(specifier));
|
||||||
} else {
|
} else {
|
||||||
// Allow any name by counting an initial " as a literal-string indicator
|
// Allow any name by counting an initial " as a literal-string indicator
|
||||||
@@ -829,45 +824,35 @@ add_data(BMessage *to_message, char *argv[], int32 *argx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// must begin with a type( value )
|
// must begin with a type( value )
|
||||||
if (strncasecmp(valuestring, "int8", strlen("int8"))==0){
|
if (strncasecmp(valuestring, "int8", strlen("int8")) == 0)
|
||||||
to_message->AddInt8(curname, atol(valuestring + strlen("int8(")));
|
to_message->AddInt8(curname, atol(valuestring + strlen("int8(")));
|
||||||
return B_OK;
|
else if (strncasecmp(valuestring, "int16", strlen("int16")) == 0)
|
||||||
} else if (strncasecmp(valuestring, "int16", strlen("int16"))==0){
|
|
||||||
to_message->AddInt16(curname, atol(valuestring + strlen("int16(")));
|
to_message->AddInt16(curname, atol(valuestring + strlen("int16(")));
|
||||||
return B_OK;
|
else if (strncasecmp(valuestring, "int32", strlen("int32")) == 0)
|
||||||
} else if (strncasecmp(valuestring, "int32", strlen("int32"))==0){
|
|
||||||
to_message->AddInt32(curname, atol(valuestring + strlen("int32(")));
|
to_message->AddInt32(curname, atol(valuestring + strlen("int32(")));
|
||||||
return B_OK;
|
else if (strncasecmp(valuestring, "int64", strlen("int64")) == 0)
|
||||||
} else if (strncasecmp(valuestring, "int64", strlen("int64"))==0){
|
|
||||||
to_message->AddInt64(curname, atol(valuestring + strlen("int64(")));
|
to_message->AddInt64(curname, atol(valuestring + strlen("int64(")));
|
||||||
return B_OK;
|
else if (strncasecmp(valuestring, "bool", strlen("bool")) == 0) {
|
||||||
} else if (strncasecmp(valuestring, "bool", strlen("bool"))==0){
|
if (strncasecmp(valuestring + strlen("bool("), "true", 4) == 0)
|
||||||
if (strncasecmp(valuestring+strlen("bool("), "true", 4)==0){
|
|
||||||
to_message->AddBool(curname, true);
|
to_message->AddBool(curname, true);
|
||||||
} else if (strncasecmp(valuestring+strlen("bool("), "false", 5)==0){
|
else if (strncasecmp(valuestring + strlen("bool("), "false", 5) == 0)
|
||||||
to_message->AddBool(curname, false);
|
to_message->AddBool(curname, false);
|
||||||
} else {
|
else
|
||||||
to_message->AddBool(curname, atol(valuestring + strlen("bool(")) == 0 ? false : true);
|
to_message->AddBool(curname, atol(valuestring + strlen("bool(")) == 0 ? false : true);
|
||||||
}
|
} else if (strncasecmp(valuestring, "float", strlen("float")) == 0)
|
||||||
return B_OK;
|
|
||||||
} else if (strncasecmp(valuestring, "float", strlen("float"))==0){
|
|
||||||
to_message->AddFloat(curname, atof(valuestring+strlen("float(")));
|
to_message->AddFloat(curname, atof(valuestring+strlen("float(")));
|
||||||
return B_OK;
|
else if (strncasecmp(valuestring, "double", strlen("double")) == 0)
|
||||||
} else if (strncasecmp(valuestring, "double", strlen("double"))==0){
|
|
||||||
to_message->AddDouble(curname, atof(valuestring+strlen("double(")));
|
to_message->AddDouble(curname, atof(valuestring+strlen("double(")));
|
||||||
return B_OK;
|
else if (strncasecmp(valuestring, "BPoint", strlen("BPoint")) == 0) {
|
||||||
} else if (strncasecmp(valuestring, "BPoint", strlen("BPoint"))==0){
|
|
||||||
float x, y;
|
float x, y;
|
||||||
x = atof(valuestring + strlen("BPoint("));
|
x = atof(valuestring + strlen("BPoint("));
|
||||||
if (strchr(valuestring, ',')){
|
if (strchr(valuestring, ','))
|
||||||
y = atof(strchr(valuestring, ',') + 1);
|
y = atof(strchr(valuestring, ',') + 1);
|
||||||
} else if (strchr(valuestring, ' ')){
|
else if (strchr(valuestring, ' '))
|
||||||
y = atof(strchr(valuestring, ' ') + 1);
|
y = atof(strchr(valuestring, ' ') + 1);
|
||||||
} else { // bad syntax
|
else // bad syntax
|
||||||
y = 0.0f;
|
y = 0.0f;
|
||||||
}
|
|
||||||
to_message->AddPoint(curname, BPoint(x,y));
|
to_message->AddPoint(curname, BPoint(x,y));
|
||||||
return B_OK;
|
|
||||||
} else if (strncasecmp(valuestring, "BRect", strlen("BRect")) == 0) {
|
} else if (strncasecmp(valuestring, "BRect", strlen("BRect")) == 0) {
|
||||||
float l = 0.0f, t = 0.0f, r = 0.0f, b = 0.0f;
|
float l = 0.0f, t = 0.0f, r = 0.0f, b = 0.0f;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
@@ -879,14 +864,12 @@ add_data(BMessage *to_message, char *argv[], int32 *argx)
|
|||||||
if (ptr) {
|
if (ptr) {
|
||||||
r = atof(ptr + 1);
|
r = atof(ptr + 1);
|
||||||
ptr = strchr(ptr + 1, ',');
|
ptr = strchr(ptr + 1, ',');
|
||||||
if (ptr){
|
if (ptr)
|
||||||
b = atof(ptr + 1);
|
b = atof(ptr + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
to_message->AddRect(curname, BRect(l,t,r,b));
|
to_message->AddRect(curname, BRect(l,t,r,b));
|
||||||
return B_OK;
|
|
||||||
} else if (strncasecmp(valuestring, "rgb_color", strlen("rgb_color")) == 0) {
|
} else if (strncasecmp(valuestring, "rgb_color", strlen("rgb_color")) == 0) {
|
||||||
rgb_color clr;
|
rgb_color clr;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
@@ -898,45 +881,40 @@ add_data(BMessage *to_message, char *argv[], int32 *argx)
|
|||||||
if (ptr) {
|
if (ptr) {
|
||||||
clr.blue = atol(ptr + 1);
|
clr.blue = atol(ptr + 1);
|
||||||
ptr = strchr(ptr + 1, ',');
|
ptr = strchr(ptr + 1, ',');
|
||||||
if (ptr){
|
if (ptr)
|
||||||
clr.alpha = atol(ptr + 1);
|
clr.alpha = atol(ptr + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
to_message->AddData(curname, B_RGB_COLOR_TYPE, &clr, sizeof(rgb_color));
|
to_message->AddData(curname, B_RGB_COLOR_TYPE, &clr, sizeof(rgb_color));
|
||||||
return B_OK;
|
|
||||||
} else if (strncasecmp(valuestring, "file", strlen("file")) == 0) {
|
} else if (strncasecmp(valuestring, "file", strlen("file")) == 0) {
|
||||||
entry_ref file_ref;
|
entry_ref file_ref;
|
||||||
|
|
||||||
// remove the last ] or )
|
// remove the last ] or )
|
||||||
if (valuestring[strlen(valuestring)-1]==')' || valuestring[strlen(valuestring)-1]==']'){
|
if (valuestring[strlen(valuestring) - 1] == ')' || valuestring[strlen(valuestring) - 1] == ']')
|
||||||
valuestring[strlen(valuestring)-1] = 0;
|
valuestring[strlen(valuestring)-1] = 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (get_ref_for_path(valuestring+5, &file_ref)!=B_OK){
|
if (get_ref_for_path(valuestring + 5, &file_ref) != B_OK)
|
||||||
return B_FILE_NOT_FOUND;
|
return B_FILE_NOT_FOUND;
|
||||||
}
|
|
||||||
|
|
||||||
// check if the ref is valid
|
// check if the ref is valid
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
if (entry.SetTo(&file_ref)!=B_OK) return B_FILE_NOT_FOUND;
|
if (entry.SetTo(&file_ref) != B_OK)
|
||||||
|
return B_FILE_NOT_FOUND;
|
||||||
//if(!entry.Exists()) return B_FILE_NOT_FOUND;
|
//if(!entry.Exists()) return B_FILE_NOT_FOUND;
|
||||||
|
|
||||||
// add both ways, refsreceived needs it as "refs" while scripting needs "data"
|
// add both ways, refsreceived needs it as "refs" while scripting needs "data"
|
||||||
to_message->AddRef("refs", &file_ref);
|
to_message->AddRef("refs", &file_ref);
|
||||||
to_message->AddRef(curname, &file_ref);
|
to_message->AddRef(curname, &file_ref);
|
||||||
return B_OK;
|
|
||||||
} else { // it is string
|
} else { // it is string
|
||||||
// does it begin with a quote?
|
// does it begin with a quote?
|
||||||
if (valuestring[0] == '\"') {
|
if (valuestring[0] == '\"') {
|
||||||
if (valuestring[strlen(valuestring)-1]=='\"') valuestring[strlen(valuestring)-1]=0;
|
if (valuestring[strlen(valuestring) - 1] == '\"')
|
||||||
|
valuestring[strlen(valuestring) - 1] = 0;
|
||||||
to_message->AddString(curname, valuestring + 1);
|
to_message->AddString(curname, valuestring + 1);
|
||||||
} else {
|
} else
|
||||||
to_message->AddString(curname, valuestring);
|
to_message->AddString(curname, valuestring);
|
||||||
}
|
}
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -955,7 +933,6 @@ print_message(BMessage *message)
|
|||||||
printf(" %s\n", (char*)textlist.ItemAt(i));
|
printf(" %s\n", (char*)textlist.ItemAt(i));
|
||||||
free(textlist.ItemAt(i));
|
free(textlist.ItemAt(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1163,6 +1140,7 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
strncpy(str + 1, ptr, size);
|
strncpy(str + 1, ptr, size);
|
||||||
strcat(str, "\"");
|
strcat(str, "\"");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_POINTER_TYPE:
|
case B_POINTER_TYPE:
|
||||||
str = new char[64];
|
str = new char[64];
|
||||||
sprintf(str, "%p", *(void**)ptr);
|
sprintf(str, "%p", *(void**)ptr);
|
||||||
@@ -1175,9 +1153,8 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
if (entry.SetTo(&aref)==B_OK){
|
if (entry.SetTo(&aref)==B_OK){
|
||||||
entry.GetPath(&path);
|
entry.GetPath(&path);
|
||||||
strcpy(str, path.Path());
|
strcpy(str, path.Path());
|
||||||
} else {
|
} else
|
||||||
strcpy(str, "invalid entry_ref");
|
strcpy(str, "invalid entry_ref");
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_SSIZE_T_TYPE:
|
case B_SSIZE_T_TYPE:
|
||||||
@@ -1191,8 +1168,7 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
case B_INT32_TYPE:
|
case B_INT32_TYPE:
|
||||||
str = new char[64];
|
str = new char[64];
|
||||||
i32 = *(int32*)ptr;
|
i32 = *(int32*)ptr;
|
||||||
sprintf(str, "%" B_PRId32 " (0x%08" B_PRId32 ")", i32,
|
sprintf(str, "%" B_PRId32 " (0x%08" B_PRId32 ")", i32, i32);
|
||||||
i32);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_INT16_TYPE:
|
case B_INT16_TYPE:
|
||||||
@@ -1211,15 +1187,13 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
case B_UINT64_TYPE:
|
case B_UINT64_TYPE:
|
||||||
str = new char[64];
|
str = new char[64];
|
||||||
ui64 = *(uint64*)ptr;
|
ui64 = *(uint64*)ptr;
|
||||||
sprintf(str, "%" B_PRIu64 " (0x%" B_PRIx64 ")", ui64,
|
sprintf(str, "%" B_PRIu64 " (0x%" B_PRIx64 ")", ui64, ui64);
|
||||||
ui64);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_UINT32_TYPE:
|
case B_UINT32_TYPE:
|
||||||
str = new char[64];
|
str = new char[64];
|
||||||
ui32 = *(uint32*)ptr;
|
ui32 = *(uint32*)ptr;
|
||||||
sprintf(str, "%" B_PRIu32 " (0x%08" B_PRIx32 ")", ui32,
|
sprintf(str, "%" B_PRIu32 " (0x%08" B_PRIx32 ")", ui32, ui32);
|
||||||
ui32);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_UINT16_TYPE:
|
case B_UINT16_TYPE:
|
||||||
@@ -1236,11 +1210,10 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
|
|
||||||
case B_BOOL_TYPE:
|
case B_BOOL_TYPE:
|
||||||
str = new char[10];
|
str = new char[10];
|
||||||
if (*ptr){
|
if (*ptr)
|
||||||
strcpy(str, "TRUE");
|
strcpy(str, "TRUE");
|
||||||
} else {
|
else
|
||||||
strcpy(str, "FALSE");
|
strcpy(str, "FALSE");
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_FLOAT_TYPE:
|
case B_FLOAT_TYPE:
|
||||||
@@ -1288,22 +1261,22 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
char *whatString = get_datatype_string(anothermsg.what);
|
char *whatString = get_datatype_string(anothermsg.what);
|
||||||
sprintf(str, "what=%s", whatString);
|
sprintf(str, "what=%s", whatString);
|
||||||
free(whatString);
|
free(whatString);
|
||||||
} else {
|
} else
|
||||||
strcpy(str, "error when unflattening");
|
strcpy(str, "error when unflattening");
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PROPERTY_INFO_TYPE: {
|
case B_PROPERTY_INFO_TYPE:
|
||||||
|
{
|
||||||
BPropertyInfo propinfo;
|
BPropertyInfo propinfo;
|
||||||
if (propinfo.Unflatten(B_PROPERTY_INFO_TYPE, (const void *)ptr, size)==B_OK){
|
if (propinfo.Unflatten(B_PROPERTY_INFO_TYPE, (const void *)ptr, size)
|
||||||
|
== B_OK) {
|
||||||
str = new char[size * 32]; // an approximation
|
str = new char[size * 32]; // an approximation
|
||||||
|
|
||||||
//propinfo.PrintToStream();
|
|
||||||
//sprintf(str, "see the printout above");
|
|
||||||
|
|
||||||
const property_info *pinfo = propinfo.Properties();
|
const property_info *pinfo = propinfo.Properties();
|
||||||
|
|
||||||
sprintf(str, "\n property commands specifiers types\n---------------------------------------------------------------------------------------------------\n");
|
sprintf(str, "\n property commands "
|
||||||
|
"specifiers types\n-----------------------------------"
|
||||||
|
"----------------------------------------------------------------\n");
|
||||||
for (int32 pinfo_index = 0; pinfo_index < propinfo.CountProperties(); pinfo_index++) {
|
for (int32 pinfo_index = 0; pinfo_index < propinfo.CountProperties(); pinfo_index++) {
|
||||||
strcat(str, " " + (strlen(pinfo[pinfo_index].name) < 16 ? strlen(pinfo[pinfo_index].name) : 16));
|
strcat(str, " " + (strlen(pinfo[pinfo_index].name) < 16 ? strlen(pinfo[pinfo_index].name) : 16));
|
||||||
strcat(str, pinfo[pinfo_index].name);
|
strcat(str, pinfo[pinfo_index].name);
|
||||||
@@ -1311,7 +1284,6 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
char *start = str + strlen(str);
|
char *start = str + strlen(str);
|
||||||
|
|
||||||
for (int32 i = 0; i < 10 && pinfo[pinfo_index].commands[i]; i++) {
|
for (int32 i = 0; i < 10 && pinfo[pinfo_index].commands[i]; i++) {
|
||||||
//id_to_string(pinfo[pinfo_index].commands[i], str+strlen(str) );
|
|
||||||
tempstr = get_datatype_string(pinfo[pinfo_index].commands[i]);
|
tempstr = get_datatype_string(pinfo[pinfo_index].commands[i]);
|
||||||
strcat(str, tempstr);
|
strcat(str, tempstr);
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
@@ -1319,32 +1291,48 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pad the rest with spaces
|
// pad the rest with spaces
|
||||||
if (strlen(start)<36){
|
if (strlen(start) < 36)
|
||||||
strcat(str, " " + strlen(start));
|
strcat(str, " " + strlen(start));
|
||||||
} else {
|
else
|
||||||
strcat(str, " " );
|
strcat(str, " " );
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 i = 0; i < 10 && pinfo[pinfo_index].specifiers[i]; i++) {
|
for (int32 i = 0; i < 10 && pinfo[pinfo_index].specifiers[i]; i++) {
|
||||||
switch (pinfo[pinfo_index].specifiers[i]) {
|
switch (pinfo[pinfo_index].specifiers[i]) {
|
||||||
case B_NO_SPECIFIER: strcat(str, "NONE "); break;
|
case B_NO_SPECIFIER:
|
||||||
case B_DIRECT_SPECIFIER: strcat(str, "DIRECT "); break;
|
strcat(str, "NONE ");
|
||||||
case B_INDEX_SPECIFIER: strcat(str, "INDEX "); break;
|
break;
|
||||||
case B_REVERSE_INDEX_SPECIFIER: strcat(str, "REV.INDEX "); break;
|
case B_DIRECT_SPECIFIER:
|
||||||
case B_RANGE_SPECIFIER: strcat(str, "RANGE "); break;
|
strcat(str, "DIRECT ");
|
||||||
case B_REVERSE_RANGE_SPECIFIER: strcat(str, "REV.RANGE "); break;
|
break;
|
||||||
case B_NAME_SPECIFIER: strcat(str, "NAME "); break;
|
case B_INDEX_SPECIFIER:
|
||||||
case B_ID_SPECIFIER: strcat(str, "ID "); break;
|
strcat(str, "INDEX ");
|
||||||
default: strcat(str, "<NONE> "); break;
|
break;
|
||||||
|
case B_REVERSE_INDEX_SPECIFIER:
|
||||||
|
strcat(str, "REV.INDEX ");
|
||||||
|
break;
|
||||||
|
case B_RANGE_SPECIFIER:
|
||||||
|
strcat(str, "RANGE ");
|
||||||
|
break;
|
||||||
|
case B_REVERSE_RANGE_SPECIFIER:
|
||||||
|
strcat(str, "REV.RANGE ");
|
||||||
|
break;
|
||||||
|
case B_NAME_SPECIFIER:
|
||||||
|
strcat(str, "NAME ");
|
||||||
|
break;
|
||||||
|
case B_ID_SPECIFIER:
|
||||||
|
strcat(str, "ID ");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strcat(str, "<NONE> ");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pad the rest with spaces
|
// pad the rest with spaces
|
||||||
if (strlen(start)<60){
|
if (strlen(start) < 60)
|
||||||
strcat(str, " " + strlen(start));
|
strcat(str, " " + strlen(start));
|
||||||
} else {
|
else
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
}
|
|
||||||
for (int32 i = 0; i < 10 && pinfo[pinfo_index].types[i] != 0; i++) {
|
for (int32 i = 0; i < 10 && pinfo[pinfo_index].types[i] != 0; i++) {
|
||||||
uint32 type = pinfo[pinfo_index].types[i];
|
uint32 type = pinfo[pinfo_index].types[i];
|
||||||
char str2[6];
|
char str2[6];
|
||||||
@@ -1378,7 +1366,6 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
strcat(str, pinfo[pinfo_index].usage);
|
strcat(str, pinfo[pinfo_index].usage);
|
||||||
strcat(str, "\n");
|
strcat(str, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1388,16 +1375,15 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
#if TEST_VALUEINFO>0
|
#if TEST_VALUEINFO>0
|
||||||
value_info vinfo[10] = { {"Backup", 'back', B_COMMAND_KIND, "This command backs up your hard drive."},
|
value_info vinfo[10] = { {"Backup", 'back', B_COMMAND_KIND, "This command backs up your hard drive."},
|
||||||
{"Abort", 'abor', B_COMMAND_KIND, "Stops the current operation..."},
|
{"Abort", 'abor', B_COMMAND_KIND, "Stops the current operation..."},
|
||||||
{"Type Code", 'type', B_TYPE_CODE_KIND, "Type code info..."}
|
{"Type Code", 'type', B_TYPE_CODE_KIND, "Type code info..."} };
|
||||||
};
|
|
||||||
vinfo_count = 3;
|
vinfo_count = 3;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vinfo && vinfo_count > 0) {
|
if (vinfo && vinfo_count > 0) {
|
||||||
sprintf(str+strlen(str), "\n name value kind\n--------------------------------------------------------------------------------\n");
|
sprintf(str + strlen(str), "\n name value kind\n"
|
||||||
|
"--------------------------------------------------------------------------------\n");
|
||||||
|
|
||||||
for (int32 vinfo_index = 0; vinfo_index < vinfo_count; vinfo_index++) {
|
for (int32 vinfo_index = 0; vinfo_index < vinfo_count; vinfo_index++) {
|
||||||
|
|
||||||
char *start = str + strlen(str);
|
char *start = str + strlen(str);
|
||||||
strcat(str, " " + (strlen(vinfo[vinfo_index].name) < 16 ? strlen(vinfo[vinfo_index].name) : 16));
|
strcat(str, " " + (strlen(vinfo[vinfo_index].name) < 16 ? strlen(vinfo[vinfo_index].name) : 16));
|
||||||
strcat(str, vinfo[vinfo_index].name);
|
strcat(str, vinfo[vinfo_index].name);
|
||||||
@@ -1409,16 +1395,23 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
strcat(str, ")");
|
strcat(str, ")");
|
||||||
|
|
||||||
// pad the rest with spaces
|
// pad the rest with spaces
|
||||||
if (strlen(start)<36+19){
|
if (strlen(start) < 36 + 19)
|
||||||
strcat(str, " " + strlen(start));
|
strcat(str, " " + strlen(start));
|
||||||
} else {
|
else
|
||||||
strcat(str, " ");
|
strcat(str, " ");
|
||||||
}
|
|
||||||
|
|
||||||
switch (vinfo[vinfo_index].kind) {
|
switch (vinfo[vinfo_index].kind) {
|
||||||
case B_COMMAND_KIND: strcat(str, "COMMAND "); break;
|
case B_COMMAND_KIND:
|
||||||
case B_TYPE_CODE_KIND: strcat(str, "TYPE CODE "); break;
|
strcat(str, "COMMAND ");
|
||||||
default: strcat(str, "unknown "); break;
|
break;
|
||||||
|
|
||||||
|
case B_TYPE_CODE_KIND:
|
||||||
|
strcat(str, "TYPE CODE ");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
strcat(str, "unknown ");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(str, "\n");
|
strcat(str, "\n");
|
||||||
@@ -1431,7 +1424,6 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
str = new char[64];
|
str = new char[64];
|
||||||
strcpy(str, "error when unflattening");
|
strcpy(str, "error when unflattening");
|
||||||
@@ -1443,7 +1435,6 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
str = new char[min_c(256, size) * 20 + 4];
|
str = new char[min_c(256, size) * 20 + 4];
|
||||||
*str = 0;
|
*str = 0;
|
||||||
for (int32 i = 0; i < min_c(256, size); i++) {
|
for (int32 i = 0; i < min_c(256, size); i++) {
|
||||||
//sprintf(idtext, "0x%02X ('%c'), ", (uint16)ptr[i], ptr[i]<32 ? 32 : ptr[i]);
|
|
||||||
sprintf(idtext, "0x%02X, ", (uint16)ptr[i]);
|
sprintf(idtext, "0x%02X, ", (uint16)ptr[i]);
|
||||||
strcat(str, idtext);
|
strcat(str, idtext);
|
||||||
}
|
}
|
||||||
@@ -1452,7 +1443,6 @@ format_data(int32 type, char *ptr, long size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1469,31 +1459,28 @@ id_to_string(long ID, char *here)
|
|||||||
if (digit1 == 0) {
|
if (digit1 == 0) {
|
||||||
if (digit2 == 0) {
|
if (digit2 == 0) {
|
||||||
// 1 digits
|
// 1 digits
|
||||||
if (is_valid_char(digit3) )
|
itsvalid = is_valid_char(digit3);
|
||||||
itsvalid=TRUE;
|
|
||||||
sprintf(here, "'%c'", digit3);
|
sprintf(here, "'%c'", digit3);
|
||||||
} else {
|
} else {
|
||||||
// 2 digits
|
// 2 digits
|
||||||
if (is_valid_char(digit2) && is_valid_char(digit3) )
|
itsvalid = is_valid_char(digit2) && is_valid_char(digit3);
|
||||||
itsvalid=TRUE;
|
|
||||||
sprintf(here, "'%c%c'", digit2, digit3);
|
sprintf(here, "'%c%c'", digit2, digit3);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 3 digits
|
// 3 digits
|
||||||
if (is_valid_char(digit1) && is_valid_char(digit2) && is_valid_char(digit3) )
|
itsvalid = is_valid_char(digit1) && is_valid_char(digit2)
|
||||||
itsvalid=TRUE;
|
&& is_valid_char(digit3);
|
||||||
sprintf(here, "'%c%c%c'", digit1, digit2, digit3);
|
sprintf(here, "'%c%c%c'", digit1, digit2, digit3);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 4 digits
|
// 4 digits
|
||||||
if (is_valid_char(digit0) && is_valid_char(digit1) && is_valid_char(digit2) && is_valid_char(digit3) )
|
itsvalid = is_valid_char(digit0) && is_valid_char(digit1)
|
||||||
itsvalid=TRUE;
|
&& is_valid_char(digit2) && is_valid_char(digit3);
|
||||||
sprintf(here, "'%c%c%c%c'", digit0, digit1, digit2, digit3);
|
sprintf(here, "'%c%c%c%c'", digit0, digit1, digit2, digit3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!itsvalid){
|
if (!itsvalid)
|
||||||
sprintf(here, "%ldL", ID);
|
sprintf(here, "%ldL", ID);
|
||||||
}
|
|
||||||
|
|
||||||
return here;
|
return here;
|
||||||
}
|
}
|
||||||
@@ -1502,6 +1489,6 @@ id_to_string(long ID, char *here)
|
|||||||
bool
|
bool
|
||||||
is_valid_char(uint8 c)
|
is_valid_char(uint8 c)
|
||||||
{
|
{
|
||||||
return (c>=32 && c<128);
|
return c >= 32 && c < 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user