/* -*- Mode: C -*- * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * If you do not have a copy of the GNU Library General Public * License, write to The Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * * For more information on this program, contact Blair MacIntyre * (bm@cs.columbia.edu) or Steven Feiner (feiner@cs.columbia.edu) * at the Computer Science Dept., Columbia University, * 500 W 120th St, Room 450, New York, NY, 10027. * * Copyright (C) Blair MacIntyre 1995, Columbia University 1995 * * Author : Ruigang Yang * Created On : Tue Feb 3 18:34:18 1998 * Last Modified By: Ruigang Yang * Last Modified On: Thu Jul 30 16:12:19 1998 * Update Count : 72 * * $Source$ * $Date$ * $Author$ * $Revision$ * * $Log$ * SCCS Status : %W% %G% * * HISTORY */ static char rcsid[] = "$Id$"; #include #include #include #include /* These are the callback handlers*/ void tracker_handler(void *userdata, const vrpn_TRACKERCB b); void closeDevices(); FILE * recordfp; int totalRecord; void tracker_handler(void *userdata, const vrpn_TRACKERCB t) { if (recordfp != NULL) fwrite(&t, sizeof(t), 1, recordfp); totalRecord ++; } //#ifdef sgi //void sighandler( ... ) //#else void sighandler( int signal ) //#endif { closeDevices(); return; } void closeDevices() { fprintf(stderr, "Closing tracker data file...%d recorded, headsize =%d", totalRecord, sizeof(int)); if(recordfp != NULL) { fseek(recordfp, 0, SEEK_SET); fwrite(&totalRecord, sizeof(int), 1, recordfp); fclose(recordfp); } fprintf(stderr, "\nAll devices closed. Exiting ...\n"); exit(0); } main() { #ifdef sgi sigset( SIGINT, sighandler ); sigset( SIGKILL, sighandler ); sigset( SIGTERM, sighandler ); sigset( SIGPIPE, sighandler ); #else signal( SIGINT, sighandler ); signal( SIGKILL, sighandler ); signal( SIGTERM, sighandler ); signal( SIGPIPE, sighandler ); #endif // sgi vrpn_Tracker_Remote *tracker; fprintf(stderr, "Attempting to connect to vrpn server.\n"); tracker = new vrpn_Tracker_Remote("Tracker0@nameless.cs.jhu.edu"); if (!tracker->connectionPtr()) { fprintf(stderr, "Application couldn't connect to vrpn server. Exiting...\n"); exit(1); } tracker->register_change_handler(NULL, (vrpn_TRACKERCHANGEHANDLER)tracker_handler); recordfp = fopen("tracker.dat", "w"); if (recordfp != NULL) { fprintf(stderr, "Writing file: tracker.dat\n"); fwrite(&totalRecord, sizeof(int), 1, recordfp); } else { perror("Can't open data file for recording:"); exit(1); } while (1) tracker->mainloop(); }