"Unix Network Programming" UNP.H Header files __ Programming

Source: Internet
Author: User

#ifndef __unp_h
#define __UNP_H
#include "... /config.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>
#ifdef have_sys_ Select_h
# include <sys/select.h>
#endif
#ifdef have_sys_sysctl_h
# include <sys/sysctl.h>< br> #endif
#ifdef have_poll_h
# include <poll.h>
#endif
#ifdef have_sys_event_h
# include <sy S/event.h>
#endif
#ifdef have_strings_h
# include <strings.h>
#endif

#ifdef Have_sys_ioctl_h
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
#ifdef Have_pthread_h
# include <pthread.h>
#endif
#ifdef Have_net_if_dl_h
# include <net/if_dl.h>
#endif
#ifdef HAVE_NETINET_SCTP_H
#include <netinet/sctp.h>
#endif

#ifdef __osf__
#undef recv
#undef Send
#define RECV (a,b,c,d) recvfrom (a,b,c,d,0,0)
#define SEND (A,b,c,d) sendto (a,b,c,d,0,0)
#endif
#ifndef Inaddr_none
#define Inaddr_none 0xFFFFFFFF
#endif
#ifndef SHUT_RD
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
#endif
#ifndef Inet_addrstrlen
#define Inet_addrstrlen 16
#endif

#ifndef Inet6_addrstrlen
#define Inet6_addrstrlen 46
#endif

#ifndef Have_bzero
#define BZERO (ptr,n) memset (PTR, 0, N)
#endif

#ifndef have_gethostbyname2
#define GETHOSTBYNAME2 (host,family) gethostbyname (host)
#endif

struct Unp_in_pktinfo {
struct IN_ADDR ipi_addr;

#ifndef Cmsg_len
#define Cmsg_len (size) (sizeof (struct CMSGHDR) + (size))
#endif
#ifndef Cmsg_space
#define CMSG_SPACE (size) (sizeof (struct CMSGHDR) + (size))
#endif

#ifndef Sun_len
# define Sun_len (SU) \
(sizeof (* (su))-sizeof ((su)->sun_path) + strlen ((su)->sun_path))
#endif

#ifndef af_local
#define Af_local Af_unix
#endif
#ifndef pf_local
#define Pf_local Pf_unix
#endif

#ifndef Inftim
#define INFTIM (-1)
#ifdef Have_poll_h
#define INFTIM_UNPH
#endif
#endif

#define LISTENQ 1024

#define Maxline 4096
#define Buffsize 8192

#define Serv_port 9877
#define SERV_PORT_STR "9877"
#define Unixstr_path "/tmp/unix.str"
#define Unixdg_path "/TMP/UNIX.DG"

#define SA struct SOCKADDR
#define Have_struct_sockaddr_storage
#ifndef Have_struct_sockaddr_storage

#define __SS_MAXSIZE 128
#define __SS_ALIGNSIZE (sizeof (int64_t))
#ifdef Have_sockaddr_sa_len
#define __SS_PAD1SIZE (__ss_alignsize-sizeof (U_char)-sizeof (sa_family_t))
#else
#define __SS_PAD1SIZE (__ss_alignsize-sizeof (sa_family_t))
#endif
#define __SS_PAD2SIZE (__ss_maxsize-2*__ss_alignsize)
struct Sockaddr_storage {
#ifdef Have_sockaddr_sa_len
U_char Ss_len;
#endif
sa_family_t ss_family;
Char __ss_pad1[__ss_pad1size];
int64_t __ss_align;
Char __ss_pad2[__ss_pad2size];
};
#endif
#define File_mode (S_IRUSR | S_IWUSR | S_irgrp | S_iroth)

#define Dir_mode (File_mode | S_IXUSR | S_ixgrp | S_ixoth)

typedef void Sigfunc (int);
#define MIN (a,b) ((a) < (b)? (a): (b))
#define MAX (A,b) ((a) > (b)? (a): (b))
#ifndef have_addrinfo_struct
# include '. /lib/addrinfo.h "
#endif
#ifndef have_if_nameindex_struct
struct If_nameindex {
unsigned int if_index;
Char *if_name;
};
#endif
#ifndef have_timespec_struct
struct Timespec {
time_t tv_sec;
Long tv_nsec;
};
#endif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.