Example #1
0
/****************************************************************************
  process commands from the client
****************************************************************************/
static void do_command(struct client_info *info, char *tok, char *line)
{
	int i;

	if ((i = process_tok(tok)) >= 0)
	{
		commands[i].fn(info);
	}
	else if (i == -2)
	{
		fprintf(out_hnd, "%s: command abbreviation ambiguous\n", CNV_LANG(tok));
	}
	else
	{
		fprintf(out_hnd, "%s: command not found\n", CNV_LANG(tok));
	}
}
Example #2
0
/****************************************************************************
  process commands from the client
****************************************************************************/
static BOOL process(char *base_directory)
{
  extern FILE *dbf;
  pstring line;
  char *cmd;

  char *InBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
  char *OutBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);

  if ((InBuffer == NULL) || (OutBuffer == NULL)) 
    return(False);
  
  bzero(OutBuffer,smb_size);

  if (!mount_send_login(InBuffer,OutBuffer))
    return(False);

  cmd = cmdstr;
  if (cmd[0] != '\0') while (cmd[0] != '\0')
    {
      char *p;
      fstring tok;
      int i;

      if ((p = strchr(cmd, ';')) == 0)
	{
	  strncpy(line, cmd, 999);
	  line[1000] = '\0';
	  cmd += strlen(cmd);
	}
      else
	{
	  if (p - cmd > 999) p = cmd + 999;
	  strncpy(line, cmd, p - cmd);
	  line[p - cmd] = '\0';
	  cmd = p + 1;
	}

      /* input language code to internal one */
      CNV_INPUT (line);
      
      /* and get the first part of the command */
      {
	char *ptr = line;
	if (!next_token(&ptr,tok,NULL)) continue;
      }

      if ((i = process_tok(tok)) >= 0)
	commands[i].fn(InBuffer,OutBuffer);
      else if (i == -2)
	DEBUG(0,("%s: command abbreviation ambiguous\n",CNV_LANG(tok)));
      else
	DEBUG(0,("%s: command not found\n",CNV_LANG(tok)));
    }
  else while (!feof(stdin))
    {
      fstring tok;
      int i;

      bzero(OutBuffer,smb_size);

      /* display a prompt */
      DEBUG(0,("smb: %s> ", CNV_LANG(cur_dir)));
      fflush(dbf);

#ifdef CLIX
      line[0] = wait_keyboard(InBuffer);
      /* this might not be such a good idea... */
      if ( line[0] == EOF)
	break;
#else
      wait_keyboard(InBuffer);
#endif
  
      /* and get a response */
#ifdef CLIX
      fgets( &line[1],999, stdin);
#else
      if (!fgets(line,1000,stdin))
	break;
#endif

      /* input language code to internal one */
      CNV_INPUT (line);

      /* special case - first char is ! */
      if (*line == '!')
	{
	  system(line + 1);
	  continue;
	}
      
      /* and get the first part of the command */
      {
	char *ptr = line;
	if (!next_token(&ptr,tok,NULL)) continue;
      }

      if ((i = process_tok(tok)) >= 0)
	commands[i].fn(InBuffer,OutBuffer);
      else if (i == -2)
	DEBUG(0,("%s: command abbreviation ambiguous\n",CNV_LANG(tok)));
      else
	DEBUG(0,("%s: command not found\n",CNV_LANG(tok)));
    }
  
  cli_send_logout(InBuffer,OutBuffer);
  return(True);
}
Example #3
0
/****************************************************************************
  process commands from the client
****************************************************************************/
static BOOL process( struct client_info *info, char *cmd_str)
{
	pstring line;
	char *cmd = cmd_str;

	if (cmd[0] != '\0') while (cmd[0] != '\0')
	{
		char *p;
		fstring tok;

		if ((p = strchr(cmd, ';')) == 0)
		{
			strncpy(line, cmd, 999);
			line[1000] = '\0';
			cmd += strlen(cmd);
		}
		else
		{
			if (p - cmd > 999) p = cmd + 999;
			strncpy(line, cmd, p - cmd);
			line[p - cmd] = '\0';
			cmd = p + 1;
		}

		/* input language code to internal one */
		CNV_INPUT (line);

		/* get the first part of the command */
		{
			char *ptr = line;
			if (!next_token(&ptr,tok,NULL, sizeof(tok))) continue;
		}

		do_command(info, tok, line);
	}
	else while (!feof(stdin))
	{
		fstring tok;

		/* display a prompt */
		fprintf(out_hnd, "smb: %s> ", CNV_LANG(info->cur_dir));
		fflush(out_hnd);

#ifdef CLIX
		line[0] = wait_keyboard(smb_cli);
		/* this might not be such a good idea... */
		if ( line[0] == EOF)
		{
			break;
		}
#else
		wait_keyboard(smb_cli);
#endif

		/* and get a response */
#ifdef CLIX
		fgets( &line[1],999, stdin);
#else
		if (!fgets(line,1000,stdin))
		{
			break;
		}
#endif

		/* input language code to internal one */
		CNV_INPUT (line);

		/* special case - first char is ! */
		if (*line == '!')
		{
			system(line + 1);
			continue;
		}

		fprintf(out_hnd, "%s\n", line);

		/* get the first part of the command */
		{
			char *ptr = line;
			if (!next_token(&ptr,tok,NULL, sizeof(tok))) continue;
		}

		do_command(info, tok, line);
	}

	return(True);
}