1 /* vi:set ts=8 sts=4 sw=4: 2 * 3 * Copyright (C) 2004 Xavier de Gaye. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2, or (at your option) 8 * any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program (see the file COPYING); if not, write to the 17 * Free Software Foundation, Inc., 18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 * 20 * $Id: clewn.h 217 2008-10-11 14:29:18Z xavier $ 21 */ 22 23 #ifndef CLEWN_H 24 # define CLEWN_H 25 26 #include <stdio.h> 27 #include <string.h> 28 #include <errno.h> 29 #include <ctype.h> 30 #include <sys/stat.h> 31 32 #ifdef HAVE_STDLIB_H 33 # include <stdlib.h> 34 #endif 35 #ifndef EXIT_SUCCESS 36 # define EXIT_SUCCESS 0 37 #endif 38 #ifndef EXIT_FAILURE 39 # define EXIT_FAILURE 1 40 #endif 41 42 #ifdef HAVE_UNISTD_H 43 # include <unistd.h> 44 #endif 45 46 #ifdef HAVE_FCNTL_H 47 # include <fcntl.h> 48 #endif 49 50 #ifdef HAVE_DIRENT_H 51 # include <dirent.h> 52 #else 53 # define dirent direct 54 # if HAVE_SYS_NDIR_H 55 # include <sys/ndir.h> 56 # endif 57 # if HAVE_SYS_DIR_H 58 # include <sys/dir.h> 59 # endif 60 # if HAVE_NDIR_H 61 # include <ndir.h> 62 # endif 63 #endif 64 65 #if !defined(HAVE_SYS_TIME_H) || defined(TIME_WITH_SYS_TIME) 66 # include <time.h> /* on some systems time.h should not be 67 included together with sys/time.h */ 68 #endif 69 #ifdef HAVE_SYS_TIME_H 70 # include <sys/time.h> 71 #endif 72 73 /* Note: Some systems need both string.h and strings.h (Savage). However, 74 * some systems can't handle both, only use string.h in that case. */ 75 #if defined(HAVE_STRINGS_H) && !defined(NO_STRINGS_WITH_STRING_H) 76 # include <strings.h> 77 #endif 78 79 #ifndef __ARGS 80 /* The AIX VisualAge cc compiler defines __EXTENDED__ instead of __STDC__ 81 * because it includes pre-ansi features. */ 82 # if defined(__STDC__) || defined(__GNUC__) || defined(__EXTENDED__) 83 # define __ARGS(x) x 84 # else 85 # define __ARGS(x) () 86 # endif 87 #endif 88 89 typedef char char_u; 90 typedef unsigned long long_u; 91 typedef long linenr_T; /* line number type */ 92 typedef unsigned colnr_T; /* column number type */ 93 94 /* return values for functions */ 95 #define OK 1 96 #define FAIL 0 97 98 /* boolean constants */ 99 #define FALSE 0 100 #define TRUE 1 101 102 /* character constants */ 103 #define NUL '\000' 104 #define BELL '\007' 105 #define BS '\010' 106 #ifndef TAB 107 #define TAB '\011' 108 #endif 109 #define NL '\012' 110 #define CR '\015' 111 #ifndef ESC 112 #define ESC '\033' 113 #endif 114 115 #define Ctrl_U 21 116 #define Ctrl_Z 26 117 118 #define NUMBUFLEN 30 /* length of a buffer to store a number in ASCII */ 119 120 #define VARIABLES_FNAME ".clewn-watched-vars.gdbvar" 121 #define TEMPDIRNAMES "$TMPDIR", "/tmp", ".", "$HOME" 122 #define TEMPNAMELEN 256 123 124 /* The _() stuff is for using gettext(). It is a no-op with Clewn. */ 125 # define _(x) ((char *)(x)) 126 127 /* defines to avoid typecasts from (char_u *) to (char *) and back */ 128 #define STRLEN(s) strlen((char *)(s)) 129 #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) 130 #define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n)) 131 #define STRCMP(d, s) strcmp((char *)(d), (char *)(s)) 132 #define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n)) 133 #define STRCAT(d, s) strcat((char *)(d), (char *)(s)) 134 135 # define MIN_SCREEN_HEIGHT 12 136 137 /* escape characters to send NetBeans commands or functions 138 * directly from readline */ 139 #define DEBUG_ESC_CMD '@' 140 #define DEBUG_ESC_FUN '#' 141 142 /* sign types */ 143 #define SIGN_ANY 0 144 #define SIGN_BP_ENABLED 1 145 #define SIGN_BP_DISABLED 2 146 147 /* key mapping types */ 148 #define KEYMAP_CONTROL 0 149 #define KEYMAP_UPPERCASE 1 150 #define KEYMAP_FUNCTION 2 151 152 /* the NetBeans event structure */ 153 typedef struct 154 { 155 char *key; /* allocated NetBeans key */ 156 char *lnum; /* allocated line number */ 157 char *pathname; /* allocated buffer name */ 158 char *text; /* allocated balloon text */ 159 int text_event; /* TRUE after receiving a balloonText netbeans event */ 160 int seqno; /* netbeans event or reply sequence number */ 161 } nb_event_T; 162 163 extern int p_asm; /* assembly support when non zero */ 164 165 /* pty.c declarations */ 166 int OpenPTY __ARGS((char **ttyn)); 167 int SetupSlavePTY __ARGS((int fd)); 168 169 typedef struct 170 { 171 int dummy; 172 } gdb_handle_T; 173 174 /* gdb interface */ 175 void gdb_docmd __ARGS((gdb_handle_T *, char *)); 176 void gdb_setwinput __ARGS((gdb_handle_T *, char *)); 177 int gdb_iswinput __ARGS((gdb_handle_T *)); 178 void gdb_free_records __ARGS((int)); 179 180 /* NetBeans interface */ 181 #define IS_NETBEANS_CONNECTED (cnb_get_connsock() >= 0 || cnb_get_datasock() >= 0) 182 int cnb_open __ARGS((char *, int *, int, int, char *)); 183 void cnb_close __ARGS((void)); 184 void cnb_saveAndExit __ARGS((void)); 185 int cnb_state __ARGS((void)); 186 int cnb_specialKeys __ARGS((void)); 187 void cnb_keymap __ARGS((int, int)); 188 189 int cnb_get_connsock __ARGS((void)); 190 void cnb_create_varbuf __ARGS((char *)); 191 void cnb_set_instance __ARGS((int)); 192 int cnb_get_datasock __ARGS((void)); 193 void cnb_conn_evt __ARGS((void)); 194 nb_event_T * cnb_data_evt __ARGS((void)); 195 void cnb_send_debug __ARGS((int, char *)); 196 void cnb_showBalloon __ARGS((char *, int, struct obstack *)); 197 void cnb_startAtomic __ARGS((int)); 198 void cnb_endAtomic __ARGS((int)); 199 int cnb_editFile __ARGS((char *, linenr_T, char *, char *, char *, int, struct obstack *)); 200 int cnb_define_sign __ARGS((int, int, int, struct obstack *)); 201 void cnb_buf_addsign __ARGS((int, int, int, linenr_T, struct obstack *)); 202 int cnb_buf_getsign __ARGS((int, int)); 203 void cnb_buf_delsign __ARGS((int, int)); 204 int cnb_create_buf __ARGS((char *)); 205 void cnb_kill __ARGS((int)); 206 void cnb_set_asm __ARGS((int)); 207 void cnb_unlink_asm __ARGS((void)); 208 char * cnb_filename __ARGS((int)); 209 int cnb_lookup_buf __ARGS((char *)); 210 int cnb_isvalid_buffer __ARGS((int)); 211 int cnb_outofbounds __ARGS((int)); 212 void cnb_append __ARGS((int, char *, struct obstack *)); 213 void cnb_clear __ARGS((int, struct obstack *)); 214 void cnb_replace __ARGS((int, char *, int, struct obstack *)); 215 char * cnb_search_obj __ARGS((char *, int *)); 216 217 /* Utilities */ 218 void EMSG __ARGS((char *)); 219 linenr_T find_fr_sign __ARGS((int)); 220 FILE * clewn_opentmpfile __ARGS((char *, char **, int)); 221 char * clewn_stripwhite __ARGS((char *)); 222 linenr_T searchfor __ARGS((char *, char *)); 223 224 #endif /* CLEWN_H */ 225 226