summaryrefslogtreecommitdiff
path: root/src/bin/exactness/injector.c
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2020-03-03 17:03:41 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2020-03-12 16:41:03 +0100
commitf8299e054234d73ba27b0bf7a6a07120279c92f1 (patch)
treeac48391850caef975393e5078358ee8fc964389a /src/bin/exactness/injector.c
parent5c8942bf393f239d9860cb663d1bc6bcbee368e8 (diff)
exactness: factor out _printf() handling into common part
First step to do some re-factoring of the exactness binaries. We will share common parts from the different binaries in common.{c,h} to reduce the code duplication. The start makes _printf() used in various places. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D11456
Diffstat (limited to 'src/bin/exactness/injector.c')
-rw-r--r--src/bin/exactness/injector.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/src/bin/exactness/injector.c b/src/bin/exactness/injector.c
index d2b29d014b..882752620d 100644
--- a/src/bin/exactness/injector.c
+++ b/src/bin/exactness/injector.c
@@ -14,6 +14,7 @@
14#include <Elementary.h> 14#include <Elementary.h>
15 15
16#include <Exactness.h> 16#include <Exactness.h>
17#include "common.h"
17 18
18typedef struct 19typedef struct
19{ 20{
@@ -135,32 +136,21 @@ EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops,
135 ); 136 );
136 137
137static void 138static void
138_printf(int verbose, const char *fmt, ...)
139{
140 va_list ap;
141 if (!_verbose || verbose > _verbose) return;
142
143 va_start(ap, fmt);
144 vprintf(fmt, ap);
145 va_end(ap);
146}
147
148static void
149_feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data) 139_feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
150{ 140{
151 switch (type) 141 switch (type)
152 { 142 {
153 case EXACTNESS_ACTION_MOUSE_IN: 143 case EXACTNESS_ACTION_MOUSE_IN:
154 { 144 {
155 _printf(1, "Mouse in\n"); 145 ex_printf(1, "Mouse in\n");
156 _printf(2, "%s evas_event_feed_mouse_in n_evas=<%d>\n", __func__, n_evas); 146 ex_printf(2, "%s evas_event_feed_mouse_in n_evas=<%d>\n", __func__, n_evas);
157 eina_debug_session_send(_session, _cid, _mouse_in_op, &n_evas, sizeof(int)); 147 eina_debug_session_send(_session, _cid, _mouse_in_op, &n_evas, sizeof(int));
158 break; 148 break;
159 } 149 }
160 case EXACTNESS_ACTION_MOUSE_OUT: 150 case EXACTNESS_ACTION_MOUSE_OUT:
161 { 151 {
162 _printf(1, "Mouse out\n"); 152 ex_printf(1, "Mouse out\n");
163 _printf(2, "%s evas_event_feed_mouse_out n_evas=<%d>\n", __func__, n_evas); 153 ex_printf(2, "%s evas_event_feed_mouse_out n_evas=<%d>\n", __func__, n_evas);
164 eina_debug_session_send(_session, _cid, _mouse_out_op, &n_evas, sizeof(int)); 154 eina_debug_session_send(_session, _cid, _mouse_out_op, &n_evas, sizeof(int));
165 break; 155 break;
166 } 156 }
@@ -169,8 +159,8 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
169 Exactness_Action_Mouse_Wheel *t = data; 159 Exactness_Action_Mouse_Wheel *t = data;
170 int len = 3*sizeof(int); 160 int len = 3*sizeof(int);
171 char *buf = malloc(len), *tmp = buf; 161 char *buf = malloc(len), *tmp = buf;
172 _printf(1, "Mouse wheel\n"); 162 ex_printf(1, "Mouse wheel\n");
173 _printf(2, "%s evas_event_feed_mouse_wheel n_evas=<%d>\n", __func__, n_evas); 163 ex_printf(2, "%s evas_event_feed_mouse_wheel n_evas=<%d>\n", __func__, n_evas);
174 STORE_INT(tmp, n_evas); 164 STORE_INT(tmp, n_evas);
175 STORE_INT(tmp, t->direction); 165 STORE_INT(tmp, t->direction);
176 STORE_INT(tmp, t->z); 166 STORE_INT(tmp, t->z);
@@ -184,7 +174,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
184 Exactness_Action_Multi_Event *t = data; 174 Exactness_Action_Multi_Event *t = data;
185 int len = 5*sizeof(int)+7*sizeof(double)+sizeof(int); 175 int len = 5*sizeof(int)+7*sizeof(double)+sizeof(int);
186 char *buf = malloc(len), *tmp = buf; 176 char *buf = malloc(len), *tmp = buf;
187 _printf(2, "%s %s n_evas=<%d>\n", __func__, 177 ex_printf(2, "%s %s n_evas=<%d>\n", __func__,
188 type == EXACTNESS_ACTION_MULTI_DOWN ? "evas_event_feed_multi_down" : 178 type == EXACTNESS_ACTION_MULTI_DOWN ? "evas_event_feed_multi_down" :
189 "evas_event_feed_multi_up", n_evas); 179 "evas_event_feed_multi_up", n_evas);
190 STORE_INT(tmp, n_evas); 180 STORE_INT(tmp, n_evas);
@@ -211,7 +201,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
211 Exactness_Action_Multi_Move *t = data; 201 Exactness_Action_Multi_Move *t = data;
212 int len = 4*sizeof(int)+7*sizeof(double); 202 int len = 4*sizeof(int)+7*sizeof(double);
213 char *buf = malloc(len), *tmp = buf; 203 char *buf = malloc(len), *tmp = buf;
214 _printf(2, "%s evas_event_feed_multi_move n_evas=<%d>\n", __func__, n_evas); 204 ex_printf(2, "%s evas_event_feed_multi_move n_evas=<%d>\n", __func__, n_evas);
215 STORE_INT(tmp, n_evas); 205 STORE_INT(tmp, n_evas);
216 STORE_INT(tmp, t->d); 206 STORE_INT(tmp, t->d);
217 STORE_INT(tmp, t->x); 207 STORE_INT(tmp, t->x);
@@ -237,7 +227,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
237 len += t->string ? strlen(t->string) : 0; 227 len += t->string ? strlen(t->string) : 0;
238 len += t->compose ? strlen(t->compose) : 0; 228 len += t->compose ? strlen(t->compose) : 0;
239 char *buf = malloc(len), *tmp = buf; 229 char *buf = malloc(len), *tmp = buf;
240 _printf(2, "%s %s n_evas=<%d>\n", __func__, 230 ex_printf(2, "%s %s n_evas=<%d>\n", __func__,
241 type == EXACTNESS_ACTION_KEY_DOWN ? "evas_event_feed_key_down " : 231 type == EXACTNESS_ACTION_KEY_DOWN ? "evas_event_feed_key_down " :
242 "evas_event_feed_key_up", n_evas); 232 "evas_event_feed_key_up", n_evas);
243 STORE_INT(tmp, n_evas); 233 STORE_INT(tmp, n_evas);
@@ -254,7 +244,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
254 } 244 }
255 case EXACTNESS_ACTION_TAKE_SHOT: 245 case EXACTNESS_ACTION_TAKE_SHOT:
256 { 246 {
257 _printf(2, "%s take shot n_evas=<%d>\n", __func__, n_evas); 247 ex_printf(2, "%s take shot n_evas=<%d>\n", __func__, n_evas);
258 eina_debug_session_send(_session, _cid, _take_shot_op, &n_evas, sizeof(int)); 248 eina_debug_session_send(_session, _cid, _take_shot_op, &n_evas, sizeof(int));
259 break; 249 break;
260 } 250 }
@@ -265,7 +255,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
265 len += t->wdg_name ? strlen(t->wdg_name) : 0; 255 len += t->wdg_name ? strlen(t->wdg_name) : 0;
266 len += t->event_name ? strlen(t->event_name) : 0; 256 len += t->event_name ? strlen(t->event_name) : 0;
267 char *buf = malloc(len), *tmp = buf; 257 char *buf = malloc(len), *tmp = buf;
268 _printf(2, "%s %s\n", __func__, "EFL event"); 258 ex_printf(2, "%s %s\n", __func__, "EFL event");
269 STORE_STRING(tmp, t->wdg_name); 259 STORE_STRING(tmp, t->wdg_name);
270 STORE_STRING(tmp, t->event_name); 260 STORE_STRING(tmp, t->event_name);
271 eina_debug_session_send(_session, _cid, _efl_event_op, buf, len); 261 eina_debug_session_send(_session, _cid, _efl_event_op, buf, len);
@@ -278,7 +268,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
278 int len = 0; 268 int len = 0;
279 len += t->wdg_name ? strlen(t->wdg_name) : 0; 269 len += t->wdg_name ? strlen(t->wdg_name) : 0;
280 char *buf = malloc(len), *tmp = buf; 270 char *buf = malloc(len), *tmp = buf;
281 _printf(2, "%s %s\n", __func__, "Click On"); 271 ex_printf(2, "%s %s\n", __func__, "Click On");
282 STORE_STRING(tmp, t->wdg_name); 272 STORE_STRING(tmp, t->wdg_name);
283 eina_debug_session_send(_session, _cid, _click_on_op, buf, len); 273 eina_debug_session_send(_session, _cid, _click_on_op, buf, len);
284 free(buf); 274 free(buf);
@@ -286,7 +276,7 @@ _feed_event(Exactness_Action_Type type, unsigned int n_evas, void *data)
286 } 276 }
287 case EXACTNESS_ACTION_STABILIZE: 277 case EXACTNESS_ACTION_STABILIZE:
288 { 278 {
289 _printf(2, "%s stabilize\n", __func__); 279 ex_printf(2, "%s stabilize\n", __func__);
290 eina_debug_session_send(_session, _cid, _stabilize_op, NULL, 0); 280 eina_debug_session_send(_session, _cid, _stabilize_op, NULL, 0);
291 break; 281 break;
292 } 282 }
@@ -321,7 +311,7 @@ _src_open()
321{ 311{
322 double diff_time = 0; /* Time to wait before feeding the first event */ 312 double diff_time = 0; /* Time to wait before feeding the first event */
323 313
324 _printf(2, "<%s> Source file is <%s>\n", __func__, _src_filename); 314 ex_printf(2, "<%s> Source file is <%s>\n", __func__, _src_filename);
325 if (!strcmp(_src_filename + strlen(_src_filename) - 4,".exu")) 315 if (!strcmp(_src_filename + strlen(_src_filename) - 4,".exu"))
326 { 316 {
327 _src_unit = exactness_unit_file_read(_src_filename); 317 _src_unit = exactness_unit_file_read(_src_filename);
@@ -336,7 +326,7 @@ _src_open()
336 326
337 if (act->delay_ms) 327 if (act->delay_ms)
338 { 328 {
339 _printf(2, " Waiting <%f>\n", diff_time); 329 ex_printf(2, " Waiting <%f>\n", diff_time);
340 ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL); 330 ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
341 } 331 }
342 else 332 else