1 /*****
2 * Xnee's Not an Event Emulator
3 *
4 * Xnee enables recording and replaying of X protocol data
5 *
6 * Copyright (C) 1999-2004, 2009-2011, 2013, 2014 Henrik Sandklef
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify1 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 <unistd.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29
30 #include "libxnee/xnee.h"
31 #include "libxnee/print.h"
32 #include "libxnee/xnee_setget.h"
33 #include "libxnee/xnee_record.h"
34 #include "libxnee/xnee_replay.h"
35 #include "libxnee/xnee_setget.h"
36 #include "libxnee/xnee_session.h"
37 #include "libxnee/xnee_utils.h"
38 #include "libxnee/xnee_alloc.h"
39 #include "libxnee/xnee_resource.h"
40 #include "libxnee/xnee_plugin.h"
41 #include "libxnee/feedback.h"
42 #include "libxnee/xnee_range.h"
43
44
45
46 static xnee_data *xd_saved;
47
48 int
xnee_set_display_name(xnee_data * xd,const char * disp)49 xnee_set_display_name (xnee_data *xd, const char *disp)
50 {
51
52 if (disp==NULL)
53 {
54 return XNEE_OK;
55 }
56
57 XNEE_FREE_IF_NOT_NULL(xd->display);
58 xd->display=strdup(disp);
59
60 if (xd->display==NULL)
61 {
62 return XNEE_MEMORY_FAULT;
63 }
64 return XNEE_OK;
65 }
66
67 char*
xnee_get_display_name(xnee_data * xd)68 xnee_get_display_name (xnee_data *xd)
69 {
70 return xd->display;
71 }
72
73
74 Display *
xnee_get_control_display(xnee_data * xd)75 xnee_get_control_display(xnee_data *xd)
76 {
77 return xd->control;
78 }
79
80 Display *
xnee_get_data_display(xnee_data * xd)81 xnee_get_data_display(xnee_data *xd)
82 {
83 return xd->data;
84 }
85
86 Display *
xnee_get_grab_display(xnee_data * xd)87 xnee_get_grab_display(xnee_data *xd)
88 {
89 return xd->grab;
90 }
91
92
93 int
xnee_set_out_file(xnee_data * xd,FILE * out)94 xnee_set_out_file (xnee_data *xd, FILE* out)
95 {
96 if ( xd->out_file != xd->saved_out_file )
97 {
98 XNEE_FCLOSE_IF_NOT_NULL(xd->out_file);
99 }
100 xd->out_file=out;
101 return XNEE_OK;
102 }
103
104 FILE*
xnee_get_out_file(xnee_data * xd)105 xnee_get_out_file (xnee_data *xd)
106 {
107 return xd->out_file;
108 }
109
110 int
xnee_set_out_name(xnee_data * xd,char * out_name)111 xnee_set_out_name (xnee_data *xd, char* out_name)
112 {
113 XNEE_FREE_IF_NOT_NULL(xd->out_name);
114 xd->out_name=strdup(out_name);
115 if (xd->out_name==NULL)
116 {
117 return XNEE_MEMORY_FAULT;
118 }
119 return XNEE_OK;
120 }
121
122 char *
xnee_get_out_name(xnee_data * xd)123 xnee_get_out_name (xnee_data *xd)
124 {
125 return xd->out_name;
126 }
127
128
129 int
xnee_set_rt_file(xnee_data * xd,FILE * rt)130 xnee_set_rt_file (xnee_data *xd, FILE* rt)
131 {
132 XNEE_FCLOSE_IF_NOT_NULL(xd->rt_file);
133 xd->rt_file=rt;
134 return XNEE_OK;
135 }
136
137 FILE*
xnee_get_rt_file(xnee_data * xd)138 xnee_get_rt_file (xnee_data *xd)
139 {
140 return xd->rt_file;
141 }
142
143 int
xnee_set_rt_name(xnee_data * xd,char * rt_name)144 xnee_set_rt_name (xnee_data *xd, char* rt_name)
145 {
146 XNEE_FREE_IF_NOT_NULL(xd->rt_name);
147 xd->rt_name=strdup(rt_name);
148 if (xd->rt_name==NULL)
149 {
150 return XNEE_MEMORY_FAULT;
151 }
152 return XNEE_OK;
153 }
154
155 char *
xnee_get_rt_name(xnee_data * xd)156 xnee_get_rt_name (xnee_data *xd)
157 {
158 return xd->rt_name;
159 }
160
161
162 int
xnee_set_err_file(xnee_data * xd,FILE * err)163 xnee_set_err_file (xnee_data *xd, FILE* err)
164 {
165 if ( xd->err_file != xd->saved_err_file )
166 {
167 XNEE_FCLOSE_IF_NOT_NULL(xd->out_file);
168 }
169 xd->err_file=err;
170 return XNEE_OK;
171 }
172
173 FILE*
xnee_get_err_file(xnee_data * xd)174 xnee_get_err_file (xnee_data *xd)
175 {
176 return xd->err_file;
177 }
178
179
180
181 int
xnee_set_err_name(xnee_data * xd,char * err_name)182 xnee_set_err_name (xnee_data *xd, char* err_name)
183 {
184 XNEE_FREE_IF_NOT_NULL(xd->err_name);
185 xd->err_name=strdup(err_name);
186
187 if (xd->err_name==NULL)
188 {
189 return XNEE_MEMORY_FAULT;
190 }
191 return XNEE_OK;
192 }
193
194 char *
xnee_get_err_name(xnee_data * xd)195 xnee_get_err_name (xnee_data *xd)
196 {
197 return xd->err_name;
198 }
199
200
201
202 int
xnee_set_rc_file(xnee_data * xd,FILE * rc)203 xnee_set_rc_file (xnee_data *xd, FILE* rc)
204 {
205 XNEE_FCLOSE_IF_NOT_NULL(xd->rc_file);
206 xd->rc_file=rc;
207 return XNEE_OK;
208 }
209
210
211 FILE*
xnee_get_rc_file(xnee_data * xd)212 xnee_get_rc_file (xnee_data *xd)
213 {
214 return xd->rc_file;
215 }
216
217
218 int
xnee_set_rc_name(xnee_data * xd,const char * rc_name)219 xnee_set_rc_name (xnee_data *xd, const char* rc_name)
220 {
221 XNEE_FREE_IF_NOT_NULL(xd->rc_name);
222 xd->rc_name=strdup(rc_name);
223 if (xd->rc_name==NULL)
224 {
225 return XNEE_MEMORY_FAULT;
226 }
227 return XNEE_OK;
228 }
229
230 char *
xnee_get_rc_name(xnee_data * xd)231 xnee_get_rc_name (xnee_data *xd)
232 {
233 return xd->rc_name;
234 }
235
236
237 int
xnee_set_rc_byname(xnee_data * xd,const char * rc_name)238 xnee_set_rc_byname (xnee_data *xd, const char *rc_name)
239 {
240 struct stat buf;
241
242 if (rc_name!=NULL)
243 {
244 xnee_set_rc_name (xd, rc_name);
245 }
246 else
247 {
248 return XNEE_OK;
249 }
250
251 if (stat(rc_name, &buf) == ENOENT)
252 {
253 xnee_set_new_project(xd);
254 }
255
256 XNEE_FCLOSE_IF_NOT_NULL(xd->rc_file);
257 xd->rc_file = fopen (xd->rc_name,"r");
258
259 if (xd->rc_file ==NULL)
260 {
261 XNEE_FREE_IF_NOT_NULL (xd->rc_name);
262 return XNEE_FILE_NOT_FOUND;
263 }
264
265 return XNEE_OK;
266 }
267
268
269
270 int
xnee_set_data_file(xnee_data * xd,FILE * data_file)271 xnee_set_data_file (xnee_data *xd, FILE* data_file)
272 {
273 XNEE_FCLOSE_IF_NOT_NULL(xd->data_file);
274 xd->data_file=data_file;
275 return XNEE_OK;
276 }
277
278 FILE*
xnee_get_data_file(xnee_data * xd)279 xnee_get_data_file (xnee_data *xd)
280 {
281 return xd->data_file;
282 }
283
284 int
xnee_set_data_name(xnee_data * xd,const char * data)285 xnee_set_data_name (xnee_data *xd, const char* data)
286 {
287 XNEE_FREE_IF_NOT_NULL(xd->data_name);
288 xd->data_name=strdup(data);
289 return XNEE_OK;
290 }
291
292 char *
xnee_get_data_name(xnee_data * xd)293 xnee_get_data_name (xnee_data *xd)
294 {
295 return xd->data_name;
296 }
297
298
299
300
301
302
303 int
xnee_set_verbose(xnee_data * xd)304 xnee_set_verbose (xnee_data *xd)
305 {
306 if (xd==NULL)
307 {
308 return (XNEE_NO_MAIN_DATA);
309 }
310 xd->verbose=XNEE_TRUE;
311 return XNEE_OK;
312 }
313
314 int
xnee_unset_verbose(xnee_data * xd)315 xnee_unset_verbose (xnee_data *xd)
316 {
317 xd->verbose=XNEE_FALSE;
318 return XNEE_OK;
319 }
320
321 int
xnee_get_verbose(xnee_data * xd)322 xnee_get_verbose (xnee_data *xd)
323 {
324 return xd->verbose;
325 }
326
327
328 int
xnee_is_verbose(xnee_data * xd)329 xnee_is_verbose (xnee_data *xd)
330 {
331 return (xd->verbose==XNEE_TRUE);
332 }
333
334
335 int
xnee_set_buf_verbose(xnee_data * xd)336 xnee_set_buf_verbose (xnee_data *xd)
337 {
338 xd->buf_verbose=XNEE_TRUE;
339 return XNEE_OK;
340 }
341
342 int
xnee_unset_buf_verbose(xnee_data * xd)343 xnee_unset_buf_verbose (xnee_data *xd)
344 {
345 xd->buf_verbose=XNEE_FALSE;
346 return XNEE_OK;
347 }
348
349 int
xnee_get_buf_verbose(xnee_data * xd)350 xnee_get_buf_verbose (xnee_data *xd)
351 {
352 return xd->buf_verbose;
353 }
354
355
356
357
358 int
xnee_set_all_clients(xnee_data * xd)359 xnee_set_all_clients (xnee_data *xd)
360 {
361 xd->all_clients=XNEE_TRUE;
362 return XNEE_OK;
363 }
364
365 int
xnee_unset_all_clients(xnee_data * xd)366 xnee_unset_all_clients (xnee_data *xd)
367 {
368 xd->all_clients=XNEE_FALSE;
369 return XNEE_OK;
370 }
371
372 int
xnee_get_all_clients(xnee_data * xd)373 xnee_get_all_clients (xnee_data *xd)
374 {
375 return xd->all_clients;
376 }
377
378 int
xnee_is_future_clients(xnee_data * xd)379 xnee_is_future_clients (xnee_data *xd)
380 {
381 return !xd->all_clients;
382 }
383
384
385 int
xnee_is_all_clients(xnee_data * xd)386 xnee_is_all_clients (xnee_data *xd)
387 {
388 return (xd->all_clients==XNEE_TRUE);
389 }
390
391
392
393
394 int
xnee_set_sync(xnee_data * xd)395 xnee_set_sync (xnee_data *xd)
396 {
397 xnee_verbose((xd, "xnee_set_sync\n"));
398 xd->sync=XNEE_TRUE;
399 return XNEE_OK;
400 }
401
402 int
xnee_unset_sync(xnee_data * xd)403 xnee_unset_sync (xnee_data *xd)
404 {
405 xnee_verbose((xd, "xnee_unset_sync\n"));
406 xd->sync=XNEE_FALSE;
407 return XNEE_OK;
408 }
409
410 int
xnee_get_sync(xnee_data * xd)411 xnee_get_sync (xnee_data *xd)
412 {
413 return xd->sync;
414 }
415
416
417 int
xnee_is_sync(xnee_data * xd)418 xnee_is_sync (xnee_data *xd)
419 {
420 return (xd->sync==XNEE_TRUE);
421 }
422
423
424 int
xnee_set_recorder(xnee_data * xd)425 xnee_set_recorder (xnee_data *xd)
426 {
427 xd->mode=XNEE_RECORDER;
428 return XNEE_OK;
429 }
430
431 int
xnee_set_replayer(xnee_data * xd)432 xnee_set_replayer (xnee_data *xd)
433 {
434 xd->mode=XNEE_REPLAYER;
435 return XNEE_OK;
436 }
437
438 int
xnee_set_distributor(xnee_data * xd)439 xnee_set_distributor (xnee_data *xd)
440 {
441 xd->mode=XNEE_REPLAYER;
442 return XNEE_OK;
443 }
444
445
446 int
xnee_set_syntax_checker(xnee_data * xd)447 xnee_set_syntax_checker (xnee_data *xd)
448 {
449 xd->mode=XNEE_SYNTAX_CHECKER;
450 return XNEE_OK;
451 }
452
453 int
xnee_set_retyper(xnee_data * xd)454 xnee_set_retyper (xnee_data *xd)
455 {
456 xd->mode=XNEE_RETYPER;
457 return XNEE_OK;
458 }
459
460
461 unsigned char
xnee_get_mode(xnee_data * xd)462 xnee_get_mode (xnee_data *xd)
463 {
464 return xd->mode;
465 }
466
467 int
xnee_set_mode(xnee_data * xd,unsigned char mode)468 xnee_set_mode (xnee_data *xd, unsigned char mode)
469 {
470 xd->mode=mode;
471 return XNEE_OK;
472 }
473
474 int
xnee_is_recorder(xnee_data * xd)475 xnee_is_recorder (xnee_data *xd)
476 {
477 return (xd->mode==XNEE_RECORDER);
478 }
479
480 int
xnee_is_syntax_checker(xnee_data * xd)481 xnee_is_syntax_checker (xnee_data *xd)
482 {
483 return (xd->mode==XNEE_SYNTAX_CHECKER);
484 }
485
486 int
xnee_is_replayer(xnee_data * xd)487 xnee_is_replayer (xnee_data *xd)
488 {
489 return (xd->mode==XNEE_REPLAYER);
490 }
491
492 int
xnee_is_distributor(xnee_data * xd)493 xnee_is_distributor (xnee_data *xd)
494 {
495 return (xd->mode==XNEE_DISTRIBUTOR);
496 }
497
498 int
xnee_is_retyper(xnee_data * xd)499 xnee_is_retyper (xnee_data *xd)
500 {
501 return (xd->mode==XNEE_RETYPER);
502 }
503
504
505
506 int
xnee_set_cont(xnee_data * xd)507 xnee_set_cont (xnee_data *xd)
508 {
509 xd->cont=XNEE_TRUE;
510 return XNEE_OK;
511 }
512
513 int
xnee_get_cont(xnee_data * xd)514 xnee_get_cont (xnee_data *xd)
515 {
516 return xd->cont;
517 }
518
519 int
xnee_unset_cont(xnee_data * xd)520 xnee_unset_cont (xnee_data *xd)
521 {
522 xd->cont=XNEE_FALSE;
523 return XNEE_OK;
524 }
525
526 int
xnee_is_cont(xnee_data * xd)527 xnee_is_cont (xnee_data *xd)
528 {
529 xd->cont=XNEE_FALSE;
530 return XNEE_OK;
531 }
532
533
534
535 int
xnee_set_key(xnee_data * xd,int mode,const char * km)536 xnee_set_key (xnee_data *xd, int mode, const char* km)
537 {
538 xnee_verbose((xd, "---> xnee_set_key\n"));
539
540 if (km==NULL)
541 {
542 return XNEE_UNKNOWN_GRAB_MODE;
543 }
544
545 switch (mode)
546 {
547 case XNEE_GRAB_STOP:
548 xnee_verbose((xd, " --- xnee_set_key stop to %s\n", km));
549 xnee_set_stop_key(xd, km);
550 break;
551 case XNEE_GRAB_PAUSE:
552 xnee_verbose((xd, " --- xnee_set_key pause to %s\n", km));
553 xnee_set_pause_key(xd, km);
554 break;
555 case XNEE_GRAB_RESUME:
556 xnee_verbose((xd, " --- xnee_set_key resume to %s\n", km));
557 xnee_set_resume_key(xd, km);
558 break;
559 case XNEE_GRAB_INSERT:
560 xnee_verbose((xd, " --- xnee_set_key insert to %s\n", km));
561 xnee_set_insert_key(xd, km);
562 break;
563 case XNEE_GRAB_EXEC:
564 xnee_verbose((xd, " --- xnee_set_key exec to %s\n", km));
565 xnee_set_exec_key(xd, km);
566 break;
567 default:
568 xnee_print_error ("Unknown grab mode\n");
569 return XNEE_UNKNOWN_GRAB_MODE;
570 }
571 xnee_verbose((xd, "<--- xnee_set_key\n"));
572 return XNEE_OK;
573 }
574
575 char*
xnee_get_key(xnee_data * xd,int mode)576 xnee_get_key (xnee_data *xd, int mode)
577 {
578 char *ret;
579 xnee_verbose((xd, "---> xnee_get_key %d\n", mode));
580 switch (mode)
581 {
582 case XNEE_GRAB_STOP:
583 xnee_verbose((xd, " --- xnee_get_key stop \n"));
584 ret = xnee_get_stop_key(xd);
585 break;
586 case XNEE_GRAB_PAUSE:
587 xnee_verbose((xd, " --- xnee_get_key pause \n"));
588 ret = xnee_get_pause_key(xd);
589 break;
590 case XNEE_GRAB_RESUME:
591 xnee_verbose((xd, " --- xnee_get_key resume \n"));
592 ret = xnee_get_resume_key(xd);
593 break;
594 case XNEE_GRAB_INSERT:
595 xnee_verbose((xd, " --- xnee_get_key insert \n"));
596 ret = xnee_get_insert_key(xd);
597 break;
598 case XNEE_GRAB_EXEC:
599 xnee_verbose((xd, " --- xnee_get_key exec \n"));
600 ret = xnee_get_exec_key(xd);
601 break;
602 default:
603 xnee_print_error ("Unknown grab mode\n");
604 return NULL;
605 }
606 xnee_verbose((xd, "<--- xnee_get_key '%s'\n", ret));
607 return ret;
608 }
609
610
611
612
613 int
xnee_set_extra_str(xnee_data * xd,int idx,const char * str)614 xnee_set_extra_str (xnee_data *xd, int idx, const char *str)
615 {
616 if ( (idx<0) && (idx>XNEE_GRAB_LAST) )
617 {
618 return XNEE_BAD_GRAB_DATA;
619 }
620 if (str==NULL)
621 {
622 return XNEE_SYNTAX_ERROR;
623 }
624 if ( ( xd != NULL ) &&
625 ( xd->grab_keys!= NULL) )
626 {
627 XNEE_FREE_IF_NOT_NULL(xd->grab_keys->action_keys[idx].extra_str);
628 xd->grab_keys->action_keys[idx].extra_str = strdup(str);
629 }
630 else
631 {
632 return XNEE_BAD_GRAB_DATA;
633 }
634 return XNEE_OK;
635 }
636
637 int
xnee_set_key_str(xnee_data * xd,int idx,const char * str)638 xnee_set_key_str (xnee_data *xd, int idx, const char *str)
639 {
640 if ( (idx<0) && (idx>XNEE_GRAB_LAST) )
641 return XNEE_BAD_GRAB_DATA;
642
643 xnee_verbose((xd, "xnee_set_key_str (xd, %d, %s)\n", idx, str));
644
645 XNEE_FREE_IF_NOT_NULL(xd->grab_keys->action_keys[idx].str);
646 xd->grab_keys->action_keys[idx].str = strdup(str);
647 return XNEE_OK;
648 }
649
650 char*
xnee_get_extra_str(xnee_data * xd,int idx)651 xnee_get_extra_str (xnee_data *xd, int idx)
652 {
653 if ( (idx<0) && (idx>XNEE_GRAB_LAST) )
654 return NULL;
655 return xd->grab_keys->action_keys[idx].extra_str;
656 }
657
658 char*
xnee_get_key_str(xnee_data * xd,int idx)659 xnee_get_key_str (xnee_data *xd, int idx)
660 {
661 if ( (idx<0) && (idx>XNEE_GRAB_LAST) )
662 return NULL;
663
664 return xd->grab_keys->action_keys[idx].str;
665 }
666
667 char*
xnee_get_exec_prog(xnee_data * xd)668 xnee_get_exec_prog (xnee_data *xd)
669 {
670 return xd->grab_keys->action_keys[XNEE_GRAB_EXEC].extra_str;
671 }
672
673
674 int
xnee_set_exec_prog(xnee_data * xd,const char * prog)675 xnee_set_exec_prog (xnee_data *xd, const char *prog)
676 {
677 int ret ;
678 ret = xnee_set_extra_str (xd, XNEE_GRAB_EXEC, prog);
679 return ret;
680 }
681
682
683 int
xnee_set_force_replay(xnee_data * xd)684 xnee_set_force_replay (xnee_data *xd)
685 {
686 xd->force_replay=XNEE_TRUE;
687 return XNEE_OK;
688 }
689
690 int
xnee_unset_force_replay(xnee_data * xd)691 xnee_unset_force_replay (xnee_data *xd)
692 {
693 xd->force_replay=XNEE_FALSE;
694 return XNEE_OK;
695 }
696
697 int
xnee_get_force_replay(xnee_data * xd)698 xnee_get_force_replay (xnee_data *xd)
699 {
700 return (xd->force_replay==XNEE_TRUE);
701 }
702
703
704
705
706 int
xnee_is_force_replay(xnee_data * xd)707 xnee_is_force_replay (xnee_data *xd)
708 {
709 return (xd->force_replay==XNEE_TRUE);
710 }
711
712
713 int
set_first_replayed_event(xnee_data * xd)714 set_first_replayed_event (xnee_data *xd)
715 {
716 xd->first_replayed_event=XNEE_TRUE;
717 return 0;
718 }
719
720 int
get_first_replayed_event(xnee_data * xd)721 get_first_replayed_event (xnee_data *xd)
722 {
723 return (xd->first_replayed_event==XNEE_TRUE);
724 }
725
726 int
is_first_replayed_event(xnee_data * xd)727 is_first_replayed_event (xnee_data *xd)
728 {
729 return xd->first_replayed_event;
730 }
731
732
733
734
735 int
xnee_set_first_last(xnee_data * xd)736 xnee_set_first_last (xnee_data *xd)
737 {
738 xd->xnee_info.first_last = XNEE_TRUE;
739 return XNEE_OK;
740 }
741
742
743 int
xnee_get_first_last(xnee_data * xd)744 xnee_get_first_last (xnee_data *xd){
745 return xd->xnee_info.first_last;
746 }
747
748 int
xnee_is_first_last(xnee_data * xd)749 xnee_is_first_last (xnee_data *xd){
750 return (xd->xnee_info.first_last==XNEE_TRUE);
751 }
752
753
754 int
xnee_unset_first_last(xnee_data * xd)755 xnee_unset_first_last (xnee_data *xd)
756 {
757 xd->xnee_info.first_last = XNEE_FALSE;
758 return XNEE_OK;
759 }
760
761
762
763
764
765
766
767
768
769
770
771 int
xnee_set_events_max(xnee_data * xd,int loops)772 xnee_set_events_max (xnee_data *xd, int loops)
773 {
774 xd->xnee_info.events_max = loops;
775 return XNEE_OK;
776 }
777
778
779 int
xnee_get_events_max(xnee_data * xd)780 xnee_get_events_max (xnee_data *xd)
781 {
782 return xd->xnee_info.events_max;
783 }
784
785
786 int
xnee_get_events_left(xnee_data * xd)787 xnee_get_events_left (xnee_data *xd)
788 {
789 return (xd->xnee_info.events_max - xd->xnee_info.events_recorded);
790 }
791
792
793 int
xnee_set_data_max(xnee_data * xd,int loops)794 xnee_set_data_max (xnee_data *xd, int loops)
795 {
796 xd->xnee_info.data_max = loops;
797 return XNEE_OK;
798 }
799
800
801 int
xnee_get_data_max(xnee_data * xd)802 xnee_get_data_max (xnee_data *xd)
803 {
804 return xd->xnee_info.data_max;
805 }
806
807
808 int
xnee_get_data_left(xnee_data * xd)809 xnee_get_data_left (xnee_data *xd){
810 return (xd->xnee_info.data_max - xd->xnee_info.data_recorded);
811 }
812
813
814 int
xnee_set_time_max(xnee_data * xd,int time)815 xnee_set_time_max (xnee_data *xd, int time)
816 {
817 xd->xnee_info.time_max = time;
818 return XNEE_OK;
819 }
820
821 int
xnee_get_time_max(xnee_data * xd)822 xnee_get_time_max (xnee_data *xd)
823 {
824 return xd->xnee_info.time_max ;
825 }
826
827
828 int
xnee_get_time_left(xnee_data * xd)829 xnee_get_time_left (xnee_data *xd)
830 {
831 return (xd->xnee_info.time_max - xd->xnee_info.time_recorded);
832 }
833
834
835
836 int
xnee_set_interval(xnee_data * xd,int interval)837 xnee_set_interval (xnee_data *xd, int interval)
838 {
839 xd->xnee_info.interval = interval ;
840 return XNEE_OK;
841 }
842
843 int
xnee_get_interval(xnee_data * xd)844 xnee_get_interval (xnee_data *xd)
845 {
846 return xd->xnee_info.interval;
847 }
848
849
850 int
xnee_set_human_printout(xnee_data * xd)851 xnee_set_human_printout (xnee_data *xd)
852 {
853 xd->rec_callback = xnee_human_dispatch;
854 return XNEE_OK;
855 }
856
857 int
xnee_set_xnee_printout(xnee_data * xd)858 xnee_set_xnee_printout (xnee_data *xd)
859 {
860 xd->rec_callback = xnee_record_dispatch;
861 return XNEE_OK;
862 }
863
864
865
866
867
868 int
xnee_set_replay_speed_str(xnee_data * xd,const char * speed_str)869 xnee_set_replay_speed_str (xnee_data *xd, const char *speed_str)
870 {
871 int speed;
872 int ret ;
873
874 if (speed_str==NULL)
875 {
876 return XNEE_SYNTAX_ERROR;
877 }
878
879 ret = sscanf(speed_str, "%d", &speed);
880
881 if (ret == 1)
882 {
883 xnee_verbose ((xd, "Setting replay speed = %d (%s)\n",
884 speed, speed_str));
885 xnee_set_replay_speed (xd, speed);
886 return XNEE_OK;
887 }
888 else
889 {
890 xnee_verbose ((xd, "Failed to set replay speed\n"));
891 return XNEE_BAD_SPEED;
892 }
893 }
894
895 int
xnee_set_replay_speed(xnee_data * xd,int speed)896 xnee_set_replay_speed (xnee_data *xd, int speed)
897 {
898 xnee_verbose ((xd, "xnee_set_replay_speed = %d \n", speed));
899 xd->speed_percent=speed;
900 return XNEE_OK;
901 }
902
903
904 int
xnee_get_replay_speed(xnee_data * xd)905 xnee_get_replay_speed(xnee_data *xd)
906 {
907 return xd->speed_percent;
908 }
909
910
911 int
xnee_set_store_mouse_pos(xnee_data * xd)912 xnee_set_store_mouse_pos(xnee_data *xd)
913 {
914 xd->xnee_info.store_mouse_pos = True ;
915 return XNEE_OK;
916 }
917
918 int
xnee_unset_store_mouse_pos(xnee_data * xd)919 xnee_unset_store_mouse_pos(xnee_data *xd)
920 {
921 xd->xnee_info.store_mouse_pos = False ;
922 return XNEE_OK;
923 }
924
925 Bool
xnee_is_store_mouse_pos(xnee_data * xd)926 xnee_is_store_mouse_pos(xnee_data *xd)
927 {
928 return (xd->xnee_info.store_mouse_pos);
929 }
930
931
932 int
xnee_set_program_name(xnee_data * xd,const char * name)933 xnee_set_program_name(xnee_data *xd, const char* name)
934 {
935 XNEE_FREE_IF_NOT_NULL(xd->program_name);
936
937 xd->program_name = strdup(name);
938 if (xd->program_name==NULL)
939 {
940 return XNEE_MEMORY_FAULT;
941 }
942 return XNEE_OK;
943 }
944
945
946 char *
xnee_get_program_name(xnee_data * xd)947 xnee_get_program_name(xnee_data *xd)
948 {
949 return (xd->program_name);
950 }
951
952
953 int
xnee_get_new_project(xnee_data * xd)954 xnee_get_new_project(xnee_data *xd)
955 {
956 return (xd->xrm.new_project);
957 }
958
959 int
xnee_set_new_project(xnee_data * xd)960 xnee_set_new_project(xnee_data *xd)
961 {
962 xd->xrm.new_project = 1;
963 return XNEE_OK;
964 }
965
966 int
xnee_unset_new_project(xnee_data * xd)967 xnee_unset_new_project(xnee_data *xd)
968 {
969 xd->xrm.new_project = 0;
970 return XNEE_OK;
971 }
972
973 int
xnee_set_application_parameters(xnee_data * xd,char ** argv)974 xnee_set_application_parameters(xnee_data *xd, char **argv)
975 {
976 xd->app_args=argv;
977 return XNEE_OK;
978 }
979
980 char **
xnee_get_application_parameters(xnee_data * xd)981 xnee_get_application_parameters(xnee_data *xd)
982 {
983 return xd->app_args;
984 }
985
986
987 int
xnee_set_autorepeat(xnee_data * xd)988 xnee_set_autorepeat (xnee_data *xd)
989 {
990 if (xd->autorepeat_saved==1)
991 {
992 return XNEE_OK;
993 }
994
995 if (xd->keep_autorepeat!=0)
996 {
997 return XNEE_OK;
998 }
999
1000 if ( (xd==NULL) || (xd->fake==NULL) )
1001 {
1002 return (XNEE_MEMORY_FAULT);
1003 }
1004
1005 /*@ ignore @*/
1006 XGetKeyboardControl (xd->fake, &xd->kbd_orig);
1007 /*@ end @*/
1008
1009 xnee_verbose ((xd," key_click_percent %d \n",
1010 xd->kbd_orig.key_click_percent));
1011 xnee_verbose ((xd," bell_percent %d\n",
1012 xd->kbd_orig.bell_percent));
1013 xnee_verbose ((xd," bell_pitch %d\n",
1014 xd->kbd_orig.bell_pitch));
1015 xnee_verbose ((xd," bell_duration %d\n",
1016 xd->kbd_orig.bell_duration));
1017 xnee_verbose ((xd," led_mask %d\n",
1018 (int)xd->kbd_orig.led_mask));
1019 xnee_verbose ((xd," global_auto_repeat %d\n",
1020 xd->kbd_orig.global_auto_repeat));
1021
1022 xnee_verbose((xd,"Auto repeat:\n"));
1023 /*
1024 for (i=0;i<32;i++)
1025 {
1026 xnee_verbose((xd,"Key\t"));
1027 for (j=1;j<=8;j++)
1028 xnee_verbose((xd,"%03d ", (i*8)+j ));
1029 xnee_verbose((xd,"\nValue\t"));
1030 for (j=1;j<=8;j++)
1031 {
1032 xnee_verbose((xd," %d ", xd->kbd_orig.auto_repeats[i] && j));
1033 }
1034 xnee_verbose((xd,"\n\n"));
1035 }
1036 */
1037 /*@ ignore @*/
1038 XAutoRepeatOff(xd->fake);
1039 /*@ end @*/
1040 xd->autorepeat_saved=1;
1041
1042 return XNEE_OK;
1043 }
1044
1045
1046 int
xnee_reset_autorepeat(xnee_data * xd)1047 xnee_reset_autorepeat (xnee_data *xd)
1048 {
1049 if (xd->autorepeat_saved==0)
1050 {
1051 return XNEE_OK;
1052 }
1053
1054 if (xd->keep_autorepeat!=0)
1055 {
1056 return XNEE_OK;
1057 }
1058
1059 xnee_verbose((xd,"Resetting autorepeat on (%p) to: ",
1060 (xd->fake==NULL)?0:(void*)xd->fake));
1061
1062 if (!xd->fake)
1063 {
1064 return XNEE_OK;
1065 }
1066
1067 if (xd->kbd_orig.global_auto_repeat==AutoRepeatModeOn)
1068 {
1069 xnee_verbose((xd,"AutoRepeatModeOn\n"));
1070 /*@ignore@*/
1071 XAutoRepeatOn(xd->fake);
1072 /*@end@*/
1073 }
1074 else
1075 {
1076 xnee_verbose((xd,"AutoRepeatModeOff\n"));
1077 /*@ignore@*/
1078 XAutoRepeatOff(xd->fake);
1079 /*@end@*/
1080 }
1081 /* Make sure the resetting of autorepeat is handled
1082 before we close down the display */
1083 /*@ignore@*/
1084 XFlush (xd->fake);
1085 /*@end@*/
1086 xd->autorepeat_saved=0;
1087 return XNEE_OK;
1088 }
1089
1090
1091 int
xnee_set_replay_offset_str(xnee_data * xd,char * str)1092 xnee_set_replay_offset_str (xnee_data *xd, char *str)
1093 {
1094 int x;
1095 int y;
1096 int ret;
1097 xnee_verbose((xd, "replay offset str: %s\n", str));
1098
1099 if (str==NULL)
1100 {
1101 return XNEE_WRONG_PARAMS;
1102 }
1103
1104 ret = sscanf(str, "%d,%d",&x,&y);
1105
1106 if (ret != 2 )
1107 {
1108 xnee_verbose((xd, "replay offset failed: %d\n", ret));
1109 return(ret);
1110 }
1111
1112 xd->res_info.x_offset = x;
1113 xd->res_info.y_offset = y;
1114
1115 xnee_verbose((xd, "replay offset OK: %dx%d\n", x,y));
1116 return XNEE_OK;
1117 }
1118
1119 int
xnee_set_replay_offset_x(xnee_data * xd,int offset)1120 xnee_set_replay_offset_x(xnee_data *xd, int offset)
1121 {
1122 xd->res_info.x_offset = offset;
1123 return XNEE_OK;
1124 }
1125
1126 int
xnee_set_replay_offset_y(xnee_data * xd,int offset)1127 xnee_set_replay_offset_y(xnee_data *xd, int offset)
1128 {
1129 xd->res_info.y_offset = offset;
1130 return XNEE_OK;
1131 }
1132
1133 int
xnee_get_replay_offset_x(xnee_data * xd)1134 xnee_get_replay_offset_x(xnee_data *xd)
1135 {
1136 return xd->res_info.x_offset ;
1137 }
1138
1139 int
xnee_get_replay_offset_y(xnee_data * xd)1140 xnee_get_replay_offset_y(xnee_data *xd)
1141 {
1142 return xd->res_info.y_offset ;
1143 }
1144
1145 int
xnee_get_new_window_pos(xnee_data * xd)1146 xnee_get_new_window_pos (xnee_data *xd)
1147 {
1148 xnee_verbose((xd, "xnee_set_new_window_pos()\n"));
1149 return xd->xnee_info.store_window_pos;
1150 }
1151
1152 int
xnee_set_new_window_pos(xnee_data * xd)1153 xnee_set_new_window_pos (xnee_data *xd)
1154 {
1155 xnee_verbose((xd, "xnee_set_new_window_pos()\n"));
1156 xd->xnee_info.store_window_pos=1;
1157 return XNEE_OK;
1158 }
1159
1160 int
xnee_set_new_window_pos_value(xnee_data * xd,int val)1161 xnee_set_new_window_pos_value (xnee_data *xd, int val)
1162 {
1163 xnee_verbose((xd, "xnee_set_new_window_pos(%d)\n", val));
1164 xd->xnee_info.store_window_pos=val;
1165 return XNEE_OK;
1166 }
1167
1168 int
xnee_get_new_window_pos_value(xnee_data * xd)1169 xnee_get_new_window_pos_value (xnee_data *xd)
1170 {
1171 return xd->xnee_info.store_window_pos;
1172 }
1173
1174 int
xnee_unset_new_window_pos(xnee_data * xd)1175 xnee_unset_new_window_pos (xnee_data *xd)
1176 {
1177 xnee_verbose((xd, "xnee_unset_new_window_pos()\n"));
1178 xd->xnee_info.store_window_pos=0;
1179 return XNEE_OK;
1180 }
1181
1182
1183 int
xnee_get_recall_window_pos(xnee_data * xd)1184 xnee_get_recall_window_pos (xnee_data *xd)
1185 {
1186 xnee_verbose((xd, "xnee_get_recall_window_pos()\n"));
1187 return xd->recall_recorded_win_pos;
1188 }
1189
1190
1191 int
xnee_set_recall_window_pos(xnee_data * xd)1192 xnee_set_recall_window_pos (xnee_data *xd)
1193 {
1194 xnee_verbose((xd, "xnee_set_recall_window_pos()\n"));
1195 xd->recall_recorded_win_pos=1;
1196 return xnee_parse_range (xd, XNEE_DELIVERED_EVENT, "ReparentNotify");
1197 }
1198
1199
1200 int
xnee_unset_recall_window_pos(xnee_data * xd)1201 xnee_unset_recall_window_pos (xnee_data *xd)
1202 {
1203 xnee_verbose((xd, "xnee_unset_recall_window_pos()\n"));
1204 xd->recall_recorded_win_pos=0;
1205 return XNEE_OK;
1206 }
1207
1208
1209 int
xnee_set_project_file(xnee_data * xd,char * name)1210 xnee_set_project_file(xnee_data *xd, char *name)
1211 {
1212 #define XNEE_PARSE_BUF 200
1213 char buf [XNEE_PARSE_BUF];
1214 int ret;
1215
1216 if (name == NULL)
1217 {
1218 return XNEE_WRONG_PARAMS;
1219 }
1220
1221 ret = xnee_set_rc_byname (xd, name);
1222 if ( ret != XNEE_OK)
1223 {
1224 xnee_verbose((xd, "Could not open project file %s\n", name));
1225
1226 if ( (strlen(name) + strlen (XNEE_RESOURCE_DIR) + 2 ) > 200)
1227 {
1228 xnee_verbose ((xd, "ERROR: Filename too big\n"));
1229 xnee_verbose ((xd, "... leaving.\n"));
1230 xnee_close_down(xd);
1231 return(XNEE_WRONG_PARAMS);
1232 }
1233 strncpy ( buf , XNEE_RESOURCE_DIR, XNEE_PARSE_BUF );
1234 strncat ( buf , "/", XNEE_PARSE_BUF - strlen(buf));
1235 strncat ( buf , name, XNEE_PARSE_BUF - strlen(buf));
1236 xnee_verbose((xd, "\ttryingresource file %s\n", buf));
1237 ret = xnee_set_rc_name (xd, buf);
1238 }
1239 if ( xnee_get_rc_file (xd) != NULL)
1240 {
1241 ret = xnee_add_resource (xd);
1242
1243 if (ret!=XNEE_OK)
1244 {
1245 xnee_verbose ((xd, "project file read: return value %d\n",
1246 ret));
1247 if (ret == XNEE_SYNTAX_ERROR)
1248 {
1249 char *tmp_str;
1250 xnee_verbose ((xd, "project file read: SYNTAX ERROR\n"));
1251 tmp_str = xnee_get_err_string();
1252 if (tmp_str!=NULL)
1253 {
1254 fprintf (stderr,"%s", tmp_str);
1255 }
1256 XNEE_FREE_IF_NOT_NULL(tmp_str);
1257 return ret;
1258 }
1259 }
1260 }
1261 else
1262 {
1263 xnee_print_error ("Unable to open resource file\n");
1264 xnee_verbose ((xd, "Could not open resource file\n"));
1265 xnee_verbose ((xd, "... leaving\n"));
1266 ret = XNEE_WRONG_PARAMS;
1267 }
1268 return ret;
1269 }
1270
1271
1272
1273 char *
xnee_get_project_name(xnee_data * xd)1274 xnee_get_project_name(xnee_data *xd)
1275 {
1276 if (xd->xrm.project_name!=NULL)
1277 {
1278 return xd->xrm.project_name;
1279 }
1280 else
1281 {
1282 return (char*)XNEE_EMPTY_STRING;
1283 }
1284 }
1285
1286 char *
xnee_get_project_descr(xnee_data * xd)1287 xnee_get_project_descr(xnee_data *xd){
1288 if (xd->xrm.project_descr!=NULL)
1289 {
1290 return xd->xrm.project_descr;
1291 }
1292 else
1293 {
1294 return (char*)XNEE_EMPTY_STRING;
1295 }
1296 }
1297
1298 char *
xnee_get_creat_date(xnee_data * xd)1299 xnee_get_creat_date(xnee_data *xd)
1300 {
1301 time_t rawtime;
1302 struct tm * timeinfo;
1303 #define XNEE_DATE_BUF_SIZE 100
1304 static char buf[XNEE_DATE_BUF_SIZE];
1305
1306 if (xd->xrm.creat_date!=NULL)
1307 {
1308 return xd->xrm.creat_date;
1309 }
1310 time ( &rawtime );
1311 timeinfo = localtime ( &rawtime );
1312 snprintf(buf, XNEE_DATE_BUF_SIZE,
1313 "%.4d-%.2d-%.2d",
1314 timeinfo->tm_year + 1900 ,
1315 timeinfo->tm_mon + 1 ,
1316 timeinfo->tm_mday );
1317
1318 return buf;
1319 }
1320
1321 char *
xnee_get_creat_program(xnee_data * xd)1322 xnee_get_creat_program(xnee_data *xd)
1323 {
1324 if (xd->xrm.creat_prog!=NULL)
1325 return xd->xrm.creat_prog;
1326 else
1327 return xnee_get_program_name(xd);
1328 }
1329
1330 char *
xnee_get_creat_prog_vers(xnee_data * xd)1331 xnee_get_creat_prog_vers(xnee_data *xd)
1332 {
1333 if (xd->xrm.creat_prog_vers!=NULL)
1334 return xd->xrm.creat_prog_vers;
1335 else
1336 return VERSION;
1337 }
1338
1339 char *
xnee_get_last_date(xnee_data * xd)1340 xnee_get_last_date(xnee_data *xd)
1341 {
1342 if (xd->xrm.last_date!=NULL)
1343 return xd->xrm.last_date;
1344 else
1345 return "none";
1346 }
1347
1348 char *
xnee_get_last_program(xnee_data * xd)1349 xnee_get_last_program(xnee_data *xd)
1350 {
1351 if (xd->xrm.last_prog!=NULL)
1352 return xd->xrm.last_prog;
1353 else
1354 return "none";
1355 }
1356
1357 char *
xnee_get_last_prog_vers(xnee_data * xd)1358 xnee_get_last_prog_vers(xnee_data *xd){
1359 if (xd->xrm.last_prog_vers!=NULL)
1360 return xd->xrm.last_prog_vers;
1361 else
1362 return "none";
1363 }
1364
1365 char *
xnee_get_author_name(xnee_data * xd)1366 xnee_get_author_name(xnee_data *xd){
1367 if (xd->xrm.author_name!=NULL)
1368 return xd->xrm.author_name;
1369 else
1370 return "none";
1371 }
1372
1373 char *
xnee_get_author_email(xnee_data * xd)1374 xnee_get_author_email(xnee_data *xd){
1375 if (xd->xrm.author_email!=NULL)
1376 return xd->xrm.author_email;
1377 else
1378 return "none";
1379 }
1380
1381
1382 int
xnee_set_project_name(xnee_data * xd,char * str)1383 xnee_set_project_name(xnee_data *xd, char *str)
1384 {
1385 if (str==NULL)
1386 {
1387 return XNEE_NO_PROJECT_FILE;
1388 }
1389
1390 XNEE_FREE_IF_NOT_NULL(xd->xrm.project_name);
1391 xd->xrm.project_name=strdup(str);
1392 return XNEE_OK;
1393 }
1394
1395 int
xnee_set_plugin_name(xnee_data * xd,char * str,unsigned char mode)1396 xnee_set_plugin_name(xnee_data *xd, char *str, unsigned char mode)
1397 {
1398 if (str==NULL)
1399 {
1400 return XNEE_NO_PLUGIN_FILE;
1401 }
1402
1403 return xnee_use_plugin(xd, str, mode);
1404 }
1405
1406
1407
1408 int
xnee_set_project_descr(xnee_data * xd,char * str)1409 xnee_set_project_descr(xnee_data *xd, char *str){
1410 xd->xrm.project_descr=strdup(str);
1411 return XNEE_OK;
1412 }
1413
1414 int
xnee_set_creat_date(xnee_data * xd,char * str)1415 xnee_set_creat_date(xnee_data *xd, char *str){
1416 XNEE_FREE_IF_NOT_NULL(xd->xrm.creat_date);
1417 xd->xrm.creat_date=strdup(str);
1418 return XNEE_OK;
1419 }
1420
1421 int
xnee_set_creat_program(xnee_data * xd,char * str)1422 xnee_set_creat_program(xnee_data *xd, char *str){
1423 XNEE_FREE_IF_NOT_NULL(xd->xrm.creat_prog_vers);
1424 xd->xrm.creat_prog=strdup(str);
1425 return XNEE_OK;
1426 }
1427
1428 int
xnee_set_creat_prog_vers(xnee_data * xd,char * str)1429 xnee_set_creat_prog_vers(xnee_data *xd, char *str){
1430 xd->xrm.creat_prog_vers=strdup(str);
1431 return XNEE_OK;
1432 }
1433
1434 int
xnee_set_last_date(xnee_data * xd,char * str)1435 xnee_set_last_date(xnee_data *xd, char *str)
1436 {
1437 XNEE_FREE_IF_NOT_NULL(xd->xrm.last_date);
1438 xd->xrm.last_date=strdup(str);
1439 return XNEE_OK;
1440 }
1441
1442 int
xnee_set_last_program(xnee_data * xd,char * str)1443 xnee_set_last_program(xnee_data *xd, char *str){
1444 xd->xrm.last_prog=strdup(str);
1445 return XNEE_OK;
1446 }
1447 int
xnee_set_last_prog_vers(xnee_data * xd,char * str)1448 xnee_set_last_prog_vers(xnee_data *xd, char *str)
1449 {
1450 xd->xrm.last_prog_vers=strdup(str);
1451 return XNEE_OK;
1452 }
1453 int
xnee_set_author_name(xnee_data * xd,char * str)1454 xnee_set_author_name(xnee_data *xd, char *str){
1455 xd->xrm.author_name=strdup(str);
1456 return XNEE_OK;
1457 }
1458
1459 int
xnee_set_author_email(xnee_data * xd,char * str)1460 xnee_set_author_email(xnee_data *xd, char *str){
1461 xd->xrm.author_email=strdup(str);
1462 return XNEE_OK;
1463 }
1464
1465 #ifdef USE_OBSOLETE
1466 int
xnee_set_first_list_str2(xnee_data * xd,char * str)1467 xnee_set_first_list_str2(xnee_data *xd, char *str)
1468 {
1469 int ret = XNEE_OK;
1470
1471 if ( str != NULL)
1472 {
1473 ret = xnee_boolstr2int(xd, str);
1474 }
1475 if (ret == XNEE_BOOL_ERROR)
1476 {
1477 ret = XNEE_SYNTAX_ERROR;
1478 }
1479 else
1480 {
1481 if (ret)
1482 {
1483 ret = xnee_set_first_last(xd);
1484 }
1485 else
1486 {
1487 ret = xnee_unset_first_last(xd);
1488 }
1489 }
1490 return ret;
1491 }
1492 #endif
1493
1494 int
xnee_set_all_clients_str(xnee_data * xd,char * str)1495 xnee_set_all_clients_str(xnee_data *xd, char *str)
1496 {
1497 int ret = XNEE_OK;
1498
1499 ret = xnee_boolstr2int(xd, str);
1500 if (ret == XNEE_BOOL_ERROR)
1501 {
1502 ret = XNEE_SYNTAX_ERROR;
1503 }
1504 else
1505 {
1506 if (ret)
1507 {
1508 ret = xnee_set_all_clients(xd);
1509 }
1510 else
1511 {
1512 ret = xnee_unset_all_clients(xd);
1513 }
1514 }
1515
1516 return ret;
1517 }
1518
1519
1520 int
xnee_set_future_clients_str(xnee_data * xd,char * str)1521 xnee_set_future_clients_str(xnee_data *xd, char *str)
1522 {
1523 int ret = XNEE_OK;
1524
1525 ret = xnee_boolstr2int(xd, str);
1526 if (ret == XNEE_BOOL_ERROR)
1527 {
1528 ret = XNEE_SYNTAX_ERROR;
1529 }
1530 else
1531 {
1532 if (ret)
1533 {
1534 ret = xnee_set_future_clients(xd);
1535 }
1536 else
1537 {
1538 ret = xnee_unset_future_clients(xd);
1539 }
1540 }
1541 return ret;
1542 }
1543
1544 int
xnee_set_future_clients(xnee_data * xd)1545 xnee_set_future_clients(xnee_data *xd)
1546 {
1547 /* Setting future clients is the same as unsetting
1548 all_clients*/
1549 return xnee_unset_all_clients(xd);
1550 }
1551
1552 int
xnee_unset_future_clients(xnee_data * xd)1553 xnee_unset_future_clients(xnee_data *xd)
1554 {
1555 /* Unsetting future clients is the same as setting
1556 all_clients*/
1557 return xnee_set_all_clients(xd);
1558 }
1559
1560
1561
1562 int
xnee_set_events_max_str(xnee_data * xd,char * str)1563 xnee_set_events_max_str (xnee_data *xd, char *str)
1564 {
1565 int ret;
1566
1567 ret = xnee_str2int (xd, str);
1568
1569 if ( ret == INT_MAX )
1570 {
1571 ret = XNEE_SYNTAX_ERROR ;
1572 }
1573 else
1574 {
1575 ret = xnee_set_events_max(xd, ret);
1576 }
1577 return ret;
1578 }
1579
1580 int
xnee_set_data_max_str(xnee_data * xd,char * str)1581 xnee_set_data_max_str (xnee_data *xd, char *str)
1582 {
1583 int ret;
1584
1585 ret = xnee_str2int (xd, str);
1586
1587 if ( ret == INT_MAX )
1588 {
1589 ret = XNEE_SYNTAX_ERROR ;
1590 }
1591 else
1592 {
1593 ret = xnee_set_data_max(xd, ret);
1594 }
1595 return ret;
1596 }
1597
1598 int
xnee_set_time_max_str(xnee_data * xd,char * str)1599 xnee_set_time_max_str (xnee_data *xd, char *str)
1600 {
1601 int ret;
1602
1603 ret = xnee_str2int (xd, str);
1604
1605 if ( ret == INT_MAX )
1606 {
1607 ret = XNEE_SYNTAX_ERROR ;
1608 }
1609 else
1610 {
1611 ret = xnee_set_time_max(xd, ret);
1612 }
1613 return ret;
1614 }
1615
1616 int
xnee_set_resolution_str(xnee_data * xd,char * str)1617 xnee_set_resolution_str (xnee_data *xd, char *str)
1618 {
1619 int ret = XNEE_OK;
1620
1621 ret = xnee_boolstr2int(xd, str);
1622 if (ret == XNEE_BOOL_ERROR)
1623 {
1624 ret = XNEE_SYNTAX_ERROR;
1625 }
1626 else
1627 {
1628 if (ret)
1629 {
1630 ret = xnee_set_resolution_used(xd);
1631 }
1632 else
1633 {
1634 ret = xnee_unset_resolution_used(xd);
1635 }
1636 }
1637 return ret;
1638 }
1639
1640
1641 int
xnee_set_sync_mode_str(xnee_data * xd,char * str)1642 xnee_set_sync_mode_str (xnee_data *xd, char *str)
1643 {
1644 int ret = XNEE_OK;
1645
1646 ret = xnee_boolstr2int(xd, str);
1647 if (ret == XNEE_BOOL_ERROR)
1648 {
1649 ret = XNEE_SYNTAX_ERROR;
1650 }
1651 else
1652 {
1653 if (ret)
1654 {
1655 ret = xnee_set_sync_mode(xd);
1656 }
1657 else
1658 {
1659 ret = xnee_unset_sync_mode(xd);
1660 }
1661 }
1662 return ret;
1663 }
1664
1665 int
xnee_unset_sync_mode_str(xnee_data * xd,char * str)1666 xnee_unset_sync_mode_str (xnee_data *xd, char *str)
1667 {
1668 int ret = XNEE_OK;
1669
1670 ret = xnee_boolstr2int(xd, str);
1671 if (ret == XNEE_BOOL_ERROR)
1672 {
1673 ret = XNEE_SYNTAX_ERROR;
1674 }
1675 else
1676 {
1677 if (ret)
1678 {
1679 ret = xnee_unset_sync_mode(xd);
1680 }
1681 else
1682 {
1683 ret = xnee_set_sync_mode(xd);
1684 }
1685 }
1686 return ret;
1687 }
1688
1689
1690 int
xnee_set_sync_mode(xnee_data * xd)1691 xnee_set_sync_mode(xnee_data *xd)
1692 {
1693 xd->sync = True;
1694 return XNEE_OK;
1695 }
1696
1697 int
xnee_get_sync_mode(xnee_data * xd)1698 xnee_get_sync_mode(xnee_data *xd)
1699 {
1700 return xd->sync ;
1701 }
1702
1703 int
xnee_unset_sync_mode(xnee_data * xd)1704 xnee_unset_sync_mode(xnee_data *xd)
1705 {
1706 xnee_verbose((xd, "Setting no sync\n"));
1707 xd->sync = False;
1708 return XNEE_OK;
1709 }
1710
1711 int
xnee_set_unsync_mode(xnee_data * xd)1712 xnee_set_unsync_mode(xnee_data *xd)
1713 {
1714 xnee_verbose((xd, "Setting unsync\n"));
1715 xd->sync = False;
1716 return XNEE_OK;
1717 }
1718
1719 int
xnee_get_unsync_mode(xnee_data * xd)1720 xnee_get_unsync_mode(xnee_data *xd)
1721 {
1722 return xd->sync ;
1723 }
1724
1725 const char *
xnee_get_xosd_font(xnee_data * xd)1726 xnee_get_xosd_font(xnee_data *xd)
1727 {
1728 return xnee_get_xosd_font_impl(xd);
1729 }
1730
1731 int
xnee_set_xosd_font(xnee_data * xd,char * font_str)1732 xnee_set_xosd_font(xnee_data *xd, char *font_str)
1733 {
1734 return xnee_set_xosd_font_impl(xd, font_str);
1735 }
1736
1737
1738 int
xnee_set_rec_resolution(xnee_data * xd,char * res_str)1739 xnee_set_rec_resolution (xnee_data *xd, char *res_str)
1740 {
1741 return xnee_str_to_res (res_str, &xd->res_info.record);
1742 }
1743
1744 int
xnee_get_rec_resolution_x(xnee_data * xd)1745 xnee_get_rec_resolution_x (xnee_data *xd)
1746 {
1747 return xd->res_info.record.x_res;
1748 }
1749
1750 int
xnee_get_rec_resolution_y(xnee_data * xd)1751 xnee_get_rec_resolution_y (xnee_data *xd)
1752 {
1753 return xd->res_info.record.y_res;
1754 }
1755
1756 int
xnee_set_rec_resolution_y(xnee_data * xd,int res)1757 xnee_set_rec_resolution_y (xnee_data *xd, int res)
1758 {
1759 xd->res_info.record.y_res = res;
1760 return XNEE_OK;
1761 }
1762
1763 int
xnee_set_rec_resolution_x(xnee_data * xd,int res)1764 xnee_set_rec_resolution_x (xnee_data *xd, int res)
1765 {
1766 xd->res_info.record.x_res = res;
1767 return XNEE_OK;
1768 }
1769
1770
1771 int
xnee_set_rep_resolution_y(xnee_data * xd,int res)1772 xnee_set_rep_resolution_y (xnee_data *xd, int res)
1773 {
1774 xd->res_info.replay.y_res = res;
1775 return XNEE_OK;
1776 }
1777
1778 int
xnee_set_rep_resolution_x(xnee_data * xd,int res)1779 xnee_set_rep_resolution_x (xnee_data *xd, int res)
1780 {
1781 xd->res_info.replay.x_res = res;
1782 return XNEE_OK;
1783 }
1784
1785
1786 int
xnee_set_rep_resolution(xnee_data * xd,char * res_str)1787 xnee_set_rep_resolution (xnee_data *xd, char *res_str)
1788 {
1789 int ret ;
1790 ret = xnee_str_to_res (res_str, &xd->res_info.replay);
1791
1792 return ret;
1793 }
1794
1795 int
xnee_get_rep_resolution_x(xnee_data * xd)1796 xnee_get_rep_resolution_x (xnee_data *xd)
1797 {
1798 return xd->res_info.replay.x_res;
1799 }
1800
1801 int
xnee_get_rep_resolution_y(xnee_data * xd)1802 xnee_get_rep_resolution_y (xnee_data *xd)
1803 {
1804 return xd->res_info.replay.y_res;
1805 }
1806
1807 xnee_data*
xnee_get_xnee_data(void)1808 xnee_get_xnee_data (void)
1809 {
1810 return xd_saved;
1811 }
1812
1813 int
xnee_set_xnee_data(xnee_data * xd)1814 xnee_set_xnee_data (xnee_data *xd)
1815 {
1816 xd_saved = xd;
1817 return XNEE_OK;
1818 }
1819
1820 int
xnee_set_keep_autorepeat(xnee_data * xd)1821 xnee_set_keep_autorepeat (xnee_data *xd)
1822 {
1823 xd->keep_autorepeat = 1;
1824 return XNEE_OK;
1825 }
1826
1827 int
xnee_set_retype_press_delay(xnee_data * xd,unsigned int delay)1828 xnee_set_retype_press_delay(xnee_data *xd, unsigned int delay)
1829 {
1830 xd->retype.key_press_delay = delay;
1831 return XNEE_OK;
1832 }
1833
1834 int
xnee_set_retype_release_delay(xnee_data * xd,unsigned int delay)1835 xnee_set_retype_release_delay(xnee_data *xd, unsigned int delay)
1836 {
1837 xd->retype.key_release_delay = delay;
1838 return XNEE_OK;
1839 }
1840
1841
1842 int
xnee_set_no_reparent_recording(xnee_data * xd)1843 xnee_set_no_reparent_recording(xnee_data *xd)
1844 {
1845 xd->no_reparent_recording = 1;
1846 return XNEE_OK;
1847 }
1848
1849 int
xnee_unset_no_reparent_recording(xnee_data * xd)1850 xnee_unset_no_reparent_recording(xnee_data *xd)
1851 {
1852 xd->no_reparent_recording = 0;
1853 return XNEE_OK;
1854 }
1855
1856 int
xnee_is_no_reparent_recording(xnee_data * xd)1857 xnee_is_no_reparent_recording(xnee_data *xd)
1858 {
1859 return xd->no_reparent_recording ;
1860 }
1861
1862
1863 int
xnee_set_replay_backend(xnee_data * xd,int replay_backend)1864 xnee_set_replay_backend(xnee_data *xd, int replay_backend)
1865 {
1866 if (( replay_backend < 0 ) || (replay_backend >= XNEE_REPLAY_LAST))
1867 {
1868 return XNEE_REPLAY_BACKEND_FAILURE;
1869 }
1870 xd->replay_backend = replay_backend;
1871 return XNEE_OK;
1872 }
1873
1874 int
xnee_set_replay_backend_name(xnee_data * xd,char * replay_backend)1875 xnee_set_replay_backend_name(xnee_data *xd, char *replay_backend)
1876 {
1877 if (replay_backend==NULL)
1878 {
1879 return XNEE_REPLAY_BACKEND_FAILURE;
1880 }
1881 if (strncmp(replay_backend,
1882 XNEE_REPLAY_XNEE_STRING,
1883 strlen(XNEE_REPLAY_XNEE_STRING))==0)
1884 {
1885 return xnee_set_replay_backend(xd, XNEE_REPLAY_XNEE);
1886 }
1887 else if (strncmp(replay_backend,
1888 XNEE_REPLAY_SWINPUT_STRING,
1889 strlen(XNEE_REPLAY_SWINPUT_STRING))==0)
1890 {
1891 return xnee_set_replay_backend(xd, XNEE_REPLAY_SWINPUT);
1892 }
1893 return XNEE_REPLAY_BACKEND_FAILURE;
1894 }
1895
1896 int
xnee_is_forced_core_device_events(xnee_data * xd)1897 xnee_is_forced_core_device_events(xnee_data *xd)
1898 {
1899 return (xd->xi_data.forced_core_replay != 0) ;
1900 }
1901
1902 int
xnee_set_forced_core_device_events(xnee_data * xd)1903 xnee_set_forced_core_device_events(xnee_data *xd)
1904 {
1905 xd->xi_data.forced_core_replay = 1 ;
1906 return XNEE_OK;
1907 }
1908
1909 int
xnee_unset_forced_core_device_events(xnee_data * xd)1910 xnee_unset_forced_core_device_events(xnee_data *xd)
1911 {
1912 xd->xi_data.forced_core_replay = 0 ;
1913 return XNEE_OK;
1914 }
1915
1916
1917 int
xnee_get_max_nr_of_moves(xnee_data * xd)1918 xnee_get_max_nr_of_moves(xnee_data *xd)
1919 {
1920 if (xd==NULL)
1921 {
1922 return -1;
1923 }
1924 return xd->max_nr_of_moves;
1925 }
1926
1927 int
xnee_set_max_nr_of_moves(xnee_data * xd,int moves)1928 xnee_set_max_nr_of_moves(xnee_data *xd, int moves)
1929 {
1930 if (xd==NULL)
1931 {
1932 return -1;
1933 }
1934
1935 xd->max_nr_of_moves = moves ;
1936 return 0 ;
1937 }
1938
1939 int
xnee_set_override_display(xnee_data * xd,int mode)1940 xnee_set_override_display(xnee_data *xd, int mode)
1941 {
1942 if ( (xd==NULL) || (mode<0) || (mode > XNEE_OVERRIDE_DISPLAY_CONTROL))
1943 {
1944 return -1;
1945 }
1946 xd->xnee_info.override_recorded_display = mode;
1947 return XNEE_OK;
1948 }
1949
1950 int
xnee_get_override_display(xnee_data * xd)1951 xnee_get_override_display(xnee_data *xd)
1952 {
1953 return xd->xnee_info.override_recorded_display;
1954 }
1955