16 "vrpn_Auxiliary_Logger Logging_request");
18 "vrpn_Auxiliary_Logger Logging_response");
20 "vrpn_Auxiliary_Logger Logging_status_request");
35 vrpn_int32
type,
const char *local_in_logfile_name,
36 const char *local_out_logfile_name,
const char *remote_in_logfile_name,
37 const char *remote_out_logfile_name)
45 if (local_in_logfile_name) {
46 lil =
static_cast<vrpn_int32
>(strlen(local_in_logfile_name));
49 if (local_out_logfile_name) {
50 lol =
static_cast<vrpn_int32
>(strlen(local_out_logfile_name));
53 if (remote_in_logfile_name) {
54 ril =
static_cast<vrpn_int32
>(strlen(remote_in_logfile_name));
57 if (remote_out_logfile_name) {
58 rol =
static_cast<vrpn_int32
>(strlen(remote_out_logfile_name));
63 static_cast<vrpn_int32
>(4 *
sizeof(lil) + lil + lol + ril + rol);
64 std::vector<char> buf;
68 fprintf(stderr,
"vrpn_Auxiliary_Logger::pack_log_message_of_type(): "
78 char *bpp = buf.data();
80 vrpn_int32 bufleft = bufsize;
86 vrpn_buffer(bp, &bufleft, local_in_logfile_name, lil);
89 vrpn_buffer(bp, &bufleft, local_out_logfile_name, lol);
92 vrpn_buffer(bp, &bufleft, remote_in_logfile_name, ril);
95 vrpn_buffer(bp, &bufleft, remote_out_logfile_name, rol);
106 const char *buf, vrpn_int32 buflen,
char **local_in_logfile_name,
107 char **local_out_logfile_name,
char **remote_in_logfile_name,
108 char **remote_out_logfile_name)
110 const char *bufptr = buf;
115 vrpn_int32 localInNameLen, localOutNameLen, remoteInNameLen,
117 if (
static_cast<size_t>(buflen) < 4 *
sizeof(localInNameLen)) {
118 fprintf(stderr,
"vrpn_Auxiliary_Logger::unpack_log_message_from_buffer:"
119 " Buffer too small for lengths.\n");
134 int size = 4 *
sizeof(localInNameLen) + localInNameLen + localOutNameLen +
135 remoteInNameLen + remoteOutNameLen;
136 if (buflen != size) {
137 fprintf(stderr,
"vrpn_Auxiliary_Logger::unpack_log_message_from_buffer:"
138 " Buffer size incorrect\n");
141 (*local_in_logfile_name) = NULL;
142 (*local_out_logfile_name) = NULL;
143 (*remote_in_logfile_name) = NULL;
144 (*remote_out_logfile_name) = NULL;
145 if (localInNameLen > 0) {
146 try { (*local_in_logfile_name) =
new char[localInNameLen + 1]; }
148 fprintf(stderr,
"vrpn_Auxiliary_Logger::unpack_log_message_from_"
149 "buffer: Out of memory\n");
152 memcpy(*local_in_logfile_name, bufptr, localInNameLen);
153 (*local_in_logfile_name)[localInNameLen] =
'\0';
154 bufptr += localInNameLen;
156 (*local_in_logfile_name) = NULL;
158 if (localOutNameLen > 0) {
159 try { (*local_out_logfile_name) =
new char[localOutNameLen + 1]; }
161 fprintf(stderr,
"vrpn_Auxiliary_Logger::unpack_log_message_from_"
162 "buffer: Out of memory\n");
165 memcpy(*local_out_logfile_name, bufptr, localOutNameLen);
166 (*local_out_logfile_name)[localOutNameLen] =
'\0';
167 bufptr += localOutNameLen;
169 (*local_out_logfile_name) = NULL;
171 if (remoteInNameLen > 0) {
172 try { (*remote_in_logfile_name) =
new char[remoteInNameLen + 1]; }
174 fprintf(stderr,
"vrpn_Auxiliary_Logger::unpack_log_message_from_"
175 "buffer: Out of memory\n");
178 memcpy(*remote_in_logfile_name, bufptr, remoteInNameLen);
179 (*remote_in_logfile_name)[remoteInNameLen] =
'\0';
180 bufptr += remoteInNameLen;
182 (*remote_in_logfile_name) = NULL;
184 if (remoteOutNameLen > 0) {
185 try { (*remote_out_logfile_name) =
new char[remoteOutNameLen + 1]; }
187 fprintf(stderr,
"vrpn_Auxiliary_Logger::unpack_log_message_from_"
188 "buffer: Out of memory\n");
191 memcpy(*remote_out_logfile_name, bufptr, remoteOutNameLen);
192 (*remote_out_logfile_name)[remoteOutNameLen] =
'\0';
193 bufptr += remoteOutNameLen;
195 (*remote_out_logfile_name) = NULL;
209 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server::vrpn_Auxiliary_Logger_"
210 "Server: can't register dropped last connection "
218 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server::vrpn_Auxiliary_Logger_"
219 "Server: can't register dropped last connection "
228 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server::vrpn_Auxiliary_Logger_"
229 "Server: can't register logging request handler\n");
237 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server::vrpn_Auxiliary_Logger_"
238 "Server: can't register logging-status request "
281 char *localInName = NULL, *localOutName = NULL, *remoteInName = NULL,
282 *remoteOutName = NULL;
286 &localInName, &localOutName,
287 &remoteInName, &remoteOutName)) {
288 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server::static_handle_request_"
289 "logging: Could not unpack buffer\n");
299 delete[] localInName;
301 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server::static_handle_request_logging: delete failed\n");
307 delete[] localOutName;
309 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server::static_handle_request_logging: delete failed\n");
315 delete[] remoteInName;
317 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server::static_handle_request_logging: delete failed\n");
323 delete[] remoteOutName;
325 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server::static_handle_request_logging: delete failed\n");
333 const char *logger_name,
const char *connection_to_log,
vrpn_Connection *c)
339 if ((connection_to_log == NULL) || (strlen(connection_to_log) == 0)) {
340 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::vrpn_Auxiliary_"
341 "Logger_Server_Generic: Empty logging name passed "
356 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::~vrpn_Auxiliary_Logger_Server_Generic: delete failed\n");
366 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::~vrpn_Auxiliary_Logger_Server_Generic: delete failed\n");
380 const char *local_in_logfile_name,
const char *local_out_logfile_name,
381 const char *remote_in_logfile_name,
const char *remote_out_logfile_name)
397 const char *where_at;
398 if ((where_at = strrchr(cname,
'@')) != NULL) {
399 cname = where_at + 1;
405 where_at, local_in_logfile_name, local_out_logfile_name,
406 remote_in_logfile_name, remote_out_logfile_name, NULL,
true);
411 "(files already exist?)",
418 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::handle_request_logging: delete failed\n");
428 remote_in_logfile_name, remote_out_logfile_name);
444 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::handle_request_logging_status: delete failed\n");
452 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::handle_request_logging_status: delete failed\n");
460 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::handle_request_logging_status: delete failed\n");
468 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::handle_request_logging_status: delete failed\n");
493 "vrpn_Auxiliary_Logger_Remote: can't register handler\n");
499 "vrpn_Auxiliary_Logger_Remote: Can't get connection!\n");
510 char *localInName = NULL, *localOutName = NULL, *remoteInName = NULL,
511 *remoteOutName = NULL;
515 &localInName, &localOutName,
516 &remoteInName, &remoteOutName)) {
517 fprintf(stderr,
"vrpn_Auxiliary_Logger_Remote::handle_report_message: "
518 "Could not unpack buffer\n");
537 delete[] localInName;
539 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::handle_report_message: delete failed\n");
545 delete[] localOutName;
547 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::handle_report_message: delete failed\n");
553 delete[] remoteInName;
555 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::handle_report_message: delete failed\n");
561 delete[] remoteOutName;
563 fprintf(stderr,
"vrpn_Auxiliary_Logger_Server_Generic::handle_report_message: delete failed\n");
static int VRPN_CALLBACK handle_report_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_Callback_List< vrpn_AUXLOGGERCB > d_callback_list
virtual void mainloop(void)
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Auxiliary_Logger_Remote(const char *name, vrpn_Connection *c=NULL)
vrpn_Auxiliary_Logger_Server_Generic(const char *logger_name, const char *connection_to_log, vrpn_Connection *c=NULL)
~vrpn_Auxiliary_Logger_Server_Generic()
vrpn_Connection * d_logging_connection
virtual void handle_request_logging(const char *local_in_logfile_name, const char *local_out_logfile_name, const char *remote_in_logfile_name, const char *remote_out_logfile_name)
virtual void handle_request_logging_status()
static int VRPN_CALLBACK static_handle_request_logging(void *userdata, vrpn_HANDLERPARAM p)
static int VRPN_CALLBACK static_handle_request_logging_status(void *userdata, vrpn_HANDLERPARAM p)
static int VRPN_CALLBACK static_handle_dropped_last_connection(void *userdata, vrpn_HANDLERPARAM p)
virtual void handle_dropped_last_connection(void)
vrpn_int32 dropped_last_connection_m_id
virtual void handle_request_logging_status()=0
virtual void handle_request_logging(const char *local_in_logfile_name, const char *local_out_logfile_name, const char *remote_in_logfile_name, const char *remote_out_logfile_name)=0
bool send_report_logging(const char *local_in_logfile_name, const char *local_out_logfile_name, const char *remote_in_logfile_name, const char *remote_out_logfile_name)
vrpn_Auxiliary_Logger_Server(const char *name, vrpn_Connection *c)
vrpn_int32 request_logging_m_id
bool unpack_log_message_from_buffer(const char *buf, vrpn_int32 buflen, char **local_in_logfile_name, char **local_out_logfile_name, char **remote_in_logfile_name, char **remote_out_logfile_name)
bool pack_log_message_of_type(vrpn_int32 type, const char *local_in_logfile_name, const char *local_out_logfile_name, const char *remote_in_logfile_name, const char *remote_out_logfile_name)
vrpn_int32 request_logging_status_m_id
vrpn_Auxiliary_Logger(const char *name, vrpn_Connection *c)
vrpn_int32 report_logging_m_id
virtual int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
vrpn_Connection * d_connection
Connection that this object talks to.
void client_mainloop(void)
Handles functions that all clients should provide in their mainloop() (warning of no server,...
vrpn_int32 d_sender_id
Sender ID registered with the connection.
int send_text_message(const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0)
Sends a NULL-terminated text message from the device d_sender_id.
vrpn_BaseClass(const char *name, vrpn_Connection *c=NULL)
Names the device and assigns or opens connection, calls registration methods.
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
Generic connection class not specific to the transport mechanism.
const char * remote_out_logfile_name
const char * local_in_logfile_name
const char * local_out_logfile_name
const char * remote_in_logfile_name
This structure is what is passed to a vrpn_Connection message callback.
const char * vrpn_dropped_last_connection
vrpn_Connection * vrpn_get_connection_by_name(const char *cname, const char *local_in_logfile_name, const char *local_out_logfile_name, const char *remote_in_logfile_name, const char *remote_out_logfile_name, const char *NIC_IPaddress, bool force_connection)
Create a client connection of arbitrary type (VRPN UDP/TCP, TCP, File, Loopback, MPI).
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
const int vrpn_ANY_SENDER
vrpn_ANY_SENDER can be used to register callbacks on a given message type from any sender.
VRPN_API int vrpn_unbuffer(const char **buffer, timeval *t)
Utility routine for taking a struct timeval from a buffer that was sent as a message.
VRPN_API int vrpn_buffer(char **insertPt, vrpn_int32 *buflen, const timeval t)
Utility routine for placing a timeval struct into a buffer that is to be sent as a message.
#define vrpn_gettimeofday