Added a very simple "code_to_name" utility that will print out the name of

an app_server code. It's always up-to-date as it just reads the header
directly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15148 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-25 14:53:34 +00:00
parent 67e79bf45a
commit c3b8f9f69a
4 changed files with 127 additions and 2 deletions
+5 -2
View File
@@ -27,6 +27,9 @@ enum {
SERVER_TRUE = B_OK,
SERVER_FALSE = B_ERROR,
// NOTE: all defines have to start with "AS_" to let the "code_to_name"
// utility work correctly
AS_REGISTER_INPUT_SERVER = 1,
AS_GET_DESKTOP,
@@ -101,7 +104,6 @@ enum {
AS_ACTIVATE_WINDOW,
AS_WINDOW_MINIMIZE,
AS_UPDATE_IF_NEEDED,
_ALL_UPDATED_, // this should be moved in place of _UPDATE_IF_NEEDED_ in AppDefs.h
// BPicture definitions
AS_CREATE_PICTURE,
@@ -316,7 +318,8 @@ enum {
AS_DW_GET_SYNC_DATA,
AS_DW_SUPPORTS_WINDOW_MODE,
AS_DW_SET_FULLSCREEN,
AS_LAST_CODE
};
#define AS_PATTERN_SIZE 8
+1
View File
@@ -138,6 +138,7 @@ HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : haiku_app_server
} # if $(TARGET_PLATFORM) = libbe_test
SubInclude HAIKU_TOP src tests servers app bitmap_drawing ;
SubInclude HAIKU_TOP src tests servers app code_to_name ;
SubInclude HAIKU_TOP src tests servers app copy_bits ;
SubInclude HAIKU_TOP src tests servers app event_mask ;
SubInclude HAIKU_TOP src tests servers app painter ;
@@ -0,0 +1,9 @@
SubDir HAIKU_TOP src tests servers app code_to_name ;
SetSubDirSupportedPlatformsBeOSCompatible ;
SimpleTest code_to_name
: code_to_name.cpp
: be
;
@@ -0,0 +1,112 @@
/*
* Copyright 2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, [email protected]
*/
#include <Entry.h>
#include <Path.h>
#include <Query.h>
#include <Volume.h>
#include <fs_info.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
extern const char* __progname;
void
skip_white_space(char*& line)
{
while (isspace(line[0]))
line++;
}
void
get_name(char* line)
{
while (isalnum(line[0]) || line[0] == '_') {
line++;
}
line[0] = '\0';
}
void
print_code(BPath& path, int32 code)
{
FILE* file = fopen(path.Path(), "r");
if (file == NULL)
return;
int32 lineNumber = 0;
char buffer[4096];
while (fgets(buffer, sizeof(buffer), file) != NULL) {
char* line = buffer;
skip_white_space(line);
if (strncmp(line, "AS_", 3))
continue;
if (++lineNumber != code)
continue;
get_name(line);
printf("code %ld: %s\n", lineNumber, line);
fclose(file);
return;
}
printf("unknown code %ld!\n", code);
fclose(file);
}
int
main(int argc, char** argv)
{
if (argc < 2) {
fprintf(stderr, "usage: %s <message-code>\n", __progname);
return -1;
}
int32 number = atol(argv[1]);
BQuery query;
query.SetPredicate("name=ServerProtocol.h");
// search on current volume only
dev_t device = dev_for_path(".");
BVolume volume(device);
query.SetVolume(&volume);
query.Fetch();
status_t status;
BEntry entry;
while ((status = query.GetNextEntry(&entry)) == B_OK) {
BPath path(&entry);
puts(path.Path());
if (strstr(path.Path(), "headers/private/app/ServerProtocol.h") != NULL) {
print_code(path, number);
break;
}
}
if (status != B_OK) {
fprintf(stderr, "%s: could not find ServerProtocol.h", __progname);
return -1;
}
return 0;
}