⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ourhead.h

📁 linux 高级编程的例子源码,包括了本书上的所有代码
💻 H
字号:
/*filename:ourhead.h*/
#ifndef _OURHEAD_H
#define _OURHEAD_H

#include <error.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/un.h>
#include <sys/select.h>
#include <poll.h>
#include <string.h>
#include <sys/ioctl.h>
#include <pthread.h>
#define LISTENQ 1024
#ifndef MAXLINE
#define MAXLINE 4096
#endif
#define BUFFERSIZE 8192
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
ssize_t readline(int fd,void *vptr,size_t maxlen)
 {
	 ssize_t rc,n;
	 char c,*ptr;

	 ptr=vptr;
         
  for (n=1;n<maxlen;n++)
	 {
   again:
	   if((rc=read(fd,&c,1))==1)
	   {
		   *ptr++=c;
		   if (c=='\n')
			   break;   
	   }
	   else if (rc==0)
	   {
		   if (n==1)
			   return 0;  /*EOF ,no data read*/
		   else 
			   break;     /*EOF,some data read*/
	   }
	   else
	   {
		   if (errno==EINTR)
			   goto again;
		   return (-1);
	   }
	 }
	 *ptr=0;
	 return n;
 }
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -