• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parse_cmd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parse_cmd函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_cmd函数的具体用法?C++ parse_cmd怎么用?C++ parse_cmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse_cmd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: parsing

int	parsing(char *str, t_shenv *shenv, int n)
{
  char	**cmd;
  int	ret;
  int	i;

  i = -1;
  if (!(init_parsing(&str, shenv, &ret, &cmd)))
    return (EXIT_SUCCESS);
  while (cmd && cmd[++i])
    {
      if (!strncmp(cmd[i], ";", 1) && cmd[i + 1]
	  && strncmp(cmd[i + 1], ";", 1))
	ret = parse_cmd(cmd[++i], shenv, n);
      if (!strncmp(cmd[i], "&&", 2) && cmd[i + 1]
	  && strncmp(cmd[i + 1], "&&", 2))
	(!ret) ? (ret = parse_cmd(cmd[++i], shenv, n)) : ++i;
      if (!strncmp(cmd[i], "||", 2) && cmd[i + 1]
	  && strncmp(cmd[i + 1], "||", 2))
	(ret == EXIT_FAILURE) ? (ret = parse_cmd(cmd[++i], shenv, n)) : ++i;
      if (ret == -1)
	return (EXIT_FAILURE);
      n = 0;
    }
  my_free_tab(cmd);
  return (EXIT_SUCCESS);
}
开发者ID:kokaz,项目名称:42sh,代码行数:27,代码来源:parsing.c


示例2: main

   /* 
    * run the program
    */
int main()
{
      // holds the directories in the path
   char path_dirs[ MAX_PATHS ][ MAX_PATH_LEN ];
      
   int num_dirs = parse_path( path_dirs );
   
   char line[ LINE_LEN ];
   command_t cmd;

      // get input
   print_prompt();
   read_cmd( line );
   parse_cmd( line, &cmd );

      // until we get a line that starts with exit or quit
   while( !cmd.argv[0] || 
          ( strcmp( cmd.argv[0], "quit" ) && 
            strcmp( cmd.argv[0], "exit" ) ) )
   {
      if( cmd.argv[0] )
         cmd.name = lookup_path( cmd.argv, path_dirs, num_dirs );

      if( cmd.name && cmd.argc > 0 )
      {
            // create the child
         pid_t child_pid = fork();
         if( child_pid < 0 )
            perror( "fork" );
         else if( child_pid == 0 ) // child
            execv( cmd.name, cmd.argv );
         else  // parent
         {
            if( !cmd.concurrent )
            {
               int status;
               waitpid( child_pid, &status, 0 );
            }
         }
      }

      cleanup_cmd( &cmd );
         
         // get input
      print_prompt();
      read_cmd( line );
      parse_cmd( line, &cmd );
   }

   return 0;
}
开发者ID:clcto,项目名称:cs620-A4,代码行数:54,代码来源:toysh.c


示例3: main_thread

static int main_thread(SceSize args, void *argp)
{
	char cmdbuf[128];
	int cpos;
	int retv;

	cpos = 0;
	while(1){
		if(usbAsyncRead(ASYNC_STDOUT, (unsigned char*)&cmdbuf[cpos], 1)<1){
			sceKernelDelayThread(250000);
			continue;
		}
		if(cmdbuf[cpos]=='\n'){
			cmdbuf[cpos] = 0;
			retv = parse_cmd(cmdbuf);
			cpos = 0;
		}else{
			if(cpos<127)
				cpos++;
		}
	}

	sceKernelExitDeleteThread(0);
	return 0;
}
开发者ID:yin8086,项目名称:psplinkusb,代码行数:25,代码来源:main.c


示例4: mu_config_new

MuConfig*
mu_config_new (int *argcp, char ***argvp)
{
	MuConfig *config;

	g_return_val_if_fail (argcp && argvp, NULL);

	config = g_new0 (MuConfig, 1);

	if (!parse_cmd (config, argcp, argvp) ||
	    !parse_params(config, argcp, argvp)) {
		mu_config_destroy (config);
		return NULL;
	}

	/* fill in the defaults if user did not specify */
	set_group_mu_defaults (config);
	set_group_index_defaults (config);
	set_group_find_defaults (config);
	set_group_cfind_defaults (config);
	set_group_view_defaults (config);
	/* set_group_mkdir_defaults (config); */

	return config;
}
开发者ID:antono,项目名称:mu,代码行数:25,代码来源:mu-config.c


示例5: run_script

int run_script(FILE *script)
{
	int scripting = 1;
	int size;
	char **args, cmd[100];
	
	while (scripting && !feof(script)) {
		size = 0;
		redirect_in = 0;
	
		dup2(defin, STDIN_FILENO);
		dup2(defout, STDOUT_FILENO);

        /* get the input from user. */
        fgets(cmd, 100, script);
		
		args = parse_cmd(cmd, &size);
		
		if (pipeFlag) {
			scripting = run_pipe_cmd(size, args);
			pipeFlag = 0;
		} else {
			scripting = run_cmd(size, args);
		}
    }
	return cmd_exit_status;
}
开发者ID:luok,项目名称:XSSH,代码行数:27,代码来源:xssh.c


示例6: wait_for_input

int			wait_for_input(t_socket *socket)
{
  char			*in[2];
  t_buffs		buffs;
  fd_set		fs[2];
  char			*cmd;
  struct timeval	tv;

  if (!create_buffer(&buffs) || !(in[0] = malloc(4097)) ||
      !(in[1] = malloc(4097)) || !memset(in[0], 0, 4097) ||
      !memset(in[1], 0, 4097) || gethostname(in[1], 4096) == -1)
    return (-1);
  while (1)
    {
      tv.tv_sec = 1;
      tv.tv_usec = 0;
      set_fds(&fs[1], &fs[0], socket->fd, &buffs);
      if (select(socket->fd != -1 ? socket->fd + 1 : 1,
		 &fs[0], &fs[1], NULL, &tv) == -1)
	return (puterr_int(ERR_SELECT, -1));
      if (!(cmd = read_all(socket->fd, &fs[0], &buffs, in)) ||
	  write_all(&fs[1], &buffs, socket->fd) == -1 ||
	  (cmd && strcmp(cmd, "") && parse_cmd(cmd, socket,
					       &buffs, in[0]) == -1))
	return (free(in[0]), free(in[1]), -1);
    }
}
开发者ID:Nyrii,项目名称:-EPITECH-my_irc,代码行数:27,代码来源:client.c


示例7: manage_stdin

static void		manage_stdin(char **env, char **path, int count)
{
	int		i;
	char	*line;
	char	**cmd;

	cmd = NULL;
	line = NULL;
	while (1)
	{
		prompt(env, count);
		if (get_next_line(0, &line) > 0)
		{
			i = -1;
			cmd = ft_strsplit(line, ';');
			ft_strdel(&line);
			while (cmd[++i])
				env = parse_cmd(env, cmd, cmd[i], path);
			free(cmd);
			cmd = NULL;
			free_tab(path);
			ft_putchar('\n');
		}
		count++;
	}
	free_tab(env);
}
开发者ID:Flovln,项目名称:minishell,代码行数:27,代码来源:main.c


示例8: main

void main(void)
{
  UCHAR cmd[0x8000];
  BOOL exitflag;

  log_init();

  hello();

  log(greeting);
  log("DosLogWrite address: %x\n", DosLogWrite);

  exitflag=FALSE;
  // Ok. Here we just in endless loop. Except for EXIT command.

  // create the global env. array
  env_create();

  while (!exitflag)
  {
    showpath();
    read_cmd (cmd);
    exitflag = parse_cmd (cmd);
  }

  // destroy the global env. array
  env_destroy();

  exit(0);
}
开发者ID:ErisBlastar,项目名称:osfree,代码行数:30,代码来源:minicmd.c


示例9: prompt

void prompt() {
	char line[MAX_PROMPT_LINE];
	Command_Info* cmd_info = newCommand_Info(MAX_PROMPT_LINE);
	
	pid_t child = 0;
	int status = 0;

	while (1) {
		printf("msh$ ");	fflush(stdout);
		fgets(line, MAX_PROMPT_LINE, stdin);
		if (feof(stdin) || ferror(stdin))
			break;

		if (parse_cmd(line, cmd_info) != 0) {
			if (!cmd_empty(cmd_info))
				fprintf(stderr, "Syntax error!\n");
			continue;
		}
			
		if (strcmp(cmd_info->arg[0], "exit") == 0) // builtin command exit
			break;
			
		if ((child = exec_simple(cmd_info)) > 0) {
			waitpid(child, &status, 0);
			
			if (WIFEXITED(status) && WEXITSTATUS(status) == 1)
				fprintf(stderr, "Command Not Found!\n");
		}
	}

	deleteCommand_Info(cmd_info);
}
开发者ID:PChambino,项目名称:sope-t1,代码行数:32,代码来源:msh.c


示例10: main

int main(void)
{
	char *argv[MAX_ARGC];
	int i, argc;
	char buf[2040];

	printf("\n\rEnter the interative mode, please make your command as follow.\n\n\r");
	for(i = 0; i < sizeof(cmd_table) / sizeof(cmd_table[0]); i ++)
		printf("\n\r    %s", cmd_table[i].command);
	printf("\n\n\r");

	do{
		printf("Wlan: ");
		gets(buf);
		printf("The command entered is : %s\n\r", buf);

		strcpy(cmd_buf, buf);		
		if((argc = parse_cmd(buf, argv)) > 0) {
			int found = 0;

			for(i = 0; i < sizeof(cmd_table) / sizeof(cmd_table[0]); i ++) {
				if(strcmp((const char *)argv[0], (const char *)(cmd_table[i].command)) == 0) {
					cmd_table[i].function(argc, argv);
					found = 1;
					break;
				}
			}

			if(!found)
				printf("unknown command '%s'\n\r", argv[0]);
		}
	}while(global_exit);	
	return 0;
}
开发者ID:qiancuo,项目名称:Ameba_sdio_device,代码行数:34,代码来源:main.c


示例11: usbshell_task

static void
usbshell_task (void *pvParameters)
{
  static portCHAR buf[128], c, *p = buf;
  shell_print (PROMPT);

  for (;;)
    {
      if (!vUSBRecvByte (&c, sizeof (c), 100))
	continue;

      if (c == '\n' || c == '\r')
	{
	  *p = '\0';
	  parse_cmd (buf);

	  p = buf;
	  shell_print (PROMPT);
	  continue;
	}
      else if (c < ' ')
	continue;

      if (p == buf + sizeof (buf) - 1)
	{
	  p = buf;
	  *p = '\0';
	}

      /* local echo */
      vUSBSendByte (c);
      *p++ = c;
    }
}
开发者ID:KhMassri,项目名称:DTNWorkspace,代码行数:34,代码来源:usbshell.c


示例12: mu_config_init

MuConfig*
mu_config_init (int *argcp, char ***argvp, GError **err)
{
	g_return_val_if_fail (argcp && argvp, NULL);

	memset (&MU_CONFIG, 0, sizeof(MU_CONFIG));

	MU_CONFIG.maxnum = -1; /* By default, output all matching entries. */

	if (!parse_cmd (argcp, argvp, err))
		goto errexit;

	if (!parse_params(argcp, argvp, err))
		goto errexit;

	/* fill in the defaults if user did not specify */
	set_group_mu_defaults();
	set_group_index_defaults();
	set_group_find_defaults();
	set_group_cfind_defaults();
	set_group_view_defaults();
	set_group_extract_defaults();
	/* set_group_mkdir_defaults (config); */

	return &MU_CONFIG;

errexit:
	mu_config_uninit (&MU_CONFIG);
	return NULL;
}
开发者ID:abelardojarab,项目名称:emacsfull,代码行数:30,代码来源:mu-config.c


示例13: parse_pipe

static void parse_pipe(cmds* cmd, prog_args* prog)
{
	prog_args* elem = NULL;
	/* parse a command                                                   */
	parse_cmd(cmd, prog);
    /* not in pipe?                                                      */
	if (lookahead.kind!=STROKE)
	{
		return;
	}
	/* builtin and starting pipe?                                        */
	if( !(cmd->kind==PROG || cmd->kind==PIPE) )
	{
		raise_error(PARSER_ILLEGAL_COMBINATION);
	}
	/* in pipe                                                           */
	cmd->kind=PIPE;
	/* output redirection?                                               */
	if (prog->output != NULL)
	{
		raise_error(PARSER_ILLEGAL_REDIRECTION);
	}
	/* skip pipe symbol and parse next command                           */
	scan();
	elem = prog_new();
	prog->next=elem;
	parse_pipe(cmd,elem);
}
开发者ID:aruscher,项目名称:OS-Projekt-2,代码行数:28,代码来源:parser.c


示例14: main

int main(int argc, char* argv[])
{
	char* cmd = NULL;
	MEM_POOL* mem_pool = mem_pool_init(MB_SIZE);
	int socket_fd;

	signal(SIGPIPE, SIG_IGN);
	signal(SIGHUP, SIG_IGN);
	signal(SIGINT, sign_handler);
	signal(SIGTERM, sign_handler);

	if((socket_fd = parse_cmd_line(argc, argv, mem_pool)) <= 0)
	{
		mem_pool_destroy(mem_pool);
		return 0;
	}
	
	while (global_start) {
		if ((cmd = readline("MILE>")) == NULL) {
			break;
		}
		parse_cmd(cmd,socket_fd,mem_pool);
		mem_pool_reset(mem_pool);
		if(cmd != NULL)
		{
			free(cmd);
			cmd = NULL;
		}
	}

	mem_pool_destroy(mem_pool);
	return 0;
}	
开发者ID:Alibaba-boonya,项目名称:mile,代码行数:33,代码来源:client.c


示例15: mu_config_init

MuConfig*
mu_config_init (int *argcp, char ***argvp)
{
	g_return_val_if_fail (argcp && argvp, NULL);

	memset (&MU_CONFIG, 0, sizeof(MU_CONFIG));

	if (!parse_cmd (argcp, argvp))
		goto errexit;

	if (!parse_params(argcp, argvp))
		goto errexit;

	/* fill in the defaults if user did not specify */
	set_group_mu_defaults();
	set_group_index_defaults();
	set_group_find_defaults();
	set_group_cfind_defaults();
	set_group_view_defaults();
	/* set_group_mkdir_defaults (config); */

	return &MU_CONFIG;

errexit:
	mu_config_uninit (&MU_CONFIG);
	return NULL;
}
开发者ID:DarwinAwardWinner,项目名称:mu,代码行数:27,代码来源:mu-config.c


示例16: shm_set_variables

static void
shm_set_variables(SynapticsSHM *synshm, int argc, char *argv[], int first_cmd)
{
    int i;
    struct Parameter *par;
    double val;

    for (i = first_cmd; i < argc; i++) {
	val = parse_cmd(argv[i], &par);

	if (!par)
	    continue;

	switch (par->type) {
	    case PT_INT:
		*(int*)((char*)synshm + par->offset) = (int)rint(val);
		break;
	    case PT_BOOL:
		*(Bool*)((char*)synshm + par->offset) = (Bool)rint(val);
		break;
	    case PT_DOUBLE:
		*(double*)((char*)synshm + par->offset) = val;
		break;
	}
    }
}
开发者ID:Docworld,项目名称:chromiumos,代码行数:26,代码来源:synclient.c


示例17: cvs_trigger_handle

int
cvs_trigger_handle(int type, char *repo, char *in, struct trigger_list *list,
    struct file_info_list *files)
{
	int r;
	char *cmd;
	struct trigger_line *line;

	TAILQ_FOREACH(line, list, flist) {
		if ((cmd = parse_cmd(type, line->line, repo, files)) == NULL)
			return (1);
		switch(type) {
		case CVS_TRIGGER_COMMITINFO:
		case CVS_TRIGGER_TAGINFO:
		case CVS_TRIGGER_VERIFYMSG:
			if ((r = cvs_exec(cmd, NULL, 1)) != 0) {
				free(cmd);
				return (r);
			}
			break;
		default:
			(void)cvs_exec(cmd, in, 1);
			break;
		}
		free(cmd);
	}

	return (0);
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:29,代码来源:trigger.c


示例18: run_bsigs

int run_bsigs(int argc, char *argv[])
{
	int ret=1;
	fzp *fzp=NULL;
	struct iobuf rbuf;
	struct blk blk;
	memset(&rbuf, 0, sizeof(struct iobuf));

	if(argc!=2)
		return usage();
	path=argv[1];

	if(!(fzp=fzp_gzopen(path, "rb")))
		goto end;
	while(1)
	{
		iobuf_free_content(&rbuf);
		switch(iobuf_fill_from_fzp(&rbuf, fzp))
		{
			case 1: ret=0; // Finished OK.
			case -1: goto end; // Error.
		}

		if(parse_cmd(&rbuf, &blk)) goto end;
	}

end:
	iobuf_free_content(&rbuf);
	fzp_close(&fzp);
	return ret;
}
开发者ID:pkdevbox,项目名称:burp,代码行数:31,代码来源:bsigs.c


示例19: read_task

int read_task(const char *filename)
{

	log_d("read_task filename:%s", filename);
	FILE *fp = fopen(filename, "r");
	if (fp == NULL)
	{
		fprintf(stderr, "cannot open %s\n", filename);
		return 0;
	}

	char str_line[1024] =
	{ };             //每行最大读取的字符数
	while (!feof(fp))
	{
		if (fgets(str_line, 1024, fp) == NULL)             //读取一行
		{
			break;
		}
		if (strlen(str_line) > 0)
		{
			trim(str_line);
			add_task(parse_cmd(str_line));
			log_d("%s", str_line); //输出
		}
		memset(str_line, 0, 1024);
	}
	fclose(fp);
	return 1;
}
开发者ID:fecloud,项目名称:timetask,代码行数:30,代码来源:task.c


示例20: echo_read_cb

static void echo_read_cb(struct bufferevent *bev, void *ctx) {
    struct evbuffer *input = bufferevent_get_input(bev);
    size_t str_len = 0;
    char* str_input = evbuffer_readln(input,&str_len,EVBUFFER_EOL_ANY);

    char* val = NULL;
    enum CMD_TYPE cmdtype = parse_cmd(str_input, str_len, &val);
    if (cmdtype == CMD_QUIT){
        bufferevent_free(bev);
        return;
    }
    struct evbuffer *ret = evbuffer_new();
    switch (cmdtype) {
        case CMD_GET:
        case CMD_ECHO:
            evbuffer_add(ret,val,strlen(val));
            break;
        case CMD_ERR:
            evbuffer_add(ret,"(ERR)",5);
            break;
        case CMD_OK:
            evbuffer_add(ret,"(OK)",4);
            break;
        case CMD_NULL:
            evbuffer_add(ret,"(NULL)",6);break;
        default:
            evbuffer_add(ret,"(UNKNOWN)",9);break;
    }
    evbuffer_add(ret,"\n",1);
    evbuffer_add_buffer(bufferevent_get_output(bev), ret);
}
开发者ID:itsusony,项目名称:adkvs,代码行数:31,代码来源:main.c



注:本文中的parse_cmd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parse_color函数代码示例发布时间:2022-05-30
下一篇:
C++ parse_boolean函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap