2 * ACE_ARGV 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_include/os_netdb.h"
7 #include "ace/OS_NS_string.h"
8 #include "ace/Log_Msg.h"
10 // Listing 1 code/ch04
12 #include "ace/Get_Opt.h"
14 int ACE_TMAIN (int, ACE_TCHAR
*[])
16 static const ACE_TCHAR options
[] = ACE_TEXT (":f:h:");
17 static const ACE_TCHAR cmdline
[] =
18 ACE_TEXT ("-f /home/managed.cfg -h $HOSTNAME");
19 ACE_ARGV
cmdline_args (cmdline
);
20 ACE_Get_Opt
cmd_opts (cmdline_args
.argc (),
23 0); // Don't skip any args
28 ACE_TCHAR config_file
[MAXPATHLEN
];
29 ACE_TCHAR hostname
[MAXHOSTNAMELEN
];
30 ACE_OS::strcpy (config_file
, ACE_TEXT ("HAStatus.conf"));
31 ACE_OS::strcpy (hostname
, ACE_TEXT ("not set"));
32 while ((option
= cmd_opts ()) != EOF
)
35 ACE_OS::strncpy (config_file
,
41 ACE_OS::strncpy (hostname
,
48 ((LM_ERROR
, ACE_TEXT ("-%c requires an argument\n"),
49 cmd_opts
.opt_opt ()), -1);
54 ((LM_ERROR
, ACE_TEXT ("Parse error.\n")), -1);
57 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Config file: %s\n"), config_file
));
58 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Hostname: %s\n"), hostname
));