本文整理汇总了C++中parse_args函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_args函数的具体用法?C++ parse_args怎么用?C++ parse_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_args函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) - Acquiring Name Service\n")));
CORBA::Object_var nmobj = orb->resolve_initial_references ("NameManager");
FT_Naming::NamingManager_var naming_manager =
FT_Naming::NamingManager::_narrow (nmobj.in());
TAO_Naming_Client name_svc;
try {
ACE_Time_Value timeout (10); // Wait up to 10 seconds for the naming service
if (name_svc.init (orb.in (), &timeout) != 0)
ACE_ERROR_RETURN ((LM_DEBUG,
ACE_TEXT ("client: Could not connect to ")
ACE_TEXT ("naming service.\n")),
1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception (
ACE_TEXT ("Exception caught while initializing name ")
ACE_TEXT ("service facade:"));
return 1;
}
Hammer hammer;
if (hammer.setup(orb.in(), naming_manager.in()) == -1)
{
return 1;
}
CosNaming::Name name (1);
name.length (1);
name[0].id = CORBA::string_dup ("basic_name");
CORBA::Object_var tmp;
Test::Basic_var basic;
// Iterate enough so we get a few wrap-arounds
for (int i = 0; i < 15; i++)
{
if (i == 3) {
hammer.activate (THR_NEW_LWP | THR_JOINABLE, hammers);
}
try {
// Each time we invoke resolve, we get a different member
tmp =
name_svc->resolve (name);
// Narrow it to a Basic object
basic =
Test::Basic::_narrow (tmp.in ());
}
catch (CORBA::Exception& ex)
{
ex._tao_print_exception (ACE_TEXT ("Error resolving name.\n"));
}
if (CORBA::is_nil (basic.in ()))
{
ACE_ERROR_RETURN ((LM_DEBUG,
ACE_TEXT ("Server obj ref not obtained ")
ACE_TEXT ("from Load Balancing Name Service\n"),
ior),
1);
}
try {
CORBA::String_var the_string =
basic->get_string ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) - Client request handled ")
ACE_TEXT ("by object at <%C>\n"),
the_string.in ()));
}
catch (CORBA::Exception& ex)
{
ex._tao_print_exception (
ACE_TEXT ("Error invoking get_string on Basic object.\n"));
return 1;
}
//.........这里部分代码省略.........
开发者ID:bjovke,项目名称:ACE_TAO,代码行数:101,代码来源:client.cpp
示例2: main
int
main(int argc, char *argv[]) {
struct sigaction sact;
cron_db database;
setprogname(argv[0]);
(void)setlocale(LC_ALL, "");
(void)setvbuf(stdout, NULL, _IOLBF, 0);
(void)setvbuf(stderr, NULL, _IOLBF, 0);
NoFork = 0;
parse_args(argc, argv);
(void)memset(&sact, 0, sizeof sact);
(void)sigemptyset(&sact.sa_mask);
sact.sa_flags = 0;
#ifdef SA_RESTART
sact.sa_flags |= SA_RESTART;
#endif
sact.sa_handler = sigchld_handler;
(void) sigaction(SIGCHLD, &sact, NULL);
sact.sa_handler = sighup_handler;
(void) sigaction(SIGHUP, &sact, NULL);
sact.sa_handler = quit;
(void) sigaction(SIGINT, &sact, NULL);
(void) sigaction(SIGTERM, &sact, NULL);
acquire_daemonlock(0);
set_cron_uid();
set_cron_cwd();
if (setenv("PATH", _PATH_DEFPATH, 1) < 0) {
log_it("CRON", getpid(), "DEATH", "can't malloc");
exit(1);
}
/* if there are no debug flags turned on, fork as a daemon should.
*/
if (DebugFlags) {
#if DEBUGGING
(void)fprintf(stderr, "[%ld] cron started\n", (long)getpid());
#endif
} else if (NoFork == 0) {
if (daemon(1, 0)) {
log_it("CRON",getpid(),"DEATH","can't fork");
exit(1);
}
}
acquire_daemonlock(0);
database.head = NULL;
database.tail = NULL;
database.mtime = (time_t) 0;
load_database(&database);
set_time(TRUE);
run_reboot_jobs(&database);
timeRunning = virtualTime = clockTime;
/*
* Too many clocks, not enough time (Al. Einstein)
* These clocks are in minutes since the epoch, adjusted for timezone.
* virtualTime: is the time it *would* be if we woke up
* promptly and nobody ever changed the clock. It is
* monotonically increasing... unless a timejump happens.
* At the top of the loop, all jobs for 'virtualTime' have run.
* timeRunning: is the time we last awakened.
* clockTime: is the time when set_time was last called.
*/
for (;;) {
time_t timeDiff;
enum timejump wakeupKind;
/* ... wait for the time (in minutes) to change ... */
do {
cron_sleep(timeRunning + 1);
set_time(FALSE);
} while (clockTime == timeRunning);
timeRunning = clockTime;
/*
* Calculate how the current time differs from our virtual
* clock. Classify the change into one of 4 cases.
*/
timeDiff = timeRunning - virtualTime;
/* shortcut for the most common case */
if (timeDiff == 1) {
virtualTime = timeRunning;
find_jobs(virtualTime, &database, TRUE, TRUE);
} else {
if (timeDiff > (3*MINUTE_COUNT) ||
timeDiff < -(3*MINUTE_COUNT))
wakeupKind = large;
else if (timeDiff > 5)
wakeupKind = medium;
else if (timeDiff > 0)
wakeupKind = small;
else
wakeupKind = negative;
//.........这里部分代码省略.........
开发者ID:IIJ-NetBSD,项目名称:netbsd-src,代码行数:101,代码来源:cron.c
示例3: start_kernel
asmlinkage void __init start_kernel(void)
{
char * command_line;
extern struct kernel_param __start___param[], __stop___param[];
smp_setup_processor_id();
/*
* Need to run as early as possible, to initialize the
* lockdep hash:
*/
unwind_init();
lockdep_init();
cgroup_init_early();
local_irq_disable();
early_boot_irqs_off();
early_init_irq_lock_class();
/*
* Interrupts are still disabled. Do necessary setups, then
* enable them
*/
lock_kernel();
tick_init();
boot_cpu_init();
page_address_init();
printk(KERN_NOTICE);
printk(linux_banner);
setup_arch(&command_line);
setup_command_line(command_line);
unwind_setup();
setup_per_cpu_areas();
smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
/*
* Set up the scheduler prior starting any interrupts (such as the
* timer interrupt). Full topology setup happens at smp_init()
* time - but meanwhile we still have a functioning scheduler.
*/
sched_init();
/*
* Disable preemption - early bootup scheduling is extremely
* fragile until we cpu_idle() for the first time.
*/
preempt_disable();
build_all_zonelists();
page_alloc_init();
printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
parse_early_param();
parse_args("Booting kernel", static_command_line, __start___param,
__stop___param - __start___param,
&unknown_bootoption);
if (!irqs_disabled()) {
printk(KERN_WARNING "start_kernel(): bug: interrupts were "
"enabled *very* early, fixing it\n");
local_irq_disable();
}
sort_main_extable();
trap_init();
rcu_init();
init_IRQ();
pidhash_init();
init_timers();
hrtimers_init();
softirq_init();
timekeeping_init();
time_init();
profile_init();
if (!irqs_disabled())
printk("start_kernel(): bug: interrupts were enabled early\n");
early_boot_irqs_on();
local_irq_enable();
/*
* HACK ALERT! This is early. We're enabling the console before
* we've done PCI setups etc, and console_init() must be aware of
* this. But we do want output early, in case something goes wrong.
*/
console_init();
if (panic_later)
panic(panic_later, panic_param);
lockdep_info();
/*
* Need to run this when irqs are enabled, because it wants
* to self-test [hard/soft]-irqs on/off lock inversion bugs
* too:
*/
locking_selftest();
#ifdef CONFIG_BLK_DEV_INITRD
if (initrd_start && !initrd_below_start_ok &&
initrd_start < min_low_pfn << PAGE_SHIFT) {
printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
"disabling it.\n",initrd_start,min_low_pfn << PAGE_SHIFT);
initrd_start = 0;
}
#endif
//.........这里部分代码省略.........
开发者ID:mobilipia,项目名称:iods,代码行数:101,代码来源:main.c
示例4: cmd_write_value
static void cmd_write_value(struct client *cli, char *cmd_str)
{
int opt, i, val;
char *argvbuf[516];
char **argv = argvbuf;
int argc = 1;
uint16_t handle;
char *endptr = NULL;
int length;
uint8_t *value = NULL;
bool without_response = false;
bool signed_write = false;
if (!bt_gatt_client_is_ready(cli->gatt)) {
printf("GATT client not initialized\n");
return;
}
if (!parse_args(cmd_str, 514, argv + 1, &argc)) {
printf("Too many arguments\n");
write_value_usage();
return;
}
optind = 0;
argv[0] = "write-value";
while ((opt = getopt_long(argc, argv, "+ws", write_value_options,
NULL)) != -1) {
switch (opt) {
case 'w':
without_response = true;
break;
case 's':
signed_write = true;
break;
default:
write_value_usage();
return;
}
}
argc -= optind;
argv += optind;
if (argc < 1) {
write_value_usage();
return;
}
handle = strtol(argv[0], &endptr, 0);
if (!endptr || *endptr != '\0' || !handle) {
printf("Invalid handle: %s\n", argv[0]);
return;
}
length = argc - 1;
if (length > 0) {
if (length > UINT16_MAX) {
printf("Write value too long\n");
return;
}
value = malloc(length);
if (!value) {
printf("Failed to construct write value\n");
return;
}
for (i = 1; i < argc; i++) {
val = strtol(argv[i], &endptr, 0);
if (endptr == argv[i] || *endptr != '\0'
|| errno == ERANGE || val < 0 || val > 255) {
printf("Invalid value byte: %s\n",
argv[i]);
goto done;
}
value[i-1] = val;
}
}
if (without_response) {
if (!bt_gatt_client_write_without_response(cli->gatt, handle,
signed_write, value, length)) {
printf("Failed to initiate write without response "
"procedure\n");
goto done;
}
printf("Write command sent\n");
goto done;
}
if (!bt_gatt_client_write_value(cli->gatt, handle, value, length,
write_cb,
NULL, NULL))
printf("Failed to initiate write procedure\n");
done:
free(value);
//.........这里部分代码省略.........
开发者ID:ghent360,项目名称:bluez,代码行数:101,代码来源:btgatt-client.c
示例5: cmd_write_prepare
static void cmd_write_prepare(struct client *cli, char *cmd_str)
{
int opt, i, val;
char *argvbuf[516];
char **argv = argvbuf;
int argc = 0;
unsigned int id = 0;
uint16_t handle;
uint16_t offset;
char *endptr = NULL;
unsigned int length;
uint8_t *value = NULL;
if (!bt_gatt_client_is_ready(cli->gatt)) {
printf("GATT client not initialized\n");
return;
}
if (!parse_args(cmd_str, 514, argv + 1, &argc)) {
printf("Too many arguments\n");
write_value_usage();
return;
}
/* Add command name for getopt_long */
argc++;
argv[0] = "write-prepare";
optind = 0;
while ((opt = getopt_long(argc, argv , "s:", write_prepare_options,
NULL)) != -1) {
switch (opt) {
case 's':
if (!optarg) {
write_prepare_usage();
return;
}
id = atoi(optarg);
break;
default:
write_prepare_usage();
return;
}
}
argc -= optind;
argv += optind;
if (argc < 3) {
write_prepare_usage();
return;
}
if (cli->reliable_session_id != id) {
printf("Session id != Ongoing session id (%u!=%u)\n", id,
cli->reliable_session_id);
return;
}
handle = strtol(argv[0], &endptr, 0);
if (!endptr || *endptr != '\0' || !handle) {
printf("Invalid handle: %s\n", argv[0]);
return;
}
endptr = NULL;
offset = strtol(argv[1], &endptr, 0);
if (!endptr || *endptr != '\0' || errno == ERANGE) {
printf("Invalid offset: %s\n", argv[1]);
return;
}
/*
* First two arguments are handle and offset. What remains is the value
* length
*/
length = argc - 2;
if (length == 0)
goto done;
if (length > UINT16_MAX) {
printf("Write value too long\n");
return;
}
value = malloc(length);
if (!value) {
printf("Failed to allocate memory for value\n");
return;
}
for (i = 2; i < argc; i++) {
val = strtol(argv[i], &endptr, 0);
if (endptr == argv[i] || *endptr != '\0' || errno == ERANGE
|| val < 0 || val > 255) {
printf("Invalid value byte: %s\n", argv[i]);
free(value);
//.........这里部分代码省略.........
开发者ID:ghent360,项目名称:bluez,代码行数:101,代码来源:btgatt-client.c
示例6: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
if (CORBA::is_nil (root_poa.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil RootPOA\n"),
1);
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
// Make all oneways "reliable."
{
CORBA::Object_var manager_object =
orb->resolve_initial_references("ORBPolicyManager");
CORBA::PolicyManager_var policy_manager =
CORBA::PolicyManager::_narrow(manager_object.in());
if (CORBA::is_nil (policy_manager.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil PolicyManager\n"),
1);
CORBA::Any policy_value;
policy_value <<= Messaging::SYNC_WITH_SERVER;
CORBA::PolicyList policies(1); policies.length(1);
policies[0] =
orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
policy_value);
policy_manager->set_policy_overrides (policies,
CORBA::ADD_OVERRIDE);
policies[0]->destroy ();
}
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var tmp =
orb->string_to_object(ior);
Test::Service_var service =
Test::Service::_narrow(tmp.in ());
if (CORBA::is_nil (service.in ()))
{
ACE_ERROR_RETURN ((LM_DEBUG,
"Nil service reference <%s>\n",
ior),
1);
}
Callback *callback_impl;
ACE_NEW_RETURN (callback_impl,
Callback(orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(callback_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (callback_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
Test::Callback_var callback =
Test::Callback::_narrow (object.in ());
poa_manager->activate ();
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) client - starting test\n"));
service->run_test (callback.in ());
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) client - running ORB\n"));
orb->run ();
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:client.cpp
示例7: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
if (parse_args (argc,
argv) == -1)
return -1;
try
{
ACE_Argv_Type_Converter satc (argc, argv);
CORBA::ORB_var sorb =
CORBA::ORB_init (satc.get_argc (),
satc.get_TCHAR_argv (),
server_orb.c_str ());
ACE_Manual_Event me;
Server_Task server_task (output,
simple_test_output,
sorb.in (),
me,
ACE_Thread_Manager::instance ());
if (server_task.activate (THR_NEW_LWP | THR_JOINABLE,
1,
1) == -1)
{
ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
}
// Wait for the server thread to do some processing
me.wait ();
ACE_Argv_Type_Converter catc (argc, argv);
CORBA::ORB_var corb =
CORBA::ORB_init (catc.get_argc (),
catc.get_TCHAR_argv (),
client_orb.c_str ());
Client_Task client_task (input,
simple_test_input,
corb.in (),
ACE_Thread_Manager::instance ());
if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
1,
1) == -1)
{
ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
}
// Wait for the client and server to finish
ACE_Thread_Manager::instance ()->wait ();
// Now that all threads have completed we can destroy the ORB
sorb->destroy ();
if (server_orb != client_orb)
{
corb->destroy ();
}
CORBA::ULong errors = client_task.error_count () + server_task.error_count ();
if (errors == 0)
{
ACE_DEBUG((LM_DEBUG, "(%P|%t) test passed\n"));
}
else
{
ACE_DEBUG((LM_DEBUG, "(%P|%t) test failed - error_count=%u\n", errors));
return 1;
}
}
catch (const CORBA::Exception&)
{
// Ignore exceptions..
}
return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:77,代码来源:Collocated_Test.cpp
示例8: main
int main(int argc, char **argv)
{
int rc;
struct worker_thread *worker;
rc = parse_args(argc, argv);
if (rc != 0) {
return rc;
}
ealargs[1] = sprintf_alloc("-c %s", g_core_mask ? g_core_mask : "0x1");
rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), ealargs);
free(ealargs[1]);
if (rc < 0) {
fprintf(stderr, "could not initialize dpdk\n");
return 1;
}
request_mempool = rte_mempool_create("nvme_request", 8192,
nvme_request_size(), 128, 0,
NULL, NULL, NULL, NULL,
SOCKET_ID_ANY, 0);
if (request_mempool == NULL) {
fprintf(stderr, "could not initialize request mempool\n");
return 1;
}
task_pool = rte_mempool_create("task_pool", 2048,
sizeof(struct perf_task),
64, 0, NULL, NULL, task_ctor, NULL,
SOCKET_ID_ANY, 0);
g_tsc_rate = rte_get_timer_hz();
register_workers();
register_controllers();
/* Launch all of the slave workers */
worker = g_workers->next;
while (worker != NULL) {
if (worker->namespaces != NULL) {
rte_eal_remote_launch(work_fn, worker, worker->lcore);
}
worker = worker->next;
}
work_fn(g_workers);
worker = g_workers->next;
while (worker != NULL) {
if (worker->namespaces != NULL) {
if (rte_eal_wait_lcore(worker->lcore) < 0) {
return -1;
}
}
worker = worker->next;
}
print_stats();
unregister_controllers();
return 0;
}
开发者ID:jupiturliu,项目名称:spdk,代码行数:68,代码来源:perf.c
示例9: main
int main (int argc, char **argv) {
unsigned int count = 0;
parse_args(argc, argv);
if (!endpoint || !name) {
zsys_error("endpoint or name not specified.");
usage();
}
mlm_client_t *client = mlm_client_new ();
assert(client);
int rv;
rv = mlm_client_connect(client, endpoint, 5000, name);
if (rv == -1) {
zsys_error("connection failed.");
mlm_client_destroy (&client);
return -1;
}
rv = mlm_client_set_producer (client, "stream");
if (rv == -1) {
zsys_error("set_producer failed.");
mlm_client_destroy (&client);
return -2;
}
zsock_t *pipe = mlm_client_msgpipe (client);
if (!pipe) {
zsys_error ("mlm_client_msgpipe() failed.");
mlm_client_destroy (&client);
return -3;
}
zpoller_t *poller = zpoller_new (pipe, NULL);
if (!poller) {
zsys_error("zpoller_new() failed.");
mlm_client_destroy (&client);
return -4;
}
while ( !zsys_interrupted && ( !num_messages || count < num_messages) ) {
zsock_t *which = zpoller_wait (poller, interval);
if ( which != NULL ) {
// so we have something to receive
zmsg_t *recv_msg = mlm_client_recv (client);
zmsg_destroy (&recv_msg);
}
// in any case we are going to send something
// zclock_sleep(interval);
zmsg_t *msg = zmsg_new();
assert (msg);
if ( count % 10 == 0) {
zmsg_pushstr (msg, "exit");
} else {
zmsg_pushstr (msg, "hello");
}
zmsg_print(msg);
mlm_client_send (client, "testing message", &msg);
zmsg_destroy (&msg);
++count;
}
mlm_client_destroy(&client);
zpoller_destroy(&poller);
free(endpoint);
free(name);
zsys_info ("finished, sent: %u.", count);
return 0;
}
开发者ID:thalman,项目名称:mlmplaygroud,代码行数:69,代码来源:sender.c
示例10: main
int main(int argc, char* argv[]) {
parse_args(argc, argv);
return argc;
}
开发者ID:Sedecimi,项目名称:chRtik,代码行数:4,代码来源:main.cpp
示例11: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc,argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (parse_args (argc, argv) != 0)
return -1;
{
test_factory_i *servant =
new test_factory_i (orb.in ());
PortableServer::ServantBase_var safe_servant (servant);
ACE_UNUSED_ARG (safe_servant);
PortableServer::ObjectId_var id_act =
root_poa->activate_object (servant);
CORBA::Object_var object = root_poa->id_to_reference (id_act.in ());
test_factory_var test_factory =
test_factory::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (test_factory.in ());
FILE *output_file = ACE_OS::fopen (ior_output_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
ior_output_file),
-1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
poa_manager->activate ();
TAO_Root_POA *tao_poa = dynamic_cast <TAO_Root_POA*> (root_poa.in ());
while (!done)
{
CORBA::ULong outstanding_requests =
tao_poa->outstanding_requests ();
ACE_DEBUG ((LM_DEBUG,
"Number of outstanding requests before ORB::perform_work(): %d\n",
outstanding_requests));
ACE_ASSERT (outstanding_requests == 0);
orb->perform_work ();
// On some systems this loop must yield or else the other threads
// will not get a chance to run.
ACE_OS::thr_yield ();
}
}
catch (...)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Failure: Unexpected exception caught\n"),
-1);
}
return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:79,代码来源:server.cpp
示例12: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
Worker worker (orb.in ());
if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
nthreads) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Cannot activate worker threads\n"),
1);
int timeout = 30;
int now = 0;
while (now < timeout && worker.got_object_not_exist () != expected_object_not_exist)
{
now += 5;
ACE_Time_Value tv (5, 0);
orb->run (tv);
}
if (do_shutdown)
{
CORBA::Object_var object =
orb->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
server->shutdown ();
}
orb->shutdown ();
worker.thr_mgr ()->wait ();
orb->destroy ();
if (worker.got_object_not_exist () != expected_object_not_exist)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t)client: test failed.\n"),
1);
}
else
{
ACE_DEBUG ((LM_DEBUG, "(%P|%t)client: test passed.\n"));
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught in main:");
return 1;
}
return 0;
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:64,代码来源:client.cpp
示例13: cmd_reset
int cmd_reset(int argc, const char **argv, const char *prefix)
{
int reset_type = NONE, update_ref_status = 0, quiet = 0;
int patch_mode = 0, unborn;
const char *rev;
unsigned char sha1[20];
const char **pathspec = NULL;
const struct option options[] = {
OPT__QUIET(&quiet, N_("be quiet, only report errors")),
OPT_SET_INT(0, "mixed", &reset_type,
N_("reset HEAD and index"), MIXED),
OPT_SET_INT(0, "soft", &reset_type, N_("reset only HEAD"), SOFT),
OPT_SET_INT(0, "hard", &reset_type,
N_("reset HEAD, index and working tree"), HARD),
OPT_SET_INT(0, "merge", &reset_type,
N_("reset HEAD, index and working tree"), MERGE),
OPT_SET_INT(0, "keep", &reset_type,
N_("reset HEAD but keep local changes"), KEEP),
OPT_BOOLEAN('p', "patch", &patch_mode, N_("select hunks interactively")),
OPT_END()
};
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, git_reset_usage,
PARSE_OPT_KEEP_DASHDASH);
pathspec = parse_args(argv, prefix, &rev);
unborn = !strcmp(rev, "HEAD") && get_sha1("HEAD", sha1);
if (unborn) {
/* reset on unborn branch: treat as reset to empty tree */
hashcpy(sha1, EMPTY_TREE_SHA1_BIN);
} else if (!pathspec) {
struct commit *commit;
if (get_sha1_committish(rev, sha1))
die(_("Failed to resolve '%s' as a valid revision."), rev);
commit = lookup_commit_reference(sha1);
if (!commit)
die(_("Could not parse object '%s'."), rev);
hashcpy(sha1, commit->object.sha1);
} else {
struct tree *tree;
if (get_sha1_treeish(rev, sha1))
die(_("Failed to resolve '%s' as a valid tree."), rev);
tree = parse_tree_indirect(sha1);
if (!tree)
die(_("Could not parse object '%s'."), rev);
hashcpy(sha1, tree->object.sha1);
}
if (patch_mode) {
if (reset_type != NONE)
die(_("--patch is incompatible with --{hard,mixed,soft}"));
return run_add_interactive(sha1_to_hex(sha1), "--patch=reset", pathspec);
}
/* git reset tree [--] paths... can be used to
* load chosen paths from the tree into the index without
* affecting the working tree nor HEAD. */
if (pathspec) {
if (reset_type == MIXED)
warning(_("--mixed with paths is deprecated; use 'git reset -- <paths>' instead."));
else if (reset_type != NONE)
die(_("Cannot do %s reset with paths."),
_(reset_type_names[reset_type]));
}
if (reset_type == NONE)
reset_type = MIXED; /* by default */
if (reset_type != SOFT && reset_type != MIXED)
setup_work_tree();
if (reset_type == MIXED && is_bare_repository())
die(_("%s reset is not allowed in a bare repository"),
_(reset_type_names[reset_type]));
/* Soft reset does not touch the index file nor the working tree
* at all, but requires them in a good order. Other resets reset
* the index file to the tree object we are switching to. */
if (reset_type == SOFT || reset_type == KEEP)
die_if_unmerged_cache(reset_type);
if (reset_type != SOFT) {
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
int newfd = hold_locked_index(lock, 1);
if (reset_type == MIXED) {
if (read_from_tree(pathspec, sha1))
return 1;
} else {
int err = reset_index(sha1, reset_type, quiet);
if (reset_type == KEEP && !err)
err = reset_index(sha1, MIXED, quiet);
if (err)
die(_("Could not reset index file to revision '%s'."), rev);
}
if (reset_type == MIXED) { /* Report what has not been updated. */
int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
refresh_index(&the_index, flags, NULL, NULL,
_("Unstaged changes after reset:"));
//.........这里部分代码省略.........
开发者ID:ANKIT-KS,项目名称:git,代码行数:101,代码来源:reset.c
示例14: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the POA.\n"),
1);
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (parse_args (argc, argv) != 0)
return 1;
Manager manager_impl (orb.in ());
PortableServer::ObjectId_var id =
root_poa->activate_object (&manager_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
Test::Manager_var manager =
Test::Manager::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (manager.in ());
// If the ior_output_file exists, output the ior to it
FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
poa_manager->activate ();
orb->run ();
// ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:66,代码来源:blocking_server.cpp
示例15: ACE_TMAIN
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int status = 0;
try
{
ACE_DEBUG((LM_INFO,"(%P|%t) %T publisher main\n"));
::DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv);
// let the Service_Participant (in above line) strip out -DCPSxxx parameters
// and then get application specific parameters.
parse_args (argc, argv);
::Xyz::FooTypeSupport_var fts(new ::Xyz::FooTypeSupportImpl);
::DDS::DomainParticipant_var dp =
dpf->create_participant(MY_DOMAIN,
PARTICIPANT_QOS_DEFAULT,
::DDS::DomainParticipantListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dp.in ()))
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) create_participant failed.\n")));
return 1 ;
}
if (::DDS::RETCODE_OK != fts->register_type(dp.in (), MY_TYPE))
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Failed to register the FooTypeSupport.")));
return 1;
}
::DDS::TopicQos topic_qos;
dp->get_default_topic_qos(topic_qos);
topic_qos.resource_limits.max_samples_per_instance =
max_samples_per_instance ;
topic_qos.history.depth = history_depth;
::DDS::Topic_var topic =
dp->create_topic (MY_TOPIC,
MY_TYPE,
topic_qos,
::DDS::TopicListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (topic.in ()))
{
return 1 ;
}
// Create the publisher
::DDS::Publisher_var pub =
dp->create_publisher(PUBLISHER_QOS_DEFAULT,
::DDS::PublisherListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (pub.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT("(%P|%t) create_publisher failed.\n")),
1);
}
// Create the datawriters
::DDS::DataWriterQos dw_qos;
pub->get_default_datawriter_qos (dw_qos);
dw_qos.history.depth = history_depth ;
dw_qos.resource_limits.max_samples_per_instance =
max_samples_per_instance ;
dw_qos.liveliness.lease_duration.sec = LEASE_DURATION_SEC ;
dw_qos.liveliness.lease_duration.nanosec = 0 ;
::DDS::DataWriter_var dw = pub->create_datawriter(topic.in (),
dw_qos,
::DDS::DataWriterListener::_nil(),
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
if (CORBA::is_nil (dw.in ()))
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) create_datawriter failed.\n")));
return 1 ;
}
// ensure that the connection and association has been fully established
ACE_OS::sleep(2); //TBD remove this kludge when the transport is fixed.
// Indicate that the publisher is ready
FILE* writers_ready = ACE_OS::fopen (pub_ready_filename.c_str (), ACE_TEXT("w"));
if (writers_ready == 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: Unable to create publisher ready file\n")));
//.........这里部分代码省略.........
开发者ID:CapXilinx,项目名称:OpenDDS,代码行数:101,代码来源:publisher.cpp
示例16: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the POA.\n"),
1);
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
// Policies for the childPOA to be created.
CORBA::PolicyList policies (1);
policies.length (1);
CORBA::Any pol;
pol <<= BiDirPolicy::BOTH;
policies[0] =
orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
pol);
// Create POA as child of RootPOA with the above policies. This POA
// will receive request in the same connection in which it sent
// the request
PortableServer::POA_var child_poa =
root_poa->create_POA ("childPOA",
poa_manager.in (),
policies);
// Creation of childPOA is over. Destroy the Policy objects.
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
policies[i]->destroy ();
}
poa_manager->activate ();
if (parse_args (argc, argv) != 0)
return 1;
Simple_Server_i *server_impl = 0;
ACE_NEW_THROW_EX (server_impl,
Simple_Server_i (orb.in (),
no_iterations),
CORBA::NO_MEMORY ());
PortableServer::ServantBase_var owner_transfer (server_impl);
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId ("simple_server");
child_poa->activate_object_with_id (id.in (),
server_impl);
CORBA::Object_var obj =
child_poa->id_to_reference (id.in ());
CORBA::String_var ior =
orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));
// If the ior_output_file exists, output the ior to it
if (ior_output_file != 0)
{
FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
// Run the event loop
orb->run ();
ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
root_poa->destroy (1, 1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return 1;
}
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:server.cpp
示例17: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int priority =
(ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
+ ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
priority);
priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
priority);
// Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
priority,
ACE_SCOPE_PROCESS)) != 0)
{
if (ACE_OS::last_error () == EPERM)
{
ACE_DEBUG ((LM_DEBUG,
"server (%P|%t): user is not superuser, "
"test runs in time-shared class\n"));
}
else
ACE_ERROR ((LM_ERROR,
"server (%P|%t): sched_params failed\n"));
}
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the POA.\n"),
1);
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (parse_args (argc, argv) != 0)
return 1;
Roundtrip *roundtrip_impl;
ACE_NEW_RETURN (roundtrip_impl,
Roundtrip (orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(roundtrip_impl);
Test::Roundtrip_var roundtrip =
roundtrip_impl->_this ();
CORBA::String_var ior =
orb->object_to_string (roundtrip.in ());
// If the ior_output_file exists, output the ior to it
FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
poa_manager->activate ();
Server_Task server_task (orb.in ());
if (server_task.activate (THR_NEW_LWP | THR_JOINABLE,
nthreads) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot activate server threads\n"),
|
请发表评论