diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/arm/arm_api.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/arm/arm_api.c')
-rw-r--r-- | src/arm/arm_api.c | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 0db9e5c3e..cc75e46da 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -141,8 +141,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
141 | "Received confirmation for service shutdown.\n"); | 141 | "Received confirmation for service shutdown.\n"); |
142 | #endif | 142 | #endif |
143 | shutdown_ctx->confirmed = GNUNET_YES; | 143 | shutdown_ctx->confirmed = GNUNET_YES; |
144 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 144 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, |
145 | &service_shutdown_handler, | ||
146 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); | 145 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); |
147 | break; | 146 | break; |
148 | default: /* Fall through */ | 147 | default: /* Fall through */ |
@@ -206,9 +205,8 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
206 | return 0; /* client disconnected */ | 205 | return 0; /* client disconnected */ |
207 | } | 206 | } |
208 | 207 | ||
209 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 208 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, |
210 | &service_shutdown_handler, shutdown_ctx, | 209 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); |
211 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
212 | shutdown_ctx->cancel_task = | 210 | shutdown_ctx->cancel_task = |
213 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 211 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
214 | (shutdown_ctx->timeout), | 212 | (shutdown_ctx->timeout), |
@@ -246,11 +244,9 @@ arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, | |||
246 | shutdown_ctx->sock = sock; | 244 | shutdown_ctx->sock = sock; |
247 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 245 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
248 | GNUNET_CLIENT_notify_transmit_ready (sock, | 246 | GNUNET_CLIENT_notify_transmit_ready (sock, |
249 | sizeof (struct | 247 | sizeof (struct GNUNET_MessageHeader), |
250 | GNUNET_MessageHeader), | 248 | timeout, GNUNET_YES, &write_shutdown, |
251 | timeout, | 249 | shutdown_ctx); |
252 | GNUNET_YES, | ||
253 | &write_shutdown, shutdown_ctx); | ||
254 | } | 250 | } |
255 | 251 | ||
256 | 252 | ||
@@ -378,16 +374,16 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
378 | "gnunet-service-arm"); | 374 | "gnunet-service-arm"); |
379 | #endif | 375 | #endif |
380 | if (GNUNET_OK != | 376 | if (GNUNET_OK != |
381 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, | 377 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "PREFIX", |
382 | "arm", "PREFIX", &loprefix)) | 378 | &loprefix)) |
383 | loprefix = GNUNET_strdup (""); | 379 | loprefix = GNUNET_strdup (""); |
384 | if (GNUNET_OK != | 380 | if (GNUNET_OK != |
385 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, | 381 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "OPTIONS", |
386 | "arm", "OPTIONS", &lopostfix)) | 382 | &lopostfix)) |
387 | lopostfix = GNUNET_strdup (""); | 383 | lopostfix = GNUNET_strdup (""); |
388 | if (GNUNET_OK != | 384 | if (GNUNET_OK != |
389 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, | 385 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "BINARY", |
390 | "arm", "BINARY", &binary)) | 386 | &binary)) |
391 | { | 387 | { |
392 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 388 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
393 | _ | 389 | _ |
@@ -401,8 +397,8 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
401 | return; | 397 | return; |
402 | } | 398 | } |
403 | if (GNUNET_OK != | 399 | if (GNUNET_OK != |
404 | GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, | 400 | GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, "arm", "CONFIG", |
405 | "arm", "CONFIG", &config)) | 401 | &config)) |
406 | { | 402 | { |
407 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 403 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
408 | _ | 404 | _ |
@@ -519,10 +515,9 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
519 | * @param type type of the request | 515 | * @param type type of the request |
520 | */ | 516 | */ |
521 | static void | 517 | static void |
522 | change_service (struct GNUNET_ARM_Handle *h, | 518 | change_service (struct GNUNET_ARM_Handle *h, const char *service_name, |
523 | const char *service_name, | 519 | struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, |
524 | struct GNUNET_TIME_Relative timeout, | 520 | void *cb_cls, uint16_t type) |
525 | GNUNET_ARM_Callback cb, void *cb_cls, uint16_t type) | ||
526 | { | 521 | { |
527 | struct RequestContext *sctx; | 522 | struct RequestContext *sctx; |
528 | size_t slen; | 523 | size_t slen; |
@@ -539,9 +534,10 @@ change_service (struct GNUNET_ARM_Handle *h, | |||
539 | } | 534 | } |
540 | #if DEBUG_ARM | 535 | #if DEBUG_ARM |
541 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
542 | (type == GNUNET_MESSAGE_TYPE_ARM_START) | 537 | (type == |
543 | ? _("Requesting start of service `%s'.\n") | 538 | GNUNET_MESSAGE_TYPE_ARM_START) ? |
544 | : _("Requesting termination of service `%s'.\n"), service_name); | 539 | _("Requesting start of service `%s'.\n") : |
540 | _("Requesting termination of service `%s'.\n"), service_name); | ||
545 | #endif | 541 | #endif |
546 | sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen); | 542 | sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen); |
547 | sctx->h = h; | 543 | sctx->h = h; |
@@ -555,15 +551,14 @@ change_service (struct GNUNET_ARM_Handle *h, | |||
555 | msg->type = htons (sctx->type); | 551 | msg->type = htons (sctx->type); |
556 | memcpy (&msg[1], service_name, slen); | 552 | memcpy (&msg[1], service_name, slen); |
557 | if (GNUNET_OK != | 553 | if (GNUNET_OK != |
558 | GNUNET_CLIENT_transmit_and_get_response (sctx->h->client, | 554 | GNUNET_CLIENT_transmit_and_get_response (sctx->h->client, msg, |
559 | msg, | ||
560 | GNUNET_TIME_absolute_get_remaining | 555 | GNUNET_TIME_absolute_get_remaining |
561 | (sctx->timeout), GNUNET_YES, | 556 | (sctx->timeout), GNUNET_YES, |
562 | &handle_response, sctx)) | 557 | &handle_response, sctx)) |
563 | { | 558 | { |
564 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 559 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
565 | (type == GNUNET_MESSAGE_TYPE_ARM_START) | 560 | (type == |
566 | ? | 561 | GNUNET_MESSAGE_TYPE_ARM_START) ? |
567 | _ | 562 | _ |
568 | ("Error while trying to transmit request to start `%s' to ARM\n") | 563 | ("Error while trying to transmit request to start `%s' to ARM\n") |
569 | : | 564 | : |
@@ -590,8 +585,7 @@ change_service (struct GNUNET_ARM_Handle *h, | |||
590 | * @param cb_cls closure for callback | 585 | * @param cb_cls closure for callback |
591 | */ | 586 | */ |
592 | void | 587 | void |
593 | GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | 588 | GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, const char *service_name, |
594 | const char *service_name, | ||
595 | struct GNUNET_TIME_Relative timeout, | 589 | struct GNUNET_TIME_Relative timeout, |
596 | GNUNET_ARM_Callback cb, void *cb_cls) | 590 | GNUNET_ARM_Callback cb, void *cb_cls) |
597 | { | 591 | { |
@@ -616,8 +610,8 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | |||
616 | sctx->cls = cb_cls; | 610 | sctx->cls = cb_cls; |
617 | sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 611 | sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
618 | memcpy (&sctx[1], service_name, slen); | 612 | memcpy (&sctx[1], service_name, slen); |
619 | GNUNET_CLIENT_service_test ("arm", | 613 | GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report, |
620 | h->cfg, timeout, &arm_service_report, sctx); | 614 | sctx); |
621 | return; | 615 | return; |
622 | } | 616 | } |
623 | if (h->client == NULL) | 617 | if (h->client == NULL) |
@@ -670,8 +664,7 @@ arm_shutdown_callback (void *cls, int reason) | |||
670 | * @param cb_cls closure for callback | 664 | * @param cb_cls closure for callback |
671 | */ | 665 | */ |
672 | void | 666 | void |
673 | GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, | 667 | GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, const char *service_name, |
674 | const char *service_name, | ||
675 | struct GNUNET_TIME_Relative timeout, | 668 | struct GNUNET_TIME_Relative timeout, |
676 | GNUNET_ARM_Callback cb, void *cb_cls) | 669 | GNUNET_ARM_Callback cb, void *cb_cls) |
677 | { | 670 | { |