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

C++ do_command函数代码示例

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

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



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

示例1: put_avr_firmware

int put_avr_firmware(char *firmware_filename)
{
    int r;
    
    r = do_command(CMD_AVR_I2CRST, bigbuf, sizeof(bigbuf));
    if (r < 0) {
	printf("do_twiboot: CMD_AVR_I2CRST: failed, but may continue...\n");
	/* no return, because in bootloader mode, 
	 AVR doesn't need I2C reset */
	/* return -1; */
    }
    usleep(100*1000L);

    if (rpi_rev == 1) {
	r = do_command(CMD_TWIBOOT_I2CREV1, bigbuf, sizeof(bigbuf));
    }
    else if (rpi_rev == 2) {
	r = do_command(CMD_TWIBOOT_I2CREV2, bigbuf, sizeof(bigbuf));
    }
    else {
	printf("put_avr_firmware: rpi_rev incorrectly, or not set\n");
    }
    
    /* DO STUFF TO CHECK twiboot SUCCESS/FAILURE FROM bigbuf*/
    
    return r;
}
开发者ID:BackupGGCode,项目名称:raspy-juice,代码行数:27,代码来源:jig-avr.c


示例2: main

int main(int argc, char *argv[])
{
	ProgramMode mode;
	LHAOptions options;

#ifdef TEST_BUILD
	// When running tests, give output to stdout in binary mode;
	// on Windows, this gives the expected output (which was
	// constructed for Unix):

	lha_arch_set_binary(stdout);
#endif

	// Parse the command line options and run command.
	// As a shortcut, a single argument can be provided to list the
	// contents of an archive ("lha foo.lzh" == "lha l foo.lzh").

	init_options(&options);

	if (argc >= 3 && parse_command_line(argv[1], &mode, &options)) {
		return !do_command(mode, argv[2], &options,
		                   argv + 3, argc - 3);
	} else if (argc == 2) {
		return !do_command(MODE_LIST, argv[1], &options, NULL, 0);
	} else {
		help_page(argv[0]);
		return 0;
	}
}
开发者ID:sagara-,项目名称:lhasa,代码行数:29,代码来源:main.c


示例3: test3

void test3(int fd) {
  /* encrypt */
  do_command(fd, (unsigned char*) "CMDencrypt#", "123456test");

  /* decrypt */
  do_command(fd, (unsigned char*) "CMDdecrypt#", "abcdwt6'16");
}
开发者ID:TheGlidd,项目名称:proto-parser,代码行数:7,代码来源:client.c


示例4: execute

void execute(WINDOW* w, ToxWindow *self, Tox *m, char *cmd, int mode)
{
    if (string_is_empty(cmd))
        return;

    char args[MAX_NUM_ARGS][MAX_STR_SIZE] = {0};
    int num_args = parse_command(w, cmd, args);

    if (num_args == -1)
        return;

    /* Try to match input command to command functions. If non-global command mode is specified, 
       try specified mode's commands first, then upon failure try global commands. 

       Note: Global commands must come last in case of duplicate command names */
    switch (mode) {
    case CHAT_COMMAND_MODE:
        if (do_command(w, self, m, num_args, CHAT_NUM_COMMANDS, chat_commands, args) == 0)
            return;
        break;

    case GROUPCHAT_COMMAND_MODE:
        break;
    }

    if (do_command(w, self, m, num_args, GLOBAL_NUM_COMMANDS, global_commands, args) == 0)
        return;

    wprintw(w, "Invalid command.\n");
}
开发者ID:IMFTC,项目名称:toxic,代码行数:30,代码来源:execute.c


示例5: execute

void execute(WINDOW *w, ToxWindow *self, Tox *m, const char *input, int mode)
{
    if (string_is_empty(input))
        return;

    char args[MAX_NUM_ARGS][MAX_STR_SIZE];
    int num_args = parse_command(w, self, input, args);

    if (num_args == -1)
        return;

    /* Try to match input command to command functions. If non-global command mode is specified,
       try specified mode's commands first, then upon failure try global commands.

       Note: Global commands must come last in case of duplicate command names */
    switch (mode) {
        case CHAT_COMMAND_MODE:
            if (do_command(w, self, m, num_args, chat_commands, args) == 0)
                return;

            break;

        case GROUPCHAT_COMMAND_MODE:
            break;
    }

    if (do_command(w, self, m, num_args, global_commands, args) == 0)
        return;

    line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid command.");
}
开发者ID:askielboe,项目名称:toxic,代码行数:31,代码来源:execute.c


示例6: timeout_func

static int timeout_func(gpointer data)
{
	int pos;
	gboolean playing;
	static char *previous_file = NULL;
	static gboolean cmd_after_already_run = FALSE;
	char *current_file;

	GDK_THREADS_ENTER();

	playing = xmms_remote_is_playing(sc_gp.xmms_session);
	pos = xmms_remote_get_playlist_pos(sc_gp.xmms_session);
	current_file = xmms_remote_get_playlist_file(sc_gp.xmms_session, pos);
	
	if ((pos != previous_song ||
	     (!previous_file && current_file) ||
	     (previous_file && !current_file) ||
	     (previous_file && current_file &&
	      strcmp(previous_file, current_file))) &&
	    xmms_remote_get_output_time(sc_gp.xmms_session) > 0)
	{
		do_command(cmd_line, current_file, pos);
		g_free(previous_file);
		previous_file = g_strdup(current_file);
		previous_song = pos;
		cmd_after_already_run = FALSE;
	}
	if (!cmd_after_already_run &&
	    ((xmms_remote_get_playlist_time(sc_gp.xmms_session,pos) -
	      xmms_remote_get_output_time(sc_gp.xmms_session)) < 100))
	{
		do_command(cmd_line_after, current_file, pos);
		cmd_after_already_run = TRUE;
	}

	if (playing)
	{
		int playlist_length = xmms_remote_get_playlist_length(sc_gp.xmms_session);
		if (pos + 1 == playlist_length)
			possible_pl_end = TRUE;
		else
			possible_pl_end = FALSE;
	}
	else if (possible_pl_end)
	{
		if (pos == 0)
			do_command(cmd_line_end, current_file, pos);
		possible_pl_end = FALSE;
		g_free(previous_file);
		previous_file = NULL;
	}

	g_free(current_file);
	current_file = NULL;

	GDK_THREADS_LEAVE();

	return TRUE;
}
开发者ID:xdien,项目名称:my_cproject,代码行数:59,代码来源:song_change.c


示例7: upsdrv_shutdown

void upsdrv_shutdown(void)
{
	char reply[8];
	
	if(!(do_command(cmd_setOutOffMode, reply, 8) != -1) &&
	(do_command(cmd_setOutOffDelay, reply, 8) != -1) &&
	(do_command(cmd_sysLoadKey, reply, 6) != -1) &&
	(do_command(cmd_shutdown, reply, 8) != -1))
	upslogx(LOG_ERR, "Failed to shutdown UPS");
}
开发者ID:AlexLov,项目名称:nut,代码行数:10,代码来源:liebert-esp2.c


示例8: set_identification

static void set_identification(const char *val) {
	char response[MAX_RESPONSE_LENGTH];

	if (do_command(POLL, IDENTIFICATION, "", response) < 0)
		return;
	if (strcmp(val, response)) {
		strncpy(response, val, MAX_RESPONSE_LENGTH);
		response[MAX_RESPONSE_LENGTH - 1] = '\0';
		do_command(SET, IDENTIFICATION, response, NULL);
	}
}
开发者ID:AlexLov,项目名称:nut,代码行数:11,代码来源:tripplitesu.c


示例9: do_reverse_command

void		do_reverse_command(t_app *app, unsigned char command)
{
	if (command >= RA && command <= RR)
		do_command(app, command + 3);
	else if (command >= RRA && command <= RRR)
		do_command(app, command - 3);
	else if (command == PA)
		do_command(app, command + 1);
	else if (command == PB)
		do_command(app, command - 1);
	else
		do_command(app, command);
}
开发者ID:HARM67,项目名称:push_swap,代码行数:13,代码来源:do_command.c


示例10: run_commands

void run_commands(unsigned int num_command, const char commands_list[max_commands][max_command_length], int to_file)
{
    if(to_file)
    {
        FILE* f = fopen("/home/box/result.out", "w");
        if(f)
        {
            close(STDOUT_FILENO);
            dup2(f->_fileno, STDOUT_FILENO);
            fclose(f);
        }
    }

    if(num_command > 0)
    {
        int pfd[2];
        pipe(pfd);

        if(!fork())
        {
            // child
            close(STDOUT_FILENO);
            dup2(pfd[1], STDOUT_FILENO);

            close(pfd[1]);
            close(pfd[0]);

            run_commands(num_command-1, commands_list, 0);
        }
        else
        {
            // parent
            close(STDIN_FILENO);
            dup2(pfd[0], STDIN_FILENO);

            close(pfd[1]);
            close(pfd[0]);

            char params[2][max_command_length];
            parce_command(commands_list[num_command], params);
            do_command(params);
        }
    }
    else
    {
        char params[2][max_command_length];
        parce_command(commands_list[num_command], params);
        do_command(params);
    }
}
开发者ID:DPOH357,项目名称:stepic,代码行数:50,代码来源:chann1.cpp


示例11: upsdrv_shutdown

void upsdrv_shutdown(void)
{
	char parm[20];

	if (!init_comm())
		printf("Status failed.  Assuming it's on battery and trying a shutdown anyway.\n");
	auto_reboot(1);
	/* in case the power is on, tell it to automatically reboot.  if
	   it is off, this has no effect. */
	snprintf(parm, sizeof(parm), "%d", 1); /* delay before reboot, in minutes */
	do_command(SET, SHUTDOWN_RESTART, parm, NULL);
	snprintf(parm, sizeof(parm), "%d", 5); /* delay before shutdown, in seconds */
	do_command(SET, SHUTDOWN_ACTION, parm, NULL);
}
开发者ID:AlexLov,项目名称:nut,代码行数:14,代码来源:tripplitesu.c


示例12: get_avr_serial

int get_avr_serial(char *sermem)
{
    int r;
    FILE *eepfile;
    
    r = do_command(CMD_AVR_QUIET R_EEPROM, bigbuf, sizeof(bigbuf));
    if (r < 0) {
	return -1;
    }
    
    if ((eepfile = fopen("eep.raw", "r")) == NULL) {
	printf("%s: open eep.raw file failed\n", __func__);
	return -2;
    }
    fseek(eepfile, 512-16, SEEK_SET);
    fread(sermem, 1, 16, eepfile);
    fclose(eepfile);
    sermem[16] = 0;

#if 0
    for (i = 0, p = serial_mem; i < 16; i++, p++) {
	if (i !=0 && (i % 8) == 0)   printf("\n");
	printf("%c 0x%02x ", isprint(*p) ? *p : '.', *p);
    }
    printf("\n");
#endif

    return 0;
}
开发者ID:BackupGGCode,项目名称:raspy-juice,代码行数:29,代码来源:jig-avr.c


示例13: remove_job

static int				/* O - Status from cups-lpd */
remove_job(int  outfd,			/* I - Command file descriptor */
           int  infd,			/* I - Response file descriptor */
	   char *dest,			/* I - Destination */
	   char **args)			/* I - Arguments */
{
  int		i;			/* Looping var */
  char		command[1024];		/* Command buffer */

 /*
  * Send the "remove jobs" command...
  */

  snprintf(command, sizeof(command), "\005%s", dest);

  for (i = 0; args[i]; i ++)
  {
    strlcat(command, " ", sizeof(command));
    strlcat(command, args[i], sizeof(command));
  }

  strlcat(command, "\n", sizeof(command));

  return (do_command(outfd, infd, command));
}
开发者ID:zdohnal,项目名称:cups,代码行数:25,代码来源:testlpd.c


示例14: main

int					main(int ac, char **av, char **env)
{
	char	*line2;
	t_e		e;

	(void)ac;
	(void)av;
	e.list = ft_env_cpy(env);
	signal(SIGQUIT, ft_signal);
	show_prompt(e.list);
	while (get_next_line(0, &(e.line)) == 1)
	{
		line2 = exange_tab_or_space(e.line);
		e.args = ft_strsplit(line2, ' ');
		if (e.args && e.args[0])
		{
			if (ft_strchr(e.args[0], '/'))
				exec_absolu(e.line, e.list);
			else
				do_command(&(e.list), e.line);
		}
		free(e.line);
		show_prompt(e.list);
		free_char_array(e.args);
	}
	ft_putchar('\n');
	return (0);
}
开发者ID:bensisko69,项目名称:projet_42,代码行数:28,代码来源:ft_sh1.c


示例15: main

int main()
{
	int running = 1;
	character player;

	/* SET START --------------------------------*/
	room start; 
	strcpy(start.description , "Game Name. [goto] the bedroom to start.");
	/* SET START --------------------------------*/

	/* SET BEDROOM --------------------------------*/
	room bedroom = {"Bedroom", {"pencil", "towel", "backpack"}};
	strcpy(bedroom.entrance_msg, "You wake up.");
	/* SET BEDROOM --------------------------------*/

	player.current_room = start;

	while (running)
	{
		print_room_summary(player.current_room);
		char command[100];
		scanf("%[^\n]", command);
		do_command(command);

	}
	return 0;
}
开发者ID:christopherliu830,项目名称:Final-Project,代码行数:27,代码来源:game.c


示例16: command_prompt

void command_prompt(void *pvParameters)
{
	char buf[128];
	char *argv[20];
        char hint[] = USER_NAME "@" USER_NAME "-STM32:~$ ";

	fio_printf(1, "\rWelcome to FreeRTOS Shell\r\n");
	while(1){
		fio_printf(1, "%s", hint);
		fio_read(0, buf, 127);
	
		int n=parse_command(buf, argv);

		/* will return pointer to the command function */
		//if (*argv[0]=='\0')
		cmdfunc *fptr=do_command(argv[0]);
		if(fptr!=NULL)
			fptr(n, argv);
		else if (*argv[0]!='\0')
			fio_printf(2, "\r\n\"%s\" command not found.\r\n", argv[0]);
		else
			fio_printf(1, "\r\n");
	}

}
开发者ID:CarterTsai,项目名称:freertos-plus,代码行数:25,代码来源:main.c


示例17: main

int			main(void)
{
	char	*line;
	char	*line2;
	t_list	*list;
	char	**args;

	list = ft_env_cpy();
	signal(SIGINT, ft_signal);
	show_prompt(list);
	while (get_next_line(0, &line) == 1)
	{
		line2 = exchange_tab_for_space(line);
		args = ft_strsplit(line2, ' ');
		if (args && args[0])
		{
			if (ft_strchr(args[0], '/'))
				exec_absolu(line, list);
			else
				do_command(&list, line);
		}
		free(line);
		show_prompt(list);
		free_char_array(args);
	}
	ft_putchar('\n');
	return (0);
}
开发者ID:bensisko69,项目名称:42,代码行数:28,代码来源:ft_sh2.c


示例18: do_client

static int do_client(void)
{
	int rv;

	rv = setup_config(CLIENT);
	if (rv < 0) {
		log_error("cannot read config");
		goto out;
	}

	switch (cl.op) {
	case CMD_LIST:
	case CMD_PEERS:
		rv = query_get_string_answer(cl.op);
		break;

	case CMD_GRANT:
	case CMD_REVOKE:
		rv = do_command(cl.op);
		break;
	}

out:
	return rv;
}
开发者ID:inouekazu,项目名称:booth,代码行数:25,代码来源:main.c


示例19: main

int main(int argc, char **argv) {
	parse_options(argc, argv);
	exec_info();

	while (1) {
		printf("> ");
		char command_line[1024];
		memset(command_line, 0, 1024);
		fgets(command_line, 1024, stdin);

		if (strlen(command_line) == 0 && feof(stdin)) {
			printf("\n");
			break;
		}

		//printf("command: %s\n", command_line);

		do_command(command_line);
	}

	int i;
	for (i = 0; i < files_count; i++) {
		file_delete(files[i]);
	}
	free(files);
	return 0;
}
开发者ID:pavel-krush,项目名称:fl,代码行数:27,代码来源:fl.c


示例20: rmt_lseek__

/* Perform an imitation lseek operation on remote tape connection
   HANDLE.  Return the new file offset if successful, -1 if on error.  */
off_t
rmt_lseek__ (int handle, off_t offset, int whence)
{
  char command_buffer[COMMAND_BUFFER_SIZE];
  char operand_buffer[UINTMAX_STRSIZE_BOUND];
  uintmax_t u = offset < 0 ? - (uintmax_t) offset : (uintmax_t) offset;
  char *p = operand_buffer + sizeof operand_buffer;

  *--p = 0;
  do
    *--p = '0' + (int) (u % 10);
  while ((u /= 10) != 0);
  if (offset < 0)
    *--p = '-';

  switch (whence)
    {
    case SEEK_SET: whence = 0; break;
    case SEEK_CUR: whence = 1; break;
    case SEEK_END: whence = 2; break;
    default: abort ();
    }

  sprintf (command_buffer, "L%s\n%d\n", p, whence);

  if (do_command (handle, command_buffer) == -1)
    return -1;

  return get_status_off (handle);
}
开发者ID:Linuxcpa,项目名称:Confederate-Patches,代码行数:32,代码来源:rtapelib.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ do_crm_log函数代码示例发布时间:2022-05-30
下一篇:
C++ do_cmd函数代码示例发布时间: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