http://www.jwz.org/xscreensaver/xscreensaver-5.08.tar.gz
[xscreensaver] / hacks / glx / sonar.h
1 /* sonar, Copyright (c) 1998-2008 Jamie Zawinski and Stephen Martin
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  */
11
12 #ifndef __SONAR_XSCREENSAVER_H__
13 #define __SONAR_XSCREENSAVER_H__
14
15 typedef struct sonar_sensor_data sonar_sensor_data;
16 typedef struct sonar_bogie sonar_bogie;
17
18 struct sonar_bogie {
19   void *closure;
20   char *name;           /* bogie name, e.g., host name */
21   char *desc;           /* second line of text, e.g., ping time */
22   double r;             /* distance, 0 - 1.0 */
23   double th;            /* heading, 0 - 2 pi */
24   double ttl;           /* time to live, 0 - 2 pi */
25   sonar_bogie *next;    /* next one in the list */
26 };
27
28 struct sonar_sensor_data {
29   void *closure;
30
31   /* Called frequently (every time the sweep moves).
32      Returns a list of new bogies to be added to the display list 
33      once the sweep comes around to their position.
34    */
35   sonar_bogie *(*scan_cb) (sonar_sensor_data *);
36
37   /* Called when a bogie is freed, to free bogie->closure */
38   void (*free_bogie_cb) (sonar_sensor_data *, void *closure);
39
40   /* Called at exit, to free ssd->closure */
41   void (*free_data_cb) (sonar_sensor_data *, void *closure);
42 };
43
44 /* frees bogie and its contents, including calling the free_bogie_cb. */
45 extern void free_bogie (sonar_sensor_data *ssd, sonar_bogie *b);
46
47 /* makes a copy of the bogie, not including the 'closure' data. */
48 extern sonar_bogie *copy_bogie (sonar_sensor_data *ssd, const sonar_bogie *b);
49
50
51 /* Set up and return sensor state for ICMP pings. */
52 extern sonar_sensor_data *init_ping (Display *dpy, 
53                                      char **error_ret,
54                                      const char *subnets,
55                                      int ping_timeout,
56                                      Bool resolve_p, Bool times_p,
57                                      Bool debug_p);
58
59 /* Set up and return sensor state for the simulation. */
60 extern sonar_sensor_data *init_simulation (Display *dpy,
61                                            char **error_ret,
62                                            const char *team_a_name, 
63                                            const char *team_b_name,
64                                            int team_a_count, 
65                                            int team_b_count,
66                                            Bool debug_p);
67
68 #endif /* __SONAR_XSCREENSAVER_H__ */