| 92 | } |
| 93 | |
| 94 | public EditLine * |
| 95 | el_init_fd(const char *prog, FILE *fin, FILE *fout, FILE *ferr, |
| 96 | int fdin, int fdout, int fderr) |
| 97 | { |
| 98 | EditLine *el = el_malloc(sizeof(*el)); |
| 99 | |
| 100 | if (el == NULL) |
| 101 | return NULL; |
| 102 | |
| 103 | memset(el, 0, sizeof(EditLine)); |
| 104 | |
| 105 | el->el_infile = fin; |
| 106 | el->el_outfile = fout; |
| 107 | el->el_errfile = ferr; |
| 108 | |
| 109 | el->el_infd = fdin; |
| 110 | el->el_outfd = fdout; |
| 111 | el->el_errfd = fderr; |
| 112 | |
| 113 | el->el_prog = Strdup(ct_decode_string(prog, &el->el_scratch)); |
| 114 | if (el->el_prog == NULL) { |
| 115 | el_free(el); |
| 116 | return NULL; |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | * Initialize all the modules. Order is important!!! |
| 121 | */ |
| 122 | el->el_flags = 0; |
| 123 | #ifdef WIDECHAR |
| 124 | if (setlocale(LC_CTYPE, NULL) != NULL){ |
| 125 | if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) |
| 126 | el->el_flags |= CHARSET_IS_UTF8; |
| 127 | } |
| 128 | #endif |
| 129 | |
| 130 | if (terminal_init(el) == -1) { |
| 131 | el_free(el->el_prog); |
| 132 | el_free(el); |
| 133 | return NULL; |
| 134 | } |
| 135 | (void) keymacro_init(el); |
| 136 | (void) map_init(el); |
| 137 | if (tty_init(el) == -1) |
| 138 | el->el_flags |= NO_TTY; |
| 139 | (void) ch_init(el); |
| 140 | (void) search_init(el); |
| 141 | (void) hist_init(el); |
| 142 | (void) prompt_init(el); |
| 143 | (void) sig_init(el); |
| 144 | (void) read_init(el); |
| 145 | |
| 146 | return el; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | /* el_end(): |
no test coverage detected