[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bluetooth-dev] Could Readline be an option ?



david LIBAULT wrote:
> 
> Do you see any problem if the use of the readline library is an option in btd
> ?
> 
> I don't want to bother installing it on my (embedded) system, and I usually
> place a simple readline function beetween comments...
> 
> I propose to commit it in the CVS and keep the stack using readline by
> default.
> 
> Any remarks ?
> 
> David.
> -
> To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
> the body of a message to majordomo@xxxxxxx.com


hi david
try this:


-------- morning ---------

//#define USE_READLINE  

#ifndef USE_READLINE
#define MAXLINE 100
static char line[MAXLINE];

int getline(char s[], int lim) {
  int c,i;
  for (i=0;i<lim-1 && (c=getchar())!=EOF && c!='\n';++i)
    s[i]=c;
  if (c == '\n') {
    s[i] = c;
    ++i;
  }
  s[i] = '\0';
  return i;
}

void read_history(char *hist_file_name){}

void write_history(char *hist_file_name){}

void add_history(char *command){}

char *readline(char *prompt)
{
  printf("%s",prompt);
  fflush(stdout);
  getline(line,MAXLINE);
  return line;
}

#endif

--------- evening ---------
-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com