Go backward to Managing the History File.
Go up to History Functions.

History Expansion
-----------------

   These functions implement `csh'-like history expansion.

 - Function: int history_expand (char *string, char **output)
     Expand STRING, placing the result into OUTPUT, a pointer to a
     string (see History Interaction.).  Returns:
    `0'
          If no expansions took place (or, if the only change in the
          text was the de-slashifying of the history expansion
          character);

    `1'
          if expansions did take place;

    `-1'
          if there was an error in expansion;

    `2'
          if the returned line should only be displayed, but not
          executed, as with the `:p' modifier (see Modifiers.).

     If an error ocurred in expansion, then OUTPUT contains a
     descriptive error message.

 - Function: char * history_arg_extract (int first, int last, char
          *string)
     Extract a string segment consisting of the FIRST through LAST
     arguments present in STRING.  Arguments are broken up as in Bash.

 - Function: char * get_history_event (char *string, int *cindex, int
          qchar)
     Returns the text of the history event beginning at STRING +
     *CINDEX.  *CINDEX is modified to point to after the event
     specifier.  At function entry, CINDEX points to the index into
     STRING where the history event specification begins.  QCHAR is a
     character that is allowed to end the event specification in
     addition to the "normal" terminating characters.

 - Function: char ** history_tokenize (char *string)
     Return an array of tokens parsed out of STRING, much as the shell
     might.  The tokens are split on white space and on the characters
     `()<>;&|$', and shell quoting conventions are obeyed.