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

C++ err_exit函数代码示例

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

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



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

示例1: verrx

void
verrx(int eval, const char *fmt, va_list ap)
{
	if (err_file == NULL)
		err_set_file(NULL);
	fprintf(err_file, "%s: ", _getprogname());
	if (fmt != NULL)
		vfprintf(err_file, fmt, ap);
	fprintf(err_file, "\n");
	if (err_exit)
		err_exit(eval);
	exit(eval);
}
开发者ID:mulichao,项目名称:freebsd,代码行数:13,代码来源:err.c


示例2: main

int
main(void)
{
	int			err;
	pthread_t	tid1, tid2;
	struct foo	*fp;

	err = pthread_create(&tid1, NULL, thr_fn1, NULL);
	if (err != 0)
		err_exit(err, "can't create thread 1");
	err = pthread_join(tid1, (void *)&fp);
	if (err != 0)
		err_exit(err, "can't join with thread 1");
	sleep(1);
	printf("parent starting second thread\n");
	err = pthread_create(&tid2, NULL, thr_fn2, NULL);
	if (err != 0)
		err_exit(err, "can't create thread 2");
	sleep(1);
	printfoo("parent:\n", fp);
	exit(0);
}
开发者ID:LinuxKernelDevelopment,项目名称:apuebookexample,代码行数:22,代码来源:11-4.c


示例3: main

int main(void)
{
	int err;
	pthread_t tid1, tid2;
	void *tret;

	err = pthread_create(&tid1, NULL, thr_fn1, (void *)1);
	if (err != 0)
		err_exit(err, "can't create thread 1");
	err = pthread_create(&tid2, NULL, thr_fn2, (void *)1);
	if (err != 0)
		err_exit(err, "can't create thread 2");
	err = pthread_join(tid1, &tret);
	if (err != 0)
		err_exit(err, "can't join with thread 1");
	printf("thread 1 exit code %ld\n", (long)tret);
	err = pthread_join(tid2, &tret);
	if (err != 0)
		err_exit(err, "can't join with thread 2");
	printf("thread 2 exit code %ld\n", (long)tret);
	exit(0);
}
开发者ID:wuzhouhui,项目名称:misc,代码行数:22,代码来源:11-5.c


示例4: extract_mtk_boot

void extract_mtk_boot(const char *filename, const char *outname) {
	char buf[MTK_PBL_SIZE];
	int n;

	FILE *in = fopen(filename, "rb");
	if (in == NULL)
		err_exit("Can't open file %s\n", filename);

	FILE *out = fopen(outname, "wb");
	if (out == NULL)
		err_exit("Can't open file %s for writing\n", outname);

	n = fread(&buf, 1, MTK_PBL_SIZE, in);
	if (n != MTK_PBL_SIZE) {
		fclose(in);
		err_exit("Error: PBL size mismatch!\n");
	}

	fclose(in);
	fwrite(&buf, 1, MTK_PBL_SIZE, out);
	fclose(out);
}
开发者ID:OliverGesch,项目名称:epk2extract,代码行数:22,代码来源:util.c


示例5: exec_lstopo

/*
 *  Execute lstopo from user's PATH sending full topology XML over stdin.
 *   Pass any extra options along to lstopo(1).
 *
 *  If running lstopo fails with ENOENT, try lstopo-no-graphics.
 */
static int exec_lstopo (optparse_t *p, int ac, char *av[], const char *topo)
{
    int status;
    FILE *fp;
    char *argz;
    size_t argz_len;
    pid_t pid;
    const char *cmds[] = { "lstopo", "lstopo-no-graphics", NULL };
    const char **cp = cmds;

    /* Ignore SIGPIPE so we don't get killed when exec() fails */
    signal (SIGPIPE, SIG_IGN);

    /* Initialize argz with first command in cmds above: */
    lstopo_argz_init ((char *) *cp, &argz, &argz_len, av+1);

    while (true) {
        const char *next = *(cp+1);
        if (!(fp = argz_popen (argz, argz_len, &pid)))
            err_exit ("popen (lstopo)");
        fputs (topo, fp);
        fclose (fp);
        if (waitpid (pid, &status, 0) < 0)
            err_exit ("waitpid");

        /* Break out of loop if exec() was succcessful, failed with
         *  an error other than "File not found", or we ran out programs
         *  to try.
         */
        if (status == 0 || !next || WEXITSTATUS (status) != ENOENT)
            break;

        /* Replace previous cmd in argz with next command to try:
         */
        argz_replace (&argz, &argz_len, *(cp++), next, NULL);
    }

    return (status);
}
开发者ID:tpatki,项目名称:flux-core,代码行数:45,代码来源:hwloc.c


示例6: is_nfsb

int is_nfsb(const char *filename) {
	FILE *file = fopen(filename, "rb");
	if (file == NULL)
		err_exit("Can't open file %s\n\n", filename);

	char header[0x11];
	if (fread(&header, 1, sizeof(header), file) != sizeof(header))
		return 0;
	fclose(file);
	if (memcmp(&header, "NFSB", 4) == 0)
		return !memcmp(&header[0xE], "md5", 3);
	return 0;
}
开发者ID:OliverGesch,项目名称:epk2extract,代码行数:13,代码来源:util.c


示例7: save_score

/* save current score in the score file */
void save_score(const int time_taken) {
    time_t tm = time(NULL);
    struct tm *today = localtime(&tm);
    char tmpbuffer[129];
    today = localtime(&tm);
    char appdata_dir[4096]; //XXX why _PC_PATH_MAX is only 4?
    const char *score_filename = "4digits.4digits.scores";
    strcpy(appdata_dir, getenv("HOME"));
    strcat(appdata_dir, "/.4digits/");
    char *scorefile = (char*)malloc(strlen(appdata_dir) + strlen(score_filename) + 1);
    if(!scorefile)
        err_exit(_("Memory allocation error.\n"));
    strcpy(scorefile, appdata_dir);
    strcat(scorefile, score_filename);

    FILE *sfp = fopen(scorefile, "a+");
    if (!sfp) {
        if (errno == ENOENT) {
            DIR *dp = opendir(appdata_dir);
            if(!dp)
                if (errno == ENOENT) {
                    int ret = mkdir(appdata_dir, 0700);
                    if (ret == -1)
                        err_exit(_("Cannot open score file.\n"));
                    sfp = fopen(scorefile, "a+");
                }
        }
        else
            err_exit(_("Cannot open score file.\n"));
    }

    strftime(tmpbuffer, 128, "%a %b %d %H:%M:%S %Y", today); 
    struct passwd *pwd;
    pwd = getpwuid(geteuid());
    // but getenv("USERNAME") conforms to C99 thus is more portable.
    fprintf(sfp, "%s %ds %s\n", pwd->pw_name, time_taken, tmpbuffer);
    free(scorefile);
}
开发者ID:hsssajx,项目名称:4digits,代码行数:39,代码来源:4digits-text.c


示例8: main

int main(int argc,cahr ** argv)
{
    int err;
    pthread_t  tid;
    char *cmd;
    struct sigaction sa;




    if((cmd=strrchr(argv[0],'/'))==NULL)
        cmd=argv[0];
    else
        cmd++;
    daemonize(cmd);




    if(already_running())
    {
        syslog(LOG_ERR,"daemon  already running");
        exit(1);
    }
    sa.sa_handler=SIG_DEL;
    sigemptyset(&sa.sa_mask);
    sa.sa_flags=0;
    if(sigaction(SIGHUP,&sa,NULL)<0)
        err_quit("%s:can't restore SIGHUP  default");
    sigfillset(&mask);
    if((err=pthread_sigmask(SIG_BLOCK,&mask,NULL))!=0)
        err_exit(err,"SIG_BLOCK error");
    err=pthread_create(&tid,NULL,thr_fn,0);
    if(err!=0)
        err_exit(err,"can't create the thread");
    exit(0);

}
开发者ID:Lewisgreat,项目名称:APUE,代码行数:38,代码来源:02-13_6MySigleDaemon.c


示例9: dlinfo_connect

/*
 * Store the file descriptor to the '*sockfd' which is connected to
 * server already. and return the socket file descriptor also.
 */
int dlinfo_connect(struct dlinfo *dl)
{
	int s;
	int fd;
	struct addrinfo hints;
	struct addrinfo *res;
	struct addrinfo *ai;

	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;

	errno = 0;
	if ((s = getaddrinfo(dl->di_host, dl->di_serv, &hints, &res)) != 0)
		err_exit("getaddrinfo: %s, host: %s:%s", gai_strerror(s),
			 dl->di_host, dl->di_serv);

	for (ai = res; ai; ai = ai->ai_next) {
		if ((fd = socket(ai->ai_family, ai->ai_socktype,
				 ai->ai_protocol)) == -1) {
			err_sys("socket");
			continue;
		}

		if (connect(fd, ai->ai_addr, ai->ai_addrlen) == 0)
			break;

		err_sys("connect");
		if (close(fd) == -1)
			err_sys("close");
	}

	if (NULL == ai)
		err_exit("Couldn't connection to: %s", dl->di_host);

	freeaddrinfo(res);
	return fd;
}
开发者ID:ghmajx,项目名称:baidudl,代码行数:42,代码来源:dlinfo.c


示例10: main

int main(int argc, char *argv[])
{
	int fd, fd2;
	unsigned short sectors, dummy;
	long size, addr1, padd_size, i;
	unsigned char ch;

	if (argc == 1) {
		fprintf(stderr, "Usage: imgsize PNX_IMG ADDR1\n");
		return 0;
	}

	if ((fd = open(argv[1], O_RDWR)) < 0) err_exit(1);

	if ((fd2 = open("ifem.bin", O_RDWR)) < 0) err_exit(1);
	if ((addr1 = lseek(fd2,0,SEEK_END)) < 0) err_exit(1);
	addr1 += 0x600;
	close(fd2);
	
	if ((size = lseek(fd,0,SEEK_END)) < 0) err_exit(1);
	sectors = (size - 512) / 512 + 1;
	
	if (lseek(fd, 2, SEEK_SET) < 0) err_exit(1);
	if (write(fd, (char *)&sectors, sizeof(sectors)) <= 0) err_exit(1);
	if (write(fd, (char *)&addr1, sizeof(addr1)) <= 0) err_exit(1);

	padd_size = size % 512;
	if (lseek(fd, 0, SEEK_END) < 0) err_exit(1);
	for (ch=0, i=padd_size; i>0; i--) 
		if (write(fd, &ch, 1) < 0) err_exit(1);
	
	close(fd);
	
	fprintf(stderr, "===============\n");
	fprintf(stderr, "ImgSize Report:\n");
	fprintf(stderr, "===============\n"); 
	fprintf(stderr, "Kernel image size = %ld bytes\n", size);
	fprintf(stderr, "Kernel image size = %d sectors\n", sectors);
	fprintf(stderr, "Padding size      = %ld bytes\n", padd_size);
	fprintf(stderr, "Kernel image successfully modified!\n");
	
	return 0;
}
开发者ID:bahmanm,项目名称:ifem-os,代码行数:43,代码来源:imgsize.c


示例11: main

/* Changing the msg_qbytes setting of a System V message queue */
int main(int argc, char *argv[])
{
	struct msqid_ds ds;
	int msqid;

	if (argc != 3 || strcmp(argv[1], "--help") == 0)
		usage_err("%s msqid max-bytes\n", argv[0]);

	/* Retrive copy of associate data struct from kernel */

	msqid = get_int(argv[1], 0, "msqid");

	if (msgctrl(msqid, IPC_STAT, &ids) == -1)
		err_exit("msgctl");

	d.msg_qbytes = get_int(argv[2], 0, "max-bytes");
	/* Update associated data structure in kernel */

	if (msgctl(msqid, IPC_SET, &ds) == -1)
		err_exit("msgctl");

	exit(EXIT_SUCCESS);
}
开发者ID:Jingtian1989,项目名称:lightlib,代码行数:24,代码来源:svmsg_chqbytes.c


示例12: init_double_link

dll_t *
init_double_link( )
{
    dll_t *dll;
    dll = (dll_t*)calloc(1,sizeof(dll_t));
    if(dll == NULL) {
        err_exit("calloc error\n");
    }
    
    dll->prev = dll;/*??prev == NULL or prev = itself??*/
    dll->next = dll;

    return dll;
}
开发者ID:liahung,项目名称:IntroductionToAlgorithm-Third-Edition,代码行数:14,代码来源:double_linked_list.c


示例13: isSTRfile

int isSTRfile(const char *filename) {
	FILE *file = fopen(filename, "rb");
	if (file == NULL) {
		err_exit("Can't open file %s\n", filename);
	}
	size_t headerSize = 0xC0 * 4;
	unsigned char buffer[headerSize];
	int read = fread(&buffer, 1, headerSize, file);
	int result = 0;
	if (read == headerSize && buffer[4] == 0x47 && buffer[0xC0 + 4] == 0x47 && buffer[0xC0 * 2 + 4] == 0x47 && buffer[0xC0 * 3 + 4] == 0x47)
		result = 1;
	fclose(file);
	return result;
}
开发者ID:OliverGesch,项目名称:epk2extract,代码行数:14,代码来源:util.c


示例14: main

int main (int argc, char *argv[])
{
    flux_t h;
    int ch;
    bool uopt = false;
    bool dopt = false;
    fmt_t fmt = FMT_RANGED;
    ns_t *ns;

    log_init ("flux-up");

    while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) {
        switch (ch) {
            case 'c': /* --comma */
                fmt = FMT_COMMA;
                break;
            case 'n': /* --newline */
                fmt = FMT_NEWLINE;
                break;
            case 'u': /* --up */
                uopt = true;
                break;
            case 'd': /* --down */
                dopt = true;
                break;
            default:
                usage ();
                break;
        }
    }
    if (optind != argc)
        usage ();

    if (!(h = flux_open (NULL, 0)))
        err_exit ("flux_open");

    if (!(ns = ns_fromkvs (h)))
        ns = ns_guess (h);
    if (dopt)
        ns_print_down (ns, fmt);
    else if (uopt)
        ns_print_up (ns, fmt);
    else
        ns_print_all (ns, fmt);
    ns_destroy (ns);

    flux_close (h);
    log_fini ();
    return 0;
}
开发者ID:dinesh121991,项目名称:flux-core,代码行数:50,代码来源:flux-up.c


示例15: push2queueout

/*
 *
 *  Read from input stream the field from current position upto and including next delimiter.
 *
 */
static void push2queueout(struct streams *s, struct queues *q, int c)
{
  int i,len;
   struct streams *t;
  t=&outstream;

  queuec_siz=QUEUEC_S;
  q->cont=malloc(queuec_siz*sizeof(char));
  if (q->cont==NULL) err_exit(ERR_PRO_QUE);
  
  len=0;
  while ((i=fgetc(s->fp)) != c) {            
    if (len+1 > queuec_siz) {
      queuec_siz*=2;
      q->cont=realloc(q->cont,queuec_siz*sizeof(char));
      if (q->cont==NULL) err_exit(ERR_PRO_QUE);
    }
    q->cont[len++]=i;
  }
  q->cont[len]='\0';
if (c != *(s->delim)) ungetc(i,s->fp);
  fprintf(t->fp,"%s",q->cont);
}
开发者ID:ajwvm,项目名称:dsvvalid,代码行数:28,代码来源:s_process.c


示例16: extract_kernel

void extract_kernel(const char *image_file, const char *destination_file) {
	FILE *file = fopen(image_file, "rb");
	if (file == NULL)
		err_exit("Can't open file %s", image_file);

	fseek(file, 0, SEEK_END);
	int fileLength = ftell(file);
	rewind(file);
	unsigned char *buffer = malloc(fileLength);
	int read = fread(buffer, 1, fileLength, file);
	if (read != fileLength) {
		err_exit("Error reading file. read %d bytes from %d.\n", read, fileLength);
		free(buffer);
	}
	fclose(file);

	struct image_header *image_header = (struct image_header *)(&buffer);
	FILE *out = fopen(destination_file, "wb");
	int header_size = sizeof(struct image_header);
	fwrite(buffer + header_size, 1, read - header_size, out);
	free(buffer);
	fclose(out);
}
开发者ID:OliverGesch,项目名称:epk2extract,代码行数:23,代码来源:util.c


示例17: test_unwatch

/* Timer pops every 1 ms, writing a new value to key.
 * After 10 calls, it calls kvs_unwatch().
 * After 20 calls, it calls flux_reactor_stop().
 * The kvs_unwatch_cb() counts the number of times it is called, should be 10.
 */
void test_unwatch (int argc, char **argv)
{
    flux_t h;
    char *key;
    int count = 0;

    if (argc != 1) {
        fprintf (stderr, "Usage: unwatch key\n");
        exit (1);
    }
    key = argv[0];
    if (!(h = flux_open (NULL, 0)))
        err_exit ("flux_open");
    if (kvs_watch_int (h, key, unwatch_watch_cb, &count) < 0)
        err_exit ("kvs_watch_int %s", key);
    if (flux_tmouthandler_add (h, 1, false, unwatch_timer_cb, key) < 0)
        err_exit ("flux_tmouthandler_add");
    if (flux_reactor_start (h) < 0)
        err_exit ("flux_reactor_start");
    if (count != 10)
        msg_exit ("watch called %d times (should be 10)", count);
    flux_close (h);
}
开发者ID:tpatki,项目名称:flux-core,代码行数:28,代码来源:watch.c


示例18: _start_cmd

static void
_start_cmd (void)
{
  uint8_t timer_state;

  if (_get_watchdog_timer_cmd (NULL,
			       &timer_state,
			       NULL,
			       NULL,
			       NULL,
			       NULL,
			       NULL,
			       NULL,
			       NULL,
			       NULL,
			       NULL,
			       NULL,
			       NULL) < 0)
    _ipmi_err_exit ("Get Watchdog Timer Error");

  if (!timer_state)
    {
      if (_reset_watchdog_timer_cmd () < 0)
        _ipmi_err_exit ("Reset Watchdog Timer Error");
    }


  if (cmd_args.gratuitous_arp || cmd_args.arp_response)
    {
      uint8_t gratuitous_arp, arp_response;
      int ret;

      if (cmd_args.gratuitous_arp)
        gratuitous_arp = cmd_args.gratuitous_arp_arg;
      else
        gratuitous_arp = IPMI_BMC_GENERATED_GRATUITOUS_ARP_DO_NOT_SUSPEND;

      if (cmd_args.arp_response)
        arp_response = cmd_args.arp_response_arg;
      else
        arp_response = IPMI_BMC_GENERATED_ARP_RESPONSE_DO_NOT_SUSPEND;

      if ((ret = _suspend_bmc_arps_cmd (gratuitous_arp,
					arp_response)) < 0)
        _ipmi_err_exit ("Suspend BMC ARPs Error");

      if (!ret)
	err_exit ("cannot suspend BMC ARPs"); 
    }
}
开发者ID:NodePrime,项目名称:freeipmi,代码行数:50,代码来源:bmc-watchdog.c


示例19: _cb_host

static int
_cb_host (conffile_t cf,
          struct conffile_data *data,
          char *optionname,
          int option_type,
          void *option_ptr,
          int option_data,
          void *app_ptr,
          int app_data)
{
  if (!hostlist_push (conf.hosts, data->string))
    err_exit ("hostlist_push: %s", strerror (errno));
  return (0);
}
开发者ID:NodePrime,项目名称:freeipmi,代码行数:14,代码来源:ipmidetectd-config.c


示例20: attach_stdin_ready_cb

static void attach_stdin_ready_cb (flux_reactor_t *r, flux_watcher_t *w,
                                   int revents, void *arg)
{
    int fd = flux_fd_watcher_get_fd (w);
    ctx_t *ctx = arg;
    char *buf = xzmalloc (ctx->blocksize);
    int len;

    do  {
        if ((len = read (fd, buf, ctx->blocksize)) < 0) {
            if (errno != EAGAIN)
                err_exit ("read stdin");
        } else if (len > 0) {
            if (kz_put (ctx->kz[0], buf, len) < 0)
                err_exit ("kz_put");
        }
    } while (len > 0);
    if (len == 0) { /* EOF */
        if (kz_close (ctx->kz[0]) < 0)
            err_exit ("kz_close");
    }
    free (buf);
}
开发者ID:tpatki,项目名称:flux-core,代码行数:23,代码来源:kzutil.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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