当前位置: 首页>>代码示例>>C++>>正文


C++ errc函数代码示例

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


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


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