readline.c File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char *command_generator __P ((const char *, int))
char * command_generator (char *text, int state) const
char * dupstr (int s)
char ** fileman_completion (char *text, int start, int end) const
void initialize_readline ()


Function Documentation

char* command_generator __P ( (const char *, int)   ) 

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

Definition at line 48 of file readline.c.

References dupstr(), mycmd_head, mycmd.name, and mycmd.next.

Referenced by fileman_completion().

00051 {
00052   static int list_index, len;
00053   char *name;
00054  static struct mycmd *pcmd;
00055 
00056   /* If this is a new word to complete, initialize now.  This
00057      includes saving the length of TEXT for efficiency, and
00058      initializing the index variable to 0. */
00059   if (!state)
00060     {
00061           pcmd = mycmd_head;
00062       len = strlen (text);
00063     }
00064 
00065   /* Return the next name which partially matches from the
00066      command list. */
00067 
00068 
00069 
00070   while (pcmd && (name = pcmd->name))
00071     {
00072           pcmd = pcmd->next;
00073 
00074       if (strncmp (name, text, len) == 0)
00075         return (dupstr(name));
00076     }
00077 
00078   /* If no names matched, then return NULL. */
00079   return ((char *)NULL);
00080 
00081 }

Here is the call graph for this function:

char* dupstr ( int  s  ) 

Definition at line 3 of file readline.c.

Referenced by command_generator(), config_generator(), and flash_complete().

00005 {
00006   char *r;
00007 
00008   r = xmalloc (strlen (s) + 1);
00009   strcpy (r, s);
00010   return (r);
00011 }

char** fileman_completion ( char *  text,
int  start,
int  end 
) const

Definition at line 15 of file readline.c.

References argvize(), command_generator(), mycmd.complete, mycmd_head, mycmd.name, and mycmd.next.

Referenced by initialize_readline().

00018 {
00019   char **matches;
00020 
00021   matches = (char **)NULL;
00022 
00023   /* If this word is at the start of the line, then it is a command
00024      to complete.  Otherwise it is the name of a file in the current
00025      directory. */
00026   if (start == 0)
00027     matches = rl_completion_matches (text, command_generator);
00028   else {
00029         struct mycmd *pcmd;
00030         char *av[20];
00031         int argc;
00032         static char buf[256];
00033         strncpy(buf,rl_line_buffer,256);
00034         argc = argvize(av,buf);
00035         if(start != end) argc--;
00036 
00037         for(pcmd = mycmd_head;pcmd && strcmp(pcmd->name,av[0]);pcmd = pcmd->next);
00038         if(pcmd && pcmd->complete)
00039          matches = pcmd->complete(argc,av,text,start,end);
00040   }
00041 
00042   return (matches);
00043 }

Here is the call graph for this function:

void initialize_readline (  ) 

Definition at line 83 of file readline.c.

References fileman_completion().

Referenced by main().

00084 {
00085   /* Allow conditional parsing of the ~/.inputrc file. */
00086         rl_readline_name = "FileMan";
00087   /* Tell the completer that we want a crack first. */
00088     rl_attempted_completion_function = fileman_completion;
00089 }

Here is the call graph for this function:


Generated on Fri Nov 5 07:24:51 2010 for ejtag debug tools for loongson 232 cpu by  doxygen 1.5.6