1 /*****
2  *       Xnee's Not an Event Emulator
3  *
4  * Xnee enables recording and replaying of X protocol data
5  *
6  *        Copyright (C) 1999, 2000, 2001, 2002, 2003 Henrik Sandklef
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 3
11  * of the License, or any later version.
12  *
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Boston,
22  * MA  02110-1301, USA.
23  ****/
24 
25 
26 #include "libxnee/xnee.h"
27 #include "libxnee/print.h"
28 #include "libxnee/xnee_record.h"
29 #include "libxnee/xnee_replay.h"
30 #include "libxnee/xnee_sem.h"
31 #include "libxnee/xnee_resolution.h"
32 #include "libxnee/xnee_threshold.h"
33 
34 
35 static int
xnee_set_threshold(int thresh,int * threshold)36 xnee_set_threshold (int thresh, int *threshold)
37 {
38   *threshold = thresh ;
39   return XNEE_OK;
40 }
41 
42 static int
xnee_set_threshold_str(char * thresh_str,int * threshold)43 xnee_set_threshold_str (char *thresh_str, int *threshold)
44 {
45   int ret;
46 
47   if (thresh_str == NULL)
48   {
49     return XNEE_BAD_THRESHOLD;
50   }
51 
52   ret = sscanf(thresh_str, "%d",
53 	       threshold);
54 
55   if ( ret == 1 )
56     {
57       return XNEE_OK;
58     }
59   return XNEE_BAD_THRESHOLD;
60 }
61 
62 
63 
64 int
xnee_set_max_threshold_str(xnee_data * xd,char * thresh_str)65 xnee_set_max_threshold_str (xnee_data *xd, char *thresh_str)
66 {
67   return xnee_set_threshold_str (thresh_str, &xd->meta_data.sum_max_threshold);
68 }
69 
70 int
xnee_set_min_threshold_str(xnee_data * xd,char * thresh_str)71 xnee_set_min_threshold_str (xnee_data *xd, char *thresh_str)
72 {
73   return xnee_set_threshold_str (thresh_str, &xd->meta_data.sum_min_threshold);
74 }
75 
76 int
xnee_set_tot_threshold_str(xnee_data * xd,char * thresh_str)77 xnee_set_tot_threshold_str (xnee_data *xd, char *thresh_str)
78 {
79   return xnee_set_threshold_str (thresh_str,
80 				 &xd->meta_data.tot_diff_threshold);
81 }
82 
83 
84 int
xnee_set_max_threshold(xnee_data * xd,int thresh)85 xnee_set_max_threshold (xnee_data *xd, int thresh)
86 {
87     return xnee_set_threshold (thresh, &xd->meta_data.sum_max_threshold);
88 }
89 
90 int
xnee_set_min_threshold(xnee_data * xd,int thresh)91 xnee_set_min_threshold (xnee_data *xd, int thresh)
92 {
93     return xnee_set_threshold (thresh, &xd->meta_data.sum_min_threshold);
94 }
95 
96 int
xnee_set_tot_threshold(xnee_data * xd,int thresh)97 xnee_set_tot_threshold (xnee_data *xd, int thresh)
98 {
99   return xnee_set_threshold (thresh, &xd->meta_data.tot_diff_threshold);
100 }
101 
102 int
xnee_get_max_threshold(xnee_data * xd)103 xnee_get_max_threshold (xnee_data *xd)
104 {
105   return xd->meta_data.sum_max_threshold;
106 }
107 
108 int
xnee_get_min_threshold(xnee_data * xd)109 xnee_get_min_threshold (xnee_data *xd)
110 {
111   return xd->meta_data.sum_min_threshold;
112 }
113 
114 int
xnee_get_tot_threshold(xnee_data * xd)115 xnee_get_tot_threshold (xnee_data *xd)
116 {
117   return xd->meta_data.tot_diff_threshold;
118 }
119 
120 
121