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

C++ errc函数代码示例

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

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



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

示例1: init

static void
init(void)
{
    if (ioctl(0, VT_GETACTIVE, &cur_info.active_vty) == -1)
        errc(1, errno, "getting active vty");

    cur_info.console_info.size = sizeof(cur_info.console_info);

    if (ioctl(0, CONS_GETINFO, &cur_info.console_info) == -1)
        errc(1, errno, "getting console information");

    if (ioctl(0, GIO_SCRNMAP, &cur_info.screen_map) == -1)
        errc(1, errno, "getting screen map");

    if (ioctl(0, CONS_GET, &cur_info.video_mode_number) == -1)
        errc(1, errno, "getting video mode number");

    cur_info.video_mode_info.vi_mode = cur_info.video_mode_number;

    if (ioctl(0, CONS_MODEINFO, &cur_info.video_mode_info) == -1)
        errc(1, errno, "getting video mode parameters");

    normal_fore_color = cur_info.console_info.mv_norm.fore;
    normal_back_color = cur_info.console_info.mv_norm.back;
    revers_fore_color = cur_info.console_info.mv_rev.fore;
    revers_back_color = cur_info.console_info.mv_rev.back;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:27,代码来源:vidcontrol.c


示例2: pam_authenticate

void context::authenticate()
{
    _M_code = pam_authenticate(_M_pamh, 0);
    if(errc(_M_code) != errc::success) throw auth_error(_M_pamh, _M_code);

    _M_code = pam_acct_mgmt(_M_pamh, 0);
    if(errc(_M_code) != errc::success) throw account_error(_M_pamh, _M_code);
}
开发者ID:dimitry-ishenko,项目名称:camel,代码行数:8,代码来源:pam.cpp


示例3: pam_close_session

void context::close_session()
{
    _M_code = pam_close_session(_M_pamh, 0);
    if(errc(_M_code) != errc::success)
    {
        rmcred();
        throw session_error(_M_pamh, _M_code);
    }

    _M_code = rmcred();
    if(errc(_M_code) != errc::success) throw cred_error(_M_pamh, _M_code);
}
开发者ID:dimitry-ishenko,项目名称:camel,代码行数:12,代码来源:pam.cpp


示例4: setcred

void context::open_session()
{
    _M_code = setcred();
    if(errc(_M_code) != errc::success) throw cred_error(_M_pamh, _M_code);

    _M_code = pam_open_session(_M_pamh, 0);
    if(errc(_M_code) != errc::success)
    {
        rmcred();
        throw session_error(_M_pamh, _M_code);
    }
}
开发者ID:dimitry-ishenko,项目名称:camel,代码行数:12,代码来源:pam.cpp


示例5: pam_set_item

void context::insert(pam::item item, const std::string& value)
{
    if(item == pam::item::conv || item == pam::item::fail_delay) throw item_error(_M_pamh, errc::bad_item);

    _M_code = pam_set_item(_M_pamh, static_cast<int>(item), value.data());
    if(errc(_M_code) != errc::success) throw item_error(_M_pamh, _M_code);
}
开发者ID:dimitry-ishenko,项目名称:camel,代码行数:7,代码来源:pam.cpp


示例6: show_adapter_info

static void
show_adapter_info(void)
{
    struct video_adapter_info ad;

    ad.va_index = 0;

    if (ioctl(0, CONS_ADPINFO, &ad) == -1) {
        revert();
        errc(1, errno, "obtaining adapter information");
    }

    printf("fb%d:\n", ad.va_index);
    printf("    %.*s%d, type:%s%s (%d), flags:0x%x\n",
           (int)sizeof(ad.va_name), ad.va_name, ad.va_unit,
           (ad.va_flags & V_ADP_VESA) ? "VESA " : "",
           adapter_name(ad.va_type), ad.va_type, ad.va_flags);
    printf("    initial mode:%d, current mode:%d, BIOS mode:%d\n",
           ad.va_initial_mode, ad.va_mode, ad.va_initial_bios_mode);
    printf("    frame buffer window:0x%x, buffer size:0x%zx\n",
           ad.va_window, ad.va_buffer_size);
    printf("    window size:0x%zx, origin:0x%x\n",
           ad.va_window_size, ad.va_window_orig);
    printf("    display start address (%d, %d), scan line width:%d\n",
           ad.va_disp_start.x, ad.va_disp_start.y, ad.va_line_width);
    printf("    reserved:0x%x\n", ad.va_unused0);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:27,代码来源:vidcontrol.c


示例7: open_score_file

int
open_score_file(void)
{
	mode_t old_mode;
	char *home;
	char scorefile[PATH_MAX];
	int ret;
	int score_fd;

	home = getenv("HOME");
	if (home == NULL || *home == '\0')
		err(1, "getenv");
	ret = snprintf(scorefile, sizeof(scorefile), "%s/%s", home,
	    ".atc.scores");
	if (ret < 0 || ret >= PATH_MAX)
		errc(1, ENAMETOOLONG, "%s/%s", home, ".atc.scores");

	old_mode = umask(0);
	score_fd = open(scorefile, O_CREAT|O_RDWR, 0644);
	if (score_fd < 0)
		err(1, "open");
	/*
	 * This is done to take advantage of stdio, while still 
	 * allowing a O_CREAT during the open(2) of the log file.
	 */
	score_fp = fdopen(score_fd, "r+");
	if (score_fp == NULL)
		err(1, "fdopen");
	umask(old_mode);
	return (0);
}
开发者ID:ilyak,项目名称:openbsd,代码行数:31,代码来源:log.c


示例8: main

int
main(void)
{
	char sfn[24];
	FILE *sfp;
	int fd, i;

	strlcpy(sfn, "/tmp/barnacles.XXXXXXXX", sizeof(sfn));
	if ((fd = mkstemp(sfn)) == -1 ||
	    (sfp = fdopen(fd, "w+")) == NULL) {
		int saved_errno = errno;
		if (fd != -1) {
			unlink(sfn);
			close(fd);
		}
		errc(1, saved_errno, "could not open temporary file");
	}

	for (i = 0; i < 4096 * THREAD_COUNT; i++)
		if (fwrite(TEXT_N, sizeof(char), strlen(TEXT_N), sfp) == 0)
			err(1, "Could not populate test file");

	run_threads(fgetln_thread, sfp);

	unlink(sfn);
	close(fd);

	exit(0);
}
开发者ID:Basskrapfen,项目名称:openbsd,代码行数:29,代码来源:fgetln_test.c


示例9: posix_spawn

void *work(void *arg)
{
    int count = (int)(intptr_t)arg;
    int i;
    int ret;
    pid_t pid;

    for (i=0; i < count; i++) {
        ret = posix_spawn(&pid, newargv[0], NULL, NULL, newargv, environ);
        if (ret != 0) {
            errc(1, ret, "posix_spawn(%s)", newargv[0]);
        }
        
        while (-1 == waitpid(pid, &ret, 0)) {
            if (errno != EINTR) {
                err(1, "waitpid(%d)", pid);
            }
        }
        
        if (WIFSIGNALED(ret)) {
            errx(1, "process exited with signal %d", WTERMSIG(ret));
        } else if (WIFSTOPPED(ret)) {
            errx(1, "process stopped with signal %d", WSTOPSIG(ret));
        } else if (WIFEXITED(ret)) {
            if (WEXITSTATUS(ret) != 42) {
                errx(1, "process exited with unexpected exit code %d", WEXITSTATUS(ret));
            }
        } else {
            errx(1, "unknown exit condition %x", ret);
        }
    }

    return NULL;
}
开发者ID:Apple-FOSS-Mirror,项目名称:xnu,代码行数:34,代码来源:run.c


示例10: mbssep

static char *
mbssep(char **stringp, const wchar_t *delim)
{
	char *s, *tok;
	const wchar_t *spanp;
	wchar_t c, sc;
	size_t n;

	if ((s = *stringp) == NULL)
		return (NULL);
	for (tok = s;;) {
		n = mbrtowc(&c, s, MB_LEN_MAX, NULL);
		if (n == (size_t)-1 || n == (size_t)-2)
			errc(1, EILSEQ, NULL);	/* XXX */
		s += n;
		spanp = delim;
		do {
			if ((sc = *spanp++) == c) {
				if (c == 0)
					s = NULL;
				else
					s[-n] = '\0';
				*stringp = s;
				return (tok);
			}
		} while (sc != 0);
	}
}
开发者ID:mulichao,项目名称:freebsd,代码行数:28,代码来源:join.c


示例11: main

int
main(void)
{
	char sfn[24];
	char buf[sizeof(TEXT)];
	FILE *sfp;
	int fd;

	strlcpy(sfn, "/tmp/barnacles.XXXXXXXX", sizeof(sfn));
	if ((fd = mkstemp(sfn)) == -1 ||
	    (sfp = fdopen(fd, "w+")) == NULL) {
		int saved_errno = errno;
		if (fd != -1) {
			unlink(sfn);
			close(fd);
		}
		errc(1, saved_errno, "could not open temporary file");
	}

	run_threads(fwrite_thread, sfp);

	while (fread(buf, sizeof(char), strlen(TEXT), sfp))	/* verify */
		if (strncmp(buf, TEXT, sizeof(TEXT)))
			err(1, "Thread writes were not atomic!!!");

	unlink(sfn);
	close(fd);

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


示例12: fcopy

int
fcopy(char *src, char *dst, mode_t mode)
{
	int		ifd, ofd;
	u_int8_t	buf[BUFSIZ];
	ssize_t		r;

	if ((ifd = open(src, O_RDONLY)) == -1)
		err(1, "open %s", src);

	if ((ofd = open(dst, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1) {
		int saved_errno = errno;
		close(ifd);
		errc(1, saved_errno, "open %s", dst);
	}

	while ((r = read(ifd, buf, sizeof(buf))) > 0) {
		write(ofd, buf, r);
	}

	close(ofd);
	close(ifd);

	return (r == -1);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:25,代码来源:ikeca.c


示例13: pam_start

context::context(const std::string& service, const std::string& username)
{
    auto s = app::clone(service), u = username.size() ? app::clone(username) : nullptr;
    pam_conv conv = { despatch, this };

    _M_code = pam_start(s.get(), u.get(), &conv, &_M_pamh);
    if(errc(_M_code) != errc::success) throw pam_error(_M_code);
}
开发者ID:dimitry-ishenko,项目名称:camel,代码行数:8,代码来源:pam.cpp


示例14: clear_history

static void
clear_history(void)
{
    if (ioctl(0, CONS_CLRHIST) == -1) {
        revert();
        errc(1, errno, "clearing history buffer");
    }
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:8,代码来源:vidcontrol.c


示例15: load_default_vt4font

static void
load_default_vt4font(void)
{
	if (ioctl(0, PIO_VFONT_DEFAULT) == -1) {
		revert();
		errc(1, errno, "loading default vt font");
	}
}
开发者ID:jamesbjackson,项目名称:src,代码行数:8,代码来源:vidcontrol.c


示例16: ccom

char ccom(char c){
    if( c == '*' )
        return cBlockComment();
    if( c == '/' )
        return cLineComment();
    else
        errc("not a comment start /", c);
    return c;
}
开发者ID:theme,项目名称:K_R,代码行数:9,代码来源:e1-24.c


示例17: cquotes

char cquotes(char q){
    if( q == '\'' )
        return cCharConst();
    if( q == '\"' )
        return cString();
    else
        errc("not a quotes start", q);
    return q;
}
开发者ID:theme,项目名称:K_R,代码行数:9,代码来源:e1-24.c


示例18: reorder_syms

void
reorder_syms(Elf_Ehdr * ehdr, Elf_Shdr * symsect,
    Elf_Sym * symtab, int symtabsize, int symtabsecnum)
{
	int             i;
	int             nsyms;
	int             cursym;
	Elf_Sym        *tmpsymtab;
	Symmap         *symmap;


	nsyms = symtabsize / sizeof(Elf_Sym);

	tmpsymtab = (Elf_Sym *) calloc(1, symtabsize);
	symmap = (Symmap *) calloc(nsyms, sizeof(Symmap));
	if (!tmpsymtab || !symmap)
		errc(5, ENOMEM, "calloc");

	bcopy(symtab, tmpsymtab, symtabsize);

	cursym = 1;
	for (i = 1; i < nsyms; i++) {
		if ((tmpsymtab[i].st_info & 0xf0) == 0x00) {
#ifdef DEBUG
			printf("copying  l o%d n%d <%s>\n", i, cursym,
			    get_str(tmpsymtab[i].st_name));
#endif
			bcopy(&(tmpsymtab[i]), &(symtab[cursym]),
			    sizeof(Elf_Sym));
			symmap[i] = cursym;
			cursym++;
		}
	}
	symsect->sh_info = cursym;
	for (i = 1; i < nsyms; i++) {
		if ((tmpsymtab[i].st_info & 0xf0) != 0x00) {
#ifdef DEBUG
			printf("copying nl o%d n%d <%s>\n", i, cursym,
			    get_str(tmpsymtab[i].st_name));
#endif
			bcopy(&(tmpsymtab[i]), &(symtab[cursym]),
			    sizeof(Elf_Sym));
			symmap[i] = cursym;
			cursym++;
		}
	}
	if (cursym != nsyms) {
		printf("miscounted symbols somewhere c %d n %d \n",
		    cursym, nsyms);
		exit(5);
	}
	renum_reloc_syms(ehdr, symmap, symtabsecnum);
	free(tmpsymtab);
	free(symmap);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:55,代码来源:elf_hide.c


示例19: cBlockComment

char cBlockComment(){
    char e, f;
    e = gc();
    if( e == EOF )
        return e;
    if( e == '*' ){
        f = gc();
        if( f == EOF || f == '/')
            return f;
    }else{
        while ( (f = gc() ) != EOF)
        {
            if ( e == '*' && f == '/'){
                return f;
            }else {
                if( e =='/' && f == '*' )
                    printf("%ld:%ld: warning: /* in block comment\n",
                            crow, ccol );
                e = f;
            }
        }
        return EOF;
    }

    while ( ( e = gc() ) != EOF && e != '*')
        ;

    if ( e == '*'){
        if((f = gc()) != EOF){
            if ( f == '/')
                return '/';
            else
                return cBlockComment();
        }else{
            errc("\tbroken block comment at EOF", ' ');
            return EOF;
        }
    }else{
        errc("\tbroken block comment at EOF", ' ');
        return EOF;
    }
}
开发者ID:theme,项目名称:K_R,代码行数:42,代码来源:e1-24.c


示例20: pam_get_item

std::string context::get(pam::item item, bool* found)
{
    if(item == pam::item::conv || item == pam::item::fail_delay) throw item_error(_M_pamh, errc::bad_item);

    const void* x = nullptr;
    _M_code = pam_get_item(_M_pamh, static_cast<int>(item), &x);
    if(errc(_M_code) != errc::success) throw item_error(_M_pamh, _M_code);

    if(found) *found = x;
    return x ? std::string(static_cast<const char*>(x)) : std::string();
}
开发者ID:dimitry-ishenko,项目名称:camel,代码行数:11,代码来源:pam.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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