summaryrefslogtreecommitdiff
path: root/src/bin/exactness/recorder.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/recorder.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 '')
-rw-r--r--src/bin/exactness/recorder.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/bin/exactness/recorder.c b/src/bin/exactness/recorder.c
index 59a4d3106e..812ef737e7 100644
--- a/src/bin/exactness/recorder.c
+++ b/src/bin/exactness/recorder.c
@@ -23,6 +23,7 @@
23#include <Exactness.h> 23#include <Exactness.h>
24 24
25#include <exactness_private.h> 25#include <exactness_private.h>
26#include "common.h"
26 27
27#define MAX_PATH 1024 28#define MAX_PATH 1024
28#define STABILIZE_KEY_STR "F1" 29#define STABILIZE_KEY_STR "F1"
@@ -42,17 +43,6 @@ static Exactness_Unit *_unit = NULL;
42static char *_shot_key = NULL; 43static char *_shot_key = NULL;
43static unsigned int _last_timestamp = 0.0; 44static unsigned int _last_timestamp = 0.0;
44 45
45static void
46_printf(int verbose, const char *fmt, ...)
47{
48 va_list ap;
49 if (!_verbose || verbose > _verbose) return;
50
51 va_start(ap, fmt);
52 vprintf(fmt, ap);
53 va_end(ap);
54}
55
56static Exactness_Action_Type 46static Exactness_Action_Type
57_event_pointer_type_get(Efl_Pointer_Action t) 47_event_pointer_type_get(Efl_Pointer_Action t)
58{ 48{
@@ -87,7 +77,7 @@ _add_to_list(Exactness_Action_Type type, unsigned int n_evas, unsigned int times
87 prev_v->n_evas == n_evas && 77 prev_v->n_evas == n_evas &&
88 (!len || !memcmp(prev_v->data, data, len))) return; 78 (!len || !memcmp(prev_v->data, data, len))) return;
89 } 79 }
90 _printf(1, "Recording %s\n", _exactness_action_type_to_string_get(type)); 80 ex_printf(1, "Recording %s\n", _exactness_action_type_to_string_get(type));
91 Exactness_Action *act = malloc(sizeof(*act)); 81 Exactness_Action *act = malloc(sizeof(*act));
92 act->type = type; 82 act->type = type;
93 act->n_evas = n_evas; 83 act->n_evas = n_evas;
@@ -122,7 +112,7 @@ _event_pointer_cb(void *data, const Efl_Event *event)
122 112
123 if (!timestamp) return; 113 if (!timestamp) return;
124 114
125 _printf(2, "Calling \"%s\" timestamp=<%u>\n", _exactness_action_type_to_string_get(evt), timestamp); 115 ex_printf(2, "Calling \"%s\" timestamp=<%u>\n", _exactness_action_type_to_string_get(evt), timestamp);
126 116
127 switch (action) 117 switch (action)
128 { 118 {
@@ -182,20 +172,20 @@ _event_key_cb(void *data, const Efl_Event *event)
182 { 172 {
183 if (!strcmp(key, _shot_key)) 173 if (!strcmp(key, _shot_key))
184 { 174 {
185 _printf(2, "Take Screenshot: %s timestamp=<%u>\n", __func__, timestamp); 175 ex_printf(2, "Take Screenshot: %s timestamp=<%u>\n", __func__, timestamp);
186 _add_to_list(EXACTNESS_ACTION_TAKE_SHOT, n_evas, timestamp, NULL, 0); 176 _add_to_list(EXACTNESS_ACTION_TAKE_SHOT, n_evas, timestamp, NULL, 0);
187 return; 177 return;
188 } 178 }
189 if (!strcmp(key, STABILIZE_KEY_STR)) 179 if (!strcmp(key, STABILIZE_KEY_STR))
190 { 180 {
191 _printf(2, "Stabilize: %s timestamp=<%u>\n", __func__, timestamp); 181 ex_printf(2, "Stabilize: %s timestamp=<%u>\n", __func__, timestamp);
192 _add_to_list(EXACTNESS_ACTION_STABILIZE, n_evas, timestamp, NULL, 0); 182 _add_to_list(EXACTNESS_ACTION_STABILIZE, n_evas, timestamp, NULL, 0);
193 return; 183 return;
194 } 184 }
195 if (!strcmp(key, SAVE_KEY_STR)) 185 if (!strcmp(key, SAVE_KEY_STR))
196 { 186 {
197 _output_write(); 187 _output_write();
198 _printf(2, "Save events: %s timestamp=<%u>\n", __func__, timestamp); 188 ex_printf(2, "Save events: %s timestamp=<%u>\n", __func__, timestamp);
199 return; 189 return;
200 } 190 }
201 evt = EXACTNESS_ACTION_KEY_DOWN; 191 evt = EXACTNESS_ACTION_KEY_DOWN;
@@ -239,7 +229,7 @@ _my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED)
239 e = _evas_new(); 229 e = _evas_new();
240 if (e) 230 if (e)
241 { 231 {
242 _printf(1, "New Evas\n"); 232 ex_printf(1, "New Evas\n");
243 _evas_list = eina_list_append(_evas_list, e); 233 _evas_list = eina_list_append(_evas_list, e);
244 efl_key_data_set(e, "__evas_id", (void *)(intptr_t)_last_evas_id++); 234 efl_key_data_set(e, "__evas_id", (void *)(intptr_t)_last_evas_id++);
245 efl_event_callback_array_add(e, _event_pointer_callbacks(), e); 235 efl_event_callback_array_add(e, _event_pointer_callbacks(), e);
@@ -502,9 +492,9 @@ int main(int argc, char **argv)
502 { 492 {
503 argv[i - opt_args] = argv[0] + (argv[i] - argv[opt_args]); 493 argv[i - opt_args] = argv[0] + (argv[i] - argv[opt_args]);
504 } 494 }
505 _printf(1, "%s ", argv[i - opt_args]); 495 ex_printf(1, "%s ", argv[i - opt_args]);
506 } 496 }
507 _printf(1, "\n"); 497 ex_printf(1, "\n");
508 498
509 if (!_shot_key) _shot_key = getenv("SHOT_KEY"); 499 if (!_shot_key) _shot_key = getenv("SHOT_KEY");
510 if (!_shot_key) _shot_key = SHOT_KEY_STR; 500 if (!_shot_key) _shot_key = SHOT_KEY_STR;