Mercurial > sdl-ios-xcode
comparison test/automated/testsdl.c @ 3741:808fad5fb593 gsoc2009_unit_tests
Added command line options.
Added verbosity levels.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Sun, 02 Aug 2009 18:58:03 +0000 |
parents | e451d5d288e9 |
children | f0b89cf4bffc |
comparison
equal
deleted
inserted
replaced
3740:e451d5d288e9 | 3741:808fad5fb593 |
---|---|
5 * | 5 * |
6 * Released under Public Domain. | 6 * Released under Public Domain. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SDL_at.h" | |
11 | |
10 #include "platform/platform.h" | 12 #include "platform/platform.h" |
11 #include "rwops/rwops.h" | 13 #include "rwops/rwops.h" |
12 #include "surface/surface.h" | 14 #include "surface/surface.h" |
13 #include "render/render.h" | 15 #include "render/render.h" |
14 | 16 |
17 #include <stdio.h> /* printf */ | |
18 #include <stdlib.h> /* exit */ | |
19 #include <unistd.h> /* getopt */ | |
20 #include <getopt.h> /* getopt_long */ | |
15 | 21 |
22 | |
23 /* | |
24 * Prototypes. | |
25 */ | |
26 static void print_usage( const char *name ); | |
27 static void parse_options( int argc, char *argv[] ); | |
28 | |
29 | |
30 /** | |
31 * @brief Displays program usage. | |
32 */ | |
33 static void print_usage( const char *name ) | |
34 { | |
35 printf("Usage: %s [OPTIONS]\n", name); | |
36 printf("Options are:\n"); | |
37 printf(" -v, --verbose increases verbosity level by 1 for each -v\n"); | |
38 printf(" -q, --quiet only displays errors\n"); | |
39 printf(" -h, --help display this message and exit\n"); | |
40 } | |
41 | |
42 | |
43 /** | |
44 * @brief Handles the options. | |
45 */ | |
46 static void parse_options( int argc, char *argv[] ) | |
47 { | |
48 static struct option long_options[] = { | |
49 { "verbose", no_argument, 0, 'v' }, | |
50 { "quiet", no_argument, 0, 'q' }, | |
51 { "help", no_argument, 0, 'h' }, | |
52 {NULL,0,0,0} | |
53 }; | |
54 int option_index = 0; | |
55 int c = 0; | |
56 int i; | |
57 | |
58 /* Iterate over options. */ | |
59 while ((c = getopt_long( argc, argv, | |
60 "vqh", | |
61 long_options, &option_index)) != -1) { | |
62 | |
63 /* Handle options. */ | |
64 switch (c) { | |
65 | |
66 /* Verbosity. */ | |
67 case 'v': | |
68 SDL_ATgeti( SDL_AT_VERBOSE, &i ); | |
69 SDL_ATseti( SDL_AT_VERBOSE, i+1 ); | |
70 break; | |
71 | |
72 /* Quiet. */ | |
73 case 'q': | |
74 SDL_ATseti( SDL_AT_QUIET, 1 ); | |
75 break; | |
76 | |
77 /* Help. */ | |
78 case 'h': | |
79 print_usage( argv[0] ); | |
80 exit(EXIT_SUCCESS); | |
81 } | |
82 } | |
83 | |
84 } | |
85 | |
86 | |
87 /** | |
88 * @brief Main entry point. | |
89 */ | |
16 int main( int argc, char *argv[] ) | 90 int main( int argc, char *argv[] ) |
17 { | 91 { |
18 (void) argc; | 92 parse_options( argc, argv ); |
19 (void) argv; | |
20 | 93 |
21 test_platform(); | 94 test_platform(); |
22 test_rwops(); | 95 test_rwops(); |
23 test_surface(); | 96 test_surface(); |
24 test_render(); | 97 test_render(); |