1 /*
2   Xnee's Not an Event Emulator enables recording and replaying of X
3   protocol data
4   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
5                 2007, 2008, 2009, 2010, 2011, 2013 Henrik Sandklef
6 
7   This program is free software; you can redistribute it and/or
8   modify it under the terms of the GNU General Public License
9   as published by the Free Software Foundation; either version 3
10   of the License, or any later version.
11 
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16 
17   You should have received a copy of the GNU General Public License
18   along with this program; if not, write to the Free Software
19   Foundation, Inc., 51 Franklin Street, Boston, MA  02110-1301, USA.
20 */
21 
22 
23 
24 #include "libxnee/xnee.h"
25 #include "libxnee/print_varargs.h"
26 #include "libxnee/print.h"
27 #include "libxnee/datastrings.h"
28 #include "libxnee/xnee_record.h"
29 #include "libxnee/xnee_replay.h"
30 #include "libxnee/xnee_resource.h"
31 #include "libxnee/xnee_threshold.h"
32 #include "libxnee/feedback.h"
33 #include "libxnee/xnee_error.h"
34 #include "libxnee/xnee_session.h"
35 #include "libxnee/xnee_xinput.h"
36 
37 
38 #define XNEE_HP_SEP " "
39 #define XNEE_HP_EQUALS "="
40 #define XNEE_HP_CONTENT_BEGIN " { "
41 #define XNEE_HP_CONTENT_END " } "
42 
43 
44 /*
45  *
46  * Prints the number and name of the XEvent
47  *
48  */
49 int
xnee_print_event_info(xnee_data * xd)50 xnee_print_event_info (xnee_data *xd)
51 {
52   int i = 2 ;
53   char *tmp = NULL;
54 
55   fprintf (xd->out_file,"  X11 Event\n\n");
56   fprintf (xd->out_file,"number\tname\n");
57   fprintf (xd->out_file,"======\t====\n");
58 
59   tmp = xnee_print_event(i) ;
60   while (tmp!=NULL)
61     {
62       if (tmp!=NULL)
63 	{
64 	  fprintf (xd->out_file,"%.2d\t%s\n",i,tmp);
65 	}
66       i++;
67       tmp = xnee_print_event(i) ;
68     }
69   return XNEE_OK;
70 }
71 
72 
73 /*
74  *
75  * Prints the number and name of the X11 error
76  *
77  */
78 int
xnee_print_error_info(xnee_data * xd)79 xnee_print_error_info (xnee_data *xd)
80 {
81   int i = 0 ;
82   char *tmp = NULL;
83   fprintf (xd->out_file,"  X11 Error\n\n");
84   fprintf (xd->out_file,"number\tname\n");
85   fprintf (xd->out_file,"======\t====\n");
86   tmp = xnee_print_error_code(i) ;
87   while (tmp!=NULL)
88     {
89       if (tmp!=NULL)
90 	{
91 	  fprintf (xd->out_file,"%.2d\t%s\n",i,tmp);
92 	}
93       i++;
94       tmp = xnee_print_error_code(i) ;
95     }
96 
97   return XNEE_OK;
98 }
99 
100 
101 /*
102  *
103  * Prints the number and name of the X11 error
104  *
105  */
106 int
xnee_print_request_info(xnee_data * xd)107 xnee_print_request_info (xnee_data *xd)
108 {
109   int i=1 ;
110   char *tmp = NULL ;
111 
112   fprintf (xd->out_file,"  X11 Request\n\n");
113   fprintf (xd->out_file,"number\tname\n");
114   fprintf (xd->out_file,"======\t====\n");
115   tmp = xnee_print_request(i);
116   while (tmp!=NULL)
117     {
118       if (tmp!=NULL)
119 	{
120 	  fprintf (xd->out_file,"%.2d\t%s\n",i,tmp);
121 	}
122       i++;
123       tmp = xnee_print_request(i);
124     }
125 
126   return XNEE_OK;
127 }
128 
129 /*
130  *
131  * Prints the number and name of the X11 reply
132  *
133  */
134 int
xnee_print_reply_info(xnee_data * xd)135 xnee_print_reply_info (xnee_data *xd)
136 {
137   (void) fprintf (xd->out_file,"  X11 Reply\n\n");
138   return XNEE_OK;
139 }
140 
141 /*
142  *
143  * Prints the number and name of the X11 data
144  *
145  */
146 int
xnee_print_data_info(xnee_data * xd)147 xnee_print_data_info (xnee_data *xd)
148 {
149   int ret ;
150 
151   ret = xnee_print_event_info (xd) ;
152   XNEE_RETURN_IF_ERR(ret);
153 
154   ret = xnee_print_error_info (xd) ;
155   XNEE_RETURN_IF_ERR(ret);
156 
157   ret = xnee_print_request_info (xd) ;
158   XNEE_RETURN_IF_ERR(ret);
159 
160   ret = xnee_print_reply_info (xd) ;
161   XNEE_RETURN_IF_ERR(ret);
162 
163   return XNEE_OK;
164 }
165 
166 
167 
168 
169 
170 
171 /*
172  * Print character representation of event if verbose mode is on.
173  */
174 void
xnee_verbose_event(xnee_data * xd,int ev)175 xnee_verbose_event (xnee_data * xd, int ev ) {
176   if ( xd->verbose != 0 )
177     {
178       (void)xnee_print_event (ev);
179     }
180 }
181 
182 
183 
184 
185 /*
186  *
187  * xnee_record_print_request.
188  *
189  */
190 void
xnee_record_print_request(xnee_data * xd,XRecordInterceptData * xrecintd)191 xnee_record_print_request (xnee_data *xd, XRecordInterceptData *xrecintd )
192 {
193   XRecordDatum *xrec_data  ;
194   int           req_type    ;
195   xResourceReq  *req;
196 
197   if ( xrecintd == NULL)
198     {
199       return;
200     }
201 
202   xrec_data =  (XRecordDatum *) xrecintd->data ;
203   req_type  =  (int)            xrec_data->type ;
204   req       =  (xResourceReq *) &xrec_data->req ;
205   (void) xd->data_fp (xd->out_file,"1,%d,%lu,%lu,%lu,%lu\n",
206 		      req_type,
207 		      req->reqType,
208 		      req->length,
209 		      req->id,
210 		      xrecintd->server_time);
211 }
212 
213 
214 
215 /*
216  *
217  * xnee_human_print_request.
218  *
219  */
220 void
xnee_human_print_request(xnee_data * xd,XRecordInterceptData * xrecintd)221 xnee_human_print_request (xnee_data *xd, XRecordInterceptData *xrecintd )
222 {
223   XRecordDatum *xrec_data;
224   int           request_type ;
225   char  *request_name ;
226   char  *name=" not defined " ;
227 
228   if ( xrecintd == NULL)
229     {
230       return;
231     }
232 
233 
234   xrec_data  = (XRecordDatum *) (xrecintd->data) ;
235 
236   request_type = (int)xrec_data->type ;
237 
238   request_name = xnee_print_request(request_type);
239     if ( request_name == NULL )
240       {
241 	request_name = name;
242       }
243 
244   (void)xd->data_fp (xd->out_file,"Request" XNEE_HP_EQUALS "%s" XNEE_HP_SEP "Number" XNEE_HP_EQUALS "%d",
245 		     request_name, request_type);
246 
247   if ( 1 )
248     {
249       (void)xd->data_fp (xd->out_file,XNEE_HP_CONTENT_BEGIN);
250       xnee_human_print_request_verbose (xd,xrecintd );
251       (void)xd->data_fp (xd->out_file,XNEE_HP_CONTENT_END);
252     }
253 
254   (void)xd->data_fp (xd->out_file,"\n");
255 }
256 
257 
258 /*
259  *
260  * xnee_human_print_request.
261  *
262  */
263 void
xnee_human_print_request_verbose(xnee_data * xd,XRecordInterceptData * xrecintd)264 xnee_human_print_request_verbose (xnee_data *xd, XRecordInterceptData *xrecintd )
265 {
266   XRecordDatum *xrec_data;
267   int           req_type ;
268   xCreateWindowReq *req_create_ptr;
269 
270   xrec_data = (XRecordDatum *) (xrecintd->data) ;
271   req_type  = (int) xrec_data->type ;
272 
273   switch (req_type)
274     {
275     case X_CreateWindow:
276       req_create_ptr = (xCreateWindowReq *) (xrecintd->data) ;
277       (void)xd->data_fp (xd->out_file,
278 			 XNEE_HP_SEP "reqType" XNEE_HP_EQUALS "%c"
279 			 XNEE_HP_SEP "depth"   XNEE_HP_EQUALS "%d"
280 			 XNEE_HP_SEP "length"  XNEE_HP_EQUALS "%lu"
281 			 XNEE_HP_SEP "wid"     XNEE_HP_EQUALS "%lu"
282 			 XNEE_HP_SEP "parent"  XNEE_HP_EQUALS "%lu"
283 			 XNEE_HP_SEP "width"   XNEE_HP_EQUALS "%lu"
284 			 XNEE_HP_SEP "height"  XNEE_HP_EQUALS "%lu"
285 			 XNEE_HP_SEP "borderWidth" XNEE_HP_EQUALS "%lu"
286 #if defined(__cplusplus) || defined(c_plusplus)
287 			 XNEE_HP_SEP "c_class" XNEE_HP_EQUALS "%lu"
288 #else
289 			 XNEE_HP_SEP "class"   XNEE_HP_EQUALS "%lu"
290 #endif
291 			 XNEE_HP_SEP "visual"  XNEE_HP_EQUALS "%lu"
292 			 XNEE_HP_SEP "mask"    XNEE_HP_EQUALS "%lu",
293 			 req_create_ptr->reqType,
294 			 req_create_ptr->depth,
295 			 req_create_ptr->length,
296 			 req_create_ptr->wid,
297 			 req_create_ptr->parent,
298 			 req_create_ptr->width,
299 			 req_create_ptr->height,
300 			 req_create_ptr->borderWidth,
301 #if defined(__cplusplus) || defined(c_plusplus)
302 			 req_create_ptr->c_class,
303 #else
304 			 req_create_ptr->class,
305 #endif
306 			 req_create_ptr->visual,
307 			 req_create_ptr->mask);
308      break;
309     case sz_xReparentWindowReq:
310       (void)xd->data_fp (xd->out_file,
311 			 XNEE_HP_SEP "length" XNEE_HP_EQUALS "%lu  RE ",
312 			 xrec_data->req.length);
313      break;
314     default:
315       (void)xd->data_fp (xd->out_file, " NOT IMPLEMENTED REQUEST ");
316       break;
317     }
318 }
319 
320 /*
321  *
322  * xnee_human_print_event.
323  *
324  */
325 void
xnee_human_print_event(xnee_data * xd,XRecordInterceptData * xrecintd)326 xnee_human_print_event (xnee_data *xd, XRecordInterceptData *xrecintd )
327 {
328   XRecordDatum *xrec_data  ;
329   int           event_type ;
330 
331 
332   char  *event_name ;
333   char  *name=" not defined " ;
334   xrec_data  = (XRecordDatum *) (xrecintd->data) ;
335   event_type = (int)xrec_data->type ;
336 
337   event_name = xnee_print_event(event_type);
338     if ( event_name == NULL )
339       {
340 	event_name = name;
341       }
342 
343   (void)xd->data_fp (xd->out_file,"Event" XNEE_HP_EQUALS "%s" XNEE_HP_SEP "Number" XNEE_HP_EQUALS "%d",
344 		     event_name, event_type);
345 
346   xnee_handle_xinput_event_human(xd,
347 				 event_type,
348 				 xrec_data,
349 				 xrecintd->server_time);
350 
351   if ( 1 )
352     {
353       (void)xd->data_fp (xd->out_file,XNEE_HP_CONTENT_BEGIN);
354       xnee_human_print_event_verbose (xd,xrecintd );
355       (void)xd->data_fp (xd->out_file,XNEE_HP_CONTENT_END);
356     }
357 
358   (void)xd->data_fp (xd->out_file,"\n");
359 }
360 
361 
362 /*
363  *
364  * xnee_human_print_event.
365  *
366  */
367 void
xnee_human_print_event_verbose(xnee_data * xd,XRecordInterceptData * xrecintd)368 xnee_human_print_event_verbose (xnee_data *xd, XRecordInterceptData *xrecintd )
369 {
370   XRecordDatum *xrec_data  ;
371   int           event_type ;
372 
373   xrec_data  = (XRecordDatum *) (xrecintd->data) ;
374   event_type = (int)xrec_data->type ;
375 
376 
377   (void)xd->data_fp (xd->out_file, "{ ");
378   switch (event_type)
379     {
380     case KeyPress:
381     case KeyRelease:
382     case ButtonPress:
383     case ButtonRelease:
384     case MotionNotify:
385       (void)xd->data_fp (xd->out_file,
386 			  "root" XNEE_HP_EQUALS "%lu"
387 			 XNEE_HP_SEP "event" XNEE_HP_EQUALS "%lu"
388 			 XNEE_HP_SEP "child" XNEE_HP_EQUALS "%lu",
389 			 xrec_data->event.u.keyButtonPointer.root,
390 			 xrec_data->event.u.keyButtonPointer.event,
391 			 xrec_data->event.u.keyButtonPointer.child
392 			 );
393       (void)xd->data_fp (xd->out_file,
394 			 XNEE_HP_SEP "rootX" XNEE_HP_EQUALS "%lu"
395 			 XNEE_HP_SEP "rootY" XNEE_HP_EQUALS "%lu"
396 			 XNEE_HP_SEP "eventX" XNEE_HP_EQUALS "%lu"
397 			 XNEE_HP_SEP "eventY" XNEE_HP_EQUALS "%lu",
398 			 xrec_data->event.u.keyButtonPointer.rootX,
399 			 xrec_data->event.u.keyButtonPointer.rootY,
400 			 xrec_data->event.u.keyButtonPointer.eventX,
401 			 xrec_data->event.u.keyButtonPointer.eventY
402 			 );
403       (void)xd->data_fp (xd->out_file,
404 			 XNEE_HP_SEP "state" XNEE_HP_EQUALS "%lu"
405 			 XNEE_HP_SEP "sameScreen" XNEE_HP_EQUALS "%d",
406 			 xrec_data->event.u.keyButtonPointer.state,
407 			 xrec_data->event.u.keyButtonPointer.sameScreen			 );
408       break;
409     case EnterNotify:
410     case LeaveNotify:
411       (void)xd->data_fp (xd->out_file,
412 			  "root" XNEE_HP_EQUALS "%lu"
413 			 XNEE_HP_SEP "event" XNEE_HP_EQUALS "%lu"
414 			 XNEE_HP_SEP "child" XNEE_HP_EQUALS "%lu"
415 			 XNEE_HP_SEP "rootX" XNEE_HP_EQUALS "%lu"
416 			 XNEE_HP_SEP "rootY" XNEE_HP_EQUALS "%lu"
417 			 XNEE_HP_SEP "eventX" XNEE_HP_EQUALS "%lu"
418 			 XNEE_HP_SEP "eventY" XNEE_HP_EQUALS "%lu"
419 			 XNEE_HP_SEP "state" XNEE_HP_EQUALS "%lu"
420 			 XNEE_HP_SEP "mode" XNEE_HP_EQUALS "%d",
421 			 xrec_data->event.u.enterLeave.root,
422 			 xrec_data->event.u.enterLeave.event,
423 			 xrec_data->event.u.enterLeave.child,
424 			 xrec_data->event.u.enterLeave.rootX,
425 			 xrec_data->event.u.enterLeave.rootY,
426 			 xrec_data->event.u.enterLeave.eventX,
427 			 xrec_data->event.u.enterLeave.eventY,
428 			 xrec_data->event.u.enterLeave.state,
429 			 xrec_data->event.u.enterLeave.mode);
430       break;
431 
432     case FocusIn:
433     case FocusOut:
434       (void)xd->data_fp (xd->out_file,
435 			  "window" XNEE_HP_EQUALS "%lu"
436 			 XNEE_HP_SEP "mode" XNEE_HP_EQUALS "%lu",
437 			 xrec_data->event.u.focus.window,
438 			 xrec_data->event.u.focus.mode);
439       break;
440     case Expose:
441       (void)xd->data_fp (xd->out_file,
442 			  "window" XNEE_HP_EQUALS "%lu"
443 			 XNEE_HP_SEP "x" XNEE_HP_EQUALS "%d"
444 			 XNEE_HP_SEP "y" XNEE_HP_EQUALS "%d"
445 			 XNEE_HP_SEP "width" XNEE_HP_EQUALS "%d"
446 			 XNEE_HP_SEP "height" XNEE_HP_EQUALS "%d"
447 			 XNEE_HP_SEP "count" XNEE_HP_EQUALS "%d",
448 			 xrec_data->event.u.expose.window,
449 			 xrec_data->event.u.expose.x,
450 			 xrec_data->event.u.expose.y,
451 			 xrec_data->event.u.expose.width,
452 			 xrec_data->event.u.expose.height,
453 			 xrec_data->event.u.expose.count);
454       break;
455     case GraphicsExpose:
456       (void)xd->data_fp (xd->out_file,
457 			  "drawable" XNEE_HP_EQUALS "%lu"
458 			 XNEE_HP_SEP "x" XNEE_HP_EQUALS "%d"
459 			 XNEE_HP_SEP "y" XNEE_HP_EQUALS "%d"
460 			 XNEE_HP_SEP "width" XNEE_HP_EQUALS "%d"
461 			 XNEE_HP_SEP "height" XNEE_HP_EQUALS "%d"
462 			 XNEE_HP_SEP "minorEvent" XNEE_HP_EQUALS "%d"
463 			 XNEE_HP_SEP "majorEvent" XNEE_HP_EQUALS "%d"
464 			 XNEE_HP_SEP "count" XNEE_HP_EQUALS "%d",
465 			 xrec_data->event.u.graphicsExposure.drawable,
466 			 xrec_data->event.u.graphicsExposure.x,
467 			 xrec_data->event.u.graphicsExposure.y,
468 			 xrec_data->event.u.graphicsExposure.width,
469 			 xrec_data->event.u.graphicsExposure.height,
470 			 xrec_data->event.u.graphicsExposure.minorEvent,
471 			 xrec_data->event.u.graphicsExposure.majorEvent,
472 			 xrec_data->event.u.graphicsExposure.count);
473       break;
474     case NoExpose:
475       (void)xd->data_fp (xd->out_file,
476 			  "drawable" XNEE_HP_EQUALS "%lu"
477 			 XNEE_HP_SEP "minorEvent" XNEE_HP_EQUALS "%d"
478 			 XNEE_HP_SEP "majorEvent" XNEE_HP_EQUALS "%d" ,
479 			 xrec_data->event.u.noExposure.drawable,
480 			 xrec_data->event.u.noExposure.minorEvent,
481 			 xrec_data->event.u.noExposure.majorEvent);
482       break;
483     case VisibilityNotify:
484       (void)xd->data_fp (xd->out_file,
485 			  "window" XNEE_HP_EQUALS "%lu"
486 			 XNEE_HP_SEP "state" XNEE_HP_EQUALS "%d" ,
487 			 xrec_data->event.u.visibility.window,
488 			 xrec_data->event.u.visibility.state);
489       break;
490     case CreateNotify:
491       (void)xd->data_fp (xd->out_file,
492 			  "parent" XNEE_HP_EQUALS "%lu"
493 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
494 			 XNEE_HP_SEP "x" XNEE_HP_EQUALS "%d"
495 			 XNEE_HP_SEP "y" XNEE_HP_EQUALS "%d"
496 			 XNEE_HP_SEP "width" XNEE_HP_EQUALS "%d"
497 			 XNEE_HP_SEP "height" XNEE_HP_EQUALS "%d"
498 			 XNEE_HP_SEP "borderWidth" XNEE_HP_EQUALS "%d"
499 			 XNEE_HP_SEP "override" XNEE_HP_EQUALS "%d" ,
500 			 xrec_data->event.u.createNotify.parent,
501 			 xrec_data->event.u.createNotify.window,
502 			 xrec_data->event.u.createNotify.x,
503 			 xrec_data->event.u.createNotify.y,
504 			 xrec_data->event.u.createNotify.width,
505 			 xrec_data->event.u.createNotify.height,
506 			 xrec_data->event.u.createNotify.borderWidth,
507 			 xrec_data->event.u.createNotify.override);
508       break;
509     case DestroyNotify:
510       (void)xd->data_fp (xd->out_file,
511 			  "event" XNEE_HP_EQUALS "%lu"
512 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu" ,
513 			 xrec_data->event.u.destroyNotify.event,
514 			 xrec_data->event.u.destroyNotify.window);
515       break;
516     case UnmapNotify:
517       (void)xd->data_fp (xd->out_file,
518 			  "event" XNEE_HP_EQUALS "%lu"
519 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
520 			 XNEE_HP_SEP "fromConfigure" XNEE_HP_EQUALS "%d" ,
521 			 xrec_data->event.u.unmapNotify.event,
522 			 xrec_data->event.u.unmapNotify.window,
523 			 xrec_data->event.u.unmapNotify.fromConfigure);
524       break;
525     case MapNotify:
526       (void)xd->data_fp (xd->out_file,
527 			  "event" XNEE_HP_EQUALS "%lu"
528 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
529 			 XNEE_HP_SEP "override" XNEE_HP_EQUALS "%d" ,
530 			 xrec_data->event.u.mapNotify.event,
531 			 xrec_data->event.u.mapNotify.window,
532 			 xrec_data->event.u.mapNotify.override);
533       break;
534     case MapRequest:
535       (void)xd->data_fp (xd->out_file,
536 			  "parent" XNEE_HP_EQUALS "%lu"
537 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu",
538 			 xrec_data->event.u.mapRequest.parent,
539 			 xrec_data->event.u.mapRequest.window);
540       break;
541     case ReparentNotify:
542       (void)xd->data_fp (xd->out_file,
543 			  "event" XNEE_HP_EQUALS "%lu"
544 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
545 			 XNEE_HP_SEP "parent" XNEE_HP_EQUALS "%d"
546 			 XNEE_HP_SEP "x" XNEE_HP_EQUALS "%d"
547 			 XNEE_HP_SEP "y" XNEE_HP_EQUALS "%d"
548 			 XNEE_HP_SEP "override" XNEE_HP_EQUALS "%d" ,
549 			 xrec_data->event.u.reparent.event,
550 			 xrec_data->event.u.reparent.window,
551 			 xrec_data->event.u.reparent.parent,
552 			 xrec_data->event.u.reparent.x,
553 			 xrec_data->event.u.reparent.y,
554 			 xrec_data->event.u.reparent.override);
555       break;
556     case ConfigureNotify:
557       (void)xd->data_fp (xd->out_file,
558 			  "event" XNEE_HP_EQUALS "%lu"
559 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
560 			 XNEE_HP_SEP "aboveSibling" XNEE_HP_EQUALS "%lu"
561 			 XNEE_HP_SEP "parent" XNEE_HP_EQUALS "%d"
562 			 XNEE_HP_SEP "x" XNEE_HP_EQUALS "%d"
563 			 XNEE_HP_SEP "y" XNEE_HP_EQUALS "%d"
564 			 XNEE_HP_SEP "width" XNEE_HP_EQUALS "%d"
565 			 XNEE_HP_SEP "height" XNEE_HP_EQUALS "%d"
566 			 XNEE_HP_SEP "borderWidth" XNEE_HP_EQUALS "%d"
567 			 XNEE_HP_SEP "override" XNEE_HP_EQUALS "%d" ,
568 			 xrec_data->event.u.configureNotify.event,
569 			 xrec_data->event.u.configureNotify.window,
570 			 xrec_data->event.u.configureNotify.aboveSibling,
571 			 xrec_data->event.u.configureNotify.x,
572 			 xrec_data->event.u.configureNotify.y,
573 			 xrec_data->event.u.configureNotify.width,
574 			 xrec_data->event.u.configureNotify.height,
575 			 xrec_data->event.u.configureNotify.borderWidth,
576 			 xrec_data->event.u.configureNotify.override);
577       break;
578     case ConfigureRequest:
579       (void)xd->data_fp (xd->out_file,
580 			  "parent" XNEE_HP_EQUALS "%lu"
581 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
582 			 XNEE_HP_SEP "sibling" XNEE_HP_EQUALS "%lu"
583 			 XNEE_HP_SEP "x" XNEE_HP_EQUALS "%d"
584 			 XNEE_HP_SEP "y" XNEE_HP_EQUALS "%d"
585 			 XNEE_HP_SEP "width" XNEE_HP_EQUALS "%d"
586 			 XNEE_HP_SEP "height" XNEE_HP_EQUALS "%d"
587 			 XNEE_HP_SEP "borderWidth" XNEE_HP_EQUALS "%d"
588 			 XNEE_HP_SEP "valueMask" XNEE_HP_EQUALS "%d" ,
589 			 xrec_data->event.u.configureRequest.parent,
590 			 xrec_data->event.u.configureRequest.window,
591 			 xrec_data->event.u.configureRequest.sibling,
592 			 xrec_data->event.u.configureRequest.x,
593 			 xrec_data->event.u.configureRequest.y,
594 			 xrec_data->event.u.configureRequest.width,
595 			 xrec_data->event.u.configureRequest.height,
596 			 xrec_data->event.u.configureRequest.borderWidth,
597 			 xrec_data->event.u.configureRequest.valueMask);
598       break;
599 
600     case GravityNotify:
601       (void)xd->data_fp (xd->out_file,
602 			 XNEE_HP_SEP "event" XNEE_HP_EQUALS "%lu"
603 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
604 			 XNEE_HP_SEP "x" XNEE_HP_EQUALS "%d"
605 			 XNEE_HP_SEP "y" XNEE_HP_EQUALS "%d" ,
606 			 xrec_data->event.u.gravity.event,
607 			 xrec_data->event.u.gravity.window,
608 			 xrec_data->event.u.gravity.x,
609 			 xrec_data->event.u.gravity.y);
610       break;
611 
612     case ResizeRequest:
613       (void)xd->data_fp (xd->out_file,
614 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
615 			 XNEE_HP_SEP "width" XNEE_HP_EQUALS "%lu"
616 			 XNEE_HP_SEP "height" XNEE_HP_EQUALS "%d" ,
617 			 xrec_data->event.u.resizeRequest.window,
618 			 xrec_data->event.u.resizeRequest.width,
619 			 xrec_data->event.u.resizeRequest.height);
620       break;
621 
622     case CirculateNotify:
623     case CirculateRequest:
624       (void)xd->data_fp (xd->out_file,
625 			 XNEE_HP_SEP "event" XNEE_HP_EQUALS "%lu"
626 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
627 			 XNEE_HP_SEP "parent" XNEE_HP_EQUALS "%lu"
628 			 XNEE_HP_SEP "place" XNEE_HP_EQUALS "%lu" ,
629 			 xrec_data->event.u.circulate.event,
630 			 xrec_data->event.u.circulate.window,
631 			 xrec_data->event.u.circulate.parent,
632 			 xrec_data->event.u.circulate.place);
633       break;
634 
635     case PropertyNotify:
636       (void)xd->data_fp (xd->out_file,
637 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
638 			 XNEE_HP_SEP "atom" XNEE_HP_EQUALS "%lu"
639 			 XNEE_HP_SEP "time" XNEE_HP_EQUALS "%lu"
640 			 XNEE_HP_SEP "state" XNEE_HP_EQUALS "%d" ,
641 			 xrec_data->event.u.property.window,
642 			 xrec_data->event.u.property.atom,
643 			 xrec_data->event.u.property.time,
644 			 xrec_data->event.u.property.state);
645       break;
646 
647     case SelectionClear:
648       (void)xd->data_fp (xd->out_file,
649 			 XNEE_HP_SEP "time" XNEE_HP_EQUALS "%lu"
650 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
651 			 XNEE_HP_SEP "atom" XNEE_HP_EQUALS "%d" ,
652 			 xrec_data->event.u.selectionClear.time,
653 			 xrec_data->event.u.selectionClear.window,
654 			 xrec_data->event.u.selectionClear.atom);
655       break;
656 
657     case SelectionRequest:
658       (void)xd->data_fp (xd->out_file,
659 			 XNEE_HP_SEP "time" XNEE_HP_EQUALS "%lu"
660 			 XNEE_HP_SEP "owner" XNEE_HP_EQUALS "%lu"
661 			 XNEE_HP_SEP "requestor" XNEE_HP_EQUALS "%lu"
662 			 XNEE_HP_SEP "selection" XNEE_HP_EQUALS "%d"
663 			 XNEE_HP_SEP "target" XNEE_HP_EQUALS "%d" ,
664 			 XNEE_HP_SEP "property" XNEE_HP_EQUALS "%d" ,
665 			 xrec_data->event.u.selectionRequest.time,
666 			 xrec_data->event.u.selectionRequest.owner,
667 			 xrec_data->event.u.selectionRequest.requestor,
668 			 xrec_data->event.u.selectionRequest.selection,
669 			 xrec_data->event.u.selectionRequest.target,
670 			 xrec_data->event.u.selectionRequest.property);
671       break;
672 
673     case SelectionNotify:
674       (void)xd->data_fp (xd->out_file,
675 			 XNEE_HP_SEP "time" XNEE_HP_EQUALS "%lu"
676 			 XNEE_HP_SEP "requestor" XNEE_HP_EQUALS "%lu"
677 			 XNEE_HP_SEP "selection" XNEE_HP_EQUALS "%d"
678 			 XNEE_HP_SEP "target" XNEE_HP_EQUALS "%d" ,
679 			 XNEE_HP_SEP "property" XNEE_HP_EQUALS "%d" ,
680 			 xrec_data->event.u.selectionNotify.time,
681 			 xrec_data->event.u.selectionNotify.requestor,
682 			 xrec_data->event.u.selectionNotify.selection,
683 			 xrec_data->event.u.selectionNotify.target,
684 			 xrec_data->event.u.selectionNotify.property);
685       break;
686 
687     case ColormapNotify:
688       (void)xd->data_fp (xd->out_file,
689 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu"
690 			 XNEE_HP_SEP "colormap" XNEE_HP_EQUALS "%lu"
691 #if defined(__cplusplus) || defined(c_plusplus)
692 			 XNEE_HP_SEP "c_new" XNEE_HP_EQUALS "%d"
693 #else
694 			 XNEE_HP_SEP "new" XNEE_HP_EQUALS "%d"
695 #endif
696 			 XNEE_HP_SEP "state" XNEE_HP_EQUALS "%d" ,
697 			 xrec_data->event.u.colormap.window,
698 			 xrec_data->event.u.colormap.colormap,
699 #if defined(__cplusplus) || defined(c_plusplus)
700 			 xrec_data->event.u.colormap.c_new,
701 #else
702 			 xrec_data->event.u.colormap.new,
703 #endif
704 			 xrec_data->event.u.colormap.state);
705       break;
706 
707     case ClientMessage:
708       (void)xd->data_fp (xd->out_file,
709 			 XNEE_HP_SEP "window" XNEE_HP_EQUALS "%lu" ,
710 			 xrec_data->event.u.clientMessage.window );
711       /*
712       (void)xd->data_fp (xd->out_file, "bytes" XNEE_HP_EQUALS " {");
713       for (i=0;i<20;i++)
714 	{
715 	  (void)xd->data_fp (xd->out_file, "%c ",
716 			     xrec_data->event.u.clientMessage.u.b.bytes[i]);
717 
718 	}
719       (void)xd->data_fp (xd->out_file, "} ");
720       */
721       break;
722 
723     case MappingNotify:
724       (void)xd->data_fp (xd->out_file,
725 			 XNEE_HP_SEP "request" XNEE_HP_EQUALS "%lu"
726 			 XNEE_HP_SEP "firstKeyCode" XNEE_HP_EQUALS "%lu"
727 			 XNEE_HP_SEP "count" XNEE_HP_EQUALS "%d" ,
728 			 xrec_data->event.u.mappingNotify.request,
729 			 xrec_data->event.u.mappingNotify.firstKeyCode,
730 			 xrec_data->event.u.mappingNotify.count);
731       break;
732 
733     default:
734       (void)xd->data_fp (xd->out_file," NOT IMPLEMENTED ");
735       break;
736     }
737   (void)xd->data_fp (xd->out_file, " }");
738 
739 }
740 
741 
742 
743 /*
744  *
745  *   xnee_record_print_reply.
746  *
747  */
xnee_record_print_reply(xnee_data * xd,XRecordInterceptData * xrecintd)748 void xnee_record_print_reply (xnee_data* xd, XRecordInterceptData *xrecintd )
749 {
750   XRecordDatum *xrec_data ;
751   int           rep_type   ;
752 
753   xrec_data = (XRecordDatum *) (xrecintd->data) ;
754   rep_type  = (int)xrec_data->type ;
755 
756   (void)xd->data_fp (xd->out_file,"2,%d,%lu\n", rep_type,xrecintd->server_time);
757 }
758 
759 
760 /*
761  *
762  *   xnee_human_print_reply.
763  *
764  */
xnee_human_print_reply(xnee_data * xd,XRecordInterceptData * xrecintd)765 void xnee_human_print_reply (xnee_data* xd, XRecordInterceptData *xrecintd )
766 {
767   XRecordDatum *xrec_data  ;
768   int           rep_type   ;
769 
770   xrec_data = (XRecordDatum *) (xrecintd->data) ;
771   rep_type  = (int)xrec_data->type ;
772 
773   (void)xd->data_fp (xd->out_file,"Reply       %d,%lu\n", rep_type,xrecintd->server_time);
774 }
775 
776 
777 
778 
779 /*
780  *
781  *   xnee_record_print_error.
782  *
783  */
xnee_record_print_error(xnee_data * xd,XRecordInterceptData * xrecintd)784 void xnee_record_print_error (xnee_data *xd, XRecordInterceptData *xrecintd )
785 {
786   XRecordDatum *xrec_data ;
787   int           err_type  ;
788 
789   xrec_data = (XRecordDatum *) (xrecintd->data) ;
790   err_type  = (int)xrec_data->type ;
791 
792   (void)xd->data_fp (xd->out_file,"3,%d,%lu\n", err_type,xrecintd->server_time);
793 }
794 
795 /*
796  *
797  *   xnee_human_print_error.
798  *
799  */
xnee_human_print_error(xnee_data * xd,XRecordInterceptData * xrecintd)800 void xnee_human_print_error (xnee_data *xd, XRecordInterceptData *xrecintd )
801 {
802   XRecordDatum *xrec_data ;
803   int           err_type  ;
804 
805   xrec_data = (XRecordDatum *) (xrecintd->data) ;
806   err_type = (int) xrec_data->type ;
807 
808   (void)xd->data_fp (xd->out_file,"Error %s\n", xnee_print_error_code(err_type));
809 }
810 
811 
812 #ifdef USE_OBSOLETE
813 /*
814  *
815  *    xnee_record_print_record_range.
816  *
817  */
818 void
old_xnee_record_print_record_range(xnee_data * xd,FILE * out)819 old_xnee_record_print_record_range (xnee_data *xd, FILE* out)
820 {
821   int i=0;
822   int max=xnee_get_max_range(xd);
823 
824   if (out == NULL)
825     {
826       if ( !xd->verbose )
827 	{
828 	  return ;
829 	}
830       out=xd->err_file;
831     }
832 
833   fprintf (out, " -------------> MAX = %d <---------- \n", max);
834 
835   fprintf (out, "\n\n- Record Information -\n\n");
836   fprintf (out, "   Variable              Value\n");
837   fprintf (out, "---------------------------------\n");
838   fprintf (out, "   data_flags            %d\n", xd->record_setup->data_flags);
839   fprintf (out, "   rState                %d\n", (int)xd->record_setup->rState);
840   fprintf (out, "   xids[0]               %ld\n", xd->record_setup->xids[0]);
841   fprintf (out, "   xids[1]               %ld\n", xd->record_setup->xids[1]);
842 
843   fprintf (out, "\n\n      - Record Ranges -\n\n");
844   for ( i=0 ; i<max ; i++ )
845     {
846       fprintf (out, "RecordRange[%d]\n", i);
847       fprintf (out, "    Variable              Value\n");
848       fprintf (out, "---------------------------------\n");
849       fprintf (out, " %s           %d-%d\n",
850 	       XNEE_REQUEST_STR,
851 	       xd->record_setup->range_array[i]->core_requests.first,
852 	       xd->record_setup->range_array[i]->core_requests.last       );
853 
854       fprintf (out, " %s            %d-%d\n",
855 	       XNEE_REPLIES_STR,
856 	       xd->record_setup->range_array[i]->core_replies.first
857 	       , xd->record_setup->range_array[i]->core_replies.last       );
858 
859       fprintf (out, " %s  %d-%d\n",
860 	       XNEE_EXT_REQ_MAJ_STR,
861 	       xd->record_setup->range_array[i]->ext_requests.ext_major.first,
862 	       xd->record_setup->range_array[i]->ext_requests.ext_major.last        );
863 
864       fprintf (out, " %s  %d-%d\n",
865 	       XNEE_EXT_REQ_MIN_STR,
866 	       xd->record_setup->range_array[i]->ext_requests.ext_minor.first,
867 	       xd->record_setup->range_array[i]->ext_requests.ext_minor.last        );
868 
869       fprintf (out, " %s   %d-%d\n",
870 	       XNEE_EXT_REP_MAJ_STR,
871 	       xd->record_setup->range_array[i]->ext_replies.ext_major.first,
872 	       xd->record_setup->range_array[i]->ext_replies.ext_major.last        );
873 
874       fprintf (out, " %s   %d-%d\n",
875 	       XNEE_EXT_REP_MIN_STR,
876 	       xd->record_setup->range_array[i]->ext_replies.ext_minor.first,
877 	       xd->record_setup->range_array[i]->ext_replies.ext_minor.last        );
878 
879       fprintf (out, " %s        %d-%d\n",
880 	       XNEE_DELIVERED_EVENT_STR,
881 	       xd->record_setup->range_array[i]->delivered_events.first,
882 	       xd->record_setup->range_array[i]->delivered_events.last      );
883 
884       fprintf (out, " %s           %d-%d\n",
885 	       XNEE_DEVICE_EVENT_STR,
886 	       xd->record_setup->range_array[i]->device_events.first,
887 	       xd->record_setup->range_array[i]->device_events.last        );
888 
889       fprintf (out, " %s                  %d-%d\n",
890 	       XNEE_ERROR_STR,
891 	       xd->record_setup->range_array[i]->errors.first,
892 	       xd->record_setup->range_array[i]->errors.last      );
893     }
894 }
895 #endif
896 
897 
898 
899 /*
900  *
901  *    xnee_record_print_sys_info.
902  *
903  */
904 int
xnee_print_sys_info(xnee_data * xd,FILE * out)905 xnee_print_sys_info(xnee_data *xd, FILE *out)
906 {
907   struct utsname uname_pointer;
908   time_t rawtime;
909   time_t ret_time;
910   struct tm * timeinfo;
911   int    ret ;
912 
913 
914   if ( (xd==NULL) || (xd->data==NULL) )
915     {
916       return XNEE_NO_MAIN_DATA;
917     }
918   if (xd->record_setup==NULL)
919     {
920       return XNEE_NO_RECORD_DATA;
921     }
922 
923 
924 
925 
926   ret_time = time ( &rawtime );
927   if ( ret_time != rawtime)
928     {
929       return XNEE_DATE_FAILURE;
930     }
931 
932   timeinfo = localtime ( &rawtime );
933   if (timeinfo == NULL)
934     {
935       return XNEE_DATE_FAILURE;
936     }
937 
938   ret = uname(&uname_pointer);
939   if (ret == -1)
940     {
941       return XNEE_DATE_FAILURE;
942     }
943 
944 
945 
946 
947   if (( xd->out_file == NULL ) && (xd->mode==XNEE_RECORDER))
948     {
949       return XNEE_OK;
950     }
951 
952   if (out == NULL)
953     {
954       if ( xd->verbose == 0 )
955 	{
956 	  return XNEE_OK;
957 	}
958       if ( xd->out_file == NULL )
959 	out=xd->err_file;
960 
961     }
962 
963 
964 
965   fprintf (out, "####################################\n");
966   fprintf (out, "#         System information       #\n");
967   fprintf (out, "####################################\n");
968 
969   fprintf (out, "# Date:                   %.4d:%.2d:%.2d \n",
970 	   timeinfo->tm_year + 1900 ,
971 	   timeinfo->tm_mon + 1 ,
972 	   timeinfo->tm_mday  );
973   fprintf (out, "# Time:                   %.2d:%.2d:%.2d \n",
974 	   timeinfo->tm_hour,
975 	   timeinfo->tm_min ,
976 	   timeinfo->tm_sec  );
977   if ( xd->program_name!=NULL)
978     {
979       fprintf (out, "# Xnee program:           %s \n", xd->program_name);
980     }
981   else
982     {
983       fprintf (out, "# Xnee program:           <missing info> \n");
984     }
985   fprintf (out, "# Xnee version:           %s \n", VERSION);
986   fprintf (out, "# Xnee home:              %s \n", XNEE_HOME_URL);
987   fprintf (out, "# Xnee info mailing list: %s \n", XNEE_MAIL);
988   fprintf (out, "# Xnee bug mailing list:  %s \n", XNEE_BUG_MAIL);
989   fprintf (out, "# X version:              %d \n", ProtocolVersion(xd->data));
990   fprintf (out, "# X revision:             %d \n", ProtocolRevision(xd->data));
991   fprintf (out, "# X vendor:               %s \n", ServerVendor (xd->data));
992   fprintf (out, "# X vendor release:       %d \n", VendorRelease (xd->data));
993   fprintf (out, "# Record version major:   %d\n",
994 	   xd->record_setup->major_return);
995   fprintf (out, "# Record version minor:   %d\n",
996 	   xd->record_setup->minor_return);
997   fprintf (out, "# OS name:                %s \n", uname_pointer.sysname);
998   fprintf (out, "# OS Release:             %s \n", uname_pointer.release);
999   fprintf (out, "# OS Version:             %s \n", uname_pointer.version);
1000   fprintf (out, "# Machine:                %s \n", uname_pointer.machine);
1001   fprintf (out, "# Nodename:               %s \n", uname_pointer.nodename);
1002   fprintf (out, "# Display name:           %s\n", xd->display);
1003   fprintf (out, "# Dimension:              %dx%d\n",
1004 	   DisplayWidth (xd->data, 0),
1005 	   DisplayHeight (xd->data, 0));
1006   return XNEE_OK;
1007 }
1008 
1009 
1010 /*
1011  *
1012  * xnee_print_distr_list.
1013  *
1014  */
1015 int
xnee_print_distr_list(xnee_data * xd,FILE * out)1016 xnee_print_distr_list (xnee_data* xd, /*@null@*/ FILE *out)
1017 {
1018   int i=0;
1019 
1020   if (xd==NULL)
1021     {
1022       return XNEE_NO_MAIN_DATA;
1023     }
1024 
1025   if (xd->distr_list==NULL)
1026     {
1027       return XNEE_OK;
1028     }
1029 
1030 
1031   if (out == NULL)
1032     {
1033       if ( xd->verbose == 0 )
1034 	{
1035 	  return 0;
1036 	}
1037       out=xd->err_file;
1038     }
1039   for (i=0 ; i<(int)xd->distr_list_size ; i++)
1040     {
1041       fprintf (out, "Distribution display[%d]=%p\n",
1042 	       i, (void*)xd->distr_list[i].dpy);
1043     }
1044   return (XNEE_OK);
1045 }
1046 
1047 
1048 int
xnee_record_print_record_range(xnee_data * xd,FILE * out)1049 xnee_record_print_record_range (xnee_data *xd, /*@null@*/ FILE* out)
1050 {
1051   int max=0;
1052   int i ;
1053 
1054   if ( (xd==NULL) ||
1055        (xd->record_setup==NULL) ||
1056        (xd->record_setup->range_array==NULL) ||
1057        (xd->record_setup->xids==NULL) )
1058     {
1059       return XNEE_NO_MAIN_DATA;
1060     }
1061 
1062   if (out == NULL)
1063     {
1064       if ( xd->verbose == 0 )
1065 	{
1066 	  return XNEE_OK;
1067 	}
1068       out=xd->err_file;
1069     }
1070 
1071   max=xnee_get_max_range(xd);
1072 
1073 
1074   fprintf (out, "#########################################\n");
1075   fprintf (out, "#          Record settings              #\n");
1076   fprintf (out, "#########################################\n");
1077   fprintf (out, "#   data_flags          %d\n",
1078 	   xd->record_setup->data_flags);
1079   fprintf (out, "#   rState              %p\n",
1080 	   (void*)xd->record_setup->rState);
1081   fprintf (out, "#   xids[0]             %d\n",
1082 	   (int) xd->record_setup->xids[0]);
1083   fprintf (out, "#   xids[1]             %d\n",
1084 	   (int) xd->record_setup->xids[1]);
1085   fprintf (out, "# Number of Ranges      %d\n",
1086 	   (int) max);
1087 
1088 
1089   for ( i=0 ; i<max ; i++ )
1090     {
1091       fprintf (out, "# RecordRange[%d]\n", i);
1092       fprintf (out, "%s            %u-%u\n",
1093 	       xnee_xns_key2string(XNEE_REQUEST_STR_KEY),
1094 	       xd->record_setup->range_array[i]->core_requests.first,
1095 	       xd->record_setup->range_array[i]->core_requests.last       );
1096 
1097       fprintf (out, "%s                   %u-%u \n",
1098 	       xnee_xns_key2string(XNEE_REPLY_STR_KEY),
1099 	       xd->record_setup->range_array[i]->core_replies.first,
1100 	       xd->record_setup->range_array[i]->core_replies.last       );
1101 
1102       fprintf (out, "%s  %u-%u \n",
1103 	       xnee_xns_key2string(XNEE_EXT_REQ_MAJ_STR_KEY),
1104 	       xd->record_setup->range_array[i]->ext_requests.ext_major.first,
1105 	       xd->record_setup->range_array[i]->ext_requests.ext_major.last);
1106 
1107       fprintf (out, "%s  %u-%u \n",
1108 	       xnee_xns_key2string(XNEE_EXT_REQ_MIN_STR_KEY),
1109 	       xd->record_setup->range_array[i]->ext_requests.ext_minor.first,
1110 	       xd->record_setup->range_array[i]->ext_requests.ext_minor.last);
1111 
1112       fprintf (out, "%s   %u-%u\n",
1113 	       xnee_xns_key2string(XNEE_EXT_REP_MAJ_STR_KEY),
1114 	       xd->record_setup->range_array[i]->ext_replies.ext_major.first,
1115 	       xd->record_setup->range_array[i]->ext_replies.ext_major.last);
1116 
1117       fprintf (out, "%s   %u-%u \n",
1118 	       xnee_xns_key2string(XNEE_EXT_REP_MIN_STR_KEY),
1119 	       xd->record_setup->range_array[i]->ext_replies.ext_minor.first,
1120 	       xd->record_setup->range_array[i]->ext_replies.ext_minor.last );
1121 
1122       fprintf (out, "%s         %u-%u \n",
1123 	       xnee_xns_key2string(XNEE_DELIVERED_EVENT_STR_KEY),
1124 	       xd->record_setup->range_array[i]->delivered_events.first,
1125 	       xd->record_setup->range_array[i]->delivered_events.last  );
1126 
1127       fprintf (out, "%s            %u-%u \n",
1128 	       xnee_xns_key2string(XNEE_DEVICE_EVENT_STR_KEY),
1129 	       xd->record_setup->range_array[i]->device_events.first,
1130 	       xd->record_setup->range_array[i]->device_events.last    );
1131 
1132       fprintf (out, "%s                   %u-%u \n",
1133 	       xnee_xns_key2string(XNEE_ERROR_STR_KEY),
1134 	       xd->record_setup->range_array[i]->errors.first,
1135 	       xd->record_setup->range_array[i]->errors.last      );
1136     }
1137 
1138 
1139   return XNEE_OK;
1140 }
1141 
1142 
1143 
1144 /*
1145  *
1146  *
1147  *
1148  */
1149 int
xnee_print_ranges(xnee_data * xd,FILE * fp)1150 xnee_print_ranges (xnee_data *xd, FILE *fp)
1151 {
1152   int max=0;
1153   int i ;
1154 
1155 
1156   if ( (xd==NULL) ||
1157        (xd->record_setup==NULL) ||
1158        (xd->record_setup->range_array==NULL) )
1159     {
1160       return XNEE_NO_MAIN_DATA;
1161     }
1162 
1163 
1164   max=xnee_get_max_range(xd);
1165 
1166   fprintf (fp, "#########################################\n");
1167   fprintf (fp, "#          Recording ranges             #\n");
1168   fprintf (fp, "#########################################\n");
1169   for ( i=0 ; i<max ; i++ )
1170     {
1171 
1172       fprintf (fp, "\n# Range nr:%d\n", i);
1173 
1174       if ( ( (int)xd->record_setup->range_array[i]->core_requests.first != 0)
1175 	   &&
1176 	   ( (int)xd->record_setup->range_array[i]->core_requests.last != 0))
1177 	{
1178 	  fprintf (fp,  "%s %u-%u\n",
1179 		   xnee_xns_key2string(XNEE_REQUEST_STR_KEY),
1180                    xd->record_setup->range_array[i]->core_requests.first,
1181                    xd->record_setup->range_array[i]->core_requests.last       );
1182 	}
1183       if ( ( (int)xd->record_setup->range_array[i]->core_replies.first != 0)
1184 	   &&
1185 	   ( (int)xd->record_setup->range_array[i]->core_replies.last != 0))
1186 	{
1187 	  fprintf (fp,   "%s                   %u-%u \n",
1188 		   xnee_xns_key2string(XNEE_REPLY_STR_KEY),
1189 		   xd->record_setup->range_array[i]->core_replies.first,
1190 		   xd->record_setup->range_array[i]->core_replies.last       );
1191 	}
1192       if ( ( (int)xd->record_setup->range_array[i]->ext_requests.ext_major.first != 0)
1193 	   &&
1194 	   ( (int)xd->record_setup->range_array[i]->ext_requests.ext_major.last != 0))
1195 	{
1196 	  fprintf (fp, "%s  %u-%u \n",
1197 		   xnee_xns_key2string(XNEE_EXT_REQ_MAJ_STR_KEY),
1198 		   xd->record_setup->range_array[i]->ext_requests.ext_major.first,
1199 		   xd->record_setup->range_array[i]->ext_requests.ext_major.last);
1200 	}
1201       if ( ( (int)xd->record_setup->range_array[i]->ext_requests.ext_minor.first != 0)
1202 	   &&
1203 	   ( (int)xd->record_setup->range_array[i]->ext_requests.ext_minor.last != 0))
1204 	{
1205 	  fprintf (fp, "%s  %u-%u \n",
1206 		   xnee_xns_key2string(XNEE_EXT_REQ_MIN_STR_KEY),
1207 		   xd->record_setup->range_array[i]->ext_requests.ext_minor.first,
1208 		   xd->record_setup->range_array[i]->ext_requests.ext_minor.last        );
1209 	}
1210 
1211       if ( ( (int)xd->record_setup->range_array[i]->ext_replies.ext_major.first != 0)
1212 	   &&
1213 	   ( (int)xd->record_setup->range_array[i]->ext_replies.ext_major.last != 0))
1214 	{
1215 	  fprintf (fp,  "%s   %u-%u\n",
1216 		   xnee_xns_key2string(XNEE_EXT_REP_MAJ_STR_KEY),
1217 		   xd->record_setup->range_array[i]->ext_replies.ext_major.first,
1218 		   xd->record_setup->range_array[i]->ext_replies.ext_major.last        );
1219 	}
1220       if ( ( (int)xd->record_setup->range_array[i]->ext_replies.ext_minor.first != 0)
1221 	   &&
1222 	   ( (int)xd->record_setup->range_array[i]->ext_replies.ext_minor.last != 0))
1223 	{
1224 
1225 	  fprintf (fp,  "%s   %u-%u \n",
1226 		   xnee_xns_key2string(XNEE_EXT_REP_MIN_STR_KEY),
1227 		   xd->record_setup->range_array[i]->ext_replies.ext_minor.first,
1228 		   xd->record_setup->range_array[i]->ext_replies.ext_minor.last);
1229 	}
1230 
1231       if ( ( (int)xd->record_setup->range_array[i]->delivered_events.first != 0)
1232 	   &&
1233 	   ( (int)xd->record_setup->range_array[i]->delivered_events.last != 0))
1234 	{
1235 	  fprintf (fp, "%s         %u-%u \n",
1236 		   xnee_xns_key2string(XNEE_DELIVERED_EVENT_STR_KEY),
1237 		   xd->record_setup->range_array[i]->delivered_events.first,
1238 		   xd->record_setup->range_array[i]->delivered_events.last      );
1239 
1240 	}
1241       if ( ( (int)xd->record_setup->range_array[i]->device_events.first != 0)
1242 	   &&
1243 	   ( (int)xd->record_setup->range_array[i]->device_events.last != 0))
1244 	{
1245 	  fprintf (fp, "%s            %u-%u \n",
1246 		   xnee_xns_key2string(XNEE_DEVICE_EVENT_STR_KEY),
1247 		   xd->record_setup->range_array[i]->device_events.first,
1248 		   xd->record_setup->range_array[i]->device_events.last        );
1249 	}
1250       if ( ( (int) xd->record_setup->range_array[i]->errors.first != 0)
1251 	   &&
1252 	   ( (int) xd->record_setup->range_array[i]->errors.last != 0))
1253 	{
1254 	  fprintf (fp,  "%s                   %u-%u \n",
1255 		   xnee_xns_key2string(XNEE_ERROR_STR_KEY),
1256 		   xd->record_setup->range_array[i]->errors.first,
1257 		   xd->record_setup->range_array[i]->errors.last      );
1258 	}
1259 
1260     }
1261   return XNEE_OK;
1262 }
1263 
1264 /*
1265  *
1266  *    xnee_print_xnee_resource_settings.
1267  *
1268  */
1269 int
xnee_print_xnee_resource_settings(xnee_data * xd,FILE * out)1270 xnee_print_xnee_resource_settings (xnee_data* xd, FILE* out)
1271 {
1272   time_t rawtime;
1273   time_t ret_time;
1274   struct tm * timeinfo;
1275 
1276 
1277 
1278 
1279 
1280   if ( (xd==NULL) || (xd->data==NULL) )
1281     {
1282       return XNEE_NO_MAIN_DATA;
1283     }
1284   if (xd->record_setup==NULL)
1285     {
1286       return XNEE_NO_RECORD_DATA;
1287     }
1288 
1289 
1290 
1291 
1292   ret_time = time ( &rawtime );
1293   if ( ret_time != rawtime)
1294     {
1295       return XNEE_DATE_FAILURE;
1296     }
1297 
1298   timeinfo = localtime ( &rawtime );
1299   if (timeinfo == NULL)
1300     {
1301       return XNEE_DATE_FAILURE;
1302     }
1303 
1304   if (out == NULL)
1305     {
1306       if ( xd->verbose == 0 )
1307 	{
1308 	  return XNEE_OK;
1309 	}
1310       out=xd->err_file;
1311     }
1312 
1313 
1314 
1315   fprintf (out,  "###############################################\n");
1316   fprintf (out,  "#                                             #\n");
1317   fprintf (out,  "#            Xnee Project file                #\n");
1318   fprintf (out,  "#                                             #\n");
1319   fprintf (out,  "#                                             #\n");
1320   fprintf (out,  "#  This file is automagically created by      #\n");
1321   fprintf (out,  "#  libxnee.... edit if you know what you do   #\n");
1322   fprintf (out,  "#                                             #\n");
1323   fprintf (out,  "###############################################\n");
1324   fprintf (out,  "\n");
1325   fprintf (out,  "\n");
1326   fprintf (out,  "\n");
1327   fprintf (out,  "##############################################\n");
1328   fprintf (out,  "#      Project info                          #\n");
1329   fprintf (out,  "##############################################\n");
1330   fprintf (out,  XNEE_RES_PROJECT":  \t\t\t%s\n",
1331 	   xnee_get_project_name(xd));
1332   fprintf (out,  XNEE_RES_DESCRIPTION":\t\t%s\n",
1333 	   xnee_get_project_descr(xd));
1334 
1335   fprintf (out,  "\n\n");
1336   fprintf (out,  "##############################################\n");
1337   fprintf (out,  "#     Creation info                          #\n");
1338   fprintf (out,  "##############################################\n");
1339   fprintf (out,  XNEE_RES_CREAT_DATE":    \t%s\n",
1340 	   xnee_get_creat_date(xd));
1341   fprintf (out,  XNEE_RES_CREAT_PROGRAM": \t%s\n",
1342 	   xnee_get_creat_program(xd));
1343   fprintf (out,  XNEE_RES_CREAT_PROG_VER":  \t%s\n",
1344 	   xnee_get_creat_prog_vers(xd));
1345 
1346 
1347   fprintf (out,  "\n\n");
1348   fprintf (out,  "##############################################\n");
1349   fprintf (out,  "#    Last change info                        #\n");
1350   fprintf (out,  "##############################################\n");
1351   fprintf (out,  XNEE_RES_LASTCHANGE_DATE":  \t%s\n",
1352 	   xnee_get_last_date(xd));
1353   fprintf (out,  XNEE_RES_LASTCHANGE_PROGRAM":\t%s\n",
1354 	   xnee_get_last_program(xd));
1355   fprintf (out,  XNEE_RES_LASTCHANGE_PROG_VER":\t%s\n",
1356 	   xnee_get_last_prog_vers(xd));
1357 
1358 
1359   fprintf (out,  "\n\n");
1360   fprintf (out,  "##############################################\n");
1361   fprintf (out,  "#      Current info                          #\n");
1362   fprintf (out,  "##############################################\n");
1363   fprintf (out,  XNEE_RES_CURRENT_CHANGE_DATE":  \t%.4d-%.2d-%.2d \n",
1364 	   timeinfo->tm_year + 1900 ,
1365 	   timeinfo->tm_mon + 1 ,
1366 	   timeinfo->tm_mday  );
1367   fprintf (out,  XNEE_RES_CURRENT_CHANGE_PROGRAM":     \t%s\n",
1368 	   PACKAGE);
1369   fprintf (out,  XNEE_RES_CURRENT_CHANGE_PROG_VER":  \t%s\n",
1370 	   VERSION);
1371   return XNEE_OK;
1372 }
1373 
1374 
1375 /*
1376  *
1377  *    xnee_print_xnee_settings.
1378  *
1379  */
1380 int
xnee_print_xnee_settings(xnee_data * xd,FILE * out)1381 xnee_print_xnee_settings (xnee_data* xd, /*@null@*/ FILE* out)
1382 {
1383   int ret;
1384   int i ;
1385 
1386   if (out == NULL)
1387     {
1388       if ( xd->verbose == 0 )
1389 	{
1390 	  return XNEE_OK;
1391 	}
1392       out=xd->err_file;
1393     }
1394 
1395   if ( (xd==NULL) ||
1396        (xd->grab_keys==NULL) ||
1397        (xd->grab_keys->action_keys==NULL) )
1398     {
1399       return XNEE_NO_MAIN_DATA;
1400     }
1401   fprintf (out,  "\n");
1402 
1403   if ( xd->app_args!= NULL)
1404     {
1405       /* Xnee application argument */
1406       fprintf (out,  "\n\n");
1407       fprintf (out,  "##############################################\n");
1408       fprintf (out,  "#      Xnee application arguments            #\n");
1409       fprintf (out,  "##############################################\n");
1410       fprintf (out,  "#  ");
1411       for (i=0;xd->app_args[i]!=NULL;i++)
1412 	{
1413 	  if ( xd->app_args[i] != NULL)
1414 	    {
1415 	      fprintf (out,  "%s ", xd->app_args[i]);
1416 	    }
1417 	}
1418       fprintf (out,  "\n");
1419     }
1420 
1421   /* DISPLAY */
1422   fprintf (out,  "\n\n");
1423   fprintf (out,  "##############################################\n");
1424   fprintf (out,  "#      Displays                              #\n");
1425   fprintf (out,  "##############################################\n");
1426   fprintf (out,  "# display %s\n",
1427 	   (xd->display==NULL) ? "NULL"  : xd->display);
1428   fprintf (out,  "# %s\n" , xnee_xns_key2string(XNEE_DISTRIBUTE_KEY));
1429   ret = xnee_print_distr_list(xd, out);
1430   XNEE_RETURN_IF_ERR(ret);
1431 
1432 
1433   /* FILES */
1434   fprintf (out,  "\n\n");
1435   fprintf (out,  "##############################################\n");
1436   fprintf (out,  "#      Files                                 #\n");
1437   fprintf (out,  "##############################################\n");
1438   fprintf (out,   "# %s %s\n",
1439 	   xnee_xns_key2string(XNEE_OUT_FILE_KEY),
1440 	   (xd->out_name==NULL) ? "stdout" : xd->out_name );
1441   fprintf (out,   "# %s %s\n",
1442 	   xnee_xns_key2string(XNEE_ERR_FILE_KEY),
1443 	   (xd->err_name==NULL) ? "stderr" : xd->err_name );
1444 
1445   /* GRAB */
1446   fprintf (out,  "\n\n");
1447   fprintf (out,  "##############################################\n");
1448   fprintf (out,  "#      Key Grabs                             #\n");
1449   fprintf (out,  "##############################################\n");
1450   fprintf (out,  "# %s         %s\n",
1451 	   xnee_xns_key2string(XNEE_STOP_KEY_KEY),
1452 	   (xd->grab_keys->action_keys[XNEE_GRAB_STOP].str) ? xd->grab_keys->action_keys[XNEE_GRAB_STOP].str: "0" );
1453   fprintf (out,   "# %s        %s\n",
1454 	   xnee_xns_key2string(XNEE_PAUSE_KEY_KEY),
1455 	   (xd->grab_keys->action_keys[XNEE_GRAB_PAUSE].str) ? xd->grab_keys->action_keys[XNEE_GRAB_PAUSE].str: "0" );
1456   fprintf (out,   "# %s       %s\n",
1457 	   xnee_xns_key2string(XNEE_RESUME_KEY_KEY),
1458 	   (xd->grab_keys->action_keys[XNEE_GRAB_RESUME].str) ? xd->grab_keys->action_keys[XNEE_GRAB_RESUME].str: "0" );
1459   fprintf (out,   "# %s       %s\n",
1460 	   xnee_xns_key2string(XNEE_INSERT_KEY_KEY),
1461 	   (xd->grab_keys->action_keys[XNEE_GRAB_INSERT].str) ? xd->grab_keys->action_keys[XNEE_GRAB_INSERT].str: "0" );
1462   fprintf (out,   "# %s         %s\n",
1463 	   xnee_xns_key2string(XNEE_EXEC_KEY_KEY),
1464 	   (xd->grab_keys->action_keys[XNEE_GRAB_EXEC].str) ? xd->grab_keys->action_keys[XNEE_GRAB_EXEC].str: "0" );
1465   fprintf (out,   "# %s         %s\n",
1466 	   xnee_xns_key2string(XNEE_EXEC_PROGRAM_KEY),
1467 	   (xd->grab_keys->action_keys[XNEE_GRAB_EXEC].extra_str)
1468 	   ? xd->grab_keys->action_keys[XNEE_GRAB_EXEC].extra_str:
1469 	   XNEE_EXEC_NO_PROG );
1470 
1471   /* Limits */
1472   fprintf (out,  "\n\n");
1473   fprintf (out,  "##############################################\n");
1474   fprintf (out,  "#      Recording limits etc                  #\n");
1475   fprintf (out,  "##############################################\n");
1476   fprintf (out,  "\n");
1477   fprintf (out,  "%s        %d\n",
1478 	   xnee_xns_key2string(XNEE_EVENT_MAX_KEY),xnee_get_events_max(xd) );
1479   fprintf (out,  "%s          %d\n",
1480 	   xnee_xns_key2string(XNEE_DATA_MAX_KEY),xnee_get_data_max(xd) );
1481   fprintf (out,  "%s       %d\n",
1482 	   xnee_xns_key2string(XNEE_TIME_MAX_KEY),xnee_get_time_left(xd) );
1483   if ( xd->xnee_info.first_last == 0 )
1484     {
1485       fprintf (out,  "# ");
1486     }
1487   fprintf (out,  "first-last\n");
1488 
1489   fprintf (out,  "\n# Record  all (including current) clients or only future ones\n");
1490   if (xnee_get_all_clients(xd)==0)
1491     {
1492       fprintf (out,  "# ");
1493     }
1494   fprintf (out,  "%s\n",
1495            xnee_xns_key2string(XNEE_ALL_CLIENTS_KEY));
1496   if (xnee_get_all_clients(xd)!=0)
1497     {
1498       fprintf (out,  "# ");
1499     }
1500   fprintf (out,  "%s\n",
1501            xnee_xns_key2string(XNEE_FUTURE_CLIENTS_KEY));
1502 
1503   fprintf (out,  "\n# Store the starting mouse position \n");
1504   if (xnee_is_store_mouse_pos(xd)==0)
1505     {
1506       fprintf (out,  "# ");
1507     }
1508   fprintf (out,  "%s\n",
1509 	   xnee_xns_key2string(XNEE_STORE_MOUSE_POS_KEY));
1510 
1511 
1512   /* Resolution */
1513   fprintf (out,  "\n\n");
1514   fprintf (out,  "##############################################\n");
1515   fprintf (out,  "#      Resolution                            #\n");
1516   fprintf (out,  "##############################################\n");
1517   fprintf (out,  "\n# Resolution\n");
1518   fprintf (out,  "#" "%s  %dx%d\n",
1519 	   xnee_xns_key2string(XNEE_RECORDED_RESOLUTION_KEY),
1520 	   xnee_get_rec_resolution_x(xd),
1521 	   xnee_get_rec_resolution_y(xd)  );
1522   fprintf (out,  "#" "%s  %dx%d\n",
1523 	   xnee_xns_key2string(XNEE_REPLAY_RESOLUTION_KEY),
1524 	   xnee_get_rep_resolution_x(xd),
1525 	   xnee_get_rep_resolution_y(xd)  );
1526   fprintf (out,  "#" "%s  %d\n",
1527 	   xnee_xns_key2string(XNEE_ADJUST_RESOLUTION_KEY),
1528 	   xnee_get_resolution_used (xd));
1529 
1530 
1531   fprintf (out,  "\n\n");
1532   fprintf (out,  "##############################################\n");
1533   fprintf (out,  "#      Speed                                 #\n");
1534   fprintf (out,  "##############################################\n");
1535   fprintf (out,  "\n# Speed\n");
1536   fprintf (out,  "#" "%s  %d\n",
1537 	   xnee_xns_key2string(XNEE_SPEED_PERCENT_KEY),
1538 	   xnee_get_replay_speed(xd));
1539 
1540 
1541   /* Limits */
1542   fprintf (out,  "\n\n");
1543   fprintf (out,  "##############################################\n");
1544   fprintf (out,  "#      Replaying limits etc                  #\n");
1545   fprintf (out,  "##############################################\n");
1546   fprintf (out,  "\n%s %d \n",
1547            xnee_xns_key2string(XNEE_MAX_THRESHOLD_KEY),
1548            xnee_get_max_threshold(xd));
1549   fprintf (out,  "%s %d \n",
1550            xnee_xns_key2string(XNEE_MIN_THRESHOLD_KEY),
1551            xnee_get_min_threshold(xd));
1552   fprintf (out,  "%s %d \n",
1553            xnee_xns_key2string(XNEE_TOT_THRESHOLD_KEY),
1554            xnee_get_tot_threshold(xd));
1555 
1556 
1557   /* Feedback */
1558   fprintf (out,  "\n\n");
1559   fprintf (out,  "##############################################\n");
1560   fprintf (out,  "#      Feedback                              #\n");
1561   fprintf (out,  "##############################################\n");
1562   if (!xnee_fb_no_requested(xd) )
1563     {
1564       fprintf (out, "#");
1565     }
1566   fprintf (out, "%s\n", xnee_xns_key2string(XNEE_FEEDBACK_NONE_KEY));
1567 
1568   if (!xnee_fb_stderr_requested(xd))
1569     {
1570       fprintf (out, "#");
1571     }
1572   fprintf (out, "%s\n", xnee_xns_key2string(XNEE_FEEDBACK_STDERR_KEY));
1573 
1574   if (!xnee_fb_xosd_requested(xd))
1575     {
1576       fprintf (out, "#");
1577     }
1578   fprintf (out, "%s\n", xnee_xns_key2string(XNEE_FEEDBACK_XOSD_KEY));
1579 
1580   fprintf (out, "%s %s\n",
1581 	   xnee_xns_key2string(XNEE_XOSD_FONT_KEY),
1582 	   EMPTY_IF_NULL((char*)xnee_get_xosd_font(xd)));
1583 
1584 
1585   fprintf (out,  "\n\n");
1586   fprintf (out,  "##############################################\n");
1587   fprintf (out,  "#      Various                               #\n");
1588   fprintf (out,  "##############################################\n");
1589   /* Plugin */
1590   fprintf (out,  "\n# Plugin file \n");
1591   if ( (xd->plugin_name                      != NULL) &&
1592        (xnee_xns_key2string(XNEE_PLUGIN_KEY) != NULL)   )
1593     {
1594       fprintf (out,  "# ");
1595       fprintf (out,  "%s       %s\n",
1596 	       xnee_xns_key2string(XNEE_PLUGIN_KEY),
1597 	       xd->plugin_name );
1598     }
1599 
1600 
1601   /* Modes */
1602   fprintf (out,  "\n# Modes (currently not used)\n");
1603   fprintf (out,  "# ");
1604   fprintf (out,    "%s\n",
1605 	   xnee_xns_key2string(XNEE_SYNC_MODE_KEY));
1606 
1607   /* Replay offset */
1608   fprintf (out,  "\n# Replay offset\n");
1609   fprintf (out,    "#%s %dx%d\n",
1610 	   xnee_xns_key2string(XNEE_REPLAY_OFFSET_KEY),
1611 	   xnee_get_replay_offset_x(xd),
1612 	   xnee_get_replay_offset_y(xd));
1613 
1614   fprintf (out,  "\n# Human printout of X11 data (instead of Xnee format)\n");
1615   if (!xnee_is_human_printout(xd))
1616     {
1617       fprintf (out,  "# ");
1618     }
1619   fprintf (out,  "%s  \n",
1620 	   xnee_xns_key2string(XNEE_HUMAN_PRINTOUT_KEY));
1621 
1622 
1623   fprintf (out,  "\n# Delay before starting record/replay\n");
1624   fprintf (out,  "# %s %d\n",
1625 	   xnee_xns_key2string(XNEE_DELAY_TIME_KEY),
1626 	   xnee_get_interval(xd) );
1627 
1628   fprintf (out,  "\n# No recording of ReparentNotify\n");
1629   if ( ! xnee_is_no_reparent_recording(xd) )
1630     {
1631       fprintf (out,  "# ");
1632     }
1633   fprintf (out,  "%s \n",
1634 	   xnee_xns_key2string(XNEE_NO_REPARENT_RECORD)    );
1635 
1636   /* Various */
1637   fprintf (out,  "\n# Various\n");
1638   return XNEE_OK;
1639 }
1640 
1641 
1642 /*
1643  *   xnee_print_data_range_count
1644  *
1645  *
1646  *
1647  */
1648 int
xnee_print_data_range_count(xnee_data * xd)1649 xnee_print_data_range_count (xnee_data * xd)
1650 {
1651   int i=0;
1652   xnee_verbose((xd, "Data ranges\n-----------\n"));
1653 
1654   for ( i=0 ; i< XNEE_NR_OF_TYPES ; i++)
1655     {
1656       xnee_verbose((xd, "PROT_DATA %d=%d\n", i,xd->xnee_info.data_ranges[i]));
1657     }
1658   xnee_verbose((xd, "MAX = %d\n", xnee_get_max_range(xd)));
1659   return (0);
1660 }
1661 
1662 
1663 
1664 /**************************************************************
1665  *                                                            *
1666  * xnee_replay_printbuffer                                    *
1667  *                                                            *
1668  *                                                            *
1669  **************************************************************/
1670 void
xnee_replay_printbuffer_impl(xnee_data * xd)1671 xnee_replay_printbuffer_impl (xnee_data *xd )
1672 {
1673   int i;
1674   fprint_fptr  fp   = xd->buffer_verbose_fp ;
1675   FILE        *file = xd->buffer_file       ;
1676   /*  int **       array= (int **)xd->data_buffer;*/
1677 
1678   if (xd->buf_verbose!=0)
1679     {
1680       (void)fp (file,"\n --- replay buffer ---\n");
1681       /*
1682 	fp (file,"\t- means from Xserver\n\t+ means from file  \n");
1683 	fp (file,"#     event  request  reply    error \n");
1684 	fp (file,"-------------------------------------\n");
1685       */
1686       for (i=0;i<XNEE_REPLAY_BUFFER_SIZE;i++)
1687 	{
1688 	  if (xd->data_buffer[XNEE_EVENT][i] ||
1689  	      xd->data_buffer[XNEE_REQUEST][i] ||
1690  	      xd->data_buffer[XNEE_REPLY][i] ||
1691  	      xd->data_buffer[XNEE_ERROR][i] )
1692 	    fp (file, "%.3d    %.3d     %.3d      %.3d    %.3d\n", i,
1693 		xd->data_buffer[XNEE_EVENT][i],
1694 		xd->data_buffer[XNEE_REQUEST][i],
1695 		xd->data_buffer[XNEE_REPLY][i],
1696 		xd->data_buffer[XNEE_ERROR][i]
1697 		);
1698 	}
1699       fp (file,"cached: max=%02d  min=%02d total=%02d  s_max=%02d s_min=%02d\n",
1700 	  xd->meta_data.cached_max,
1701 	  xd->meta_data.cached_min,
1702 	  xd->meta_data.total_diff,
1703 	  xd->meta_data.sum_max,
1704 	  xd->meta_data.sum_min
1705 	  );
1706       fp (file,"\n");
1707     }
1708 }
1709 
1710 
1711 
1712 /*
1713  *
1714  *
1715  *
1716  */
1717 void
xnee_store_mouse_pos(xnee_data * xd)1718 xnee_store_mouse_pos (xnee_data* xd )
1719 {
1720   int rx;
1721   int ry;
1722   int wx;
1723   int wy;
1724   Window root;
1725   Window child;
1726   unsigned int mask;
1727 
1728   XQueryPointer(xd->data,
1729 		RootWindow(xd->data,0),
1730 		&root,
1731 		&child,
1732 		&rx,
1733 		&ry,
1734 		&wx,
1735 		&wy,
1736 		&mask);
1737 
1738   xd->data_fp (xd->out_file,
1739 	       "%s "
1740 	       "%s=%d "
1741 	       "%s=%d \n" ,
1742 	       XNEE_FAKE_MOTION,
1743 	       XNEE_FAKE_X_ARG, rx,
1744 	       XNEE_FAKE_Y_ARG, ry );
1745 }
1746 
1747 
1748 
1749 /**************************************************************
1750  *                                                            *
1751  * xnee_version                                               *
1752  *                                                            *
1753  *                                                            *
1754  **************************************************************/
1755 void
xnee_version(xnee_data * xd)1756 xnee_version(xnee_data* xd)
1757 {
1758   xnee_verbose ((xd, " --> xnee_version\n"));
1759   fprintf (stderr, "%s %s\n",PACKAGE, VERSION);
1760   fprintf (stderr, "Copyright (C) 2000-2013 Henrik Sandklef \n");
1761   fprintf (stderr, "%s and all its included programs come with ", PACKAGE);
1762   fprintf (stderr, "NO WARRANTY,\nto the extent permitted by law.\n" );
1763   fprintf (stderr, "This is free software, and you may redistribute\n");
1764   fprintf (stderr, "copies of it under terms of GNU General Public License.\n");
1765   /*
1766   fprintf (stderr, "For questions: \n\t%s  \n", XNEE_MAIL);
1767   fprintf (stderr, "Xnee, Xnee's not an Event Emulator \n\t%s \n", XNEE_HOME_URL);
1768   fprintf (stderr, "GPL, GNU General Public License \n\t%s\n",  GNU_HOME_URL);
1769   */
1770   xnee_verbose ((xd, " <-- xnee_version\n"));
1771 }
1772 
1773 
1774 
1775 int
xnee_print_xnee_data(xnee_data * xd)1776 xnee_print_xnee_data(xnee_data *xd)
1777 {
1778 
1779   fprintf (stderr, "xnee_data\n");
1780   fprintf (stderr, "  xd:          %p\n", (void*)xd);
1781   fprintf (stderr, "  xd->data:    %p\n", (void*)xd->data);
1782   fprintf (stderr, "  xd->control: %p\n", (void*)xd->control);
1783   fprintf (stderr, "  xd->fake:    %p\n", (void*)xd->fake);
1784   fprintf (stderr, "  xd->grab:    %p\n", (void*)xd->grab);
1785   return XNEE_OK;
1786 }
1787 
1788 
1789 
1790 int
xnee_print_data_str(xnee_data * xd,char * tmp,int type)1791 xnee_print_data_str(xnee_data *xd, char *tmp, int type)
1792 {
1793   char *data;
1794   int ret = XNEE_OK;
1795   int data_nr;
1796 
1797   XNEE_VERBOSE_ENTER_FUNCTION();
1798 
1799   if ( (tmp[0] >= '0') && (tmp[0] <= '9') )
1800     {
1801       /* We have data as a number */
1802       if (sscanf(tmp, "%d", &data_nr) != 1 )
1803 	{
1804 	  ret = XNEE_WRONG_PARAMS;
1805 	}
1806       else
1807 	{
1808 	  data = (char*) xnee_int2data (type, data_nr);
1809 	  if ( data != NULL)
1810 	    {
1811 	      fprintf (stdout, "%s\n", data);
1812 	    }
1813 	  else
1814 	    {
1815 	      ret = XNEE_WRONG_PARAMS;
1816 	    }
1817 	}
1818     }
1819   else
1820     {
1821       /* We have data as a string */
1822       data = tmp;
1823       data_nr = xnee_data2int(type, tmp);
1824       if ( data_nr == -1)
1825 	{
1826 	  ret = XNEE_WRONG_PARAMS;
1827 	}
1828       else
1829 	{
1830 	  fprintf (stdout, "%d\n", data_nr);
1831 	}
1832     }
1833   XNEE_VERBOSE_LEAVE_FUNCTION();
1834 
1835   return ret;
1836 }
1837