1 /* --------------------------------------------------------------------- 2 $Id: redfront.h 3960 2017-03-19 08:01:16Z thomas-sturm $ 3 --------------------------------------------------------------------- 4 (c) 1999-2009 A. Dolzmann and T. Sturm, 1999-2014 T. Sturm 5 --------------------------------------------------------------------- 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions 8 are met: 9 10 * Redistributions of source code must retain the relevant 11 copyright notice, this list of conditions and the following 12 disclaimer. 13 * Redistributions in binary form must reproduce the above 14 copyright notice, this list of conditions and the following 15 disclaimer in the documentation and/or other materials provided 16 with the distribution. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifdef HAVE_CONFIG_H 32 #include "config.h" 33 #endif 34 35 #include <stdio.h> 36 37 #include <stdarg.h> 38 39 #include <stdlib.h> 40 41 #include <errno.h> 42 43 #include <ctype.h> 44 45 #include <string.h> 46 47 #include <libgen.h> 48 49 #include <sys/types.h> 50 51 #include <sys/socket.h> 52 53 #include <fcntl.h> 54 55 #include <sys/ioctl.h> 56 57 #include <unistd.h> 58 59 #include <signal.h> 60 61 #if defined HAVE_WAIT_H 62 #include <wait.h> 63 #elif defined HAVE_SYS_WAIT_H 64 #include <sys/wait.h> 65 #endif 66 67 #ifdef HAVE_LIBEDIT 68 69 #include <editline/readline.h> 70 #include <histedit.h> 71 72 /* obsolete */ 73 int line_startup(const char *,int); 74 int line_pre_input(const char *,int); 75 76 #else 77 78 #include <readline/readline.h> 79 #ifndef RL_PROMPT_START_IGNORE 80 #define RL_PROMPT_START_IGNORE '\001' 81 #endif 82 #ifndef RL_PROMPT_END_IGNORE 83 #define RL_PROMPT_END_IGNORE '\002' 84 #endif 85 86 #ifdef HAVE_HISTORY 87 #include <readline/history.h> 88 #endif 89 90 #endif 91 92 #define CSLB 0 93 #define CSL 1 94 #define PSL 2 95 96 extern int errno; 97 98 struct strbuf { 99 char c; 100 struct strbuf *next,*prev; 101 }; 102 103 struct oStrl { 104 char *this; 105 struct oStrl* next; 106 }; 107 108 typedef struct oStrl *strl; 109 110 int textcolor(int); 111 void resetcolor(void); 112 int vbprintf(const char *,...); 113 void rf_exit(int); 114 115 void parent(void); 116 void send_reduce(char *); 117 118 void child(char **); 119 120 void line_init_history(void); 121 void line_add_history(char *); 122 char *line_read(char *); 123 char *line_quit(const char *); 124 char *line_color_prompt(char *); 125 void line_cleanup_after_signal(void); 126 void line_end_history(void); 127 void line_init(void); 128 void line_learn_completion(char *); 129 void line_end(void); 130 131 RETSIGTYPE sig_sigInt(int); 132 void sig_installHandlers(void); 133 void sig_killChild(void); 134 135 struct strbuf *addchar(char,struct strbuf *); 136 struct strbuf *remtail(struct strbuf *,struct strbuf *); 137 void prtbuf(struct strbuf *); 138 strl strl_cadd(strl,char *); 139 strl strl_delete(strl); 140 141 void deb_init(void); 142 int deb_fprintf(FILE *,const char *,...); 143 void deb_cleanup(void); 144 145 #define BLACK 0 146 #define RED 1 147 #define GREEN 2 148 #define YELLOW 3 149 #define BLUE 4 150 #define MAGENTA 5 151 #define CYAN 6 152 #define WHITE 7 153 #define USER 9 154