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

C++ set_opt函数代码示例

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

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



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

示例1: get_opts

int get_opts(int argc, char *argv[], struct wldbg_options *opts)
{
	int n = 1;
	for (; n < argc; ++n) {
		/* separator */
		if (strcmp("--", argv[n]) == 0) {
			++n;
			break;
		}

		/* options */
		if (is_prefix_of("--", argv[n])) {
			if (!set_opt(argv[n] + 2, opts))
				return -1;
		} else if (is_prefix_of("-", argv[n])) {
			/* -g is a synonym for objinfo */
			if (argv[n][1] == 'g' && argv[n][2] == 0) {
				/* objinfo */
				set_opt("objinfo", opts);
				continue;
			}

			if (!set_opt(argv[n] + 1, opts))
				return -1;
		} else
			break;
	}

	dbg("Passes or programs are starting at %d\n", n);
	/* return how many options we have */
	return n;
}
开发者ID:mchalupa,项目名称:wldbg,代码行数:32,代码来源:getopt.c


示例2: cmd_config

int cmd_config(int argc,char **argv,struct sub_command* cmd) {
  char* home=configdir();
  char* path=cat(home,"config",NULL);
  if(argc==1) {
    printf("oneshot:\n");
    print_opts(local_opt);
    printf("local:\n");
    print_opts(global_opt);
  }else {
    struct opts* opt=global_opt;
    struct opts** opts=&opt;
    // TBD parse options
    if(argc==2) {
      unset_opt(opts, argv[1]);
      save_opts(path,opt);
    }else {
      if(strcmp(argv[1],"set")==0) {
        set_opt(opts, argv[2],(char*)argv[3],0);
        save_opts(path,opt);
      }else if (strcmp(argv[1],"show")==0) {
        printf("%s\n",_get_opt(opt,argv[2]));
      }else {
        set_opt(opts, argv[1],(char*)argv[2],0);
        save_opts(path,opt);
      }
    }
  }
  s(home),s(path);
  return 0;
}
开发者ID:suthsc,项目名称:roswell,代码行数:30,代码来源:cmd-config.c


示例3: copyprefs

static void copyprefs(void)
{
	int button;

	/* Set states of appropriate options buttons */

	set_opt(copyoptions, options.cprefs, CF_COPY, CCOPY);
	set_opt(copyoptions, options.cprefs, CF_DEL, CDEL);
	set_opt(copyoptions, options.cprefs, CF_OVERW, COVERW);
	set_opt(copyoptions, options.cprefs, CF_PRINT, CPRINT); /* DjV 031 010203 */
	/* set_opt(copyoptions, options.cprefs, CF_KEEP, CKEEP); DjV 016 140203 nothing done yet */

	itoa(options.bufsize, copybuffer, 10);

	button = xd_dialog(copyoptions, 0);

	if (button == COPTOK) /* selected OK ? */
	{	  
		/* Get new states of options buttons and new copy buffer size */

		get_opt( copyoptions, &options.cprefs, CF_COPY, CCOPY );
		get_opt( copyoptions, &options.cprefs, CF_DEL, CDEL );
		get_opt( copyoptions, &options.cprefs, CF_OVERW, COVERW );
		get_opt( copyoptions, &options.cprefs, CF_PRINT, CPRINT ); /* DjV 031 010203 */
		/* get_opt( copyoptions, &options.cprefs, CF_KEEP, CKEEP ); DjV 016 140203 nothing done about thio yet */

		if ((options.bufsize = atoi(copybuffer)) < 1)
			options.bufsize = 1;
	}
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:30,代码来源:MAIN.C


示例4: process_cmdline

/* ------------------------------------------------------------- **
** Functions to read / parse the config file.
** ------------------------------------------------------------- */
int process_cmdline(int argc, char *argv[])
{
	int i;
	struct option_array *opt;
	sstr *arg;
	char *optp, *argp;

	set_defaults();
	if (argc <= 1)
		return 0;

	arg = sstr_init(0);

	i = 1;
	optp = argv[i] + 1;

	while (i < argc) {
		if (argv[i][0] != '-')
			usage(-1);
		opt = opts;
		if (*optp == '-')
			usage(-1);	/*?TODO longopts */
		else {
			while (opt->name != NULL && opt->cmdline != *optp)
				opt++;
			if (opt->name == NULL)
				usage(*optp);
			if (strlen(cmdline_set) < 99)
				cmdline_set[strlen(cmdline_set)] = *optp;
			if (opt->type == BOOL) {
				sstr_cpy2(arg, "yes");
				set_opt(opt, arg);
				if (*(++optp) == 0) {
					i++;
					optp = argv[i] + 1;
				}
			} else {
				argp = optp + 1;
				if (*argp == 0) {
					if (i >= argc - 1 ||
					    *(argp = argv[++i]) == '-')
						usage(*optp);

				}
				sstr_cpy2(arg, argp);
				set_opt(opt, arg);
				i++;
				optp = argv[i] + 1;
			}
		}
	}
	sstr_free(arg);
	return (0);
}
开发者ID:Distrotech,项目名称:frox,代码行数:57,代码来源:configs.c


示例5: default_options

static void default_options(struct f2fs_sb_info *sbi)
{
	/* init some FS parameters */
	sbi->active_logs = NR_CURSEG_TYPE;

	set_opt(sbi, BG_GC);
	set_opt(sbi, INLINE_DATA);

#ifdef CONFIG_F2FS_FS_XATTR
	set_opt(sbi, XATTR_USER);
#endif
#ifdef CONFIG_F2FS_FS_POSIX_ACL
	set_opt(sbi, POSIX_ACL);
#endif
}
开发者ID:Swapnil133609,项目名称:Zeus_sprout,代码行数:15,代码来源:super.c


示例6: main

int main(void) {
	int fd;
	int nread;
	char buff[10];
	char testbf[] = {"abcde"};
	int ntestbf = 5;

	memset(buff, 0, 10);

	if ((fd = open_port()) < 0) {
		perror("open_port error");
		return -1;
	}
	if (set_opt(fd, 9600, 8, 'N', 1) < 0) {
		perror("set_opt error");
		return -1;
	}
	printf("fd = %d\n", fd);

	while(1) {
		nread = read(fd, buff, 10);
		printf("nread = %d\n", nread);
		tcflush(fd, TCIFLUSH);
		if (nread > 0)
			printf("result: %d %s\n", nread, buff);
		//memset(buff, 0, sizeof(buff));
		//write(fd, buff, nread);
		write(fd, testbf, ntestbf);
		sleep(1);
		tcflush(fd, TCOFLUSH);
	}
	close(fd);
	return 0;
}
开发者ID:PWESiberiaBear,项目名称:cy30-uart-test,代码行数:34,代码来源:uart_test.c


示例7: parse_line

/*
	parse_line
	Parses a line from the config file.  Lines must be of the form
	"option-name[whitespace]value[\n]"
	We're kinda restrictive for now, but the options are so simple that
	we shouldn't need anything complex for now.
	Returns -1 on error, 0 otherwise.
*/
static int parse_line(char *line)
{
	char	*opt = line, 
		*val,
		*p;

	p = strchr(line, '\n');	/* Strip the trailing newline. */
	if(p != NULL)
		*p = '\0';

	/* Seperate the value from the option. */
	val = opt;
	while(!isspace(*val)) {
		val++;
		if(*val == '\0') {
			io_err("Missing value for '%s'!'\n", opt);
			return -1;
		}
	}
	
	*val = '\0';
	val++;

	while(isspace(*val)) {
		val++;
		if(*val == '\0') {    
                        io_err("Missing value for '%s'!'\n", opt);
                        return -1;
                }
	}

	if(is_default_opt(opt) && !parsed_yet) 
		return set_opt(opt, val);
	return 0;
}
开发者ID:pete,项目名称:freenote-probe,代码行数:43,代码来源:config_parse.c


示例8: main

int	main()
{
  int	fd;
  int	nread;
  char	command[256];
  char	buf;
  int	nset;

  fd = open("/dev/ttySAC1", O_RDONLY);
  if (fd == -1)
    {
      printf("open failed\n");
      exit(1);
    }
  nset = set_opt(fd, 4800, 8, 'N', 1);
  if (nset == -1)
    {
      printf("set_opt failed\n");
      exit(1);
    }
  memset(command, '\0', 256);
  while	(1)
    {
      nread = read(fd, &buf, 1);
      if (nread > 0)
	{
	  concat_command(command, buf);
	  if (buf == 'q')
	    break;
	}
    }
  close(fd);
  return (0);
}
开发者ID:Qstar,项目名称:intersting,代码行数:34,代码来源:GPSDemo3.c


示例9: main

int main(void)
{
    int  fd;
    int  nwrite, i;
    char buff[] = "Hello\n";

    /*打开串口*/
    if((fd = open_port(fd, 1))<0){
        perror("open_port error");
        return;
    }

    /*对串口进行设置*/
    if((i = set_opt(fd, 115200, 8, 'N', 1))<0){
        perror("set_opt error");
        return;
    }
    printf("fd=%d\n",fd);

    /*对串口进行写操作*/
    for(i = 0; i < 20; i++){
        nwrite = write(fd, buff, 6);
        printf("nwrite=%d,%s\n", nwrite, buff);
        sleep(1);
    }
    close(fd);
    return;
}
开发者ID:SunshineMou,项目名称:Study,代码行数:28,代码来源:ttyTest.c


示例10: parse_line

int parse_line(sstr * buf)
{
	struct option_array *opt;
	sstr *tok;
	tok = sstr_init(0);

	if (sstr_getchar(buf, 0) == '#')
		return (0);
	if (sstr_token(buf, tok, " =\t\r\n", 0) == -1)
		return (0);

	if (!sstr_casecmp2(tok, "EndSection"))
		return (sublevel > 0 ? 1 : -1);

	opt = opts;
	while (opt->name != NULL && sstr_casecmp2(tok, opt->name))
		opt++;
	if (opt->name == NULL) {
		fprintf(stderr,"Unrecognised option \"%s\" at line %d of %s\n",
			sstr_buf(tok), line_no, config.config_file);
		return (-1);
	}
	if (opt->cmdline && strchr(cmdline_set, opt->cmdline)) {
		fprintf(stderr,
			"\"%s\" specified on the command line: ignored\n",
			opt->name);
		return (0);
	}
	if (set_opt(opt, buf) == -1) {
		fprintf(stderr, "Invalid argument to %s at line %d of %s\n",
			opt->name, line_no, config.config_file);
		return (-1);
	}
	return (0);
}
开发者ID:Distrotech,项目名称:frox,代码行数:35,代码来源:configs.c


示例11: main

int main(void)
{
    int fd;
    int nread;    
    char buff[10];
    if((fd=open_port(0))<0)
    {
        perror("open_port error");
        return;
    }
    if(set_opt(fd,115200,8,'N',1)<0)
    {
        perror("set_opt error");
        return;
    }
    printf("fd=%d\n",fd);        
    int i;
    while(1)
    {
       memset(buff,'\0',sizeof(buff));
       if((nread=read(fd,buff,11)) != 0)
       {
//           for(i=0;i<4;i++)
               printf("nread=%d,%u,%d,%s\n",nread,*((unsigned int*)buff),buff,buff);
       }
       else
           printf("hehe\n");
    }
    close(fd);
    return;
}
开发者ID:msggood,项目名称:test,代码行数:31,代码来源:uart0.c


示例12: set_opt

void Options::set_opt ( const QString &opt, const QList<int> &val )
{
    QStringList vals;
    for (QList<int>::const_iterator itVal = val.begin(); itVal != val.end(); ++itVal )
        vals << QString::number( *itVal );
    set_opt( opt, vals );
}
开发者ID:modlfo,项目名称:oqamldebug_qt5,代码行数:7,代码来源:options.cpp


示例13: main

int main(void)
{
	int fd1,fd2,nset1,nset2,nread;
	char buf;
	char buff[256];
	fd2 = open("/dev/ttySAC1", O_RDONLY);
//	fd2 = open( "/home/junhan/Desktop/part4/test1", O_RDWR);  //for ok6410-B GPS module
	if (fd2 == -1)
		exit(1);
	nset2 = set_opt(fd2, 4800, 8, 'N', 1);
	if (nset2 == -1)
		exit(1);  //使用的时候取消注释
	memset(buff, '\0', 256);
	while(1)
	{	
		nread = read(fd2, &buf, 1);
		if(nread > 0){
		concat_command(buff,buf);
		if(buf == 'q')
			break;
		}
	}


	close(fd2);

	return 0;

}
开发者ID:JunhanYan,项目名称:Embeded-System-Application,代码行数:29,代码来源:gps3.c


示例14: printf

MyPrint::MyPrint()
{


   //int num;
    if (num=set_opt()<0){
            printf("set_opt error");
            //return -1;
    }
}
开发者ID:marxsu,项目名称:IFMA,代码行数:10,代码来源:myprint.cpp


示例15: Serial_Init

void Serial_Init(void)
{

	SerFd_1 = open("/dev/ttySAC0",O_RDWR|O_NOCTTY|O_NDELAY);
	if(0 < SerFd_1){
		set_opt(SerFd_1,B115200,DATA_BIT_8,PARITY_NONE,STOP_BIT_1);
		printf("open /dev/ttySAC0 is ok \n");
	}else{
		printf("open /dev/ttySAC0 error \n");
	}

	SerFd = open("/dev/ttySAC1",O_RDWR|O_NOCTTY|O_NDELAY);
	if(0 < SerFd){
		set_opt(SerFd,B115200,DATA_BIT_8,PARITY_NONE,STOP_BIT_1);
		printf("open /dev/ttySAC1 is ok \n");
	}else{
		printf("open /dev/ttySAC1 error \n");
	}

}
开发者ID:zhucz,项目名称:mylinux,代码行数:20,代码来源:main.c


示例16: conf_setting

static Cmdret conf_setting(List *args, Cmdarg *ca)
{
  log_msg("CONFIG", "conf_setting");
  char *name = list_arg(args, 1, VAR_STRING);
  Token *oper = tok_arg(args, 2);
  Token *rhs = tok_arg(args, 3);
  if (!name|| !oper || !rhs)
    return NORET;
  char *value = cmdline_line_from(ca->cmdline, 3);
  set_opt(name, value);
  return NORET;
}
开发者ID:Hummer12007,项目名称:nav,代码行数:12,代码来源:config.c


示例17: while

void *pthread_ck2316_alarm(void *arg)
{
    int com_fd;
    int recv_ret = 0;
    //unsigned char recv_buffer[72] = {0};

    while (1) 
    {
        recv_ret = ck2316_alarm_init();
        if (recv_ret == -1) 
        {
            printf("FUNC[%s] LINE[%d]\tCK2316 alarm init failed!\n",__FUNCTION__, __LINE__);
            sleep(10);
        }
        else
            break;
    }

    while (1) 
    {
        com_fd = OpenDev(CK2316_UART_DEVICE);
        if (com_fd == -1) 
        {
            printf("FUNC[%s] LINE[%d]\tOpen uart failed!\n",__FUNCTION__, __LINE__);
            sleep(10);
            continue;
        }
        //fd nSpeed nBits nEvent nStop)
        //set_opt(com_fd, 2400, 3, 2, 0); //for ck2316
        //recv_ret = set_opt(com_fd, 9600, 3, 0, 0); //for ck2316
        //recv_ret = set_opt(com_fd, CK2316_UART_BOARD, CK2316_UART_DATA_BIT, CK2316_UART_CHECK_BIT, CK2316_UART_STOP_BIT);
        recv_ret = set_opt(com_fd, ck2316_alarm_data.ck2316_alarm_serial_pamater.serialAttr.dwBaudRate, ck2316_alarm_data.ck2316_alarm_serial_pamater.serialAttr.byDataBit, ck2316_alarm_data.ck2316_alarm_serial_pamater.serialAttr.byParity, ck2316_alarm_data.ck2316_alarm_serial_pamater.serialAttr.byStopBit);
        if (recv_ret == -1) 
        {
            printf("FUNC[%s] LINE[%d]\tInit uart failed!\n",__FUNCTION__, __LINE__);
            sleep(10);
            continue;
        }
        ClrCom(com_fd);

        recv_ret = ck2316_alarm_handshake_and_setup(&com_fd);
        if (recv_ret == -1) 
        {
            close(com_fd);
            sleep(10);
        }
    }

    return (void *)1;
}
开发者ID:github188,项目名称:integration_server_app,代码行数:50,代码来源:ck2316_alarm.c


示例18: Start

// 开启通信服务
int CComDev::Start()
{
	if (OpenDev(m_cDev) != TRUE)
	{
		return FALSE;
	}
	if (set_opt(115200, 8, 'N', 1) != TRUE)
	{
		return FALSE;
	}
	//开启接收线程
	pthread_create(&m_RecvPt, NULL, threadRecv, this);

	return TRUE;
}
开发者ID:huoyan108,项目名称:SMS,代码行数:16,代码来源:ComDev.cpp


示例19: ext2_remount

int ext2_remount (struct super_block * sb, int * flags, char * data)
{
    struct ext2_super_block * es;
    unsigned short resuid = sb->u.ext2_sb.s_resuid;
    unsigned short resgid = sb->u.ext2_sb.s_resgid;
    unsigned long new_mount_opt;
    unsigned long tmp;

    /*
     * Allow the "check" option to be passed as a remount option.
     */
    set_opt (sb->u.ext2_sb.s_mount_opt, CHECK_NORMAL);
    if (!parse_options (data, &tmp, &resuid, &resgid,
                &new_mount_opt))
        return -EINVAL;

    sb->u.ext2_sb.s_mount_opt = new_mount_opt;
    sb->u.ext2_sb.s_resuid = resuid;
    sb->u.ext2_sb.s_resgid = resgid;
    es = sb->u.ext2_sb.s_es;
    if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
        return 0;
    if (*flags & MS_RDONLY) {
        if (es->s_state & EXT2_VALID_FS ||
            !(sb->u.ext2_sb.s_mount_state & EXT2_VALID_FS))
            return 0;
        /*
         * OK, we are remounting a valid rw partition rdonly, so set
         * the rdonly flag and then mark the partition as valid again.
         */
        es->s_state = sb->u.ext2_sb.s_mount_state;
        es->s_mtime = CURRENT_TIME;
        mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
        sb->s_dirt = 1;
        ext2_commit_super (sb, es);
    }
    else {
        /*
         * Mounting a RDONLY partition read-write, so reread and
         * store the current valid flag.  (It may have been changed
         * by e2fsck since we originally mounted the partition.)
         */
        sb->u.ext2_sb.s_mount_state = es->s_state;
        sb->s_flags &= ~MS_RDONLY;
        ext2_setup_super (sb, es);
    }
    return 0;
}
开发者ID:OS2World,项目名称:DRV-ext2,代码行数:48,代码来源:super.c


示例20: open

int Serial::init()
{	
	SerFd = -1;
	SerFd = open("/dev/ttyUSB0", O_RDWR|O_NOCTTY|O_NDELAY); 
	if (0 < SerFd)  
	{
		set_opt(SerFd, BAUD_2400, DATA_BIT_8, PARITY_NONE, STOP_BIT_1);
	}
	else
	{
		 printf("open_port ERROR !\n");  
		 return -1;

	}
	return 0;
}
开发者ID:githubmsj1,项目名称:RVISION,代码行数:16,代码来源:serial.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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