本文整理汇总了C++中perror_msg_and_die函数的典型用法代码示例。如果您正苦于以下问题:C++ perror_msg_and_die函数的具体用法?C++ perror_msg_and_die怎么用?C++ perror_msg_and_die使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了perror_msg_and_die函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: xopen3
// Die if we can't open a file and return a fd
int xopen3(const char *pathname, int flags, int mode)
{
int ret;
ret = open(pathname, flags, mode);
if (ret < 0)
perror_msg_and_die("Can't open '%s'", pathname);
return ret;
}
开发者ID:credmon,项目名称:libreport,代码行数:9,代码来源:xfuncs.c
示例17: ensure_writable_dir
void ensure_writable_dir(const char *dir, mode_t mode, const char *user)
{
struct passwd *pw = getpwnam(user);
if (!pw)
perror_msg_and_die("Can't find user '%s'", user);
ensure_writable_dir_uid_gid(dir, mode, pw->pw_uid, pw->pw_gid);
}
开发者ID:arhledvink,项目名称:abrt,代码行数:8,代码来源:hooklib.c
示例18: add_watch_or_die
/* Helpers */
static guint add_watch_or_die(GIOChannel *channel, unsigned condition, GIOFunc func)
{
errno = 0;
guint r = g_io_add_watch(channel, (GIOCondition)condition, func, NULL);
if (!r)
perror_msg_and_die("g_io_add_watch failed");
return r;
}
开发者ID:wlindauer,项目名称:abrt,代码行数:9,代码来源:abrtd.c
示例19: 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);
recursive_add_directory(".");
if (devtable)
parse_device_table(devtable);
create_target_filesystem();
cleanup();
return 0;
}
开发者ID:nhanh0,项目名称:hah,代码行数:18,代码来源:mkfs.jffs2.c
示例20: ensure_writable_dir
void ensure_writable_dir(const char *dir, mode_t mode, const char *user)
{
struct stat sb;
if (mkdir(dir, mode) != 0 && errno != EEXIST)
perror_msg_and_die("Can't create '%s'", dir);
if (stat(dir, &sb) != 0 || !S_ISDIR(sb.st_mode))
error_msg_and_die("'%s' is not a directory", dir);
struct passwd *pw = getpwnam(user);
if (!pw)
perror_msg_and_die("Can't find user '%s'", user);
if ((sb.st_uid != pw->pw_uid || sb.st_gid != pw->pw_gid) && lchown(dir, pw->pw_uid, pw->pw_gid) != 0)
perror_msg_and_die("Can't set owner %u:%u on '%s'", (unsigned int)pw->pw_uid, (unsigned int)pw->pw_gid, dir);
if ((sb.st_mode & 07777) != mode && chmod(dir, mode) != 0)
perror_msg_and_die("Can't set mode %o on '%s'", mode, dir);
}
开发者ID:RavenB,项目名称:abrt,代码行数:18,代码来源:hooklib.c
注:本文中的perror_msg_and_die函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论