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


C++ perror_msg_and_die函数代码示例

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


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

示例1: ensure_writable_dir_group

void ensure_writable_dir_group(const char *dir, mode_t mode, const char *user, const char *group)
{
    struct passwd *pw = getpwnam(user);
    if (!pw)
        perror_msg_and_die("Can't find user '%s'", user);

    struct group *gr = getgrnam(group);
    if (!gr)
        perror_msg_and_die("Can't find group '%s'", group);

    ensure_writable_dir_uid_gid(dir, mode, pw->pw_uid, gr->gr_gid);
}
开发者ID:xsulca00,项目名称:abrt,代码行数:12,代码来源:hooklib.c

示例2: do_loadtable

static void
do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
{
	struct unimapinit advice;
	struct unimapdesc ud;
	struct unipair *up;
	int ct = 0, maxct;
	int glyph;
	u_short unicode;

	maxct = tailsz;				/* more than enough */
	up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));

	for (glyph = 0; glyph < fontsize; glyph++) {
		while (tailsz >= 2) {
			unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
			tailsz -= 2;
			inbuf += 2;
			if (unicode == PSF_SEPARATOR)
				break;
			up[ct].unicode = unicode;
			up[ct].fontpos = glyph;
			ct++;
		}
	}

	/* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP
	   this printf did not work on many kernels */

	advice.advised_hashsize = 0;
	advice.advised_hashstep = 0;
	advice.advised_hashlevel = 0;
	if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
		if (errno == ENOIOCTLCMD) {
			error_msg("It seems this kernel is older than 1.1.92");
			error_msg_and_die("No Unicode mapping table loaded.");
		} else
#endif
			perror_msg_and_die("PIO_UNIMAPCLR");
	}
	ud.entry_ct = ct;
	ud.entries = up;
	if (ioctl(fd, PIO_UNIMAP, &ud)) {
#if 0
		if (errno == ENOMEM) {
			/* change advice parameters */
		}
#endif
		perror_msg_and_die("PIO_UNIMAP");
	}
}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:52,代码来源:loadfont.c

示例3: parse_devtable

static int parse_devtable(FILE * devtable)
{
	struct stat sb;

	if (lstat(rootdir, &sb)) {
		perror_msg_and_die("%s", rootdir);
	}
	if (chdir(rootdir))
		perror_msg_and_die("%s", rootdir);

	if (devtable)
		parse_device_table(devtable);

	return 0;
}
开发者ID:01org,项目名称:luv-yocto,代码行数:15,代码来源:makedevs.c

示例4: go

static int go(char *dname, FILE * devtable)
{
	struct stat sb;

	if (lstat(dname, &sb)) {
		perror_msg_and_die("%s", dname);
	}
	if (chdir(dname))
		perror_msg_and_die("%s", dname);

	if (devtable)
		parse_device_table(devtable);

	return 0;
}
开发者ID:jacobbarsoe,项目名称:rpi-base,代码行数:15,代码来源:makedevs.c

示例5: fstat_st_size_or_die

off_t fstat_st_size_or_die(int fd)
{
    struct stat statbuf;
    if (fstat(fd, &statbuf))
        perror_msg_and_die("Can't stat");
    return statbuf.st_size;
}
开发者ID:credmon,项目名称:libreport,代码行数:7,代码来源:xfuncs.c

示例6: realloc

extern void *xrealloc(void *ptr, size_t size)
{
	ptr = realloc(ptr, size);
	if (ptr == NULL && size != 0)
		perror_msg_and_die("realloc");
	return ptr;
}
开发者ID:0x000000FF,项目名称:opkg4edison,代码行数:7,代码来源:xfuncs.c

示例7: stat_st_size_or_die

off_t stat_st_size_or_die(const char *filename)
{
    struct stat statbuf;
    if (stat(filename, &statbuf))
        perror_msg_and_die("Can't stat '%s'", filename);
    return statbuf.st_size;
}
开发者ID:credmon,项目名称:libreport,代码行数:7,代码来源:xfuncs.c

示例8: xdup

int xdup(int from)
{
    int fd = dup(from);
    if (fd < 0)
        perror_msg_and_die("Can't duplicate file descriptor");
    return fd;
}
开发者ID:credmon,项目名称:libreport,代码行数:7,代码来源:xfuncs.c

示例9: calloc

extern void *xcalloc(size_t nmemb, size_t size)
{
	void *ptr = calloc(nmemb, size);
	if (ptr == NULL && nmemb != 0 && size != 0)
		perror_msg_and_die("calloc");
	return ptr;
}
开发者ID:0x000000FF,项目名称:opkg4edison,代码行数:7,代码来源:xfuncs.c

示例10: mkfifo_main

extern int mkfifo_main(int argc, char **argv)
{
	char *thisarg;
	mode_t mode = 0666;

	argc--;
	argv++;

	/* Parse any options */
	while (argc > 1) {
		if (**argv != '-')
			show_usage();
		thisarg = *argv;
		thisarg++;
		switch (*thisarg) {
		case 'm':
			argc--;
			argv++;
			parse_mode(*argv, &mode);
			break;
		default:
			show_usage();
		}
		argc--;
		argv++;
	}
	if (argc < 1 || *argv[0] == '-')
		show_usage();
	if (mkfifo(*argv, mode) < 0)
		perror_msg_and_die("mkfifo");
	return EXIT_SUCCESS;
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:32,代码来源:mkfifo.c

示例11: perror_msg_and_die

FILE *xfopen(const char *path, const char *mode)
{
	FILE *fp;
	if ((fp = fopen(path, mode)) == NULL)
		perror_msg_and_die("%s", path);
	return fp;
}
开发者ID:0x000000FF,项目名称:opkg4edison,代码行数:7,代码来源:xfuncs.c

示例12: do_loadfont

static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
{
	char buf[16384];
	int i;

	memset(buf, 0, sizeof(buf));

	if (unit < 1 || unit > 32)
		error_msg_and_die("Bad character size %d", unit);

	for (i = 0; i < fontsize; i++)
		memcpy(buf + (32 * i), inbuf + (unit * i), unit);

#if defined( PIO_FONTX ) && !defined( __sparc__ )
	{
		struct consolefontdesc cfd;

		cfd.charcount = fontsize;
		cfd.charheight = unit;
		cfd.chardata = buf;

		if (ioctl(fd, PIO_FONTX, &cfd) == 0)
			return;				/* success */
		perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
	}
#endif
	if (ioctl(fd, PIO_FONT, buf))
		perror_msg_and_die("PIO_FONT ioctl error");
}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:29,代码来源:loadfont.c

示例13: fdopen

FILE *xfdopen(int fd, const char *mode)
{
    FILE *const r = fdopen(fd, mode);
    if (NULL == r)
        perror_msg_and_die("Can't open file descriptor %d as FILE", fd);
    return r;
}
开发者ID:abrt,项目名称:libreport,代码行数:7,代码来源:xfuncs.c

示例14: malloc

extern void *xmalloc(size_t size)
{
	void *ptr = malloc(size);
	if (ptr == NULL && size != 0)
		perror_msg_and_die("malloc");
	return ptr;
}
开发者ID:0x000000FF,项目名称:opkg4edison,代码行数:7,代码来源:xfuncs.c

示例15: klogd_main

extern int klogd_main(int argc, char **argv)
{
	/* no options, no getopt */
	int opt;
	int doFork = TRUE;

	/* do normal option parsing */
	while ((opt = getopt(argc, argv, "n")) > 0) {
		switch (opt) {
			case 'n':
				doFork = FALSE;
				break;
			default:
				show_usage();
		}
	}

	if (doFork) {
#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__)
		if (daemon(0, 1) < 0)
			perror_msg_and_die("daemon");
#else
			error_msg_and_die("daemon not supported");
#endif
	}
	doKlogd();
	
	return EXIT_SUCCESS;
}
开发者ID:zipangotes,项目名称:DSL-G624T_GPL_code,代码行数:29,代码来源:klogd.c


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