| 1 | /* | |
| 2 | * Portions of this file Copyright 1999-2005 University of Chicago | |
| 3 | * Portions of this file Copyright 1999-2005 The University of Southern California. | |
| 4 | * | |
| 5 | * This file or a portion of this file is licensed under the | |
| 6 | * terms of the Globus Toolkit Public License, found at | |
| 7 | * http://www.globus.org/toolkit/download/license.html. | |
| 8 | * If you redistribute this file, with or without | |
| 9 | * modifications, you must include this notice in the file. | |
| 10 | */ | |
| 11 | ||
| 12 | ||
| 13 | #include "globus_handler.h" | |
| 14 | #include "globus_soap_message.h" | |
| 15 | #include "globus_soap_message_handle.h" | |
| 16 | #include "version.h" | |
| 17 | ||
| 18 | void | |
| 19 | globus_handler_debug_request_invoke( | |
| 20 | globus_handler_session_descriptor_t session, | |
| 21 | globus_soap_message_handle_t message_handle, | |
| 22 | globus_result_t result) | |
| 23 | 0 | { |
| 24 | 0 | char * buffer; |
| 25 | 0 | size_t length; |
| 26 | 0 | globus_abstime_t current_time; |
| 27 | 0 | char buf[256]; |
| 28 | ||
| 29 | 0 | result = globus_soap_message_get_marked_buffers( |
| 30 | message_handle, | |
| 31 | NULL, NULL, | |
| 32 | &buffer, | |
| 33 | &length); | |
| 34 | 0 | if(result == GLOBUS_SUCCESS) |
| 35 | { | |
| 36 | 0 | GlobusTimeAbstimeGetCurrent(current_time); |
| 37 | 0 | sprintf(buf, "%lu.%.9lu", |
| 38 | (unsigned long) current_time.tv_sec, | |
| 39 | (unsigned long) current_time.tv_nsec); | |
| 40 | 0 | fprintf(stderr, |
| 41 | "\n=== REQUEST MESSAGE (length %lu) (time %s) ===\n", | |
| 42 | (unsigned long) length, buf); | |
| 43 | 0 | fwrite(buffer, length, 1, stderr); |
| 44 | 0 | fprintf(stderr, |
| 45 | "\n----------------------------------------------\n"); | |
| 46 | } | |
| 47 | ||
| 48 | 0 | globus_handler_finished(session, result); |
| 49 | return; | |
| 50 | } | |
| 51 | ||
| 52 | void | |
| 53 | globus_handler_debug_response_invoke( | |
| 54 | globus_handler_session_descriptor_t session, | |
| 55 | globus_soap_message_handle_t message_handle, | |
| 56 | globus_result_t result) | |
| 57 | 0 | { |
| 58 | 0 | char * buffer; |
| 59 | 0 | size_t length; |
| 60 | 0 | globus_abstime_t current_time; |
| 61 | 0 | char buf[256]; |
| 62 | ||
| 63 | 0 | result = globus_soap_message_get_marked_buffers( |
| 64 | message_handle, | |
| 65 | NULL, NULL, | |
| 66 | &buffer, | |
| 67 | &length); | |
| 68 | 0 | if(result == GLOBUS_SUCCESS) |
| 69 | { | |
| 70 | 0 | GlobusTimeAbstimeGetCurrent(current_time); |
| 71 | 0 | sprintf(buf, "%lu.%.9lu", |
| 72 | (unsigned long) current_time.tv_sec, | |
| 73 | (unsigned long) current_time.tv_nsec); | |
| 74 | 0 | fprintf(stderr, |
| 75 | "\n=== RESPONSE MESSAGE (length %lu) (time %s) ===\n", | |
| 76 | (unsigned long) length, buf); | |
| 77 | 0 | fwrite(buffer, length, 1, stderr); |
| 78 | 0 | fprintf(stderr, |
| 79 | "\n----------------------------------------------\n"); | |
| 80 | } | |
| 81 | ||
| 82 | 0 | globus_handler_finished(session, result); |
| 83 | return; | |
| 84 | } | |
| 85 | ||
| 86 | globus_handler_descriptor_t globus_l_handler_debug_descriptor = | |
| 87 | { | |
| 88 | NULL, | |
| 89 | globus_handler_debug_request_invoke, | |
| 90 | NULL, NULL, | |
| 91 | globus_handler_debug_response_invoke, | |
| 92 | NULL, NULL, NULL | |
| 93 | }; | |
| 94 | ||
| 95 | int | |
| 96 | globus_l_handler_debug_activate(void); | |
| 97 | ||
| 98 | int | |
| 99 | globus_l_handler_debug_deactivate(void); | |
| 100 | ||
| 101 | ||
| 102 | GlobusExtensionDefineModule(globus_handler_debug) = | |
| 103 | { | |
| 104 | "debug", | |
| 105 | globus_l_handler_debug_activate, | |
| 106 | globus_l_handler_debug_deactivate, | |
| 107 | NULL, | |
| 108 | NULL, | |
| 109 | &local_version | |
| 110 | }; | |
| 111 | ||
| 112 | int | |
| 113 | globus_l_handler_debug_activate(void) | |
| 114 | 0 | { |
| 115 | 0 | int res = 0; |
| 116 | ||
| 117 | 0 | res = globus_extension_registry_add( |
| 118 | GLOBUS_HANDLER_REGISTRY, | |
| 119 | "globus_handler_debug", | |
| 120 | GlobusExtensionMyModule(globus_handler_debug), | |
| 121 | &globus_l_handler_debug_descriptor); | |
| 122 | 0 | if(res != GLOBUS_SUCCESS) |
| 123 | { | |
| 124 | 0 | goto exit; |
| 125 | } | |
| 126 | ||
| 127 | exit: | |
| 128 | 0 | return res; |
| 129 | } | |
| 130 | ||
| 131 | int | |
| 132 | globus_l_handler_debug_deactivate(void) | |
| 133 | 0 | { |
| 134 | 0 | globus_extension_registry_remove( |
| 135 | GLOBUS_HANDLER_REGISTRY, | |
| 136 | "globus_handler_debug"); | |
| 137 | ||
| 138 | 0 | return 0; |