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

C++ err_ret函数代码示例

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

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



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

示例1: main

int main(int argc,char **argv)
{
	int i,fd;
	unsigned char c,*ptr;
	struct stat stat;
	
	if(argc!=2)
		err_quit("usgae: shmread <name>");
	fd=Shm_open(argv[1],O_RDONLY,FILE_MODE);
	Fstat(fd,&stat);
	ptr=Mmap(NULL,stat.st_size,PROT_READ,MAP_SHARED,fd,0);

	Close(fd);

	for(i=0;i<stat.st_size;i++)
		if((c=*ptr++)!=(i%256))
			err_ret("ptr[%d] =%d",i,c);
	exit(0);
}
开发者ID:woai110120130,项目名称:unix,代码行数:19,代码来源:shmread.c


示例2: swap_straddr

int
swap_straddr(char *src, char *dst)
{
	char a[3];
	int i, slen;
	char *crow, *tmp, *atom;
	int count = 0, offset = 0;

	slen = strlen(src);
	if (slen > DNS_MAX_HNAME_LEN)
		goto mlf_addr;
	tmp = src;
	for (i = 0; i < 4; i++) {
		count = 0;
		atom = a;
		while (*tmp && *tmp != '.') {
			if (count > 2)
				goto mlf_addr;
			*atom++ = *tmp++;
			count++;
		}
		if (!count)
			goto mlf_addr;
		crow = dst + slen - count - offset;
		strncpy(crow, a, count);
		offset += count;
		if (!(*tmp))
			break;
		else {
			if (i == 3)
				goto mlf_addr;
			*(crow - 1) = '.';
			offset++;
			tmp++;
		}

	}
	*(dst + slen) = 0;
	return 0;
  mlf_addr:
	debug(DBG_INSANE, "in swap_straddr: invalid address `%s`.\n", src);
	err_ret(ERR_DNSMDD, -1);
}
开发者ID:Netsukuku,项目名称:netsukuku,代码行数:43,代码来源:dnslib.c


示例3: dopath

/* 
 * Descend through the hierachy, starting at "fullpath".
 * If "fullpath" is anything other than a directory, we lstat() it,
 * recursively for each name in the directory.
 */
static int dopath(Func *func)
{
	struct stat statbuf;
	struct dirent *dirp;
	DIR *dp;
	int ret, n;

	if (lstat(fullpath, &statbuf) < 0) /* stat error */
		return (func(fullpath, &statbuf, FTW_NS));
	if (S_ISDIR(statbuf.st_mode) == 0) /* not a directory */
		return (func(fullpath, &statbuf, FTW_F));

	/*
	 * It's a directory. First call func() for the directory,
	 * then process each filename in the directory.
	 */
	if ((ret = func(fullpath, &statbuf, FTW_D)) != 0)
		return (ret);
	n = strlen(fullpath);
	if (n + NAME_MAX + 2 > pathlen) { /* expand path buffer */
		pathlen *= 2;
		if ((realloc(fullpath, pathlen)) == NULL)
			err_sys("realloc failed");
	}
	fullpath[n++] = '/';
	fullpath[n] = 0;

	if ((dp = opendir(fullpath)) == NULL) /* cannot read directory */
		return(func(fullpath, &statbuf, FTW_DNR));

	while ((dirp = readdir(dp)) != NULL) {
		if (strcmp(dirp->d_name, ".") == 0 ||
		    strcmp(dirp->d_name, "..") == 0)
			continue; /* ignore dot and dot-dot */
		strcpy(&fullpath[n], dirp->d_name); /* append after "/" */
		if ((ret = dopath(func)) != 0)
			break;	/* time to leave */
	}
	fullpath[n-1] = 0;	/* erase everything from slash onward */
	if (closedir(dp) < 0)
		err_ret("Cannot close dir: %s", fullpath);
	return ret;
}
开发者ID:tcharding,项目名称:self_learning,代码行数:48,代码来源:traverse.c


示例4: dopath

/*
 * Descend through the hierarchy, starting at "fullpath".
 * If "fullpath" is anything other than a directory, we lstat() it,
 * call func(), and return. For a directory, we all ourself
 * recursively for each name in the directory.
 */
static int dopath(Myfunc* func)             /* we return whatever func() returns */
{   
    struct stat         statbuf;
    struct dirent       *dirp;
    DIR                 *dp;
    int                 ret;
    char                *ptr;

    if (lstat(fullpath, &statbuf) < 0)      /* stat error */
        return(func(fullpath, &statbuf, FTW_NS));
    if (S_ISDIR(statbuf.st_mode) == 0)      /* not a directory */
        return(func(fullpath, &statbuf, FTW_F));

    /*
     * It's a directory. First call func() for the directory,
     * then process each filename in the directory.
     */
    if ((ret = func(fullpath, &statbuf, FTW_D)) != 0)
        return(ret);
    
    ptr = fullpath + strlen(fullpath);      /* point to end of fullpath */
    *ptr++ = '/';
    *ptr = 0;

    if ((dp = opendir(fullpath)) == NULL)   /* can't read directory */
        return(func(fullpath, &statbuf, FTW_DNR));

    while ((dirp = readdir(dp)) != NULL) {
        if (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0)
            continue;                       /* ignore dot and dot-dot */

        strcpy(ptr, dirp->d_name);          /* append name after slash */

        if ((ret = dopath(func)) != 0)      /* recursive */
            break;                          /* time to leave */
    }
    ptr[-1] = 0;                            /* erase everything from slash onward */

    if (closedir(dp) < 0)
        err_ret("can't close directory %s", fullpath);
    return(ret);
}
开发者ID:ElvisKwok,项目名称:code,代码行数:48,代码来源:4-21.c


示例5: main

int main (int argc, char **argv)
{
	int fd;
	int i;

	if (argc < 2)
		err_quit ("Usage: isastream file ...");

	for (i = 1; i < argc; i++) {
		if ((fd = open (argv [i], O_RDONLY)) == -1) {
			err_ret ("Can't open %s", argv [i]);
			continue;
		}

		printf ("%s %s a STREAMS device\n", argv [i],
			(isastream (fd)) ? "is" : "is not");
	}

	return (0);
}
开发者ID:AlexKordic,项目名称:sandbox,代码行数:20,代码来源:isastream.c


示例6: getlblptr

/*
 * Takes a label: is there a ptr?
 * Returns:
 *      -1  is a malformed label is found
 *       0  if there's no pointer
 *      <offset from start_pkt> if a pointer is found
 */
int
getlblptr(char *buf)
{
	uint16_t dlbl;
	char c[2];

	memcpy(c, buf, 2);

	if (!LBL_PTR(*c))			/* No ptr */
		return 0;
	if (LBL_PTR(*c) != LBL_PTR_MASK) {
		debug(DBG_INSANE, "In getlblptr: invalid octet %02x",
			  (unsigned char) c[0]);
		err_ret(ERR_DNSMLO, -1);
	}
	(*c) &= LBL_PTR_OFF_MASK;
	memcpy(&dlbl, c, 2);
	dlbl = ntohs(dlbl);
	return dlbl;				/* offset */
}
开发者ID:Netsukuku,项目名称:netsukuku,代码行数:27,代码来源:dnslib.c


示例7: delete_ntk_forward_chain

int
delete_ntk_forward_chain(iptc_handle_t * t)
{
	int res;

	res = iptc_is_chain(NTK_MARK_CHAIN, *t);
	if (!res)
		return 0;
	res = iptc_flush_entries(NTK_MARK_CHAIN, t);
	if (!res)
		goto cannot_delete;
	res = iptc_delete_chain(NTK_MARK_CHAIN, t);
	if (!res)
		goto cannot_delete;
	return 0;

  cannot_delete:
	error("In delete_ntk_forward_chain: -> %s", iptc_strerror(errno));
	err_ret(ERR_NETDEL, -1);
}
开发者ID:willsure,项目名称:netsukuku,代码行数:20,代码来源:mark.c


示例8: main

int main(int argc, char *argv[])
{
	int i;
	struct stat buf;
	for (i = 1; i < argc; i++) {
		printf("%s: ", argv[i]);
		if (stat(argv[i], &buf) < 0) {
			err_ret("stat error");
			continue;
		}
		printf("dev = %d/%d", major(buf.st_dev), minor(buf.st_dev));
		if (S_ISCHR(buf.st_mode) || S_ISBLK(buf.st_mode)) {
			printf(" (%s) rdev = %d/%d",
					(S_ISCHR(buf.st_mode)) ? "character" : "block",
					major(buf.st_dev), minor(buf.st_dev));
		}
		printf("/n");
	}
	exit(0);
}
开发者ID:kaiiak,项目名称:APUE,代码行数:20,代码来源:4.25.c


示例9: d_qsts_u

/*
 * Disassembles a DNS qst_section_set.
 * Use the above function for each question section.
 * -1 on error. Number of bytes readed on success.
 *  If -1 is returned, rcode ha sto be set to E_INTRPRT
 */
int
d_qsts_u(char *start_buf, char *buf, dns_pkt * dp, int limit_len)
{
	int offset = 0, res;
	int i, count;

	if (!(count = DP_QDCOUNT(dp)))
		return 0;				/* No questions. */

	for (i = 0; i < count; i++) {
		if ((res =
			 d_qst_u(start_buf, buf + offset, dp,
					 limit_len - offset)) == -1) {
			error(err_str);
			err_ret(ERR_DNSMDD, -1);
		}
		offset += res;
	}
	return offset;
}
开发者ID:Netsukuku,项目名称:netsukuku,代码行数:26,代码来源:dnslib.c


示例10: main

int main(int argc, char *argv[]) {
    int i;
    struct stat buf;
    char *ptr;

    for (i = 1; i < argc; i++) {
        if (stat(argv[i], &buf) < 0) {
            err_ret("lstat error");
            continue;
        }
        if (S_ISREG(buf.st_mode) ) 
            ptr = "regular";
        else if (S_ISDIR(buf.st_mode) ) 
            ptr = "directory";

        printf("%s\n", ptr);
    }

    exit(0);
}
开发者ID:Alastiran,项目名称:learn,代码行数:20,代码来源:file_types.c


示例11: main

int main(void){
    char buf[MAXLINE];
    pid_t pid;
    int status;
    printf("%% ");
    while(fgets(buf,MAXLINE,stdin)!=NULL){
        buf[strlen(buf)-1]=0;
        if((pid=fork())<0)
            err_sys("fork error");
        else if(pid==0){
            execlp(buf,buf,(char*)0);
            err_ret("could not execute:%s",buf);
            exit(127);
        }
        if((pid=waitpid(pid,&status,0))<0)
            err_sys("waitpid error");
        printf("%% ");
    }
    exit(0);
}
开发者ID:gettogetto,项目名称:Apue-Learn-Code,代码行数:20,代码来源:1_5_fork.c


示例12: main

int main(int argc, char const *argv[])
{
  int apipe[2], len;
  char buf[BUFSIZE];

  if (pipe(apipe) == -1)
    err_ret("pipe error", "");

  printf("Got a pipe. It is descriptors: %d, %d\n", apipe[0], apipe[1]);

  if ((fgets(buf, BUFSIZE, stdin)) != NULL)
  {
    write(apipe[1], buf, strlen(buf));
  }

  len = read(apipe[0], buf, BUFSIZE);
  write(1, buf, len);

  return 0;
}
开发者ID:yangmiemie,项目名称:books,代码行数:20,代码来源:pipedemo.c


示例13: main

int main(void)
{
	STARTUPINFO si;
	PROCESS_INFORMATION pi;
	DWORD dwChildID = 0;
	char szBuff[MAXLINE];

	// Initialize data
	ZeroMemory( &si, sizeof(si) );
	si.cb = sizeof(si);
	ZeroMemory( &pi, sizeof(pi) );

	printf("%% ");	/* print prompt (printf requires %% to print %) */
	while (fgets(szBuff, MAXLINE, stdin) != NULL) {
		szBuff[strlen(szBuff) - 1] = 0;	/* replace newline with null */

		/* Start the child process */
		if ( ! CreateProcess( 
			NULL,  // No module name (use command line)
			szBuff,  // Command line
			NULL,  // Process handle not inheritable
			NULL,  // Thread handle not inheritable. 
			FALSE,  // Set handle inheritance to FALSE. 
			0,  // No creation flags. 
			NULL,  // Use parent's environment block. 
			NULL,  // Use parent's starting directory. 
			&si,  // Pointer to STARTUPINFO structure.
			&pi )  // Pointer to PROCESS_INFORMATION struct
		)
		{
			err_ret( "CreateProcess failed." );
		}

		/* parent */
		/* wait for normal termination of child process */
		WaitForSingleObject(pi.hProcess, INFINITE);

		printf("%% ");
	}
	exit(0);
}
开发者ID:HaseebNain,项目名称:CS-253,代码行数:41,代码来源:shell1.c


示例14: main

int main(int argc, char **argv)
{
    char *ptr, **pptr;
    char str[16]; /* ddd.ddd.ddd.ddd\0 */
    struct hostent *hptr;

    while (--argc > 0) {
        ptr = *++argv;
        if ((hptr = gethostbyname(ptr)) == NULL) {
            err_msg("gethostbyname error for host: %s: %s",
                    ptr, hstrerror(h_errno));
            continue;
        }
        printf("official hostname: %s\n", hptr->h_name);

        for (pptr = hptr->h_aliases; *pptr != NULL; pptr++)
            printf("\talias: %s\n", *pptr);

        switch (hptr->h_addrtype) {
            case AF_INET:
                pptr = hptr->h_addr_list;
                for (; *pptr != NULL; pptr++) {
                    printf("\taddress: %s\n",
                            Inet_ntop(hptr->h_addrtype, *pptr, str, sizeof(str)));
                    hptr = gethostbyaddr(*pptr, hptr->h_length, hptr->h_addrtype);
                    if (hptr == NULL)
                        err_msg("gethostbyaddr error: %s", hstrerror(h_errno));
                    else if (hptr ->h_name != NULL)
                        printf("\tname: %s\n", hptr->h_name);
                    else
                        printf("\t(no hostname returned by gethostbyaddr)\n");
                }
                break;
            default:
                err_ret("unknown address type");
                break;
        }
    }
    exit(0);

}
开发者ID:GongCun,项目名称:UNIX_Network_Programming_3thEd_Volume1,代码行数:41,代码来源:exer01_v01.c


示例15: do_path

static int do_path(myfunc* func)
{
	struct stat statbuf;
	struct dirent *dirp;
	DIR *dp;
	int ret, n;

	if (lstat(fullpath, &statbuf) < 0)
		return(func(fullpath, &statbuf, FTW_NS));
	if (S_ISDIR(statbuf.st_mode) == 0)
		return(func(fullpath, &statbuf, FTW_F));
	if ((ret = func(fullpath, &statbuf, FTW_D)) != 0)
		return ret;

	n = strlen(fullpath);
	if (n + NAME_MAX + 2 > pathlen)
	{
		pathlen *= 2;
		if ((fullpath = realloc(fullpath, pathlen)) == NULL)
			err_sys("realloc failed");
	}
	fullpath[n++] = '/';
	fullpath[n] = 0;
	if ((dp = opendir(fullpath)) == NULL)
		return(func(fullpath, &statbuf, FTW_DNR));

	while ((dirp = readdir(dp)) != NULL)
	{
		if (strcmp(dirp->d_name, ".") == 0 ||
			strcmp(dirp->d_name, "..") == 0)
			continue;
		strcpy(&fullpath[n], dirp->d_name);
		if ((ret = do_path(func)) != 0)
			break;
	}
	fullpath[n-1] = 0;

	if (closedir(dp) < 0)
		err_ret("cannot close directory %s", fullpath)	;
	return ret;
}
开发者ID:njuguoyi,项目名称:APUE3,代码行数:41,代码来源:4-7.c


示例16: main

int main (int argc,char **argv)
{
	int		i;
	struct	stat buf;
	char	*ptr;
	for(i=1;i<argc;i++)
	{
		printf("%s: \n \t",argv[i]);
		if(lstat(argv[i],&buf)<0)
		{
			err_ret("lstat error");
			continue;
		}
		if(S_ISREG(buf.st_mode))
			ptr="regular file";
		else if(S_ISDIR(buf.st_mode))
			ptr="directory file";
		else if(S_ISCHR(buf.st_mode))
			ptr="character special";
		else if(S_ISBLK(buf.st_mode))
			ptr="block special";
		else if(S_ISFIFO(buf.st_mode))
			ptr="fifo ";
		else if(S_ISLNK(buf.st_mode))
			ptr="symbolic link";
		else if(S_ISSOCK(buf.st_mode))
			ptr="socket";
		else
			ptr="** unknown mode **";
		printf("%s\n",ptr);

	}
	exit(0);







}
开发者ID:Lewisgreat,项目名称:APUE,代码行数:41,代码来源:MyJudgementIo.c


示例17: pthread_self

int CXSPAsyncSocket::SocketEpollDel(const int sockfd, const int event)
{
	EPOLLEVENT epollevent;
	epollevent.data.fd = sockfd;
	epollevent.events = event;
	pthread_t thrid = pthread_self();
	struct EpollWaitObject *pEwobj=NULL;
	if(m_ThreadId2Ewobj.Find(thrid, pEwobj) == 0)
	{
		int ret = epoll_ctl(pEwobj->epollId, EPOLL_CTL_DEL, sockfd, &epollevent);
		if(-1 == ret)
		{
			err_ret(GetLastError(ERROR_EPOLL_CTL));
			return -1;
		}
		m_ThreadId2Ewobj.Set(thrid, pEwobj);
		SafeDecreaseEvent();
		return ret;
	}
	return -2;
}
开发者ID:dx01259,项目名称:libxsp,代码行数:21,代码来源:XSPAsyncSocket.cpp


示例18: main

int main(int argc, char **argv)
{
	int i, fd;
	struct stat stat;
	unsigned char c, *ptr;

	if (argc != 2)
		err_quit("Usage: read <name>");

	//open, get size, map
	fd = Shm_open(argv[1], O_RDONLY, FILE_MODE);
	Fstat(fd, &stat);
	ptr = Mmap(NULL, stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
	Close(fd);

	//check teh ptr[0] = 0, ptr[1] = 1, etc.
	for (i = 0; i < stat.st_size; i++)
		if ((c = *ptr++) != (i % 256))
			err_ret("ptr[%d] = %d", i, c);
	exit(0);
}
开发者ID:crazy-canux,项目名称:cAPI,代码行数:21,代码来源:read.c


示例19: main

int main(int argc, char *argv[])
{
  int fd, pid;

  if ((pid = fork()) == -1)
    err_ret("fork", "");
  else if (pid == 0)
  {
    fd = open(argv[1], O_RDONLY);
    close(0);
    dup(fd);
    close(fd);

    execlp("sort", "sort", NULL);
  }
  else
  {
    wait(NULL);
  }
  return 0;
}
开发者ID:yangmiemie,项目名称:books,代码行数:21,代码来源:sortfromfile.c


示例20: dopath

static int dopath(Myfunc* func)
{
    struct stat statbuf;
    struct dirent *dirp;
    DIR *dp;
    int ret;
    char *ptr;
    
    if(lstat(fullpath, &statbuf) < 0)
        return (func(fullpath, &statbuf, FTW_NS));
    if(S_ISDIR(statbuf.st_mode) == 0)//not a dir
        return (func(fullpath, &statbuf, FTW_F));
    //dir
    if((ret = func(fullpath, &statbuf, FTW_D)) != 0)
        return (ret);
	
    //printf("%s_______fullpath_in_dopath\n", fullpath);
    ptr = fullpath + strlen(fullpath);//point to end of path
    *ptr++ = '/';//这里不需要了,fullpath=realpath,realpath后面有已经有'/'
	//printf("after_/_fullpath______%s\n", fullpath);
    *ptr = 0;
    //if can't read dir
    if ((dp = opendir(fullpath)) == NULL)
        return (func(fullpath, &statbuf, FTW_DNR));
    //read
    while((dirp = readdir(dp)) != NULL)
    {
        if(strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0)
            continue;
        strcpy(ptr, dirp->d_name);//append dname after '/'
        
        if((ret = dopath(func)) != 0)//recursive 递归,循环
            break;//time to leave
    }

    //ptr[-1] = 0;//erase everything from slash onwards  ???
    if(closedir(dp) < 0)
        err_ret("can't close dir %s", fullpath);
    return (ret);
}
开发者ID:Beatrice7,项目名称:CPP_RECORD,代码行数:40,代码来源:myfind.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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