2 * ACE_Get_Opt examples not in a larger program. Sample code from The ACE
3 * Programmer's Guide, Copyright 2003 Addison-Wesley. All Rights Reserved.
6 #include "ace/OS_NS_string.h"
7 #include "ace/Get_Opt.h"
8 #include "ace/Log_Msg.h"
11 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
13 // Example for a long option without a corresponding short option.
14 // Just put some context here so the following compiles and runs.
15 static const ACE_TCHAR options
[] = ACE_TEXT (":f:");
16 ACE_Get_Opt
cmd_opts (argc
, argv
, options
);
18 // Listing 1 code/ch04
19 cmd_opts
.long_option (ACE_TEXT ("cool_option"));
20 cmd_opts
.long_option (ACE_TEXT ("the_answer"), 42);
24 ACE_TCHAR config_file
[MAXPATHLEN
];
25 ACE_OS::strcpy (config_file
, ACE_TEXT ("HAStatus.conf"));
26 while ((option
= cmd_opts ()) != EOF
)
29 ACE_OS::strncpy (config_file
,
34 // Listing 2 code/ch04
36 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Yes, very cool.\n")));
40 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("the_answer is 42\n")));
46 ((LM_ERROR
, ACE_TEXT ("-%c requires an argument\n"),
47 cmd_opts
.opt_opt ()), -1);
52 ((LM_ERROR
, ACE_TEXT ("Parse error.\n")), -1);