readline.c File Reference

#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <pwd.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include "histedit.h"
#include "readline.h"
#include "el.h"
#include "fcns.h"

Include dependency graph for readline.c:

Go to the source code of this file.

Defines

#define ADD_STRING(what, len)
#define GDB_411_HACK
#define TAB   '\r'

Functions

 __RCSID ("$NetBSD: readline.c,v 1.21 2002/03/18 16:20:36 christos Exp $")
static unsigned char _el_rl_complete (EditLine *, int)
static char * _get_prompt (EditLine *)
static int _history_expand_command (const char *, size_t, char **)
static int _history_search_gen (const char *, int, int)
static HIST_ENTRY_move_history (int)
static char * _rl_compat_sub (const char *, const char *, const char *, int)
static int _rl_qsort_string_compare (void *i1, void *i2) const
static int _rl_qsort_string_compare (const void *, const void *)
int add_history (const char *line)
void clear_history (void)
char ** completion_matches (const char *text, CPFunction *genfunc)
HIST_ENTRYcurrent_history (void)
char * filename_completion_function (const char *text, int state)
int history_expand (char *str, char **output)
HIST_ENTRYhistory_get (int num)
int history_is_stifled (void)
int history_search (const char *str, int direction)
int history_search_pos (const char *str, int direction, int pos)
int history_search_prefix (const char *str, int direction)
int history_set_pos (int pos)
char ** history_tokenize (const char *str)
int history_total_bytes (void)
HIST_ENTRYnext_history (void)
HIST_ENTRYprevious_history (void)
int read_history (const char *filename)
char * readline (const char *prompt)
int rl_bind_key (int c, int func(int, int))
int rl_complete (int ignore, int invoking_key)
static int rl_complete_internal (int)
void rl_display_match_list (char **matches, int len, int max)
int rl_initialize (void)
int rl_insert (int count, int c)
int rl_read_key (void)
void rl_reset_terminal (const char *p)
void stifle_history (int max)
char * tilde_expand (char *txt)
int unstifle_history (void)
char * username_completion_function (const char *text, int state)
void using_history (void)
int where_history (void)
int write_history (const char *filename)

Variables

static int _rl_complete_show_all = 0
static char break_chars []
static EditLinee = NULL
static int el_rl_complete_cmdnum = 0
static char * el_rl_prompt = NULL
static char empty [] = { '\0' }
static char expand_chars [] = { ' ', '\t', '\n', '=', '(', '\0' }
static Historyh = NULL
int history_base = 1
char history_expansion_char = '!'
Functionhistory_inhibit_expansion_function = NULL
int history_length = 0
char * history_no_expand_chars = expand_chars
char history_subst_char = '^'
int max_input_history = 0
CPPFunctionrl_attempted_completion_function = NULL
int rl_attempted_completion_over = 0
char * rl_basic_word_break_characters = break_chars
char * rl_completer_quote_characters = NULL
char * rl_completer_word_break_characters = NULL
int rl_completion_append_character = ' '
CPFunctionrl_completion_entry_function = NULL
int rl_completion_query_items = 100
int rl_completion_type = 0
int rl_end = 0
int rl_inhibit_completion = 0
FILE * rl_instream = NULL
const char * rl_library_version = "EditLine wrapper"
char * rl_line_buffer = NULL
FILE * rl_outstream = NULL
int rl_point = 0
char * rl_readline_name = empty
char * rl_special_prefixes = (char *)NULL


Define Documentation

#define ADD_STRING ( what,
len   ) 

Referenced by history_expand().

#define GDB_411_HACK

Definition at line 68 of file readline.c.

#define TAB   '\r'

Definition at line 65 of file readline.c.

Referenced by rl_complete().


Function Documentation

__RCSID ( "$NetBSD: readline.  c,
v 1.21 2002/03/18 16:20:36 christos Exp $"   
)

static unsigned char _el_rl_complete ( EditLine el,
int  ch 
) [static]

Definition at line 1323 of file readline.c.

References rl_complete().

Referenced by rl_initialize().

01324 {
01325    return (unsigned char) rl_complete(0, ch);
01326 }

static char * _get_prompt ( EditLine el  )  [static]

Definition at line 154 of file readline.c.

References el_rl_prompt.

Referenced by rl_initialize().

00155 {
00156    return (el_rl_prompt);
00157 }

static int _history_expand_command ( const char *  command,
size_t  cmdlen,
char **  result 
) [static]

Definition at line 389 of file readline.c.

References _rl_compat_sub(), end, free, H_CURR, H_NEXT_EVENT, history(), history_expansion_char, history_get(), history_length, history_search(), history_search_prefix(), history_tokenize(), len(), _hist_entry::line, malloc, max, NULL, HistEvent::num, prefix, realloc, retval, rl_outstream, HistEvent::str, and strdup.

Referenced by history_expand().

00390 {
00391    char **arr, *tempcmd, *line, *search = NULL, *cmd;
00392    const char *event_data = NULL;
00393    static char *from = NULL, *to = NULL;
00394    int start = -1, end = -1, max, i, idx;
00395    int h_on = 0, t_on = 0, r_on = 0, e_on = 0, p_on = 0, g_on = 0;
00396    int event_num = 0, retval;
00397    size_t cmdsize;
00398 
00399    *result = NULL;
00400 
00401    cmd = alloca(cmdlen + 1);
00402    (void) strncpy(cmd, command, cmdlen);
00403    cmd[cmdlen] = 0;
00404 
00405    idx = 1;
00406    /* find out which event to take */
00407    if (cmd[idx] == history_expansion_char) {
00408       event_num = history_length;
00409       idx++;
00410    } else {
00411       int off, num;
00412       size_t len;
00413       off = idx;
00414       while (cmd[off] && !strchr(":^$*-%", cmd[off]))
00415          off++;
00416       num = atoi(&cmd[idx]);
00417       if (num != 0) {
00418          event_num = num;
00419          if (num < 0)
00420             event_num += history_length + 1;
00421       } else {
00422          int prefix = 1, curr_num;
00423          HistEvent ev;
00424 
00425          len = off - idx;
00426          if (cmd[idx] == '?') {
00427             idx++, len--;
00428             if (cmd[off - 1] == '?')
00429                len--;
00430             else if (cmd[off] != '\n' && cmd[off] != '\0')
00431                return (-1);
00432             prefix = 0;
00433          }
00434          search = alloca(len + 1);
00435          (void) strncpy(search, &cmd[idx], len);
00436          search[len] = '\0';
00437 
00438          if (history(h, &ev, H_CURR) != 0)
00439             return (-1);
00440          curr_num = ev.num;
00441 
00442          if (prefix)
00443             retval = history_search_prefix(search, -1);
00444          else
00445             retval = history_search(search, -1);
00446 
00447          if (retval == -1) {
00448             fprintf(rl_outstream, "%s: Event not found\n",
00449                 search);
00450             return (-1);
00451          }
00452          if (history(h, &ev, H_CURR) != 0)
00453             return (-1);
00454          event_data = ev.str;
00455 
00456          /* roll back to original position */
00457          history(h, &ev, H_NEXT_EVENT, curr_num);
00458       }
00459       idx = off;
00460    }
00461 
00462    if (!event_data && event_num >= 0) {
00463       HIST_ENTRY *rl_he;
00464       rl_he = history_get(event_num);
00465       if (!rl_he)
00466          return (0);
00467       event_data = rl_he->line;
00468    } else
00469       return (-1);
00470 
00471    if (cmd[idx] != ':')
00472       return (-1);
00473    cmd += idx + 1;
00474 
00475    /* recognize cmd */
00476    if (*cmd == '^')
00477       start = end = 1, cmd++;
00478    else if (*cmd == '$')
00479       start = end = -1, cmd++;
00480    else if (*cmd == '*')
00481       start = 1, end = -1, cmd++;
00482    else if (isdigit((unsigned char) *cmd)) {
00483       const char *temp;
00484       int shifted = 0;
00485 
00486       start = atoi(cmd);
00487       temp = cmd;
00488       for (; isdigit((unsigned char) *cmd); cmd++);
00489       if (temp != cmd)
00490          shifted = 1;
00491       if (shifted && *cmd == '-') {
00492          if (!isdigit((unsigned char) *(cmd + 1)))
00493             end = -2;
00494          else {
00495             end = atoi(cmd + 1);
00496             for (; isdigit((unsigned char) *cmd); cmd++);
00497          }
00498       } else if (shifted && *cmd == '*')
00499          end = -1, cmd++;
00500       else if (shifted)
00501          end = start;
00502    }
00503    if (*cmd == ':')
00504       cmd++;
00505 
00506    line = strdup(event_data);
00507    for (; *cmd; cmd++) {
00508       if (*cmd == ':')
00509          continue;
00510       else if (*cmd == 'h')
00511          h_on = 1 | g_on, g_on = 0;
00512       else if (*cmd == 't')
00513          t_on = 1 | g_on, g_on = 0;
00514       else if (*cmd == 'r')
00515          r_on = 1 | g_on, g_on = 0;
00516       else if (*cmd == 'e')
00517          e_on = 1 | g_on, g_on = 0;
00518       else if (*cmd == 'p')
00519          p_on = 1 | g_on, g_on = 0;
00520       else if (*cmd == 'g')
00521          g_on = 2;
00522       else if (*cmd == 's' || *cmd == '&') {
00523          char *what, *with, delim;
00524          int len, from_len;
00525          size_t size;
00526 
00527          if (*cmd == '&' && (from == NULL || to == NULL))
00528             continue;
00529          else if (*cmd == 's') {
00530             delim = *(++cmd), cmd++;
00531             size = 16;
00532             what = realloc(from, size);
00533             len = 0;
00534             for (; *cmd && *cmd != delim; cmd++) {
00535                if (*cmd == '\\'
00536                    && *(cmd + 1) == delim)
00537                   cmd++;
00538                if (len >= size)
00539                   what = realloc(what,
00540                       (size <<= 1));
00541                what[len++] = *cmd;
00542             }
00543             what[len] = '\0';
00544             from = what;
00545             if (*what == '\0') {
00546                free(what);
00547                if (search)
00548                   from = strdup(search);
00549                else {
00550                   from = NULL;
00551                   free(line);
00552                   return (-1);
00553                }
00554             }
00555             cmd++;   /* shift after delim */
00556             if (!*cmd)
00557                continue;
00558 
00559             size = 16;
00560             with = realloc(to, size);
00561             len = 0;
00562             from_len = strlen(from);
00563             for (; *cmd && *cmd != delim; cmd++) {
00564                if (len + from_len + 1 >= size) {
00565                   size += from_len + 1;
00566                   with = realloc(with, size);
00567                }
00568                if (*cmd == '&') {
00569                   /* safe */
00570                   (void) strcpy(&with[len], from);
00571                   len += from_len;
00572                   continue;
00573                }
00574                if (*cmd == '\\'
00575                    && (*(cmd + 1) == delim
00576                   || *(cmd + 1) == '&'))
00577                   cmd++;
00578                with[len++] = *cmd;
00579             }
00580             with[len] = '\0';
00581             to = with;
00582 
00583             tempcmd = _rl_compat_sub(line, from, to,
00584                 (g_on) ? 1 : 0);
00585             free(line);
00586             line = tempcmd;
00587             g_on = 0;
00588          }
00589       }
00590    }
00591 
00592    arr = history_tokenize(line);
00593    free(line);    /* no more needed */
00594    if (arr && *arr == NULL)
00595       free(arr), arr = NULL;
00596    if (!arr)
00597       return (-1);
00598 
00599    /* find out max valid idx to array of array */
00600    max = 0;
00601    for (i = 0; arr[i]; i++)
00602       max++;
00603    max--;
00604 
00605    /* set boundaries to something relevant */
00606    if (start < 0)
00607       start = 1;
00608    if (end < 0)
00609       end = max - ((end < -1) ? 1 : 0);
00610 
00611    /* check boundaries ... */
00612    if (start > max || end > max || start > end) {
00613       for (i = 0; i <= max; i++) {
00614          free(arr[i]);
00615       }
00616       free(arr), arr = (char **) NULL;
00617       return (-1);
00618    }
00619 
00620    for (i = 0; i <= max; i++) {
00621       char *temp;
00622       if (h_on && (i == 1 || h_on > 1) &&
00623           (temp = strrchr(arr[i], '/')))
00624          *(temp + 1) = '\0';
00625       if (t_on && (i == 1 || t_on > 1) &&
00626           (temp = strrchr(arr[i], '/')))
00627          (void) strcpy(arr[i], temp + 1);
00628       if (r_on && (i == 1 || r_on > 1) &&
00629           (temp = strrchr(arr[i], '.')))
00630          *temp = '\0';
00631       if (e_on && (i == 1 || e_on > 1) &&
00632           (temp = strrchr(arr[i], '.')))
00633          (void) strcpy(arr[i], temp);
00634    }
00635 
00636    cmdsize = 1, cmdlen = 0;
00637    tempcmd = malloc(cmdsize);
00638    for (i = start; start <= i && i <= end; i++) {
00639       int arr_len;
00640 
00641       arr_len = strlen(arr[i]);
00642       if (cmdlen + arr_len + 1 >= cmdsize) {
00643          cmdsize += arr_len + 1;
00644          tempcmd = realloc(tempcmd, cmdsize);
00645       }
00646       (void) strcpy(&tempcmd[cmdlen], arr[i]);  /* safe */
00647       cmdlen += arr_len;
00648       tempcmd[cmdlen++] = ' ';   /* add a space */
00649    }
00650    while (cmdlen > 0 && isspace((unsigned char) tempcmd[cmdlen - 1]))
00651       cmdlen--;
00652    tempcmd[cmdlen] = '\0';
00653 
00654    *result = tempcmd;
00655 
00656    for (i = 0; i <= max; i++)
00657       free(arr[i]);
00658    free(arr), arr = (char **) NULL;
00659    return (p_on) ? 2 : 1;
00660 }

static int _history_search_gen ( const char *  str,
int  direction,
int  pos 
) [static]

Definition at line 1069 of file readline.c.

References H_CURR, H_NEXT, H_NEXT_EVENT, H_PREV, H_PREV_EVENT, history(), HistEvent::num, and HistEvent::str.

Referenced by history_search(), and history_search_prefix().

01070 {
01071    HistEvent ev;
01072    const char *strp;
01073    int curr_num;
01074 
01075    if (history(h, &ev, H_CURR) != 0)
01076       return (-1);
01077    curr_num = ev.num;
01078 
01079    for (;;) {
01080       strp = strstr(ev.str, str);
01081       if (strp && (pos < 0 || &ev.str[pos] == strp))
01082          return (int) (strp - ev.str);
01083       if (history(h, &ev, direction < 0 ? H_PREV : H_NEXT) != 0)
01084          break;
01085    }
01086 
01087    history(h, &ev, direction < 0 ? H_NEXT_EVENT : H_PREV_EVENT, curr_num);
01088 
01089    return (-1);
01090 }

static HIST_ENTRY * _move_history ( int  op  )  [static]

Definition at line 164 of file readline.c.

References _hist_entry::data, history(), _hist_entry::line, NULL, and HistEvent::str.

Referenced by current_history(), next_history(), and previous_history().

00165 {
00166    HistEvent ev;
00167    static HIST_ENTRY rl_he;
00168 
00169    if (history(h, &ev, op) != 0)
00170       return (HIST_ENTRY *) NULL;
00171 
00172    rl_he.line = ev.str;
00173    rl_he.data = "";
00174 
00175    return (&rl_he);
00176 }

static char * _rl_compat_sub ( const char *  str,
const char *  what,
const char *  with,
int  globally 
) [static]

Definition at line 333 of file readline.c.

References len(), malloc, NULL, realloc, and result.

Referenced by _history_expand_command().

00335 {
00336    char *result;
00337    const char *temp, *new;
00338    int len, with_len, what_len, add;
00339    size_t size, i;
00340 
00341    result = malloc((size = 16));
00342    temp = str;
00343    with_len = strlen(with);
00344    what_len = strlen(what);
00345    len = 0;
00346    do {
00347       new = strstr(temp, what);
00348       if (new) {
00349          i = new - temp;
00350          add = i + with_len;
00351          if (i + add + 1 >= size) {
00352             size += add + 1;
00353             result = realloc(result, size);
00354          }
00355          (void) strncpy(&result[len], temp, i);
00356          len += i;
00357          (void) strcpy(&result[len], with);  /* safe */
00358          len += with_len;
00359          temp = new + what_len;
00360       } else {
00361          add = strlen(temp);
00362          if (len + add + 1 >= size) {
00363             size += add + 1;
00364             result = realloc(result, size);
00365          }
00366          (void) strcpy(&result[len], temp);  /* safe */
00367          len += add;
00368          temp = NULL;
00369       }
00370    } while (temp && globally);
00371    result[len] = '\0';
00372 
00373    return (result);
00374 }

static int _rl_qsort_string_compare ( void *  i1,
void *  i2 
) const [static]

Definition at line 1385 of file readline.c.

01387 {
01388    /* LINTED const castaway */
01389    const char *s1 = ((const char **)i1)[0];
01390    /* LINTED const castaway */
01391    const char *s2 = ((const char **)i2)[0];
01392 
01393    return strcasecmp(s1, s2);
01394 }

static int _rl_qsort_string_compare ( const void *  ,
const void *   
) [static]

Referenced by rl_display_match_list().

int add_history ( const char *  line  ) 

Definition at line 929 of file readline.c.

References H_ENTER, H_GETSIZE, history(), history_length, NULL, HistEvent::num, and rl_initialize().

Referenced by history_expand().

00930 {
00931    HistEvent ev;
00932 
00933    if (h == NULL || e == NULL)
00934       rl_initialize();
00935 
00936    (void) history(h, &ev, H_ENTER, line);
00937    if (history(h, &ev, H_GETSIZE) == 0)
00938       history_length = ev.num;
00939 
00940    return (!(history_length > 0));  /* return 0 if all is okay */
00941 }

void clear_history ( void   ) 

Definition at line 948 of file readline.c.

References H_CLEAR, and history().

00949 {
00950    HistEvent ev;
00951 
00952    history(h, &ev, H_CLEAR);
00953 }

char** completion_matches ( const char *  text,
CPFunction genfunc 
)

Definition at line 1333 of file readline.c.

References malloc, NULL, realloc, and rl_initialize().

Referenced by rl_complete_internal().

01334 {
01335    char **match_list = NULL, *retstr, *prevstr;
01336    size_t match_list_len, max_equal, which, i;
01337    int matches;
01338 
01339    if (h == NULL || e == NULL)
01340       rl_initialize();
01341 
01342    matches = 0;
01343    match_list_len = 1;
01344    while ((retstr = (*genfunc) (text, matches)) != NULL) {
01345       if (matches + 1 >= match_list_len) {
01346          match_list_len <<= 1;
01347          match_list = realloc(match_list,
01348              match_list_len * sizeof(char *));
01349       }
01350       match_list[++matches] = retstr;
01351    }
01352 
01353    if (!match_list)
01354       return (char **) NULL;  /* nothing found */
01355 
01356    /* find least denominator and insert it to match_list[0] */
01357    which = 2;
01358    prevstr = match_list[1];
01359    max_equal = strlen(prevstr);
01360    for (; which <= matches; which++) {
01361       for (i = 0; i < max_equal &&
01362           prevstr[i] == match_list[which][i]; i++)
01363          continue;
01364       max_equal = i;
01365    }
01366 
01367    retstr = malloc(max_equal + 1);
01368    (void) strncpy(retstr, match_list[1], max_equal);
01369    retstr[max_equal] = '\0';
01370    match_list[0] = retstr;
01371 
01372    /* add NULL as last pointer to the array */
01373    if (matches + 1 >= match_list_len)
01374       match_list = realloc(match_list,
01375           (match_list_len + 1) * sizeof(char *));
01376    match_list[matches + 1] = (char *) NULL;
01377 
01378    return (match_list);
01379 }

HIST_ENTRY* current_history ( void   ) 

Definition at line 982 of file readline.c.

References _move_history(), and H_CURR.

00983 {
00984 
00985    return (_move_history(H_CURR));
00986 }

char* filename_completion_function ( const char *  text,
int  state 
)

Definition at line 1204 of file readline.c.

References free, len(), malloc, NULL, realloc, strdup, and tilde_expand().

Referenced by complete_fn(), and rl_complete_internal().

01205 {
01206    DIR *dir = NULL;
01207    char *filename = NULL, *dirname = NULL;
01208    size_t filename_len = 0;
01209    struct dirent *entry;
01210    char *temp;
01211    size_t len;
01212 
01213    temp = strrchr(text, '/');
01214    if (temp) {
01215       temp++;
01216       filename = realloc(filename, strlen(temp) + 1);
01217       (void) strcpy(filename, temp);
01218       len = temp - text;   /* including last slash */
01219       dirname = realloc(dirname, len + 1);
01220       (void) strncpy(dirname, text, len);
01221       dirname[len] = '\0';
01222    } else {
01223       filename = strdup(text);
01224       dirname = NULL;
01225    }
01226 
01227    /* support for ``~user'' syntax */
01228    if (dirname && *dirname == '~') {
01229       temp = tilde_expand(dirname);
01230       dirname = realloc(dirname, strlen(temp) + 1);
01231       (void) strcpy(dirname, temp); /* safe */
01232       free(temp); /* no longer needed */
01233    }
01234    /* will be used in cycle */
01235    filename_len = strlen(filename);
01236 
01237    dir = opendir(dirname ? dirname : ".");
01238    if (!dir) {
01239       free(filename);
01240       free(dirname);
01241       return (NULL); /* cannot open the directory */
01242    }
01243 
01244    /* find the match */
01245    while ((entry = readdir(dir)) != NULL) {
01246       /* otherwise, get first entry where first */
01247       /* filename_len characters are equal     */
01248       if (
01249 #if defined(__SVR4) || defined(__linux__)
01250           strlen(entry->d_name) >= filename_len
01251 #else
01252           entry->d_namlen >= filename_len
01253 #endif
01254           && strncmp(entry->d_name, filename,
01255          filename_len) == 0
01256          && (state-- == 0))
01257          break;
01258    }
01259 
01260    if (entry) {      /* match found */
01261 
01262       struct stat stbuf;
01263 #if defined(__SVR4) || defined(__linux__)
01264       len = strlen(entry->d_name) +
01265 #else
01266       len = entry->d_namlen +
01267 #endif
01268           ((dirname) ? strlen(dirname) : 0) + 1 + 1;
01269       temp = malloc(len);
01270       (void) sprintf(temp, "%s%s",
01271           dirname ? dirname : "", entry->d_name);  /* safe */
01272 
01273       /* test, if it's directory */
01274       if (stat(temp, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))
01275          strcat(temp, "/");   /* safe */
01276    } else
01277       temp = NULL;
01278    closedir(dir);
01279    free(filename);
01280    free(dirname);
01281 
01282    return (temp);
01283 }

int history_expand ( char *  str,
char **  output 
)

Definition at line 667 of file readline.c.

References _history_expand_command(), add_history(), ADD_STRING, free, history_expansion_char, history_inhibit_expansion_function, history_no_expand_chars, history_subst_char, len(), NULL, result, retval, rl_initialize(), and strdup.

00668 {
00669    int i, retval = 0, idx;
00670    size_t size;
00671    char *temp, *result;
00672 
00673    if (h == NULL || e == NULL)
00674       rl_initialize();
00675 
00676    *output = strdup(str);  /* do it early */
00677 
00678    if (str[0] == history_subst_char) {
00679       /* ^foo^foo2^ is equivalent to !!:s^foo^foo2^ */
00680       temp = alloca(4 + strlen(str) + 1);
00681       temp[0] = temp[1] = history_expansion_char;
00682       temp[2] = ':';
00683       temp[3] = 's';
00684       (void) strcpy(temp + 4, str);
00685       str = temp;
00686    }
00687 #define  ADD_STRING(what, len)                  \
00688    {                       \
00689       if (idx + len + 1 > size)           \
00690          result = realloc(result, (size += len + 1)); \
00691       (void)strncpy(&result[idx], what, len);         \
00692       idx += len;                \
00693       result[idx] = '\0';              \
00694    }
00695 
00696    result = NULL;
00697    size = idx = 0;
00698    for (i = 0; str[i];) {
00699       int start, j, loop_again;
00700       size_t len;
00701 
00702       loop_again = 1;
00703       start = j = i;
00704 loop:
00705       for (; str[j]; j++) {
00706          if (str[j] == '\\' &&
00707              str[j + 1] == history_expansion_char) {
00708             (void) strcpy(&str[j], &str[j + 1]);
00709             continue;
00710          }
00711          if (!loop_again) {
00712             if (str[j] == '?') {
00713                while (str[j] && str[++j] != '?');
00714                if (str[j] == '?')
00715                   j++;
00716             } else if (isspace((unsigned char) str[j]))
00717                break;
00718          }
00719          if (str[j] == history_expansion_char
00720              && !strchr(history_no_expand_chars, str[j + 1])
00721              && (!history_inhibit_expansion_function ||
00722              (*history_inhibit_expansion_function)(str, j) == 0))
00723             break;
00724       }
00725 
00726       if (str[j] && str[j + 1] != '#' && loop_again) {
00727          i = j;
00728          j++;
00729          if (str[j] == history_expansion_char)
00730             j++;
00731          loop_again = 0;
00732          goto loop;
00733       }
00734       len = i - start;
00735       temp = &str[start];
00736       ADD_STRING(temp, len);
00737 
00738       if (str[i] == '\0' || str[i] != history_expansion_char
00739           || str[i + 1] == '#') {
00740          len = j - i;
00741          temp = &str[i];
00742          ADD_STRING(temp, len);
00743          if (start == 0)
00744             retval = 0;
00745          else
00746             retval = 1;
00747          break;
00748       }
00749       retval = _history_expand_command(&str[i], (size_t) (j - i),
00750           &temp);
00751       if (retval != -1) {
00752          len = strlen(temp);
00753          ADD_STRING(temp, len);
00754       }
00755       i = j;
00756    }        /* for(i ...) */
00757 
00758    if (retval == 2) {
00759       add_history(temp);
00760 #ifdef GDB_411_HACK
00761       /* gdb 4.11 has been shipped with readline, where */
00762       /* history_expand() returned -1 when the line     */
00763       /* should not be executed; in readline 2.1+    */
00764       /* it should return 2 in such a case        */
00765       retval = -1;
00766 #endif
00767    }
00768    free(*output);
00769    *output = result;
00770 
00771    return (retval);
00772 }

HIST_ENTRY* history_get ( int  num  ) 

Definition at line 894 of file readline.c.

References _hist_entry::data, H_CURR, H_FIRST, H_LAST, H_NEXT_EVENT, H_PREV, history(), _hist_entry::line, NULL, HistEvent::num, rl_initialize(), and HistEvent::str.

Referenced by _history_expand_command(), _jb_get(), jb_getinfo(), and jb_next().

00895 {
00896    static HIST_ENTRY she;
00897    HistEvent ev;
00898    int i = 1, curr_num;
00899 
00900    if (h == NULL || e == NULL)
00901       rl_initialize();
00902 
00903    /* rewind to beginning */
00904    if (history(h, &ev, H_CURR) != 0)
00905       return (NULL);
00906    curr_num = ev.num;
00907    if (history(h, &ev, H_LAST) != 0)
00908       return (NULL); /* error */
00909    while (i < num && history(h, &ev, H_PREV) == 0)
00910       i++;
00911    if (i != num)
00912       return (NULL); /* not so many entries */
00913 
00914    she.line = ev.str;
00915    she.data = NULL;
00916 
00917    /* rewind history to the same event it was before */
00918    (void) history(h, &ev, H_FIRST);
00919    (void) history(h, &ev, H_NEXT_EVENT, curr_num);
00920 
00921    return (&she);
00922 }

int history_is_stifled ( void   ) 

Definition at line 852 of file readline.c.

References max_input_history.

00853 {
00854 
00855    /* cannot return true answer */
00856    return (max_input_history != INT_MAX);
00857 }

int history_search ( const char *  str,
int  direction 
)

Definition at line 1097 of file readline.c.

References _history_search_gen().

Referenced by _history_expand_command().

01098 {
01099 
01100    return (_history_search_gen(str, direction, -1));
01101 }

int history_search_pos ( const char *  str,
int  direction,
int  pos 
)

Definition at line 1121 of file readline.c.

References H_CURR, H_NEXT, H_NEXT_EVENT, H_PREV, H_PREV_EVENT, history(), history_set_pos(), HistEvent::num, and HistEvent::str.

01122 {
01123    HistEvent ev;
01124    int curr_num, off;
01125 
01126    off = (pos > 0) ? pos : -pos;
01127    pos = (pos > 0) ? 1 : -1;
01128 
01129    if (history(h, &ev, H_CURR) != 0)
01130       return (-1);
01131    curr_num = ev.num;
01132 
01133    if (history_set_pos(off) != 0 || history(h, &ev, H_CURR) != 0)
01134       return (-1);
01135 
01136 
01137    for (;;) {
01138       if (strstr(ev.str, str))
01139          return (off);
01140       if (history(h, &ev, (pos < 0) ? H_PREV : H_NEXT) != 0)
01141          break;
01142    }
01143 
01144    /* set "current" pointer back to previous state */
01145    history(h, &ev, (pos < 0) ? H_NEXT_EVENT : H_PREV_EVENT, curr_num);
01146 
01147    return (-1);
01148 }

int history_search_prefix ( const char *  str,
int  direction 
)

Definition at line 1108 of file readline.c.

References _history_search_gen().

Referenced by _history_expand_command().

01109 {
01110 
01111    return (_history_search_gen(str, direction, 0));
01112 }

int history_set_pos ( int  pos  ) 

Definition at line 1019 of file readline.c.

References H_CURR, H_FIRST, H_NEXT, H_NEXT_EVENT, history(), history_length, and HistEvent::num.

Referenced by history_search_pos().

01020 {
01021    HistEvent ev;
01022    int off, curr_num;
01023 
01024    if (pos > history_length || pos < 0)
01025       return (-1);
01026 
01027    history(h, &ev, H_CURR);
01028    curr_num = ev.num;
01029    history(h, &ev, H_FIRST);
01030    off = 0;
01031    while (off < pos && history(h, &ev, H_NEXT) == 0)
01032       off++;
01033 
01034    if (off != pos) { /* do a rollback in case of error */
01035       history(h, &ev, H_FIRST);
01036       history(h, &ev, H_NEXT_EVENT, curr_num);
01037       return (-1);
01038    }
01039    return (0);
01040 }

char** history_tokenize ( const char *  str  ) 

Definition at line 779 of file readline.c.

References len(), malloc, NULL, realloc, and result.

Referenced by _history_expand_command().

00780 {
00781    int size = 1, result_idx = 0, i, start;
00782    size_t len;
00783    char **result = NULL, *temp, delim = '\0';
00784 
00785    for (i = 0; str[i]; i++) {
00786       while (isspace((unsigned char) str[i]))
00787          i++;
00788       start = i;
00789       for (; str[i]; i++) {
00790          if (str[i] == '\\') {
00791             if (str[i+1] != '\0')
00792                i++;
00793          } else if (str[i] == delim)
00794             delim = '\0';
00795          else if (!delim &&
00796                 (isspace((unsigned char) str[i]) ||
00797             strchr("()<>;&|$", str[i])))
00798             break;
00799          else if (!delim && strchr("'`\"", str[i]))
00800             delim = str[i];
00801       }
00802 
00803       if (result_idx + 2 >= size) {
00804          size <<= 1;
00805          result = realloc(result, size * sizeof(char *));
00806       }
00807       len = i - start;
00808       temp = malloc(len + 1);
00809       (void) strncpy(temp, &str[start], len);
00810       temp[len] = '\0';
00811       result[result_idx++] = temp;
00812       result[result_idx] = NULL;
00813    }
00814 
00815    return (result);
00816 }

int history_total_bytes ( void   ) 

Definition at line 993 of file readline.c.

References H_CURR, H_FIRST, H_NEXT, H_PREV_EVENT, history(), HistEvent::num, and HistEvent::str.

00994 {
00995    HistEvent ev;
00996    int curr_num, size;
00997 
00998    if (history(h, &ev, H_CURR) != 0)
00999       return (-1);
01000    curr_num = ev.num;
01001 
01002    history(h, &ev, H_FIRST);
01003    size = 0;
01004    do
01005       size += strlen(ev.str);
01006    while (history(h, &ev, H_NEXT) == 0);
01007 
01008    /* get to the same position as before */
01009    history(h, &ev, H_PREV_EVENT, curr_num);
01010 
01011    return (size);
01012 }

HIST_ENTRY* next_history ( void   ) 

Definition at line 1058 of file readline.c.

References _move_history(), and H_NEXT.

01059 {
01060 
01061    return (_move_history(H_NEXT));
01062 }

HIST_ENTRY* previous_history ( void   ) 

Definition at line 1047 of file readline.c.

References _move_history(), and H_PREV.

01048 {
01049 
01050    return (_move_history(H_PREV));
01051 }

int read_history ( const char *  filename  ) 

Definition at line 864 of file readline.c.

References H_LOAD, history(), NULL, and rl_initialize().

00865 {
00866    HistEvent ev;
00867 
00868    if (h == NULL || e == NULL)
00869       rl_initialize();
00870    return (history(h, &ev, H_LOAD, filename));
00871 }

char* readline ( const char *  prompt  ) 

Definition at line 275 of file readline.c.

References buf, el_gets(), el_rl_prompt, free, H_GETSIZE, history(), history_length, NULL, HistEvent::num, rl_initialize(), and strdup.

00276 {
00277    HistEvent ev;
00278    int count;
00279    const char *ret;
00280    char *buf;
00281 
00282    if (e == NULL || h == NULL)
00283       rl_initialize();
00284 
00285    /* update prompt accordingly to what has been passed */
00286    if (!prompt)
00287       prompt = "";
00288    if (strcmp(el_rl_prompt, prompt) != 0) {
00289       free(el_rl_prompt);
00290       el_rl_prompt = strdup(prompt);
00291    }
00292    /* get one line from input stream */
00293    ret = el_gets(e, &count);
00294 
00295    if (ret && count > 0) {
00296       int lastidx;
00297 
00298       buf = strdup(ret);
00299       lastidx = count - 1;
00300       if (buf[lastidx] == '\n')
00301          buf[lastidx] = '\0';
00302    } else
00303       buf = NULL;
00304 
00305    history(h, &ev, H_GETSIZE);
00306    history_length = ev.num;
00307 
00308    return buf;
00309 }

int rl_bind_key ( int  c,
int   funcint, int 
)

Definition at line 1610 of file readline.c.

References editline::el_map, func, el_map_t::key, NULL, retval, rl_initialize(), and rl_insert().

01611 {
01612    int retval = -1;
01613 
01614    if (h == NULL || e == NULL)
01615       rl_initialize();
01616 
01617    if (func == rl_insert) {
01618       /* XXX notice there is no range checking of ``c'' */
01619       e->el_map.key[c] = ED_INSERT;
01620       retval = 0;
01621    }
01622    return (retval);
01623 }

int rl_complete ( int  ignore,
int  invoking_key 
)

Definition at line 1585 of file readline.c.

References _rl_complete_show_all, CC_REFRESH, el_rl_complete_cmdnum, editline::el_state, el_state_t::lastcmd, NULL, rl_complete_internal(), rl_inhibit_completion, rl_initialize(), rl_insert(), and TAB.

Referenced by _el_rl_complete().

01586 {
01587    if (h == NULL || e == NULL)
01588       rl_initialize();
01589 
01590    if (rl_inhibit_completion) {
01591       rl_insert(ignore, invoking_key);
01592       return (CC_REFRESH);
01593    } else if (e->el_state.lastcmd == el_rl_complete_cmdnum)
01594       return rl_complete_internal('?');
01595    else if (_rl_complete_show_all)
01596       return rl_complete_internal('!');
01597    else
01598       return (rl_complete_internal(TAB));
01599 }

static int rl_complete_internal ( int  what_to_do  )  [static]

Definition at line 1446 of file readline.c.

References buf, lineinfo::buffer, CC_NORM, CC_REDISPLAY, CC_REFRESH, completion_matches(), lineinfo::cursor, el_beep(), el_deletestr(), el_insertstr(), el_line(), editline::el_outfile, end, filename_completion_function(), free, lineinfo::lastchar, len(), NULL, retval, rl_attempted_completion_function, rl_basic_word_break_characters, rl_completion_append_character, rl_completion_entry_function, rl_completion_query_items, rl_completion_type, rl_display_match_list(), rl_end, rl_initialize(), rl_point, and rl_special_prefixes.

Referenced by rl_complete().

01447 {
01448    CPFunction *complet_func;
01449    const LineInfo *li;
01450    char *temp, **matches;
01451    const char *ctemp;
01452    size_t len;
01453 
01454    rl_completion_type = what_to_do;
01455 
01456    if (h == NULL || e == NULL)
01457       rl_initialize();
01458 
01459    complet_func = rl_completion_entry_function;
01460    if (!complet_func)
01461       complet_func = filename_completion_function;
01462 
01463    /* We now look backwards for the start of a filename/variable word */
01464    li = el_line(e);
01465    ctemp = (const char *) li->cursor;
01466    while (ctemp > li->buffer
01467        && !strchr(rl_basic_word_break_characters, ctemp[-1])
01468        && (!rl_special_prefixes
01469          || !strchr(rl_special_prefixes, ctemp[-1]) ) )
01470       ctemp--;
01471 
01472    len = li->cursor - ctemp;
01473    temp = alloca(len + 1);
01474    (void) strncpy(temp, ctemp, len);
01475    temp[len] = '\0';
01476 
01477    /* these can be used by function called in completion_matches() */
01478    /* or (*rl_attempted_completion_function)() */
01479    rl_point = li->cursor - li->buffer;
01480    rl_end = li->lastchar - li->buffer;
01481 
01482    if (!rl_attempted_completion_function)
01483       matches = completion_matches(temp, complet_func);
01484    else {
01485       int end = li->cursor - li->buffer;
01486       matches = (*rl_attempted_completion_function) (temp, (int)
01487           (end - len), end);
01488    }
01489 
01490    if (matches) {
01491       int i, retval = CC_REFRESH;
01492       int matches_num, maxlen, match_len, match_display=1;
01493 
01494       /*
01495        * Only replace the completed string with common part of
01496        * possible matches if there is possible completion.
01497        */
01498       if (matches[0][0] != '\0') {
01499          el_deletestr(e, (int) len);
01500          el_insertstr(e, matches[0]);
01501       }
01502 
01503       if (what_to_do == '?')
01504          goto display_matches;
01505 
01506       if (matches[2] == NULL && strcmp(matches[0], matches[1]) == 0) {
01507          /*
01508           * We found exact match. Add a space after
01509           * it, unless we do filename completition and the
01510           * object is a directory.
01511           */
01512          size_t alen = strlen(matches[0]);
01513          if ((complet_func != filename_completion_function
01514                || (alen > 0 && (matches[0])[alen - 1] != '/'))
01515              && rl_completion_append_character) {
01516             char buf[2];
01517             buf[0] = rl_completion_append_character;
01518             buf[1] = '\0';
01519             el_insertstr(e, buf);
01520          }
01521       } else if (what_to_do == '!') {
01522     display_matches:
01523          /*
01524           * More than one match and requested to list possible
01525           * matches.
01526           */
01527 
01528          for(i=1, maxlen=0; matches[i]; i++) {
01529             match_len = strlen(matches[i]);
01530             if (match_len > maxlen)
01531                maxlen = match_len;
01532          }
01533          matches_num = i - 1;
01534             
01535          /* newline to get on next line from command line */
01536          fprintf(e->el_outfile, "\n");
01537 
01538          /*
01539           * If there are too many items, ask user for display
01540           * confirmation.
01541           */
01542          if (matches_num > rl_completion_query_items) {
01543             fprintf(e->el_outfile,
01544             "Display all %d possibilities? (y or n) ",
01545                matches_num);
01546             fflush(e->el_outfile);
01547             if (getc(stdin) != 'y')
01548                match_display = 0;
01549             fprintf(e->el_outfile, "\n");
01550          }
01551 
01552          if (match_display)
01553             rl_display_match_list(matches, matches_num,
01554                maxlen);
01555          retval = CC_REDISPLAY;
01556       } else if (matches[0][0]) {
01557          /*
01558           * There was some common match, but the name was
01559           * not complete enough. Next tab will print possible
01560           * completions.
01561           */
01562          el_beep(e);
01563       } else {
01564          /* lcd is not a valid object - further specification */
01565          /* is needed */
01566          el_beep(e);
01567          retval = CC_NORM;
01568       }
01569 
01570       /* free elements of array and the array itself */
01571       for (i = 0; matches[i]; i++)
01572          free(matches[i]);
01573       free(matches), matches = NULL;
01574 
01575       return (retval);
01576    }
01577    return (CC_NORM);
01578 }

void rl_display_match_list ( char **  matches,
int  len,
int  max 
)

Definition at line 1402 of file readline.c.

References _rl_qsort_string_compare(), editline::el_outfile, editline::el_term, coord_t::h, and el_term_t::t_size.

Referenced by rl_complete_internal().

01405 {
01406    int i, idx, limit, count;
01407    int screenwidth = e->el_term.t_size.h;
01408 
01409    /*
01410     * Find out how many entries can be put on one line, count
01411     * with two spaces between strings.
01412     */
01413    limit = screenwidth / (max + 2);
01414    if (limit == 0)
01415       limit = 1;
01416 
01417    /* how many lines of output */
01418    count = len / limit;
01419    if (count * limit < len)
01420       count++;
01421 
01422    /* Sort the items if they are not already sorted. */
01423    qsort(&matches[1], (size_t)(len - 1), sizeof(char *),
01424        _rl_qsort_string_compare);
01425 
01426    idx = 1;
01427    for(; count > 0; count--) {
01428       for(i=0; i < limit && matches[idx]; i++, idx++)
01429          fprintf(e->el_outfile, "%-*s  ", max, matches[idx]);
01430       fprintf(e->el_outfile, "\n");
01431    }
01432 }

int rl_initialize ( void   ) 

Definition at line 187 of file readline.c.

References _el_rl_complete(), _get_prompt(), lineinfo::buffer, ECHO, EL_ADDFN, EL_BIND, EL_EDITMODE, EL_EDITOR, el_end(), EL_HIST, el_init(), el_line(), editline::el_map, EL_PROMPT, el_rl_complete_cmdnum, el_rl_prompt, el_set(), EL_SIGNAL, el_source(), el_map_t::func, H_SETSIZE, history(), history_end(), history_init(), history_length, max_input_history, el_map_t::nfunc, NULL, rl_end, rl_instream, rl_line_buffer, rl_outstream, rl_point, rl_readline_name, and strdup.

Referenced by add_history(), completion_matches(), history_expand(), history_get(), read_history(), readline(), rl_bind_key(), rl_complete(), rl_complete_internal(), rl_insert(), rl_read_key(), rl_reset_terminal(), stifle_history(), using_history(), and write_history().

00188 {
00189    HistEvent ev;
00190    const LineInfo *li;
00191    int i;
00192    int editmode = 1;
00193    struct termios t;
00194 
00195    if (e != NULL)
00196       el_end(e);
00197    if (h != NULL)
00198       history_end(h);
00199 
00200    if (!rl_instream)
00201       rl_instream = stdin;
00202    if (!rl_outstream)
00203       rl_outstream = stdout;
00204 
00205    /*
00206     * See if we don't really want to run the editor
00207     */
00208    if (tcgetattr(fileno(rl_instream), &t) != -1 && (t.c_lflag & ECHO) == 0)
00209       editmode = 0;
00210 
00211    e = el_init(rl_readline_name, rl_instream, rl_outstream, stderr);
00212 
00213    if (!editmode)
00214       el_set(e, EL_EDITMODE, 0);
00215 
00216    h = history_init();
00217    if (!e || !h)
00218       return (-1);
00219 
00220    history(h, &ev, H_SETSIZE, INT_MAX);   /* unlimited */
00221    history_length = 0;
00222    max_input_history = INT_MAX;
00223    el_set(e, EL_HIST, history, h);
00224 
00225    /* for proper prompt printing in readline() */
00226    el_rl_prompt = strdup("");
00227    el_set(e, EL_PROMPT, _get_prompt);
00228    el_set(e, EL_SIGNAL, 1);
00229 
00230    /* set default mode to "emacs"-style and read setting afterwards */
00231    /* so this can be overriden */
00232    el_set(e, EL_EDITOR, "emacs");
00233 
00234    /*
00235     * Word completition - this has to go AFTER rebinding keys
00236     * to emacs-style.
00237     */
00238    el_set(e, EL_ADDFN, "rl_complete",
00239        "ReadLine compatible completition function",
00240        _el_rl_complete);
00241    el_set(e, EL_BIND, "^I", "rl_complete", NULL);
00242 
00243    /*
00244     * Find out where the rl_complete function was added; this is
00245     * used later to detect that lastcmd was also rl_complete.
00246     */
00247    for(i=EL_NUM_FCNS; i < e->el_map.nfunc; i++) {
00248       if (e->el_map.func[i] == _el_rl_complete) {
00249          el_rl_complete_cmdnum = i;
00250          break;
00251       }
00252    }
00253       
00254    /* read settings from configuration file */
00255    el_source(e, NULL);
00256 
00257    /*
00258     * Unfortunately, some applications really do use rl_point
00259     * and rl_line_buffer directly.
00260     */
00261    li = el_line(e);
00262    /* a cheesy way to get rid of const cast. */
00263    rl_line_buffer = memchr(li->buffer, *li->buffer, 1);
00264    rl_point = rl_end = 0;
00265 
00266    return (0);
00267 }

int rl_insert ( int  count,
int  c 
)

Definition at line 1660 of file readline.c.

References el_push(), NULL, and rl_initialize().

Referenced by rl_bind_key(), and rl_complete().

01661 {
01662    char arr[2];
01663 
01664    if (h == NULL || e == NULL)
01665       rl_initialize();
01666 
01667    /* XXX - int -> char conversion can lose on multichars */
01668    arr[0] = c;
01669    arr[1] = '\0';
01670 
01671    for (; count > 0; count--)
01672       el_push(e, arr);
01673 
01674    return (0);
01675 }

int rl_read_key ( void   ) 

Definition at line 1631 of file readline.c.

References el_getc(), NULL, and rl_initialize().

01632 {
01633    char fooarr[2 * sizeof(int)];
01634 
01635    if (e == NULL || h == NULL)
01636       rl_initialize();
01637 
01638    return (el_getc(e, fooarr));
01639 }

void rl_reset_terminal ( const char *  p  ) 

Definition at line 1647 of file readline.c.

References el_reset(), NULL, and rl_initialize().

01648 {
01649 
01650    if (h == NULL || e == NULL)
01651       rl_initialize();
01652    el_reset(e);
01653 }

void stifle_history ( int  max  ) 

Definition at line 823 of file readline.c.

References H_SETSIZE, history(), max_input_history, NULL, and rl_initialize().

00824 {
00825    HistEvent ev;
00826 
00827    if (h == NULL || e == NULL)
00828       rl_initialize();
00829 
00830    if (history(h, &ev, H_SETSIZE, max) == 0)
00831       max_input_history = max;
00832 }

char* tilde_expand ( char *  txt  ) 

Definition at line 1162 of file readline.c.

References free, len(), malloc, NULL, pass, and strdup.

Referenced by filename_completion_function().

01163 {
01164    struct passwd *pass;
01165    char *temp;
01166    size_t len = 0;
01167 
01168    if (txt[0] != '~')
01169       return (strdup(txt));
01170 
01171    temp = strchr(txt + 1, '/');
01172    if (temp == NULL)
01173       temp = strdup(txt + 1);
01174    else {
01175       len = temp - txt + 1;   /* text until string after slash */
01176       temp = malloc(len);
01177       (void) strncpy(temp, txt + 1, len - 2);
01178       temp[len - 2] = '\0';
01179    }
01180    pass = getpwnam(temp);
01181    free(temp);    /* value no more needed */
01182    if (pass == NULL)
01183       return (strdup(txt));
01184 
01185    /* update pointer txt to point at string immedially following */
01186    /* first slash */
01187    txt += len;
01188 
01189    temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);
01190    (void) sprintf(temp, "%s/%s", pass->pw_dir, txt);
01191 
01192    return (temp);
01193 }

int unstifle_history ( void   ) 

Definition at line 839 of file readline.c.

References H_SETSIZE, history(), and max_input_history.

00840 {
00841    HistEvent ev;
00842    int omax;
00843 
00844    history(h, &ev, H_SETSIZE, INT_MAX);
00845    omax = max_input_history;
00846    max_input_history = INT_MAX;
00847    return (omax);    /* some value _must_ be returned */
00848 }

char* username_completion_function ( const char *  text,
int  state 
)

Definition at line 1294 of file readline.c.

References NULL, and strdup.

01295 {
01296    struct passwd *pwd;
01297 
01298    if (text[0] == '\0')
01299       return (NULL);
01300 
01301    if (*text == '~')
01302       text++;
01303 
01304    if (state == 0)
01305       setpwent();
01306 
01307    while ((pwd = getpwent()) && text[0] == pwd->pw_name[0]
01308        && strcmp(text, pwd->pw_name) == 0);
01309 
01310    if (pwd == NULL) {
01311       endpwent();
01312       return (NULL);
01313    }
01314    return (strdup(pwd->pw_name));
01315 }

void using_history ( void   ) 

Definition at line 320 of file readline.c.

References NULL, and rl_initialize().

00321 {
00322    if (h == NULL || e == NULL)
00323       rl_initialize();
00324 }

int where_history ( void   ) 

Definition at line 960 of file readline.c.

References H_CURR, H_FIRST, H_NEXT, history(), and HistEvent::num.

00961 {
00962    HistEvent ev;
00963    int curr_num, off;
00964 
00965    if (history(h, &ev, H_CURR) != 0)
00966       return (0);
00967    curr_num = ev.num;
00968 
00969    history(h, &ev, H_FIRST);
00970    off = 1;
00971    while (ev.num != curr_num && history(h, &ev, H_NEXT) == 0)
00972       off++;
00973 
00974    return (off);
00975 }

int write_history ( const char *  filename  ) 

Definition at line 878 of file readline.c.

References H_SAVE, history(), NULL, and rl_initialize().

00879 {
00880    HistEvent ev;
00881 
00882    if (h == NULL || e == NULL)
00883       rl_initialize();
00884    return (history(h, &ev, H_SAVE, filename));
00885 }


Variable Documentation

int _rl_complete_show_all = 0 [static]

Definition at line 129 of file readline.c.

Referenced by rl_complete().

char break_chars[] [static]

Initial value:

 { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', '$',
    '>', '<', '=', ';', '|', '&', '{', '(', '\0' }

Definition at line 75 of file readline.c.

EditLine* e = NULL [static]

int el_rl_complete_cmdnum = 0 [static]

Definition at line 133 of file readline.c.

Referenced by rl_complete(), and rl_initialize().

char* el_rl_prompt = NULL [static]

Definition at line 149 of file readline.c.

Referenced by _get_prompt(), readline(), and rl_initialize().

char empty[] = { '\0' } [static]

Definition at line 73 of file readline.c.

Referenced by __container_unlink_node_debug(), conf_exec(), and socket_process_helper().

char expand_chars[] = { ' ', '\t', '\n', '=', '(', '\0' } [static]

Definition at line 74 of file readline.c.

History* h = NULL [static]

int history_base = 1

Definition at line 84 of file readline.c.

Definition at line 87 of file readline.c.

Referenced by _history_expand_command(), and history_expand().

Definition at line 90 of file readline.c.

Referenced by history_expand().

int history_length = 0

Definition at line 89 of file readline.c.

Referenced by history_expand().

char history_subst_char = '^'

Definition at line 88 of file readline.c.

Referenced by history_expand().

Definition at line 86 of file readline.c.

Referenced by history_is_stifled(), rl_initialize(), stifle_history(), and unstifle_history().

Definition at line 98 of file readline.c.

Referenced by rl_complete_internal().

Definition at line 93 of file readline.c.

Definition at line 94 of file readline.c.

Referenced by rl_complete_internal().

Definition at line 96 of file readline.c.

Definition at line 95 of file readline.c.

Definition at line 124 of file readline.c.

Referenced by rl_complete_internal().

Definition at line 97 of file readline.c.

Referenced by rl_complete_internal().

Definition at line 111 of file readline.c.

Referenced by rl_complete_internal().

Definition at line 105 of file readline.c.

Referenced by rl_complete_internal().

int rl_end = 0

Definition at line 81 of file readline.c.

Referenced by rl_complete_internal(), and rl_initialize().

Definition at line 92 of file readline.c.

Referenced by rl_complete().

FILE* rl_instream = NULL

Definition at line 78 of file readline.c.

Referenced by rl_initialize().

const char* rl_library_version = "EditLine wrapper"

Definition at line 72 of file readline.c.

char* rl_line_buffer = NULL

Definition at line 82 of file readline.c.

Referenced by rl_initialize().

FILE* rl_outstream = NULL

Definition at line 79 of file readline.c.

Referenced by _history_expand_command(), and rl_initialize().

int rl_point = 0

Definition at line 80 of file readline.c.

Referenced by rl_complete_internal(), and rl_initialize().

Definition at line 77 of file readline.c.

Referenced by rl_initialize().

char* rl_special_prefixes = (char *)NULL

Definition at line 118 of file readline.c.

Referenced by rl_complete_internal().


Generated on Thu Apr 16 06:32:32 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6