This section defines operations for registering callouts. Callouts may be registered either through a configuration file or through calls to globus_callout_register.
|
|||||||||
|
Read callout configuration from file. This function read a configuration file with the following format:
Definition at line 301 of file globus_callout.c. References globus_i_callout_data_s::file, GLOBUS_CALLOUT_ERRNO_ERROR_RESULT, GLOBUS_CALLOUT_ERROR_OPENING_CONF_FILE, GLOBUS_CALLOUT_ERROR_PARSING_CONF_FILE, GLOBUS_CALLOUT_ERROR_RESULT, GLOBUS_CALLOUT_ERROR_WITH_HASHTABLE, globus_callout_handle_t, GLOBUS_CALLOUT_MALLOC_ERROR, globus_i_callout_data_t, GLOBUS_I_CALLOUT_DEBUG_ENTER, GLOBUS_I_CALLOUT_DEBUG_EXIT, globus_l_callout_data_free(), globus_i_callout_data_s::next, globus_i_callout_data_s::symbol, globus_i_callout_handle_s::symbol_htable, and globus_i_callout_data_s::type.
00304 {
00305 FILE * conf_file;
00306 char buffer[512];
00307 char type[128];
00308 char library[256];
00309 char symbol[128];
00310 char * flavor_start;
00311 char * pound;
00312 int index;
00313 int rc;
00314 globus_result_t result;
00315 globus_i_callout_data_t * datum = NULL;
00316 globus_i_callout_data_t * existing_datum;
00317
00318
00319 static char * _function_name_ =
00320 "globus_callout_read_config";
00321
00322 GLOBUS_I_CALLOUT_DEBUG_ENTER;
00323
00324 conf_file = fopen(filename, "r");
00325
00326 if(conf_file == NULL)
00327 {
00328 GLOBUS_CALLOUT_ERRNO_ERROR_RESULT(
00329 result,
00330 GLOBUS_CALLOUT_ERROR_OPENING_CONF_FILE,
00331 ("filename %s", filename));
00332 goto error_exit;
00333 }
00334
00335 while(fgets(buffer,512,conf_file))
00336 {
00337 /* strip any comments */
00338
00339 pound = strchr(buffer, '#');
00340
00341 if(pound != NULL)
00342 {
00343 *pound = '\0';
00344 }
00345
00346 /* strip white space from start */
00347
00348 index = 0;
00349
00350 while(buffer[index] == '\t' || buffer[index] == ' ')
00351 {
00352 index++;
00353 }
00354
00355 /* if blank line continue */
00356
00357 if(buffer[index] == '\0' || buffer[index] == '\n')
00358 {
00359 continue;
00360 }
00361
00362 if(sscanf(&buffer[index],"%127s%255s%127s",type,library,symbol) < 3)
00363 {
00364 GLOBUS_CALLOUT_ERROR_RESULT(
00365 result,
00366 GLOBUS_CALLOUT_ERROR_PARSING_CONF_FILE,
00367 ("malformed line: %s", &buffer[index]));
00368 goto error_exit;
00369 }
00370
00371 /* push values into hash */
00372
00373 datum = malloc(sizeof(globus_i_callout_data_t));
00374
00375 if(datum == NULL)
00376 {
00377 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00378 goto error_exit;
00379 }
00380
00381 memset(datum,'\0',sizeof(globus_i_callout_data_t));
00382
00383 /* check if library is flavored already */
00384
00385 if((flavor_start = strrchr(library,'_')) &&
00386 (strstr(flavor_start, "32") || strstr(flavor_start, "64")))
00387 {
00388 datum->file = strdup(library);
00389
00390 if(datum->file == NULL)
00391 {
00392 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00393 goto error_exit;
00394 }
00395 }
00396 else
00397 {
00398 datum->file = malloc(strlen(library) + 2 + strlen(flavor));
00399 if(datum->file == NULL)
00400 {
00401 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00402 goto error_exit;
00403 }
00404 datum->file[0] = '\0';
00405 strcat(datum->file, library);
00406 strcat(datum->file, "_");
00407 strcat(datum->file, flavor);
00408 }
00409
00410 datum->symbol = strdup(symbol);
00411
00412 if(datum->symbol == NULL)
00413 {
00414 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00415 goto error_exit;
00416 }
00417
00418 datum->type = strdup(type);
00419
00420 if(datum->type == NULL)
00421 {
00422 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00423 goto error_exit;
00424 }
00425
00426 if((rc = globus_hashtable_insert(&handle->symbol_htable,
00427 datum->type,
00428 datum)) == -1)
00429 {
00430 existing_datum = globus_hashtable_lookup(&handle->symbol_htable,
00431 datum->type);
00432 while(existing_datum->next)
00433 {
00434 existing_datum = existing_datum->next;
00435 }
00436 existing_datum->next = datum;
00437 }
00438 else if(rc < 0)
00439 {
00440 GLOBUS_CALLOUT_ERROR_RESULT(
00441 result,
00442 GLOBUS_CALLOUT_ERROR_WITH_HASHTABLE,
00443 ("globus_hashtable_insert retuned %d", rc));
00444 goto error_exit;
00445 }
00446 }
00447
00448 fclose(conf_file);
00449
00450 GLOBUS_I_CALLOUT_DEBUG_EXIT;
00451
00452 return GLOBUS_SUCCESS;
00453
00454 error_exit:
00455
00456 if(datum != NULL)
00457 {
00458 globus_l_callout_data_free(datum);
00459 }
00460
00461 if(conf_file != NULL)
00462 {
00463 fclose(conf_file);
00464 }
00465
00466 return result;
00467 }/*globus_callout_read_config*/
|
|
|||||||||||||||
|
Register callout configuration. This function registers a callout type in the given handle.
Definition at line 490 of file globus_callout.c. References globus_i_callout_data_s::file, GLOBUS_CALLOUT_ERROR_RESULT, GLOBUS_CALLOUT_ERROR_WITH_HASHTABLE, globus_callout_handle_t, GLOBUS_CALLOUT_MALLOC_ERROR, globus_i_callout_data_t, GLOBUS_I_CALLOUT_DEBUG_ENTER, GLOBUS_I_CALLOUT_DEBUG_EXIT, globus_l_callout_data_free(), globus_i_callout_data_s::next, globus_i_callout_data_s::symbol, globus_i_callout_handle_s::symbol_htable, and globus_i_callout_data_s::type.
00495 {
00496 int rc;
00497 globus_result_t result;
00498 globus_i_callout_data_t * datum = NULL;
00499 globus_i_callout_data_t * existing_datum;
00500 char * flavor_start;
00501
00502 static char * _function_name_ =
00503 "globus_callout_register";
00504
00505 GLOBUS_I_CALLOUT_DEBUG_ENTER;
00506
00507
00508 /* push values into hash */
00509
00510 datum = malloc(sizeof(globus_i_callout_data_t));
00511
00512 if(datum == NULL)
00513 {
00514 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00515 goto error_exit;
00516 }
00517
00518 memset(datum,'\0',sizeof(globus_i_callout_data_t));
00519
00520 if((flavor_start = strrchr(library,'_')) &&
00521 (strstr(flavor_start, "32") || strstr(flavor_start, "64")))
00522 {
00523 datum->file = strdup(library);
00524
00525 if(datum->file == NULL)
00526 {
00527 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00528 goto error_exit;
00529 }
00530 }
00531 else
00532 {
00533 datum->file = malloc(strlen(library) + 2 + strlen(flavor));
00534 if(datum->file == NULL)
00535 {
00536 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00537 goto error_exit;
00538 }
00539 datum->file[0] = '\0';
00540 strcat(datum->file, library);
00541 strcat(datum->file, "_");
00542 strcat(datum->file, flavor);
00543 }
00544
00545 datum->symbol = strdup(symbol);
00546
00547 if(datum->symbol == NULL)
00548 {
00549 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00550 goto error_exit;
00551 }
00552
00553 datum->type = strdup(type);
00554
00555 if(datum->type == NULL)
00556 {
00557 GLOBUS_CALLOUT_MALLOC_ERROR(result);
00558 goto error_exit;
00559 }
00560
00561 if((rc = globus_hashtable_insert(&handle->symbol_htable,
00562 datum->type,
00563 datum)) == -1)
00564 {
00565 existing_datum = globus_hashtable_lookup(&handle->symbol_htable,
00566 datum->type);
00567 while(existing_datum->next)
00568 {
00569 existing_datum = existing_datum->next;
00570 }
00571 existing_datum->next = datum;
00572 }
00573 else if(rc < 0)
00574 {
00575 GLOBUS_CALLOUT_ERROR_RESULT(
00576 result,
00577 GLOBUS_CALLOUT_ERROR_WITH_HASHTABLE,
00578 ("globus_hashtable_insert retuned %d", rc));
00579 goto error_exit;
00580 }
00581
00582 GLOBUS_I_CALLOUT_DEBUG_EXIT;
00583
00584 return GLOBUS_SUCCESS;
00585
00586 error_exit:
00587
00588 GLOBUS_I_CALLOUT_DEBUG_EXIT;
00589
00590 if(datum != NULL)
00591 {
00592 globus_l_callout_data_free(datum);
00593 }
00594
00595 return result;
00596 }/*globus_callout_register*/
|
about globus |
grid research |
globus toolkit |
software development
Comments? webmaster@globus.org