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 * 2010, 2014 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 #include "libxnee/xnee.h" 27 #include "libxnee/print.h" 28 #include "libxnee/xnee_dl.h" 29 #include "libxnee/xnee_sem.h" 30 #include "libxnee/xnee_setget.h" 31 #include "libxnee/xnee_resolution.h" 32 #include "libxnee/xnee_grab.h" 33 #include "libxnee/xnee_km.h" 34 #include "libxnee/datastrings.h" 35 36 37 #ifndef XNEE_RESOURCE_H 38 #define XNEE_RESOURCE_H 39 40 extern xnee_option_t *xnee_options; 41 42 43 44 #define XNEE_RES_PROJECT "ProjectName" 45 #define XNEE_RES_DESCRIPTION "ProjectDescription" 46 #define XNEE_RES_CREAT_DATE "ProjectCreationDate" 47 #define XNEE_RES_CREAT_PROGRAM "ProjectCreationProgram" 48 #define XNEE_RES_CREAT_PROG_VER "ProjectCreationProgVersion" 49 #define XNEE_RES_LASTCHANGE_DATE "ProjectLastChangeDate" 50 #define XNEE_RES_LASTCHANGE_PROGRAM "ProjectLastChangeProgram" 51 #define XNEE_RES_LASTCHANGE_PROG_VER "ProjectLastChangeProgVersion" 52 #define XNEE_RES_CURRENT_CHANGE_DATE "ProjectCurrentChangeDate" 53 #define XNEE_RES_CURRENT_CHANGE_PROGRAM "ProjectCurrentChangeProgram" 54 #define XNEE_RES_CURRENT_CHANGE_PROG_VER "ProjectCurrentChangeProgVersion" 55 56 #define XNEE_RES_AUTHOR_NAME "Author" 57 #define XNEE_RES_AUTHOR_EMAIL "Email" 58 59 #define XNEE_NO_SYNTAX 0 60 #define XNEE_CLI_SYNTAX 1 61 #define XNEE_XNS_SYNTAX 2 62 #define XNEE_CLI_PREFIX "--" 63 #define xnee_find_resource_option_entry(xd, option, options) \ 64 xnee_find_option_entry_impl (xd, option, options, XNEE_XNS_SYNTAX) 65 #define xnee_find_cli_option_entry(xd, option, options) \ 66 xnee_find_option_entry_impl(xd, option, options, XNEE_CLI_SYNTAX) 67 68 69 #define XNEE_OPTION_VISIBLE 1 70 #define XNEE_LAST_OPTION -1 71 #define XNEE_OPTION_NOT_FOUND -1 72 73 74 75 #define XNEE_RESOURCE_CHECK(a,b) strncmp(a,b,strlen(a)) 76 #define XNEE_REMOVE_BEGINING_BLANKS(val) \ 77 do { val++ ;} while( (val[0] == ' ') || (val[0] == '\t') ); 78 #define XNEE_REMOVE_TRAILING_CRAP(a) \ 79 do { a[strlen(a)-1]='\0'; } \ 80 while ( (a[strlen(a)-1] == ' ') || (a[strlen(a)-1] == '\n') ) ; 81 82 83 int 84 xnee_init_xnee_resource_meta(xnee_resource_meta* xrm); 85 86 int 87 xnee_new_xnee_resource_meta(xnee_resource_meta* xrm); 88 89 int 90 xnee_free_xnee_resource_meta(xnee_resource_meta* xrm); 91 92 enum XNEE_OPTION_KEYS 93 { 94 XNEE_NO_OPTION_KEY=0 , 95 XNEE_ERR_FILE_KEY , 96 XNEE_OUT_FILE_KEY , 97 XNEE_DISPLAY_KEY , 98 XNEE_FIRST_LAST_KEY , 99 XNEE_ALL_EVENTS_KEY , 100 XNEE_ALL_CLIENTS_KEY , 101 XNEE_FUTURE_CLIENTS_KEY , 102 XNEE_DIMENSION_KEY , 103 XNEE_EVENT_MAX_KEY , 104 XNEE_DATA_MAX_KEY , 105 XNEE_TIME_MAX_KEY , 106 /* XNEE_LOOPS_LEFT_KEY , */ 107 XNEE_STOP_KEY_KEY , 108 XNEE_PAUSE_KEY_KEY , 109 XNEE_RESUME_KEY_KEY , 110 XNEE_INSERT_KEY_KEY , 111 XNEE_EXEC_KEY_KEY , 112 XNEE_EXEC_PROGRAM_KEY , 113 XNEE_EXEC_MARK_KEY , 114 XNEE_NEW_WINDOW_MARK_KEY , 115 XNEE_EVERYTHING_KEY , 116 XNEE_DELAY_TIME_KEY , 117 XNEE_SPEED_PERCENT_KEY , 118 XNEE_RECORDED_RESOLUTION_KEY, 119 XNEE_REPLAY_RESOLUTION_KEY, 120 XNEE_ADJUST_RESOLUTION_KEY, 121 XNEE_DISTRIBUTE_KEY , 122 XNEE_RECORD_OPTION_KEY , 123 XNEE_REPLAY_OPTION_KEY , 124 XNEE_NO_EXPOSE_KEY , 125 XNEE_NO_SYNC_MODE_KEY , 126 /* XNEE_USE_SYNC_KEY , */ 127 XNEE_SYNC_MODE_KEY , 128 XNEE_RECALL_WINDOW_POS_KEY, 129 XNEE_REPLAY_OFFSET_KEY , 130 XNEE_KEEP_AUTOREPEAT , 131 XNEE_HUMAN_PRINTOUT_KEY , 132 XNEE_LOOPS_KEY , 133 XNEE_FORCE_REPLAY_KEY , 134 XNEE_RESOURCE_KEY , 135 XNEE_PLUGIN_KEY , 136 XNEE_ERROR_FD_KEY , 137 XNEE_VERBOSE_KEY , 138 XNEE_BUFFER_VERBOSE_KEY , 139 XNEE_STORE_MOUSE_POS_KEY , 140 XNEE_XOSD_FONT_KEY , 141 XNEE_FEEDBACK_XOSD_KEY , 142 XNEE_FEEDBACK_STDERR_KEY , 143 XNEE_FEEDBACK_NONE_KEY , 144 XNEE_MAX_THRESHOLD_KEY , 145 XNEE_MIN_THRESHOLD_KEY , 146 XNEE_TOT_THRESHOLD_KEY , 147 XNEE_REQUEST_STR_KEY , 148 XNEE_DEVICE_EVENT_STR_KEY , 149 XNEE_DELIVERED_EVENT_STR_KEY, 150 XNEE_ERROR_STR_KEY , 151 XNEE_REPLY_STR_KEY , 152 XNEE_EXT_REQ_MAJ_STR_KEY , 153 XNEE_EXT_REQ_MIN_STR_KEY , 154 XNEE_EXT_REP_MAJ_STR_KEY , 155 XNEE_EXT_REP_MIN_STR_KEY , 156 XNEE_RETYPE_PRESS_DELAY , 157 XNEE_RETYPE_RELEASE_DELAY , 158 XNEE_NO_REPARENT_RECORD , 159 XNEE_MAX_WINDOW_MOVES , 160 XNEE_RECORD_FROM_DATA_DISPLAY, 161 XNEE_RECORD_FROM_CONTROL_DISPLAY 162 }; 163 164 165 /** 166 * Opens the resource file as specified in xd. Reads it and calls xnee_add_resource_syntax where applicable. 167 * @param xd xnee's main structure 168 * @return int 0 means OK. 169 */ 170 int 171 xnee_add_resource(xnee_data *xd); 172 173 174 /** 175 * Takes a Xnee setting in form of a string (using Xnee Session/Resource file format) 176 * @param xd 177 * @param tmp 178 * @return int 1 on success, 0 on failure. 179 * \todo (return values need to be changed) 180 */ 181 #define xnee_add_resource_syntax(xd, tmp_str) xnee_add_resource_syntax_impl(xd, tmp_str, XNEE_XNS_SYNTAX) 182 183 /** 184 * Takes a Xnee setting in form of a string as used by program (gnee, cnee) 185 * @param xd 186 * @param tmp 187 * @return int 1 on success, 0 on failure. 188 * \todo (return values need to be changed) 189 */ 190 #define xnee_add_cli_syntax(xd, tmp_str) xnee_add_resource_syntax_impl(xd, tmp_str, XNEE_CLI_SYNTAX) 191 192 /** 193 * Takes a Xnee setting in form of a string 194 * @param xd 195 * @param tmp 196 * @return int 1 on success, 0 on failure. 197 * \todo (return values need to be changed) 198 */ 199 int 200 xnee_add_resource_syntax_impl(xnee_data *xd, char *str, int syntax_type); 201 202 int 203 xnee_set_project_name(xnee_data *xd, char* project_name_str); 204 205 int 206 xnee_set_project_descr(xnee_data *xd, char* project_descr_str); 207 int 208 xnee_set_creat_date(xnee_data *xd, char* creat_date_str); 209 int 210 xnee_set_creat_program(xnee_data *xd, char* creat_prog_str); 211 int 212 xnee_set_creat_prog_vers(xnee_data *xd, char* creat_prog_date_str); 213 int 214 xnee_set_last_date(xnee_data *xd, char* last_date_str); 215 int 216 xnee_set_last_program(xnee_data *xd, char* last_prog_str); 217 int 218 xnee_set_last_prog_vers(xnee_data *xd, char* last_prog_date_str); 219 int 220 xnee_set_author_name(xnee_data *xd, char* author_name_str); 221 int 222 xnee_set_author_email(xnee_data *xd, char* author_email_str); 223 int 224 xnee_set_char(xnee_data *xd, char* char_str); 225 226 227 int 228 xnee_handle_resource_meta (xnee_data *xd, char *meta_str); 229 230 /* 231 int 232 xnee_is_option(xnee_data *xd, 233 xnee_options_t *options, 234 const char *str, 235 int syntax_type); 236 237 int 238 xnee_is_resource_option(xnee_data *xd, const char *str, int syntax_type); 239 240 241 int 242 xnee_add_strings (xnee_data *xd, 243 xnee_options_t *options, 244 const char *long_option, 245 const char *short_option, 246 char *args, 247 char *option_descr, 248 int type); 249 250 int 251 xnee_find_option_entry (xnee_data *xd, const char *option, xnee_options_t *options); 252 253 #define xnee_parse_check(xd, str, opt) \ 254 xnee_parse_check_impl(xd, xnee_options, str, opt) 255 256 int 257 xnee_parse_check_impl(xnee_data *xd, 258 xnee_options_t *options, 259 const char *str, 260 char *opt); 261 262 */ 263 264 265 266 const char * 267 xnee_key2string(xnee_data *xd, 268 xnee_option_t *options, 269 int key); 270 271 272 #define xnee_xns_key2string(key) \ 273 xnee_key2string(xd, xnee_options, key) 274 275 #define xnee_parse_xns_option(x,o,a) xnee_parse_option_impl(x,o,a,XNEE_XNS_SYNTAX) 276 #define xnee_parse_cli_option(x,o,a) xnee_parse_option_impl(x,o,a,XNEE_CLI_SYNTAX) 277 278 int 279 xnee_parse_option_impl(xnee_data *xd, char **opt_and_args, int *args_used, int syntax_mode); 280 281 282 int 283 xnee_find_option_entry_impl (xnee_data *xd, 284 xnee_option_t *options, 285 const char *option, 286 int syntax_type); 287 288 289 #endif /* XNEE_RESOURCE_H */ 290