diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index 660191266a..c95ec5c171 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -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 diff --git a/src/tests/servers/app/Jamfile b/src/tests/servers/app/Jamfile index ac1cf93666..6f31a23769 100644 --- a/src/tests/servers/app/Jamfile +++ b/src/tests/servers/app/Jamfile @@ -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 ; diff --git a/src/tests/servers/app/code_to_name/Jamfile b/src/tests/servers/app/code_to_name/Jamfile new file mode 100644 index 0000000000..03e80e8244 --- /dev/null +++ b/src/tests/servers/app/code_to_name/Jamfile @@ -0,0 +1,9 @@ +SubDir HAIKU_TOP src tests servers app code_to_name ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +SimpleTest code_to_name + : code_to_name.cpp + : be +; + diff --git a/src/tests/servers/app/code_to_name/code_to_name.cpp b/src/tests/servers/app/code_to_name/code_to_name.cpp new file mode 100644 index 0000000000..89c70002c0 --- /dev/null +++ b/src/tests/servers/app/code_to_name/code_to_name.cpp @@ -0,0 +1,112 @@ +/* + * Copyright 2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, axeld@pinc-software.de + */ + + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + + +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 \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; +}