From http://www.jwz.org/xscreensaver/xscreensaver-5.18.tar.gz
[xscreensaver] / hacks / glx / sonar.h
1 /* sonar, Copyright (c) 1998-2012 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 sonar_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 *sonar_copy_bogie (sonar_sensor_data *,
49                                       const sonar_bogie *);
50
51
52 /* Set up and return sensor state for ICMP pings. */
53 extern sonar_sensor_data *sonar_init_ping (Display *dpy, 
54                                            char **error_ret,
55                                            char **desc_ret,
56                                            const char *subnets,
57                                            int ping_timeout,
58                                            Bool resolve_p, Bool times_p,
59                                            Bool debug_p);
60
61 /* Set up and return sensor state for the simulation. */
62 extern sonar_sensor_data *sonar_init_simulation (Display *dpy,
63                                                  char **error_ret,
64                                                  char **desc_ret,
65                                                  const char *team_a_name, 
66                                                  const char *team_b_name,
67                                                  int team_a_count, 
68                                                  int team_b_count,
69                                                  Bool debug_p);
70
71 #endif /* __SONAR_XSCREENSAVER_H__ */