#include <stdio.h> #include <stdlib.h> #include <spy.h> #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif char *circname = (char *) NULL; int spydump_opt (int n, char *argv[]) { int help = FALSE; register int i; for (i=1 ; i < n ; ++i) if (argv[i][0] == '-') switch (argv[i][1]) { case 'c': circname = argv[++i]; break; case 'h': help = TRUE; break; default: break; } if (help) { printf ("\nUsage : spyempty [options]\n\n\tOptions:\n" "\t -c\t<circname> (default = /tmp/B_1_1)\n" "\t -h\t (help)\n"); exit (0); } if (circname == (char *) NULL) { circname = malloc (strlen ("/tmp/B_1_1") + 1); strcpy (circname, "/tmp/B_1_1"); } return TRUE; } int main(int argc, char *argv[]) { int err; int buflen; SPY_id spy_id; spydump_opt (argc, argv); if ((err=spy_open(circname,&spy_id))!=SPY_ERROR_OK) { puts("Error in opening spy.\n"); return 1; } while (1) { /* loop forever */ buflen = 0; err = spy_refresh(spy_id); err = spy_get(spy_id,(char *) NULL,&buflen); } spy_close(spy_id); return 0; }