- putchar(m_ch);
- fflush(stdout);
-
- wxThread::Sleep(100);
- }
-
- return 0;
-}
-
-void MyDetachedThread::OnExit()
-{
- wxCriticalSectionLocker lock(gs_critsect);
- if ( !--gs_counter )
- gs_cond.Signal();
-}
-
-#endif // TEST_THREADS
-
-// ----------------------------------------------------------------------------
-// arrays
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_ARRAYS
-
-void PrintArray(const char* name, const wxArrayString& array)
-{
- printf("Dump of the array '%s'\n", name);
-
- size_t nCount = array.GetCount();
- for ( size_t n = 0; n < nCount; n++ )
- {
- printf("\t%s[%u] = '%s'\n", name, n, array[n].c_str());
- }
-}
-
-#endif // TEST_ARRAYS
-
-// ----------------------------------------------------------------------------
-// entry point
-// ----------------------------------------------------------------------------
-
-int main(int argc, char **argv)
-{
- if ( !wxInitialize() )
- {
- fprintf(stderr, "Failed to initialize the wxWindows library, aborting.");
- }
-
-#ifdef TEST_ARRAYS
- wxArrayString a1;
- a1.Add("tiger");
- a1.Add("cat");
- a1.Add("lion");
- a1.Add("dog");
- a1.Add("human");
- a1.Add("ape");
-
- puts("*** Initially:");
-
- PrintArray("a1", a1);
-
- wxArrayString a2(a1);
- PrintArray("a2", a2);
-
- wxSortedArrayString a3(a1);
- PrintArray("a3", a3);
-
- puts("*** After deleting a string from a1");
- a1.Remove(2);
-
- PrintArray("a1", a1);
- PrintArray("a2", a2);
- PrintArray("a3", a3);
-
- puts("*** After reassigning a1 to a2 and a3");
- a3 = a2 = a1;
- PrintArray("a2", a2);
- PrintArray("a3", a3);
-#endif // TEST_ARRAYS
-
-#ifdef TEST_LOG
- wxString s;
- for ( size_t n = 0; n < 8000; n++ )
- {
- s << (char)('A' + (n % 26));
- }
-
- wxString msg;
- msg.Printf("A very very long message: '%s', the end!\n", s.c_str());
-
- // this one shouldn't be truncated
- printf(msg);
-
- // but this one will because log functions use fixed size buffer
- // (note that it doesn't need '\n' at the end neither - will be added
- // by wxLog anyhow)
- wxLogMessage("A very very long message 2: '%s', the end!", s.c_str());
-#endif // TEST_LOG
-
-#ifdef TEST_THREADS
- puts("Testing detached threads...");
+ case 0:
+ // everything is ok; proceed
+ if (parser.Found("d"))
+ {
+ wxPrintf("Dummy switch was given...\n");
+
+ while (1)
+ {
+ wxChar input[128];
+ wxPrintf("Try to guess the magic number (type 'quit' to escape): ");
+ if ( !wxFgets(input, WXSIZEOF(input), stdin) )
+ break;
+
+ // kill the last '\n'
+ input[wxStrlen(input) - 1] = 0;
+
+ if (wxStrcmp(input, "quit") == 0)
+ break;
+
+ long val;
+ if (!wxString(input).ToLong(&val))
+ {
+ wxPrintf("Invalid number...\n");
+ continue;
+ }
+
+ if (val == 42)
+ wxPrintf("You guessed!\n");
+ else
+ wxPrintf("Bad luck!\n");
+ }
+ }
+ break;