Example #1
0
void uma_dbg_read_prompt(int socketId, char * pr) {
  char *c = pr;
  char *pt = msg.buffer; 
    
  // Read the prompt
  if (debug_run_this_cmd(socketId, "who", SILENT) < 0)  return;
  
  // skip 1rst line
  while ((*pt != 0)&&(*pt != '\n')) pt++;
  
  if (*pt != 0) {

    pt++;
  
    if (strncmp(pt,SYSTEM_HEADER, strlen(SYSTEM_HEADER)) == 0) {

      pt += strlen(SYSTEM_HEADER);

      while((*pt != '\n')&&(*pt != 0)) {
	*c = *pt;
	c++;
	pt++;
      }
    }
  }  
  *c++ = '>';
  *c++ = ' ';     
  *c = 0;
}
Example #2
0
void uma_dbg_read_all_cmd_list(int socketId) {
  char * p, * begin;
  int len;
    
  // Read the command list
  if (debug_run_this_cmd(socketId, "", SILENT) < 0)  return;

  nbCmd = 0;
  p = msg.buffer;
    
  if (strncmp(p,LIST_COMMAND_HEADER, strlen(LIST_COMMAND_HEADER)) != 0) return;  
  while(*p != '\n') p++;    
  p++;
    
  while (p) {
  
    // Skip ' '
    while (*p == ' ') p++;  
    
    // Is it the end
    if (strncmp(p,"exit", 4) == 0) break;
    
    // Read command in list
    begin = p;
    len = 0;
    while(*p != '\n') {
      len++;  
      p++;
    }
    add_cmd_in_list(begin, len);
    p++;
  }
}
Example #3
0
void debug_run_command_list(int socketId) {
  int idx;  

  for (idx=0; idx < nbCmd; idx++) {
//    printf("_________________________________________________________\n");
//    printf("< %s >\n", cmd[idx]);  
    if (debug_run_this_cmd(socketId, cmd[idx], NOT_SILENT) < 0)  break;
  }
} 
Example #4
0
void uma_dbg_read_prompt(int socketId, char * pr) {
  int i=strlen(SYSTEM_HEADER);
  char *c = pr;
    
  // Read the prompt
  if (debug_run_this_cmd(socketId, "who", SILENT) < 0)  return;
  
  if (strncmp(msg.buffer,SYSTEM_HEADER, strlen(SYSTEM_HEADER)) == 0) {

    while(msg.buffer[i] != '\n') {
      *c = msg.buffer[i];
      c++;
      i++;
    }
    *c++ = '>';
    *c++ = ' ';     
    *c = 0;
  }
  else {
    strcpy(pr,"rzdbg> ");
  }
}
Example #5
0
void debug_interactive_loop(int socketId) {
//  char mycmd[1024]; 
  char *mycmd = NULL; 
//  int len;
//  int fd;
  
//  fd = open("/dev/stdin", O_RDONLY);
  using_history();
  rl_bind_key('\t',rl_complete);   
  while (1) {

    printf("_________________________________________________________\n");
//    len = readln (fd, mycmd,sizeof(mycmd));
//    if (len == (uint32_t)-1) break;
    mycmd = readline (prompt);
    if (mycmd == NULL) break;
    if (strcasecmp(mycmd,"exit") == 0) {
      printf("Diagnostic session end\n");
      break;
    }
    if (strcasecmp(mycmd,"q") == 0) {
      printf("Diagnostic session end\n");
      break;
    }
    if (strcasecmp(mycmd,"quit") == 0) {
      printf("Diagnostic session end\n");
      break;
    }
    if ((mycmd[0] != 0) && (strcasecmp(mycmd,"!!") != 0)) {
       add_history(mycmd);
    }
    if (debug_run_this_cmd(socketId, mycmd, NOT_SILENT) < 0)  break;
    free(mycmd);
  }
  if (mycmd != NULL) free(mycmd);
//  close(fd);  
}