/usr/include/libxnee/xnee.h is in libxnee-dev 3.19-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | /*****
* Xnee's Not an Event Emulator
*
* Xnee enables recording and replaying of X protocol data
*
* Copyright (C) 1999-2003, 2009, 2010, 2014 Henrik Sandklef
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Boston,
* MA 02110-1301, USA.
****/
#ifndef XNEE_XNEE_H
#define XNEE_XNEE_H
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <semaphore.h>
#include <sys/utsname.h>
#include "libxnee/x11_files.h"
#include "libxnee/xnee_internal.h"
#include "libxnee/xnee_strings.h"
#include "libxnee/xnee_error.h"
#include "libxnee/xnee_settings.h"
#define XNEE_CLI "cnee"
#define XNEE_CLI_UC "CNEE"
typedef int xnee_keymask;
/*
* Return values
*/
enum return_values
{
XNEE_OK = 0 ,
XNEE_MEMORY_FAULT ,
XNEE_FILE_NOT_FOUND ,
XNEE_TIMED_OUT ,
XNEE_USER_INTR ,
XNEE_SYNCH_FAULT ,
XNEE_WRONG_PARAMS ,
XNEE_NO_REC_EXT ,
XNEE_NO_TEST_EXT ,
XNEE_NO_PROT_CHOOSEN ,
XNEE_NOT_OPEN_DISPLAY ,
XNEE_AMBIGOUS_CMD ,
XNEE_OUT_OF_SYNC ,
XNEE_NOT_SYNCING ,
XNEE_NO_PLUGIN_FILE ,
XNEE_PLUGIN_FILE_ERROR ,
XNEE_NO_PROJECT_FILE ,
XNEE_NO_MAIN_DATA ,
XNEE_NO_RECORD_DATA ,
XNEE_NO_REPLAY_DATA ,
XNEE_SYNTAX_ERROR ,
XNEE_UNKNOWN_GRAB_MODE ,
XNEE_NO_GRAB_DATA ,
XNEE_GRAB_DATA ,
XNEE_BAD_GRAB_DATA ,
XNEE_BAD_LOG_FILE ,
XNEE_BAD_SPEED ,
XNEE_BAD_RESOLUTION ,
XNEE_BAD_THRESHOLD ,
XNEE_BAD_CONTEXT ,
XNEE_BLANK_LINE ,
XNEE_XOSD_FAILURE ,
XNEE_FEEDBACK_FAILURE ,
XNEE_MODE_NOT_SET ,
XNEE_GRAB_MEM_FAILURE ,
XNEE_RECORD_FAILURE ,
XNEE_DATE_FAILURE ,
XNEE_SCREEN_MISSING ,
XNEE_RANGE_FAILURE ,
XNEE_BAD_OFFSET ,
XNEE_WINDOW_POS_ADJ_ERROR ,
XNEE_MISSING_ARG ,
XNEE_OK_LEAVE ,
XNEE_GRAB_CONFUSION ,
XNEE_PROJECT_SYNTAX_ERROR ,
XNEE_CLI_ERROR ,
XNEE_XINPUT_EXTENSION_FAILURE ,
XNEE_REPLAY_BACKEND_FAILURE ,
XNEE_OVERRIDE_DISPLAY_FAILURE ,
XNEE_LAST_ERROR
} _return_values;
enum bool_string_values
{
XNEE_BOOL_EXPLICIT_FALSE=0,
XNEE_BOOL_IMPLICIT_TRUE,
XNEE_BOOL_EXPLICIT_TRUE,
XNEE_BOOL_ERROR
} _bool_string_values;
enum xnee_protocol_data_numbers
{
XNEE_PROTO_EVENT = 0,
XNEE_PROTO_REQUEST ,
XNEE_PROTO_REPLY ,
XNEE_PROTO_ERROR ,
XNEE_PROTO_DUMMY1 ,
XNEE_PROTO_DUMMY2 ,
XNEE_PROTO_XINPUT_EVENT_MASTER,
XNEE_PROTO_XINPUT_EVENT_SLAVE,
XNEE_PROTO_LAST
} _xnee_protocol_data_numbers;
enum xnee_replay_backend
{
XNEE_REPLAY_XNEE = 0,
XNEE_REPLAY_SWINPUT,
XNEE_REPLAY_LAST
} _xnee_replay_backend;
/**
* \brief simply a X error.
*
*/
typedef struct {
int type; /*!< Simply an X error. Put in a struct if things are to be added later on */
}xnee_error;
/**
* \brief simply a X reply.
*
*/
typedef struct {
int type; /*!< Simply an X reply. Put in a struct if things are to be added later on */
}xnee_reply;
/**
* \brief simply a X request.
*
*/
typedef struct {
int type; /*!< Simply an X requets. Put in a struct if things are to be added later on */
}xnee_request;
/**
* \brief simply an X event.
*
*/
typedef struct {
int type ; /*!< type of Xevent (e.g MotionNotify)*/
int x, y ; /*!< x, y coordinates. These are only used when type is MotionXXX*/
int button ; /*!< x, y coordinates. These are only used when type is Button*/
int keycode ; /*!< x, y coordinates. These are only used when type is Key*/
int screen_nr ; /*!< The screen on which the event occured */
}xnee_event;
typedef struct _xinput_device
{
char *name;
int deviceid;
int is_slave;
int masterid;
XDevice *device; /* for replay */
} xinput_device ;
typedef struct _xinput_data
{
int xinput_event_base;
int xinput_record_mouse;
int xinput_record_keyboard;
int nr_of_xi_devices;
xinput_device xi_devices[XNEE_NR_OF_XINPUT_DEVICES];
int forced_core_replay;
int recording_enabled;
} xinput_data;
typedef struct _saved_xinput_event
{
int button;
int type;
int x;
int y;
int deviceid;
int detail;
Time time;
} saved_xinput_event ;
/**
* \brief an Xinput event.
*
*/
typedef struct {
int type ; /*!< type of Xevent (e.g MotionNotify)*/
int x, y ; /*!< x, y coordinates. These are only used when type is MotionXXX*/
int button ;
int keycode ;
int screen_nr ; /*!< The screen on which the event occured */
int detail; /*!< The id of the originating device */
int deviceid;
char name[100];
}xnee_xinput_event;
struct data_description
{
int data_nr;
char *data_name;
char *data_descr;
};
enum
{
XNEE_ANY_OPTION,
XNEE_GENERAL_OPTION,
XNEE_RECORD_OPTION,
XNEE_REPLAY_OPTION,
XNEE_SYNC_OPTION,
XNEE_GRAB_OPTION,
XNEE_MISC_OPTION,
XNEE_INTERNAL_OPTION,
XNEE_OBSOLETE_OPTION,
XNEE_RETYPE_OPTION
} xnee_option_type;
enum
{
XNEE_OVERRIDE_DISPLAY_NONE,
XNEE_OVERRIDE_DISPLAY_DATA,
XNEE_OVERRIDE_DISPLAY_CONTROL
} xnee_override_display;
typedef struct
{
int key;
char *option;
char *short_option;
char *args;
char *description;
int type;
int visible;
} xnee_option_t;
/*
typedef struct
{
xnee_option_t **options;
int nr_of_options;
} xnee_options_t;
*/
typedef struct
{
Bool new_project;
char *project_name ;
char *project_descr;
char *creat_date;
char *creat_prog;
char *creat_prog_vers;
char *last_date;
char *last_prog;
char *last_prog_vers;
char *author_name;
char *author_email;
} xnee_resource_meta ;
/*! \brief Holds information about Record Extension setup
*
*/
typedef struct
{
int xtest_version_major ; /*!< Major version number of XTest */
int xtest_version_minor ; /*!< Minor version number of XTest */
int xtest_error_basep ; /*!< First error number for this extension*/
int xtest_event_basep ; /*!< First event number for this extension*/
} xnee_testext_setup;
/*! \brief Holds a
*
*/
typedef struct
{
KeyCode key ; /*!< key */
char *str; /*!< string representation of the key */
char *extra_str;
} xnee_action_key;
/*! \brief Holds a information about the sync state
*
*/
typedef struct
{
int max ; /*!< max positive diff */
int min ; /*!< max negative diff */
int total ; /*!< total diff */
} xnee_diff;
/*! \brief Holds information about keycodes needed to fake a letter press
*
*/
typedef struct
{
KeyCode kc ; /*!< key to fake */
int shift_press ; /*!< is a SHIT press needed */
int alt_press ; /*!< is a ALT press needed */
int alt_gr_press; /*!< is a ALT GRAPH press needed */
int ctrl_press ; /*!< is a CTRL press needed */
} old_xnee_key_code;
/*! \brief Holds information about keycodes needed to fake a letter press
*
*/
typedef struct
{
KeyCode kc ; /*!< key to fake */
KeyCode mod_keycodes[XNEE_NR_OF_MODIFIERS];
} xnee_key_code;
/*! \brief Resolution of X server
*
*/
typedef struct
{
int x_res ; /*!< Xserver resoluton: x */
int y_res ; /*!< Xserver resoluton: y */
} xnee_res;
/*! \brief Data needed for distribution
*
*/
typedef struct
{
xnee_res res ; /*!< resolution when replaying */
int is_used ; /*!< flag to say if we should
convert resolution at all */
Display *dpy ;
} xnee_distr;
/*! \brief Resolution of X server
*
*/
typedef struct
{
xnee_res record ; /*!< resolution when recorded */
xnee_res replay ; /*!< resolution when replaying */
int is_used ; /*!< flag to say if we should convert resolution at all */
int x_offset ; /*!< Xserver offset for X */
int y_offset ; /*!< Xserver offset for Y */
} xnee_resolution_info;
/*! \brief time scale settings for Xnee
*
*/
typedef struct
{
int percent ; /*!< percentage of the original time (0-10000) */
int is_used ; /*!< flag to say if we should scale time at all */
} xnee_timescale_info;
/*! \brief holds replay delay information.
* Xnee chooses at replay/fake-time one of these to
* use as delay.
*/
typedef struct
{
Time f_delay ; /*!< time to wait before next event is faked */
Time s_delay ; /*!< time to sleep before next event is faked */
} xnee_delay_time;
/**
* Used for holding data of what we've received (from file)
*
* u
* type Type of event/request/error/reply... eg MotionNotify
* newtime
* oldtime
*
*/
typedef struct {
union {
xnee_event event ;
xnee_request request ;
xnee_reply reply ;
xnee_error error ;
xnee_xinput_event xievent ;
} u ; /*!< What have we got ... event, request, reply or error */
int type ; /*!< Type of event/request/error/reply... eg MotionNotify */
Time newtime ; /*!< Time when data (u.type) occured */
Time oldtime ; /*!< Remember when the last data occured*/
} xnee_intercept_data;
/**
* Used for holding scripting data
*
* x mouse position's X coord
* y mouse position's Y coord
* x_rel X coord is relative
* y_rel Y coord is relative
* button nr of button to fake
* button_state XNEE_PRESS or XNEE_RELEASE
* key nr of key to fake
* key_state XNEE_PRESS or XNEE_RELEASE
* valid 1 if whole struct is valid, else 0
* msecs Nr of msecs to sleep before fakeing
* kc keycode of the key to fake
*
*/
typedef struct
{
/* Mouse */
int x ;
int y ;
int x_rel ;
int y_rel ;
int button ;
int button_state ;
/* Keyboard */
int key ;
int key_state ;
int valid ;
int msecs ;
int xinput_deviceid ;
xnee_key_code kc;
} xnee_script_s ;
/* *
* this typedef should, according to XRecord,
* specification be defined in <X11/extensions/record.h>
* ... can't find .... errrh?
*
*/
typedef union {
unsigned char type ;
xEvent event ;
xReq req ;
xGenericReply reply ;
xError error ;
xConnSetupPrefix setup;
} XRecordDatum ;
/**
* Holds information about the xnee_record session
*/
typedef struct
{
Bool first_last ; /*!< when true, only first and last motion events are printed */
Bool last_motion ; /*!< was the last event a motion event */
int store_mouse_pos; /*!< shall we save the mouse position before starting recording */
Bool store_window_pos; /*!< shall we store every new window position 0=don't, 1=only for window pos, 2=window pos and user resuested recording*/
unsigned long server_time ; /*!< when the X11 data did occur */
int x ; /*!< last MotionNotify RootX-value */
int y ; /*!< last MotionNotify RootY-value */
int events_recorded; /*!< .. to Intercept */
int data_recorded ; /*!< .. to Intercept */
int time_recorded ; /*!< .. to Intercept */
int events_max ; /*!< .. to Intercept */
int data_max ; /*!< .. to Intercept */
int time_max ; /*!< .. to Intercept */
unsigned int interval ; /*!< how many seconds to record */
unsigned int size ; /*!< max size of file */
int replayed_events;
int data_ranges[XNEE_NR_OF_TYPES] ; /*!< Count how many data ranges specified */
int interrupt ;
int override_recorded_display;
} xnee_record_init_data ;
/**
*
*/
typedef struct
{
int grab ; /*!< true if any key is grabbed */
int grabbed_action ; /*!< set to the action when grabbed */
xnee_action_key action_keys[XNEE_GRAB_LAST];
} xnee_grab_keys;
/**
* Holds information about Record Extension setup
*/
typedef struct
{
/*@null@*/ /*@only@*/ XRecordClientSpec * xids;
/*@null@*/ /*@only@*/ XRecordState * rState;
/*@null@*/ /*@only@*/ XRecordRange ** range_array ;
XID id ;
XRecordContext rContext;
int data_flags;
int major_return;
int minor_return ;
int nclients;
int active;
} xnee_recordext_setup;
typedef struct
{
unsigned int key_press_delay ;
unsigned int key_release_delay ;
} retype_settings ;
struct buffer_meta_data
{
int sum_max ;
/*!< sum of the maximum in the buffer. */
int sum_min ;
/*!< sum of the minimum values in the buffer. */
int total_diff ;
/*!< the total sum of positive values in the buffer */
int cached_max ;
/*!< a cached value of the maximum value in the buffer.
(-1 for unknown state) */
int cached_min ;
/*!< a cached value of the minimum value in the buffer.
(-1 for unknown state) */
/* thresholds used during synch */
int sum_max_threshold;
int sum_min_threshold;
int tot_diff_threshold;
} ;
/**
* Holds most information about the Xnee session.
*
*/
typedef struct
{
/*@null@*/ char *program_name; /*!< name of the program currently using libxnee */
/*@null@*/ char *out_name ; /*!< name of output file (e.g stdout, /tmp/xnee.log*/
/*@null@*/ char *err_name ; /*!< name of error file (e.g stdout, /tmp/xnee.log*/
/*@null@*/ char *rc_name ; /*!< name of resource file (e.g netscape.xns, /tmp/xterm.xns*/
/*@null@*/ char *data_name ; /*!< name of data file (e.g */
/*@null@*/ char *rt_name ; /*!< name of retype file (e.g stdout, /home/user/myfile.txt */
/*@null@*/ /*@dependent@*/FILE *data_file ; /*!< data input file descriptor */
/*@null@*/ /*@dependent@*/FILE *out_file ; /*!< output file descriptor */
/*@null@*/ /*@dependent@*/ FILE *err_file ; /*!< error file descriptor */
/*@null@*/ /*@dependent@*/FILE *rc_file ; /*!< resource file descriptor */
/*@null@*/ /*@dependent@*/FILE *rt_file ; /*!< retype file descriptor */
/*@null@*/ /*@dependent@*/FILE *buffer_file ; /*!< verbose buffer printout file descriptor */
FILE *saved_out_file ; /*!< output file descriptor */
FILE *saved_err_file ; /*!< error file descriptor */
char **app_args ;
Bool verbose ; /*!< true if verbose mode */
Bool buf_verbose ; /*!< true if verbose mode for buffer printouts */
Bool all_clients ; /*!< True if recording all clients
(else Xneee recods only future clients) */
Bool sync ; /*!< True if Record used when replaying */
Bool keep_autorepeat ; /*!< True = use autorepeat */
unsigned char mode ; /*!< Xnee's current mode (RECORDER/REPLAY/SYNTAX_CHECK...) */
/*@null@*/ void *plugin_handle ; /*!< Handle for the plugin file */
/*@null@*/ char *plugin_name ; /*!< Name of the plugin file */
callback_ptr rec_callback ; /*!< recording callback function */
callback_ptr rep_callback ; /*!< replaying callback function */
callback_ptr sync_fun ; /*!< synchronisation function */
fprint_fptr buffer_verbose_fp; /*!< pointer to buffer verbose fun */
vfprint_fptr verbose_fp; /*!< pointer to verbose fun */
fprint_fptr data_fp ; /*!< pointer to xnee protcol print fun */
/*@null@*/ /*@observer@*/
/*@null@*/ char * display ; /*!< char representation of the Display */
/*@null@*/ Display *data ; /*!< used for sending recored data between Xnee and Xserver*/
/*@null@*/ Display *control ; /*!< used for sending info between Xnee and Xserver */
/*@null@*/ Display *fake ; /*!< used for faking events */
/*@null@*/ Display *grab ; /*!< used for holding the grabbed key/modifier */
int first_replayed_event; /*!< True if the event to replay is the first one.
Needed to set the start time of the first event to 0 */
int recall_recorded_win_pos; /*!< True if Xnee (during replay) shall use the recorded.
window position*/
int cont ; /*!< A simple flag telling Xnee wether to keep
recording/replaying or to quit. */
/*@null@*/ xnee_distr *distr_list ; /*!< array of displays to distribute events to */
size_t distr_list_size ; /*!< size of array of displays to distribute events to */
/*@null@*/ /*@reldef@*/
#ifdef XNEE_USE_SEMAPHORES
sem_t *buf_sem ; /*!< semaphore to protect the replay buffer */
#endif /* XNEE_USE_SEMAPHORES */
long first_read_time ; /*!< server time of the first read from recorded file */
int force_replay ; /*!< Keep replaying even if we are out of sync .... dangerous */
XKeyboardState kbd_orig; /*!< User keyboard state before Xnee messes is up */
int autorepeat_saved; /*!< Flag indicating if we have a stored keyboard state */
/*@only@*/ /*@null@*/
xnee_record_init_data xnee_info ;
int no_reparent_recording ;
int max_nr_of_moves;
/*@only@*/ /*@null@*/
xnee_recordext_setup *record_setup;
/*@only@*/ /*@null@*/
xnee_testext_setup *replay_setup;
int data_buffer[4][XNEE_REPLAY_BUFFER_SIZE];
struct buffer_meta_data meta_data;
int speed_percent;
/*@only@*/ /*@null@*/
xnee_grab_keys *grab_keys;
int button_pressed ;
int key_pressed ;
xnee_resolution_info res_info;
xnee_resource_meta xrm;
XModifierKeymap *map ;
int in_use;
retype_settings retype;
unsigned char x_version_major;
unsigned char x_version_minor;
unsigned char x_version_minor_sub;
char * x_vendor_name ;
xinput_data xi_data;
unsigned char replay_backend;
} xnee_data ;
/**
* Checks if the first argument is equals to any of the other two arguments
* @param arg string to compare
* @param long_arg with this one
* @param short_arg and with this one
* @return int 1 if arg was equal to any of long_arg or short_arg, else it returns 0
*/
int
xnee_check ( const char *arg, const char *long_arg , const char *short_arg );
#define xnee_print_obsolete_mess(s) fprintf (stderr, s)
int
xnee_start(xnee_data *xd);
/**
* Allocates a new xnee_data structure.
* To free the memory, xnee_free_xnee_data can be used.
* @return xnee_data * NULL if alloc failed
*/
/*@null@ The implementation of this function is located in xnee_alloc.c*/
xnee_data*
xnee_new_xnee_data(void);
#define DEBUG_XNEE_DATA
#ifdef DEBUG_XNEE_DATA
void
xnee_debug_xnee_data(xnee_data *xd, char *str) ;
#endif
#endif /* XNEE_XNEE_H */
|