1 /***** 2 * Xnee's Not an Event Emulator 3 * 4 * Xnee enables recording and replaying of X protocol data 5 * 6 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 7 * 2004, 2010, 2011 Henrik Sandklef 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License 11 * as published by the Free Software Foundation; either version 3 12 * of the License, or any later version. 13 * 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Boston, 23 * MA 02110-1301, USA. 24 ****/ 25 26 27 28 29 #ifndef XNEE_XNEE_UTILS_H 30 #define XNEE_XNEE_UTILS_H 31 #include "xnee.h" 32 33 #ifdef LONG64 34 #define CARD32_PRINTF_FMT "%ld" 35 #define SIZE_T_PRINTF_FMT "%d" 36 #else 37 #define CARD32_PRINTF_FMT "%ld" 38 #define SIZE_T_PRINTF_FMT "%d" 39 #endif 40 #define TIME_PRINTF_FMT CARD32_PRINTF_FMT 41 42 43 /** 44 * Removes XNEE_COMMENT_START from the argument 45 * and removes unnecessary allocated memory 46 * @param xd xnee's main structure 47 * @param str string to clean up 48 * @return int 1 on success 49 */ 50 int 51 xnee_rem_comment_start(xnee_data *xd, char *str) ; 52 53 54 55 int 56 xnee_write_settings_to_file (xnee_data *xd, FILE *fp); 57 58 59 60 61 62 /* 63 * INTERNAL USE 64 * 65 * Sleep for int seconds 66 * and print some information to the user about the remaining time 67 * 68 * Useful if a user wants to wait for a few seconds in order to iconize 69 * the terminal window where record was started .... just an exanple 70 * 71 */ 72 void xnee_delay (int , char *) ; 73 74 75 /** 76 * Removes blanks from the argument 77 * and removes unnecessary allocated memory 78 * 79 * @param xd xnee's main structure 80 * @param str string to clean up 81 * @return int 1 on success 82 */ 83 int 84 xnee_strip(xnee_data *xd, char *str) ; 85 86 87 88 89 90 int 91 rem_all_blanks (char *array, size_t size); 92 93 94 int 95 rem_begin_blanks (char *array, int size); 96 97 int 98 rem_blanks (char *array, int size); 99 100 101 102 103 104 105 /** 106 * Returns the clients (displays) id (resource ) 107 * @param dpy display of the client 108 * @return XID client's X ID 109 */ 110 XID 111 xnee_client_id (Display *dpy); 112 113 #define XNEE_ATOI_FUNCTION(func, xd, str, xnee_macro_in_ret_val) \ 114 { \ 115 int my_xnee_atio_macro_function_ret ; \ 116 if ( sscanf(str, "%d", &my_xnee_atio_macro_function_ret) == 1) \ 117 xnee_macro_in_ret_val = func(xd, my_xnee_atio_macro_function_ret); \ 118 else {\ 119 xnee_macro_in_ret_val = XNEE_WRONG_PARAMS ; \ 120 }\ 121 } 122 123 124 125 126 127 int 128 xnee_str2int(xnee_data *xd, char *str); 129 130 char ** 131 xnee_str2strptr (char *tmp, int fill_option); 132 133 void 134 xnee_print_strptr(xnee_data *xd, char **strptr); 135 136 int 137 xnee_free_strptr(char **strptr); 138 139 140 int 141 xnee_boolstr2int(xnee_data *xd, char *str); 142 143 int 144 xnee_record_from_data_display(xnee_data *xd); 145 146 Display * 147 xnee_get_display_for_recordcontext(xnee_data *xd); 148 149 int 150 xnee_get_xinput_event_base(Display *dpy); 151 152 int 153 xnee_check_true(char *expr); 154 155 int 156 xnee_check_false(char *expr); 157 158 int 159 xnee_is_screen_ok(xnee_data *xd, int screen); 160 161 162 163 #endif /* XNEE_XNEE_UTILS_H */ 164