From 2b8d9334961ad2879b1bf15512c1288871cb916f Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Thu, 8 Nov 2007 20:20:59 +0000 Subject: [PATCH] Make cpucount more similar to the RosBE-Unix version - Show the Usage text, when any unknown parameter has been specified - Makes the whole code a bit smaller :-D svn path=/trunk/tools/RosBE-Windows/; revision=514 --- RosBE-Windows/Tools/cpucount.c | 46 ++++++++++++++++------------------ 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/RosBE-Windows/Tools/cpucount.c b/RosBE-Windows/Tools/cpucount.c index f874da1..a8d531a 100644 --- a/RosBE-Windows/Tools/cpucount.c +++ b/RosBE-Windows/Tools/cpucount.c @@ -20,34 +20,30 @@ int main(int argc, char* argv[]) fprintf(stderr, "%s: Error too many parameters specified.\n", argv[0]); return -1; } + GetSystemInfo(&SystemInformation); - if (argc == 1) + + if(argc != 1) { - printf("%ld\n", SystemInformation.dwNumberOfProcessors); - } - else if ((!strncmp(argv[1], "/?", 2)) || - (!strncmp(argv[1], "-h", 2)) || - (!strncmp(argv[1], "--help", 6))) - { - printf("Usage: %s [OPTIONS]\n", argv[0]); - printf("Running cpucount without options returns the number of\n"); - printf("processors in the system.\n"); - printf("-x1 - Number of processors in the system, plus 1.\n"); - printf("-x2 - Number of processors in the system, doubled.\n"); - } - else if (!strncmp(argv[1], "-x1", 3)) - { - printf("%ld\n", (SystemInformation.dwNumberOfProcessors + 1)); - } - else if (!strncmp(argv[1], "-x2", 3)) - { - printf("%ld\n", (SystemInformation.dwNumberOfProcessors + SystemInformation.dwNumberOfProcessors)); - } - else - { - fprintf(stderr, "%s: Error unknown parameter '%s' specified.\n", argv[0], argv[1]); - return -1; + if(!strncmp(argv[1], "-x1", 3)) + { + SystemInformation.dwNumberOfProcessors++; + } + else if(!strncmp(argv[1], "-x2", 3)) + { + SystemInformation.dwNumberOfProcessors += SystemInformation.dwNumberOfProcessors; + } + else + { + printf("Usage: %s [OPTIONS]\n", argv[0]); + printf("Running cpucount without options returns the number of\n"); + printf("processors in the system.\n"); + printf("-x1 - Number of processors in the system, plus 1.\n"); + printf("-x2 - Number of processors in the system, doubled.\n"); + return 0; + } } + printf("%u\n", SystemInformation.dwNumberOfProcessors); return 0; }