int main (int argc, char * argv []) { const char * devicename = "Logger0@localhost"; struct timeval start; struct timeval now; int ret = 0; // parse args if (argc == 1) { // Fine, use defaults. } else if (argc > 2) { fprintf(stderr, "Usage: %s Device_name\n" " Device_name: VRPN name of data source to contact\n" " example: Logger0@localhost\n", argv[0]); exit(0); } else { devicename = argv[1]; } // Open the logger and set up its callback handler. fprintf(stderr, "Logger's name is %s.\n", devicename); g_logger = new vrpn_Auxiliary_Logger_Remote (devicename); g_logger->register_report_handler(NULL, handle_log_report); // Main loop for half a second to get things started on the // connection. vrpn_gettimeofday(&start, NULL); do { g_logger->mainloop(); vrpn_gettimeofday(&now, NULL); } while (vrpn_TimevalDurationSeconds(now, start) < 0.5); // Try to create four named log files. Wait for a second after // creation to give it something to log. if (!test_logfile_names("temp1_local_in", "temp1_local_out", "temp1_remote_in", "temp1_remote_out") ) { fprintf(stderr,"Error creating first set of logs\n"); ret = -1; } vrpn_gettimeofday(&start, NULL); do { g_logger->mainloop(); vrpn_gettimeofday(&now, NULL); } while (vrpn_TimevalDurationSeconds(now, start) < 5.0); // send a log-file-name request g_logger->send_logging_status_request( ); vrpn_gettimeofday(&start, NULL); do { g_logger->mainloop(); vrpn_gettimeofday(&now, NULL); } while (vrpn_TimevalDurationSeconds(now, start) < 5.0); // Try to create blank log files (no log should be made). Wait for a second after // creation to give it something to log. if (!test_logfile_names("", "", "", "") ) { fprintf(stderr,"Error turning off logs\n"); ret = -1; } vrpn_gettimeofday(&start, NULL); do { g_logger->mainloop(); vrpn_gettimeofday(&now, NULL); } while (vrpn_TimevalDurationSeconds(now, start) < 5.0); // Try to create just one named log file. Wait for a second after // creation to give it something to log. if (!test_logfile_names("temp2_local_in", "", "", "") ) { fprintf(stderr,"Error creating second set of logs\n"); ret = -1; } vrpn_gettimeofday(&start, NULL); do { g_logger->mainloop(); vrpn_gettimeofday(&now, NULL); } while (vrpn_TimevalDurationSeconds(now, start) < 5.0); // Try to create blank log files (no log should be made). Wait for a second after // creation to give it something to log. if (!test_logfile_names("", "", "", "") ) { fprintf(stderr,"Error turning off logs\n"); ret = -1; } vrpn_gettimeofday(&start, NULL); do { g_logger->mainloop(); vrpn_gettimeofday(&now, NULL); } while (vrpn_TimevalDurationSeconds(now, start) < 5.0); // Done. if (ret == 0) { printf("Success!\n"); } else { printf("Make sure that files with the requested names don't already exist.\n"); } delete g_logger; return ret; } /* main */
int main (int argc, char * argv []) { const char * devicename = "Logger0@localhost"; const char * logfilename = "deleteme.vrpn"; int log_duration_seconds = 120; struct timeval start; struct timeval now; int ret = 0; // parse args if (argc != 4) { fprintf(stderr, "Usage: %s Device_name remote_logfile_name time_seconds\n" " Device_name: VRPN name of data source to contact\n" " example: Logger0@localhost\n" " remote_logfile_name: The name of the file to log remotely\n" " time_seconds: How long to log before closing and exiting\n", argv[0]); exit(0); } else { devicename = argv[1]; logfilename = argv[2]; log_duration_seconds = atoi(argv[3]); } // Open the logger and set up its callback handler. fprintf(stderr, "Logger's name is %s.\n", devicename); g_logger = new vrpn_Auxiliary_Logger_Remote (devicename); g_logger->register_report_handler(NULL, handle_log_report); // Main loop for half a second to get things started on the // connection. vrpn_gettimeofday(&start, NULL); do { g_logger->mainloop(); vrpn_gettimeofday(&now, NULL); } while (duration(now, start) < 0.5); // Try to create the named log file as the remote outgoing log // on the server. Wait for the specified duration to give it // time to log. if (!test_logfile_names("", "", "", logfilename) ) { fprintf(stderr,"Error creating remote outgoing log file %s\n",logfilename); ret = -1; } vrpn_gettimeofday(&start, NULL); do { g_logger->mainloop(); vrpn_gettimeofday(&now, NULL); } while (duration(now, start) <= log_duration_seconds); // Try to create blank log files (no log should be made). Wait for a while after // creation to give time to stop logging. if (!test_logfile_names("", "", "", "") ) { fprintf(stderr,"Error turning off logs\n"); ret = -1; } vrpn_gettimeofday(&start, NULL); do { g_logger->mainloop(); vrpn_gettimeofday(&now, NULL); } while (duration(now, start) < 5.0); // Done. if (ret == 0) { printf("Success!\n"); } else { printf("Make sure that files with the requested names don't already exist.\n"); } delete g_logger; return ret; } /* main */