- ANSI C
- » Variable handling
- » Miscellaneous
- » POSIX
- » Date/Time
- » Math
- » menu_code_ansiccode_strings
- » PCRE
- » Arrays
- » Classes
- » Program execute
- » Directories
- » Filesystem
- » Memory
- » GD
- » Network
- » Sockets
- PERL
- PHP
- JavaScript
CONTENT
- CHANGES
Szukaj
#top Network¶
- Network
- Makefile
- Makefile (linux)
- Makefile.obsd
- Makefile.fbsd
- Makefile.sol
- Makefile.beos
- Makefile.win
- Predefined Constants
- AF_FILE
- AF_INET
- AF_INET6
- AF_LOCAL
- AF_UNIX
- AF_UNSPEC
- HOST_NOT_FOUND
- INADDR_ANY
- NETDB_INTERNAL
- NETDB_SUCCESS
- NO_ADDRESS
- NO_DATA
- NO_RECOVERY
- PF_FILE
- PF_INET
- PF_INET6
- PF_LOCAL
- PF_UNIX
- PF_UNSPEC
- TRY_AGAIN
- Datatypes / MACROS
- __h_errno_location
- __SOCKADDR_COMMON
- __socklen_t
- h_errno
- in_addr_t
- in_port_t
- sa_family_t
- size_t
- socklen_t
- struct addrinfo
- struct in_addr
- struct in6_addr
- struct hostent
- struct netent
- struct protoent
- struct servent
- struct sockaddr
- struct sockaddr_in
- struct sockaddr_in6
- struct sockaddr_un
- uint8_t
- uint16_t
- uint32_t
- Network Functions
- endhostent
- endnetent
- endnetgrent
- endprotoent
- endservent
- freeaddrinfo
- gai_strerror
- getaddrinfo
- getdomainname
- gethostbyaddr
- gethostbyname
- gethostbyname2
- gethostent
- gethostname
- getnameinfo
- getnetbyaddr
- getnetbyname
- getnetent
- getnetgrent
- getprotobyname
- getprotobynumber
- getprotoent
- getservbyname
- getservbyport
- getservent
- hstrerror
- htonl
- htons
- inet_addr
- inet_aton
- inet_lnaof
- inet_makeaddr
- inet_net_ntop
- inet_net_pton
- inet_neta
- inet_netof
- inet_network
- inet_nsap_addr
- inet_nsap_ntoa
- inet_ntoa
- inet_ntop
- inet_pton
- innetgr
- ntohl
- ntohs
- setdomainname
- sethostent
- sethostname
- setnetent
- setnetgrent
- setprotoent
- setservent
- Resolv
- Resolv Predefined Constants
- MAXDNSRCH
- MAXNS
- MAXRESOLVSORT
- Resolv Datatypes / MACROS
- __u_char
- __u_int
- __u_long
- __u_short
- res_send_qhook
- res_send_rhook
- res_state
- struct __res_state
- u_char
- u_int
- u_int16_t
- u_int32_t
- u_long
- u_short
- Resolv Functions
- dn_expand
- dn_skipname
- res_nclose
- res_ninit
- res_nmkquery
- res_nsend
- res_search
code / ansic / Network
#top Makefile¶
Dla ułatwienia korzystania z przykładów został utworzony jeden zbiorczy plik
Makefile
kompilujący przykłady użycia poniżej wymienionych funkcji związanych z operacjami sieciowymi (funkcje dotyczące rozwiązywania nazw).Poniższe pliki Makefile zakładają obecność wszystkich plików przykładów, w przypadku chęci kompilacji za pomocą Makefile tylko wybranego przykładu należy zakomentować w pliku Makefile ostatnią pozycję zawierającą listę wszystkich targetów do wykonania
make: $(FREEADDRINFO) ...
, a następnie odkomentować powyżej komendę make zawierającą nazwę targetu dla bieżącego przykładu, np: w przypadku chęci kompilacji tylko przykładu freeaddrinfo
należy zakomentować ostatnią pozycję rozpoczynającą się od make: $(FREEADDRINFO) ...
(wstawić na początku przed make znak #
), a następnie odkomentować pozycję: #make: $(FREEADDRINFO)
(usunąć znak #
).#top Makefile (linux)¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = -DHAVE_GETDOMAINNAME=1 -DHAVE_SETDOMAINNAME=1 -DHAVE_GETHOSTBYNAME2=1 -DHAVE_INET_LNAOF=1 -DHAVE_RES_SEARCH=1 -DHAVE_RES_NMKQUERY=1 CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing LIBS = -lresolv LIBDIRS = LDFLAGS = $(LIBDIRS) $(LIBS) RM = rm -f MKDCMD = mkdir -p DN_EXPAND = dn_expand DN_SKIPNAME = dn_skipname ENDHOSTENT = endhostent ENDNETENT = endnetent ENDNETGRENT = endnetgrent ENDPROTOENT = endprotoent ENDSERVENT = endservent FREEADDRINFO= freeaddrinfo GETADDRINFO = getaddrinfo GETDOMAINNAME= getdomainname GETHOSTBYADDR= gethostbyaddr GETHOSTBYNAME2= gethostbyname2 GETHOSTBYNAME= gethostbyname GETHOSTENT = gethostent GETHOSTNAME = gethostname GETNAMEINFO = getnameinfo GETNETBYADDR= getnetbyaddr GETNETBYNAME= getnetbyname GETNETENT = getnetent GETNETGRENT = getnetgrent GETPROTOBYNAME= getprotobyname GETPROTOBYNUMBER= getprotobynumber GETPROTOENT = getprotoent GETSERVBYNAME= getservbyname GETSERVBYPORT= getservbyport GETSERVENT = getservent HSTRERROR = hstrerror HTONL = htonl HTONS = htons INET_ADDR = inet_addr INET_ATON = inet_aton INET_LNAOF = inet_lnaof INET_MAKEADDR= inet_makeaddr INET_NETA = inet_neta INET_NET_NTOP= inet_net_ntop INET_NETOF = inet_netof INET_NET_PTON= inet_net_pton INET_NETWORK= inet_network INET_NSAP_ADDR= inet_nsap_addr INET_NSAP_NTOA= inet_nsap_ntoa INET_NTOA = inet_ntoa INET_NTOP = inet_ntop INET_PTON = inet_pton INNETGR = innetgr NTOHL = ntohl NTOHS = ntohs RES_NCLOSE = res_nclose RES_NMKQUERY= res_nmkquery RES_NSEND = res_nsend RES_SEARCH = res_search SETDOMAINNAME= setdomainname SETHOSTENT = sethostent SETHOSTNAME = sethostname SETNETENT = setnetent SETNETGRENT = setnetgrent SETPROTOENT = setprotoent SETSERVENT = setservent all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(DN_EXPAND) #make: $(DN_SKIPNAME) #make: $(ENDHOSTENT) #make: $(ENDNETENT) #make: $(ENDNETGRENT) #make: $(ENDPROTOENT) #make: $(ENDSERVENT) #make: $(FREEADDRINFO) #make: $(GETADDRINFO) #make: $(GETDOMAINNAME) #make: $(GETHOSTBYADDR) #make: $(GETHOSTBYNAME2) #make: $(GETHOSTBYNAME) #make: $(GETHOSTENT) #make: $(GETHOSTNAME) #make: $(GETNAMEINFO) #make: $(GETNETBYADDR) #make: $(GETNETBYNAME) #make: $(GETNETENT) #make: $(GETNETGRENT) #make: $(GETPROTOBYNAME) #make: $(GETPROTOBYNUMBER) #make: $(GETPROTOENT) #make: $(GETSERVBYNAME) #make: $(GETSERVBYPORT) #make: $(GETSERVENT) #make: $(HSTRERROR) #make: $(HTONL) #make: $(HTONS) #make: $(INET_ADDR) #make: $(INET_ATON) #make: $(INET_LNAOF) #make: $(INET_MAKEADDR) #make: $(INET_NETA) #make: $(INET_NET_NTOP) #make: $(INET_NETOF) #make: $(INET_NET_PTON) #make: $(INET_NETWORK) #make: $(INET_NSAP_ADDR) #make: $(INET_NSAP_NTOA) #make: $(INET_NTOA) #make: $(INET_NTOP) #make: $(INET_PTON) #make: $(INNETGR) #make: $(NTOHL) #make: $(NTOHS) #make: $(RES_NCLOSE) #make: $(RES_NMKQUERY) #make: $(RES_NSEND) #make: $(RES_SEARCH) #make: $(SETDOMAINNAME) #make: $(SETHOSTENT) #make: $(SETHOSTNAME) #make: $(SETNETENT) #make: $(SETNETGRENT) #make: $(SETPROTOENT) #make: $(SETSERVENT) make: $(DN_EXPAND) $(DN_SKIPNAME) $(ENDHOSTENT) $(ENDNETENT) $(ENDNETGRENT) $(ENDPROTOENT) $(ENDSERVENT) $(FREEADDRINFO) $(GETADDRINFO) $(GETDOMAINNAME) $(GETHOSTBYADDR) $(GETHOSTBYNAME2) $(GETHOSTBYNAME) $(GETHOSTENT) $(GETHOSTNAME) $(GETNAMEINFO) $(GETNETBYADDR) $(GETNETBYNAME) $(GETNETENT) $(GETNETGRENT) $(GETPROTOBYNAME) $(GETPROTOBYNUMBER) $(GETPROTOENT) $(GETSERVBYNAME) $(GETSERVBYPORT) $(GETSERVENT) $(HSTRERROR) $(HTONL) $(HTONS) $(INET_ADDR) $(INET_ATON) $(INET_LNAOF) $(INET_MAKEADDR) $(INET_NETA) $(INET_NET_NTOP) $(INET_NETOF) $(INET_NET_PTON) $(INET_NETWORK) $(INET_NSAP_ADDR) $(INET_NSAP_NTOA) $(INET_NTOA) $(INET_NTOP) $(INET_PTON) $(INNETGR) $(NTOHL) $(NTOHS) $(RES_NCLOSE) $(RES_NMKQUERY) $(RES_NSEND) $(RES_SEARCH) $(SETDOMAINNAME) $(SETHOSTENT) $(SETHOSTNAME) $(SETNETENT) $(SETNETGRENT) $(SETPROTOENT) $(SETSERVENT) $(DN_EXPAND): $(DN_EXPAND).o $(GCC) -o $(DN_EXPAND) obj/$(DN_EXPAND).o $(LDFLAGS) $(DN_EXPAND).o: $(GCC) -o obj/$(DN_EXPAND).o -c $(DN_EXPAND).c $(CFLAGS) $(DN_SKIPNAME): $(DN_SKIPNAME).o $(GCC) -o $(DN_SKIPNAME) obj/$(DN_SKIPNAME).o $(LDFLAGS) $(DN_SKIPNAME).o: $(GCC) -o obj/$(DN_SKIPNAME).o -c $(DN_SKIPNAME).c $(CFLAGS) $(ENDHOSTENT): $(ENDHOSTENT).o $(GCC) -o $(ENDHOSTENT) obj/$(ENDHOSTENT).o $(LDFLAGS) $(ENDHOSTENT).o: $(GCC) -o obj/$(ENDHOSTENT).o -c $(ENDHOSTENT).c $(CFLAGS) $(ENDNETENT): $(ENDNETENT).o $(GCC) -o $(ENDNETENT) obj/$(ENDNETENT).o $(LDFLAGS) $(ENDNETENT).o: $(GCC) -o obj/$(ENDNETENT).o -c $(ENDNETENT).c $(CFLAGS) $(ENDNETGRENT): $(ENDNETGRENT).o $(GCC) -o $(ENDNETGRENT) obj/$(ENDNETGRENT).o $(LDFLAGS) $(ENDNETGRENT).o: $(GCC) -o obj/$(ENDNETGRENT).o -c $(ENDNETGRENT).c $(CFLAGS) $(ENDPROTOENT): $(ENDPROTOENT).o $(GCC) -o $(ENDPROTOENT) obj/$(ENDPROTOENT).o $(LDFLAGS) $(ENDPROTOENT).o: $(GCC) -o obj/$(ENDPROTOENT).o -c $(ENDPROTOENT).c $(CFLAGS) $(ENDSERVENT): $(ENDSERVENT).o $(GCC) -o $(ENDSERVENT) obj/$(ENDSERVENT).o $(LDFLAGS) $(ENDSERVENT).o: $(GCC) -o obj/$(ENDSERVENT).o -c $(ENDSERVENT).c $(CFLAGS) $(FREEADDRINFO): $(FREEADDRINFO).o $(GCC) -o $(FREEADDRINFO) obj/$(FREEADDRINFO).o $(LDFLAGS) $(FREEADDRINFO).o: $(GCC) -o obj/$(FREEADDRINFO).o -c $(FREEADDRINFO).c $(CFLAGS) $(GETADDRINFO): $(GETADDRINFO).o $(GCC) -o $(GETADDRINFO) obj/$(GETADDRINFO).o $(LDFLAGS) $(GETADDRINFO).o: $(GCC) -o obj/$(GETADDRINFO).o -c $(GETADDRINFO).c $(CFLAGS) $(GETDOMAINNAME): $(GETDOMAINNAME).o $(GCC) -o $(GETDOMAINNAME) obj/$(GETDOMAINNAME).o $(LDFLAGS) $(GETDOMAINNAME).o: $(GCC) -o obj/$(GETDOMAINNAME).o -c $(GETDOMAINNAME).c $(CFLAGS) $(GETHOSTBYADDR): $(GETHOSTBYADDR).o $(GCC) -o $(GETHOSTBYADDR) obj/$(GETHOSTBYADDR).o $(LDFLAGS) $(GETHOSTBYADDR).o: $(GCC) -o obj/$(GETHOSTBYADDR).o -c $(GETHOSTBYADDR).c $(CFLAGS) $(GETHOSTBYNAME2): $(GETHOSTBYNAME2).o $(GCC) -o $(GETHOSTBYNAME2) obj/$(GETHOSTBYNAME2).o $(LDFLAGS) $(GETHOSTBYNAME2).o: $(GCC) -o obj/$(GETHOSTBYNAME2).o -c $(GETHOSTBYNAME2).c $(CFLAGS) $(GETHOSTBYNAME): $(GETHOSTBYNAME).o $(GCC) -o $(GETHOSTBYNAME) obj/$(GETHOSTBYNAME).o $(LDFLAGS) $(GETHOSTBYNAME).o: $(GCC) -o obj/$(GETHOSTBYNAME).o -c $(GETHOSTBYNAME).c $(CFLAGS) $(GETHOSTENT): $(GETHOSTENT).o $(GCC) -o $(GETHOSTENT) obj/$(GETHOSTENT).o $(LDFLAGS) $(GETHOSTENT).o: $(GCC) -o obj/$(GETHOSTENT).o -c $(GETHOSTENT).c $(CFLAGS) $(GETHOSTNAME): $(GETHOSTNAME).o $(GCC) -o $(GETHOSTNAME) obj/$(GETHOSTNAME).o $(LDFLAGS) $(GETHOSTNAME).o: $(GCC) -o obj/$(GETHOSTNAME).o -c $(GETHOSTNAME).c $(CFLAGS) $(GETNAMEINFO): $(GETNAMEINFO).o $(GCC) -o $(GETNAMEINFO) obj/$(GETNAMEINFO).o $(LDFLAGS) $(GETNAMEINFO).o: $(GCC) -o obj/$(GETNAMEINFO).o -c $(GETNAMEINFO).c $(CFLAGS) $(GETNETBYADDR): $(GETNETBYADDR).o $(GCC) -o $(GETNETBYADDR) obj/$(GETNETBYADDR).o $(LDFLAGS) $(GETNETBYADDR).o: $(GCC) -o obj/$(GETNETBYADDR).o -c $(GETNETBYADDR).c $(CFLAGS) $(GETNETBYNAME): $(GETNETBYNAME).o $(GCC) -o $(GETNETBYNAME) obj/$(GETNETBYNAME).o $(LDFLAGS) $(GETNETBYNAME).o: $(GCC) -o obj/$(GETNETBYNAME).o -c $(GETNETBYNAME).c $(CFLAGS) $(GETNETENT): $(GETNETENT).o $(GCC) -o $(GETNETENT) obj/$(GETNETENT).o $(LDFLAGS) $(GETNETENT).o: $(GCC) -o obj/$(GETNETENT).o -c $(GETNETENT).c $(CFLAGS) $(GETNETGRENT): $(GETNETGRENT).o $(GCC) -o $(GETNETGRENT) obj/$(GETNETGRENT).o $(LDFLAGS) $(GETNETGRENT).o: $(GCC) -o obj/$(GETNETGRENT).o -c $(GETNETGRENT).c $(CFLAGS) $(GETPROTOBYNAME): $(GETPROTOBYNAME).o $(GCC) -o $(GETPROTOBYNAME) obj/$(GETPROTOBYNAME).o $(LDFLAGS) $(GETPROTOBYNAME).o: $(GCC) -o obj/$(GETPROTOBYNAME).o -c $(GETPROTOBYNAME).c $(CFLAGS) $(GETPROTOBYNUMBER): $(GETPROTOBYNUMBER).o $(GCC) -o $(GETPROTOBYNUMBER) obj/$(GETPROTOBYNUMBER).o $(LDFLAGS) $(GETPROTOBYNUMBER).o: $(GCC) -o obj/$(GETPROTOBYNUMBER).o -c $(GETPROTOBYNUMBER).c $(CFLAGS) $(GETPROTOENT): $(GETPROTOENT).o $(GCC) -o $(GETPROTOENT) obj/$(GETPROTOENT).o $(LDFLAGS) $(GETPROTOENT).o: $(GCC) -o obj/$(GETPROTOENT).o -c $(GETPROTOENT).c $(CFLAGS) $(GETSERVBYNAME): $(GETSERVBYNAME).o $(GCC) -o $(GETSERVBYNAME) obj/$(GETSERVBYNAME).o $(LDFLAGS) $(GETSERVBYNAME).o: $(GCC) -o obj/$(GETSERVBYNAME).o -c $(GETSERVBYNAME).c $(CFLAGS) $(GETSERVBYPORT): $(GETSERVBYPORT).o $(GCC) -o $(GETSERVBYPORT) obj/$(GETSERVBYPORT).o $(LDFLAGS) $(GETSERVBYPORT).o: $(GCC) -o obj/$(GETSERVBYPORT).o -c $(GETSERVBYPORT).c $(CFLAGS) $(GETSERVENT): $(GETSERVENT).o $(GCC) -o $(GETSERVENT) obj/$(GETSERVENT).o $(LDFLAGS) $(GETSERVENT).o: $(GCC) -o obj/$(GETSERVENT).o -c $(GETSERVENT).c $(CFLAGS) $(HSTRERROR): $(HSTRERROR).o $(GCC) -o $(HSTRERROR) obj/$(HSTRERROR).o $(LDFLAGS) $(HSTRERROR).o: $(GCC) -o obj/$(HSTRERROR).o -c $(HSTRERROR).c $(CFLAGS) $(HTONL): $(HTONL).o $(GCC) -o $(HTONL) obj/$(HTONL).o $(LDFLAGS) $(HTONL).o: $(GCC) -o obj/$(HTONL).o -c $(HTONL).c $(CFLAGS) $(HTONS): $(HTONS).o $(GCC) -o $(HTONS) obj/$(HTONS).o $(LDFLAGS) $(HTONS).o: $(GCC) -o obj/$(HTONS).o -c $(HTONS).c $(CFLAGS) $(INET_ADDR): $(INET_ADDR).o $(GCC) -o $(INET_ADDR) obj/$(INET_ADDR).o $(LDFLAGS) $(INET_ADDR).o: $(GCC) -o obj/$(INET_ADDR).o -c $(INET_ADDR).c $(CFLAGS) $(INET_ATON): $(INET_ATON).o $(GCC) -o $(INET_ATON) obj/$(INET_ATON).o $(LDFLAGS) $(INET_ATON).o: $(GCC) -o obj/$(INET_ATON).o -c $(INET_ATON).c $(CFLAGS) $(INET_LNAOF): $(INET_LNAOF).o $(GCC) -o $(INET_LNAOF) obj/$(INET_LNAOF).o $(LDFLAGS) $(INET_LNAOF).o: $(GCC) -o obj/$(INET_LNAOF).o -c $(INET_LNAOF).c $(CFLAGS) $(INET_MAKEADDR): $(INET_MAKEADDR).o $(GCC) -o $(INET_MAKEADDR) obj/$(INET_MAKEADDR).o $(LDFLAGS) $(INET_MAKEADDR).o: $(GCC) -o obj/$(INET_MAKEADDR).o -c $(INET_MAKEADDR).c $(CFLAGS) $(INET_NETA): $(INET_NETA).o $(GCC) -o $(INET_NETA) obj/$(INET_NETA).o $(LDFLAGS) $(INET_NETA).o: $(GCC) -o obj/$(INET_NETA).o -c $(INET_NETA).c $(CFLAGS) $(INET_NET_NTOP): $(INET_NET_NTOP).o $(GCC) -o $(INET_NET_NTOP) obj/$(INET_NET_NTOP).o $(LDFLAGS) $(INET_NET_NTOP).o: $(GCC) -o obj/$(INET_NET_NTOP).o -c $(INET_NET_NTOP).c $(CFLAGS) $(INET_NETOF): $(INET_NETOF).o $(GCC) -o $(INET_NETOF) obj/$(INET_NETOF).o $(LDFLAGS) $(INET_NETOF).o: $(GCC) -o obj/$(INET_NETOF).o -c $(INET_NETOF).c $(CFLAGS) $(INET_NET_PTON): $(INET_NET_PTON).o $(GCC) -o $(INET_NET_PTON) obj/$(INET_NET_PTON).o $(LDFLAGS) $(INET_NET_PTON).o: $(GCC) -o obj/$(INET_NET_PTON).o -c $(INET_NET_PTON).c $(CFLAGS) $(INET_NETWORK): $(INET_NETWORK).o $(GCC) -o $(INET_NETWORK) obj/$(INET_NETWORK).o $(LDFLAGS) $(INET_NETWORK).o: $(GCC) -o obj/$(INET_NETWORK).o -c $(INET_NETWORK).c $(CFLAGS) $(INET_NSAP_ADDR): $(INET_NSAP_ADDR).o $(GCC) -o $(INET_NSAP_ADDR) obj/$(INET_NSAP_ADDR).o $(LDFLAGS) $(INET_NSAP_ADDR).o: $(GCC) -o obj/$(INET_NSAP_ADDR).o -c $(INET_NSAP_ADDR).c $(CFLAGS) $(INET_NSAP_NTOA): $(INET_NSAP_NTOA).o $(GCC) -o $(INET_NSAP_NTOA) obj/$(INET_NSAP_NTOA).o $(LDFLAGS) $(INET_NSAP_NTOA).o: $(GCC) -o obj/$(INET_NSAP_NTOA).o -c $(INET_NSAP_NTOA).c $(CFLAGS) $(INET_NTOA): $(INET_NTOA).o $(GCC) -o $(INET_NTOA) obj/$(INET_NTOA).o $(LDFLAGS) $(INET_NTOA).o: $(GCC) -o obj/$(INET_NTOA).o -c $(INET_NTOA).c $(CFLAGS) $(INET_NTOP): $(INET_NTOP).o $(GCC) -o $(INET_NTOP) obj/$(INET_NTOP).o $(LDFLAGS) $(INET_NTOP).o: $(GCC) -o obj/$(INET_NTOP).o -c $(INET_NTOP).c $(CFLAGS) $(INET_PTON): $(INET_PTON).o $(GCC) -o $(INET_PTON) obj/$(INET_PTON).o $(LDFLAGS) $(INET_PTON).o: $(GCC) -o obj/$(INET_PTON).o -c $(INET_PTON).c $(CFLAGS) $(INNETGR): $(INNETGR).o $(GCC) -o $(INNETGR) obj/$(INNETGR).o $(LDFLAGS) $(INNETGR).o: $(GCC) -o obj/$(INNETGR).o -c $(INNETGR).c $(CFLAGS) $(NTOHL): $(NTOHL).o $(GCC) -o $(NTOHL) obj/$(NTOHL).o $(LDFLAGS) $(NTOHL).o: $(GCC) -o obj/$(NTOHL).o -c $(NTOHL).c $(CFLAGS) $(NTOHS): $(NTOHS).o $(GCC) -o $(NTOHS) obj/$(NTOHS).o $(LDFLAGS) $(NTOHS).o: $(GCC) -o obj/$(NTOHS).o -c $(NTOHS).c $(CFLAGS) $(RES_NCLOSE): $(RES_NCLOSE).o $(GCC) -o $(RES_NCLOSE) obj/$(RES_NCLOSE).o $(LDFLAGS) $(RES_NCLOSE).o: $(GCC) -o obj/$(RES_NCLOSE).o -c $(RES_NCLOSE).c $(CFLAGS) $(RES_NMKQUERY): $(RES_NMKQUERY).o $(GCC) -o $(RES_NMKQUERY) obj/$(RES_NMKQUERY).o $(LDFLAGS) $(RES_NMKQUERY).o: $(GCC) -o obj/$(RES_NMKQUERY).o -c $(RES_NMKQUERY).c $(CFLAGS) $(RES_NSEND): $(RES_NSEND).o $(GCC) -o $(RES_NSEND) obj/$(RES_NSEND).o $(LDFLAGS) $(RES_NSEND).o: $(GCC) -o obj/$(RES_NSEND).o -c $(RES_NSEND).c $(CFLAGS) $(RES_SEARCH): $(RES_SEARCH).o $(GCC) -o $(RES_SEARCH) obj/$(RES_SEARCH).o $(LDFLAGS) $(RES_SEARCH).o: $(GCC) -o obj/$(RES_SEARCH).o -c $(RES_SEARCH).c $(CFLAGS) $(SETDOMAINNAME): $(SETDOMAINNAME).o $(GCC) -o $(SETDOMAINNAME) obj/$(SETDOMAINNAME).o $(LDFLAGS) $(SETDOMAINNAME).o: $(GCC) -o obj/$(SETDOMAINNAME).o -c $(SETDOMAINNAME).c $(CFLAGS) $(SETHOSTENT): $(SETHOSTENT).o $(GCC) -o $(SETHOSTENT) obj/$(SETHOSTENT).o $(LDFLAGS) $(SETHOSTENT).o: $(GCC) -o obj/$(SETHOSTENT).o -c $(SETHOSTENT).c $(CFLAGS) $(SETHOSTNAME): $(SETHOSTNAME).o $(GCC) -o $(SETHOSTNAME) obj/$(SETHOSTNAME).o $(LDFLAGS) $(SETHOSTNAME).o: $(GCC) -o obj/$(SETHOSTNAME).o -c $(SETHOSTNAME).c $(CFLAGS) $(SETNETENT): $(SETNETENT).o $(GCC) -o $(SETNETENT) obj/$(SETNETENT).o $(LDFLAGS) $(SETNETENT).o: $(GCC) -o obj/$(SETNETENT).o -c $(SETNETENT).c $(CFLAGS) $(SETNETGRENT): $(SETNETGRENT).o $(GCC) -o $(SETNETGRENT) obj/$(SETNETGRENT).o $(LDFLAGS) $(SETNETGRENT).o: $(GCC) -o obj/$(SETNETGRENT).o -c $(SETNETGRENT).c $(CFLAGS) $(SETPROTOENT): $(SETPROTOENT).o $(GCC) -o $(SETPROTOENT) obj/$(SETPROTOENT).o $(LDFLAGS) $(SETPROTOENT).o: $(GCC) -o obj/$(SETPROTOENT).o -c $(SETPROTOENT).c $(CFLAGS) $(SETSERVENT): $(SETSERVENT).o $(GCC) -o $(SETSERVENT) obj/$(SETSERVENT).o $(LDFLAGS) $(SETSERVENT).o: $(GCC) -o obj/$(SETSERVENT).o -c $(SETSERVENT).c $(CFLAGS)
#top Makefile.obsd¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = -DHAVE_GETDOMAINNAME=1 -DHAVE_SETDOMAINNAME=1 -DHAVE_GETHOSTBYNAME2=1 -DNEED_DEF_S6_ADDR_U6ADDR=1 -DNEED_NETGROUP_H=1 CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing LIBS = LIBDIRS = LDFLAGS = $(LIBDIRS) $(LIBS) RM = rm -f MKDCMD = mkdir -p DN_EXPAND = dn_expand DN_SKIPNAME = dn_skipname ENDHOSTENT = endhostent ENDNETENT = endnetent ENDNETGRENT = endnetgrent ENDPROTOENT = endprotoent ENDSERVENT = endservent FREEADDRINFO= freeaddrinfo GETADDRINFO = getaddrinfo GETDOMAINNAME= getdomainname GETHOSTBYADDR= gethostbyaddr GETHOSTBYNAME2= gethostbyname2 GETHOSTBYNAME= gethostbyname GETHOSTENT = gethostent GETHOSTNAME = gethostname GETNAMEINFO = getnameinfo GETNETBYADDR= getnetbyaddr GETNETBYNAME= getnetbyname GETNETENT = getnetent GETNETGRENT = getnetgrent GETPROTOBYNAME= getprotobyname GETPROTOBYNUMBER= getprotobynumber GETPROTOENT = getprotoent GETSERVBYNAME= getservbyname GETSERVBYPORT= getservbyport GETSERVENT = getservent HSTRERROR = hstrerror HTONL = htonl HTONS = htons INET_ADDR = inet_addr INET_ATON = inet_aton INET_LNAOF = inet_lnaof INET_MAKEADDR= inet_makeaddr INET_NETA = inet_neta INET_NET_NTOP= inet_net_ntop INET_NETOF = inet_netof INET_NET_PTON= inet_net_pton INET_NETWORK= inet_network INET_NSAP_ADDR= inet_nsap_addr INET_NSAP_NTOA= inet_nsap_ntoa INET_NTOA = inet_ntoa INET_NTOP = inet_ntop INET_PTON = inet_pton INNETGR = innetgr NTOHL = ntohl NTOHS = ntohs RES_NCLOSE = res_nclose RES_NMKQUERY= res_nmkquery RES_NSEND = res_nsend RES_SEARCH = res_search SETDOMAINNAME= setdomainname SETHOSTENT = sethostent SETHOSTNAME = sethostname SETNETENT = setnetent SETNETGRENT = setnetgrent SETPROTOENT = setprotoent SETSERVENT = setservent all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(DN_EXPAND) #make: $(DN_SKIPNAME) #make: $(ENDHOSTENT) #make: $(ENDNETENT) #make: $(ENDNETGRENT) #make: $(ENDPROTOENT) #make: $(ENDSERVENT) #make: $(FREEADDRINFO) #make: $(GETADDRINFO) #make: $(GETDOMAINNAME) #make: $(GETHOSTBYADDR) #make: $(GETHOSTBYNAME2) #make: $(GETHOSTBYNAME) #make: $(GETHOSTENT) #make: $(GETHOSTNAME) #make: $(GETNAMEINFO) #make: $(GETNETBYADDR) #make: $(GETNETBYNAME) #make: $(GETNETENT) #make: $(GETNETGRENT) #make: $(GETPROTOBYNAME) #make: $(GETPROTOBYNUMBER) #make: $(GETPROTOENT) #make: $(GETSERVBYNAME) #make: $(GETSERVBYPORT) #make: $(GETSERVENT) #make: $(HSTRERROR) #make: $(HTONL) #make: $(HTONS) #make: $(INET_ADDR) #make: $(INET_ATON) #make: $(INET_LNAOF) #make: $(INET_MAKEADDR) #make: $(INET_NETA) #make: $(INET_NET_NTOP) #make: $(INET_NETOF) #make: $(INET_NET_PTON) #make: $(INET_NETWORK) #make: $(INET_NSAP_ADDR) #make: $(INET_NSAP_NTOA) #make: $(INET_NTOA) #make: $(INET_NTOP) #make: $(INET_PTON) #make: $(INNETGR) #make: $(NTOHL) #make: $(NTOHS) #make: $(RES_NCLOSE) #make: $(RES_NMKQUERY) #make: $(RES_NSEND) #make: $(RES_SEARCH) #make: $(SETDOMAINNAME) #make: $(SETHOSTENT) #make: $(SETHOSTNAME) #make: $(SETNETENT) #make: $(SETNETGRENT) #make: $(SETPROTOENT) #make: $(SETSERVENT) make: $(DN_EXPAND) $(DN_SKIPNAME) $(ENDHOSTENT) $(ENDNETENT) $(ENDNETGRENT) $(ENDPROTOENT) $(ENDSERVENT) $(FREEADDRINFO) $(GETADDRINFO) $(GETDOMAINNAME) $(GETHOSTBYADDR) $(GETHOSTBYNAME2) $(GETHOSTBYNAME) $(GETHOSTENT) $(GETHOSTNAME) $(GETNAMEINFO) $(GETNETBYADDR) $(GETNETBYNAME) $(GETNETENT) $(GETNETGRENT) $(GETPROTOBYNAME) $(GETPROTOBYNUMBER) $(GETPROTOENT) $(GETSERVBYNAME) $(GETSERVBYPORT) $(GETSERVENT) $(HSTRERROR) $(HTONL) $(HTONS) $(INET_ADDR) $(INET_ATON) $(INET_LNAOF) $(INET_MAKEADDR) $(INET_NETA) $(INET_NET_NTOP) $(INET_NETOF) $(INET_NET_PTON) $(INET_NETWORK) $(INET_NSAP_ADDR) $(INET_NSAP_NTOA) $(INET_NTOA) $(INET_NTOP) $(INET_PTON) $(INNETGR) $(NTOHL) $(NTOHS) $(RES_NCLOSE) $(RES_NMKQUERY) $(RES_NSEND) $(RES_SEARCH) $(SETDOMAINNAME) $(SETHOSTENT) $(SETHOSTNAME) $(SETNETENT) $(SETNETGRENT) $(SETPROTOENT) $(SETSERVENT) $(DN_EXPAND): $(DN_EXPAND).o $(GCC) -o $(DN_EXPAND) obj/$(DN_EXPAND).o $(LDFLAGS) $(DN_EXPAND).o: $(GCC) -o obj/$(DN_EXPAND).o -c $(DN_EXPAND).c $(CFLAGS) $(DN_SKIPNAME): $(DN_SKIPNAME).o $(GCC) -o $(DN_SKIPNAME) obj/$(DN_SKIPNAME).o $(LDFLAGS) $(DN_SKIPNAME).o: $(GCC) -o obj/$(DN_SKIPNAME).o -c $(DN_SKIPNAME).c $(CFLAGS) $(ENDHOSTENT): $(ENDHOSTENT).o $(GCC) -o $(ENDHOSTENT) obj/$(ENDHOSTENT).o $(LDFLAGS) $(ENDHOSTENT).o: $(GCC) -o obj/$(ENDHOSTENT).o -c $(ENDHOSTENT).c $(CFLAGS) $(ENDNETENT): $(ENDNETENT).o $(GCC) -o $(ENDNETENT) obj/$(ENDNETENT).o $(LDFLAGS) $(ENDNETENT).o: $(GCC) -o obj/$(ENDNETENT).o -c $(ENDNETENT).c $(CFLAGS) $(ENDNETGRENT): $(ENDNETGRENT).o $(GCC) -o $(ENDNETGRENT) obj/$(ENDNETGRENT).o $(LDFLAGS) $(ENDNETGRENT).o: $(GCC) -o obj/$(ENDNETGRENT).o -c $(ENDNETGRENT).c $(CFLAGS) $(ENDPROTOENT): $(ENDPROTOENT).o $(GCC) -o $(ENDPROTOENT) obj/$(ENDPROTOENT).o $(LDFLAGS) $(ENDPROTOENT).o: $(GCC) -o obj/$(ENDPROTOENT).o -c $(ENDPROTOENT).c $(CFLAGS) $(ENDSERVENT): $(ENDSERVENT).o $(GCC) -o $(ENDSERVENT) obj/$(ENDSERVENT).o $(LDFLAGS) $(ENDSERVENT).o: $(GCC) -o obj/$(ENDSERVENT).o -c $(ENDSERVENT).c $(CFLAGS) $(FREEADDRINFO): $(FREEADDRINFO).o $(GCC) -o $(FREEADDRINFO) obj/$(FREEADDRINFO).o $(LDFLAGS) $(FREEADDRINFO).o: $(GCC) -o obj/$(FREEADDRINFO).o -c $(FREEADDRINFO).c $(CFLAGS) $(GETADDRINFO): $(GETADDRINFO).o $(GCC) -o $(GETADDRINFO) obj/$(GETADDRINFO).o $(LDFLAGS) $(GETADDRINFO).o: $(GCC) -o obj/$(GETADDRINFO).o -c $(GETADDRINFO).c $(CFLAGS) $(GETDOMAINNAME): $(GETDOMAINNAME).o $(GCC) -o $(GETDOMAINNAME) obj/$(GETDOMAINNAME).o $(LDFLAGS) $(GETDOMAINNAME).o: $(GCC) -o obj/$(GETDOMAINNAME).o -c $(GETDOMAINNAME).c $(CFLAGS) $(GETHOSTBYADDR): $(GETHOSTBYADDR).o $(GCC) -o $(GETHOSTBYADDR) obj/$(GETHOSTBYADDR).o $(LDFLAGS) $(GETHOSTBYADDR).o: $(GCC) -o obj/$(GETHOSTBYADDR).o -c $(GETHOSTBYADDR).c $(CFLAGS) $(GETHOSTBYNAME2): $(GETHOSTBYNAME2).o $(GCC) -o $(GETHOSTBYNAME2) obj/$(GETHOSTBYNAME2).o $(LDFLAGS) $(GETHOSTBYNAME2).o: $(GCC) -o obj/$(GETHOSTBYNAME2).o -c $(GETHOSTBYNAME2).c $(CFLAGS) $(GETHOSTBYNAME): $(GETHOSTBYNAME).o $(GCC) -o $(GETHOSTBYNAME) obj/$(GETHOSTBYNAME).o $(LDFLAGS) $(GETHOSTBYNAME).o: $(GCC) -o obj/$(GETHOSTBYNAME).o -c $(GETHOSTBYNAME).c $(CFLAGS) $(GETHOSTENT): $(GETHOSTENT).o $(GCC) -o $(GETHOSTENT) obj/$(GETHOSTENT).o $(LDFLAGS) $(GETHOSTENT).o: $(GCC) -o obj/$(GETHOSTENT).o -c $(GETHOSTENT).c $(CFLAGS) $(GETHOSTNAME): $(GETHOSTNAME).o $(GCC) -o $(GETHOSTNAME) obj/$(GETHOSTNAME).o $(LDFLAGS) $(GETHOSTNAME).o: $(GCC) -o obj/$(GETHOSTNAME).o -c $(GETHOSTNAME).c $(CFLAGS) $(GETNAMEINFO): $(GETNAMEINFO).o $(GCC) -o $(GETNAMEINFO) obj/$(GETNAMEINFO).o $(LDFLAGS) $(GETNAMEINFO).o: $(GCC) -o obj/$(GETNAMEINFO).o -c $(GETNAMEINFO).c $(CFLAGS) $(GETNETBYADDR): $(GETNETBYADDR).o $(GCC) -o $(GETNETBYADDR) obj/$(GETNETBYADDR).o $(LDFLAGS) $(GETNETBYADDR).o: $(GCC) -o obj/$(GETNETBYADDR).o -c $(GETNETBYADDR).c $(CFLAGS) $(GETNETBYNAME): $(GETNETBYNAME).o $(GCC) -o $(GETNETBYNAME) obj/$(GETNETBYNAME).o $(LDFLAGS) $(GETNETBYNAME).o: $(GCC) -o obj/$(GETNETBYNAME).o -c $(GETNETBYNAME).c $(CFLAGS) $(GETNETENT): $(GETNETENT).o $(GCC) -o $(GETNETENT) obj/$(GETNETENT).o $(LDFLAGS) $(GETNETENT).o: $(GCC) -o obj/$(GETNETENT).o -c $(GETNETENT).c $(CFLAGS) $(GETNETGRENT): $(GETNETGRENT).o $(GCC) -o $(GETNETGRENT) obj/$(GETNETGRENT).o $(LDFLAGS) $(GETNETGRENT).o: $(GCC) -o obj/$(GETNETGRENT).o -c $(GETNETGRENT).c $(CFLAGS) $(GETPROTOBYNAME): $(GETPROTOBYNAME).o $(GCC) -o $(GETPROTOBYNAME) obj/$(GETPROTOBYNAME).o $(LDFLAGS) $(GETPROTOBYNAME).o: $(GCC) -o obj/$(GETPROTOBYNAME).o -c $(GETPROTOBYNAME).c $(CFLAGS) $(GETPROTOBYNUMBER): $(GETPROTOBYNUMBER).o $(GCC) -o $(GETPROTOBYNUMBER) obj/$(GETPROTOBYNUMBER).o $(LDFLAGS) $(GETPROTOBYNUMBER).o: $(GCC) -o obj/$(GETPROTOBYNUMBER).o -c $(GETPROTOBYNUMBER).c $(CFLAGS) $(GETPROTOENT): $(GETPROTOENT).o $(GCC) -o $(GETPROTOENT) obj/$(GETPROTOENT).o $(LDFLAGS) $(GETPROTOENT).o: $(GCC) -o obj/$(GETPROTOENT).o -c $(GETPROTOENT).c $(CFLAGS) $(GETSERVBYNAME): $(GETSERVBYNAME).o $(GCC) -o $(GETSERVBYNAME) obj/$(GETSERVBYNAME).o $(LDFLAGS) $(GETSERVBYNAME).o: $(GCC) -o obj/$(GETSERVBYNAME).o -c $(GETSERVBYNAME).c $(CFLAGS) $(GETSERVBYPORT): $(GETSERVBYPORT).o $(GCC) -o $(GETSERVBYPORT) obj/$(GETSERVBYPORT).o $(LDFLAGS) $(GETSERVBYPORT).o: $(GCC) -o obj/$(GETSERVBYPORT).o -c $(GETSERVBYPORT).c $(CFLAGS) $(GETSERVENT): $(GETSERVENT).o $(GCC) -o $(GETSERVENT) obj/$(GETSERVENT).o $(LDFLAGS) $(GETSERVENT).o: $(GCC) -o obj/$(GETSERVENT).o -c $(GETSERVENT).c $(CFLAGS) $(HSTRERROR): $(HSTRERROR).o $(GCC) -o $(HSTRERROR) obj/$(HSTRERROR).o $(LDFLAGS) $(HSTRERROR).o: $(GCC) -o obj/$(HSTRERROR).o -c $(HSTRERROR).c $(CFLAGS) $(HTONL): $(HTONL).o $(GCC) -o $(HTONL) obj/$(HTONL).o $(LDFLAGS) $(HTONL).o: $(GCC) -o obj/$(HTONL).o -c $(HTONL).c $(CFLAGS) $(HTONS): $(HTONS).o $(GCC) -o $(HTONS) obj/$(HTONS).o $(LDFLAGS) $(HTONS).o: $(GCC) -o obj/$(HTONS).o -c $(HTONS).c $(CFLAGS) $(INET_ADDR): $(INET_ADDR).o $(GCC) -o $(INET_ADDR) obj/$(INET_ADDR).o $(LDFLAGS) $(INET_ADDR).o: $(GCC) -o obj/$(INET_ADDR).o -c $(INET_ADDR).c $(CFLAGS) $(INET_ATON): $(INET_ATON).o $(GCC) -o $(INET_ATON) obj/$(INET_ATON).o $(LDFLAGS) $(INET_ATON).o: $(GCC) -o obj/$(INET_ATON).o -c $(INET_ATON).c $(CFLAGS) $(INET_LNAOF): $(INET_LNAOF).o $(GCC) -o $(INET_LNAOF) obj/$(INET_LNAOF).o $(LDFLAGS) $(INET_LNAOF).o: $(GCC) -o obj/$(INET_LNAOF).o -c $(INET_LNAOF).c $(CFLAGS) $(INET_MAKEADDR): $(INET_MAKEADDR).o $(GCC) -o $(INET_MAKEADDR) obj/$(INET_MAKEADDR).o $(LDFLAGS) $(INET_MAKEADDR).o: $(GCC) -o obj/$(INET_MAKEADDR).o -c $(INET_MAKEADDR).c $(CFLAGS) $(INET_NETA): $(INET_NETA).o $(GCC) -o $(INET_NETA) obj/$(INET_NETA).o $(LDFLAGS) $(INET_NETA).o: $(GCC) -o obj/$(INET_NETA).o -c $(INET_NETA).c $(CFLAGS) $(INET_NET_NTOP): $(INET_NET_NTOP).o $(GCC) -o $(INET_NET_NTOP) obj/$(INET_NET_NTOP).o $(LDFLAGS) $(INET_NET_NTOP).o: $(GCC) -o obj/$(INET_NET_NTOP).o -c $(INET_NET_NTOP).c $(CFLAGS) $(INET_NETOF): $(INET_NETOF).o $(GCC) -o $(INET_NETOF) obj/$(INET_NETOF).o $(LDFLAGS) $(INET_NETOF).o: $(GCC) -o obj/$(INET_NETOF).o -c $(INET_NETOF).c $(CFLAGS) $(INET_NET_PTON): $(INET_NET_PTON).o $(GCC) -o $(INET_NET_PTON) obj/$(INET_NET_PTON).o $(LDFLAGS) $(INET_NET_PTON).o: $(GCC) -o obj/$(INET_NET_PTON).o -c $(INET_NET_PTON).c $(CFLAGS) $(INET_NETWORK): $(INET_NETWORK).o $(GCC) -o $(INET_NETWORK) obj/$(INET_NETWORK).o $(LDFLAGS) $(INET_NETWORK).o: $(GCC) -o obj/$(INET_NETWORK).o -c $(INET_NETWORK).c $(CFLAGS) $(INET_NSAP_ADDR): $(INET_NSAP_ADDR).o $(GCC) -o $(INET_NSAP_ADDR) obj/$(INET_NSAP_ADDR).o $(LDFLAGS) $(INET_NSAP_ADDR).o: $(GCC) -o obj/$(INET_NSAP_ADDR).o -c $(INET_NSAP_ADDR).c $(CFLAGS) $(INET_NSAP_NTOA): $(INET_NSAP_NTOA).o $(GCC) -o $(INET_NSAP_NTOA) obj/$(INET_NSAP_NTOA).o $(LDFLAGS) $(INET_NSAP_NTOA).o: $(GCC) -o obj/$(INET_NSAP_NTOA).o -c $(INET_NSAP_NTOA).c $(CFLAGS) $(INET_NTOA): $(INET_NTOA).o $(GCC) -o $(INET_NTOA) obj/$(INET_NTOA).o $(LDFLAGS) $(INET_NTOA).o: $(GCC) -o obj/$(INET_NTOA).o -c $(INET_NTOA).c $(CFLAGS) $(INET_NTOP): $(INET_NTOP).o $(GCC) -o $(INET_NTOP) obj/$(INET_NTOP).o $(LDFLAGS) $(INET_NTOP).o: $(GCC) -o obj/$(INET_NTOP).o -c $(INET_NTOP).c $(CFLAGS) $(INET_PTON): $(INET_PTON).o $(GCC) -o $(INET_PTON) obj/$(INET_PTON).o $(LDFLAGS) $(INET_PTON).o: $(GCC) -o obj/$(INET_PTON).o -c $(INET_PTON).c $(CFLAGS) $(INNETGR): $(INNETGR).o $(GCC) -o $(INNETGR) obj/$(INNETGR).o $(LDFLAGS) $(INNETGR).o: $(GCC) -o obj/$(INNETGR).o -c $(INNETGR).c $(CFLAGS) $(NTOHL): $(NTOHL).o $(GCC) -o $(NTOHL) obj/$(NTOHL).o $(LDFLAGS) $(NTOHL).o: $(GCC) -o obj/$(NTOHL).o -c $(NTOHL).c $(CFLAGS) $(NTOHS): $(NTOHS).o $(GCC) -o $(NTOHS) obj/$(NTOHS).o $(LDFLAGS) $(NTOHS).o: $(GCC) -o obj/$(NTOHS).o -c $(NTOHS).c $(CFLAGS) $(RES_NCLOSE): $(RES_NCLOSE).o $(GCC) -o $(RES_NCLOSE) obj/$(RES_NCLOSE).o $(LDFLAGS) $(RES_NCLOSE).o: $(GCC) -o obj/$(RES_NCLOSE).o -c $(RES_NCLOSE).c $(CFLAGS) $(RES_NMKQUERY): $(RES_NMKQUERY).o $(GCC) -o $(RES_NMKQUERY) obj/$(RES_NMKQUERY).o $(LDFLAGS) $(RES_NMKQUERY).o: $(GCC) -o obj/$(RES_NMKQUERY).o -c $(RES_NMKQUERY).c $(CFLAGS) $(RES_NSEND): $(RES_NSEND).o $(GCC) -o $(RES_NSEND) obj/$(RES_NSEND).o $(LDFLAGS) $(RES_NSEND).o: $(GCC) -o obj/$(RES_NSEND).o -c $(RES_NSEND).c $(CFLAGS) $(RES_SEARCH): $(RES_SEARCH).o $(GCC) -o $(RES_SEARCH) obj/$(RES_SEARCH).o $(LDFLAGS) $(RES_SEARCH).o: $(GCC) -o obj/$(RES_SEARCH).o -c $(RES_SEARCH).c $(CFLAGS) $(SETDOMAINNAME): $(SETDOMAINNAME).o $(GCC) -o $(SETDOMAINNAME) obj/$(SETDOMAINNAME).o $(LDFLAGS) $(SETDOMAINNAME).o: $(GCC) -o obj/$(SETDOMAINNAME).o -c $(SETDOMAINNAME).c $(CFLAGS) $(SETHOSTENT): $(SETHOSTENT).o $(GCC) -o $(SETHOSTENT) obj/$(SETHOSTENT).o $(LDFLAGS) $(SETHOSTENT).o: $(GCC) -o obj/$(SETHOSTENT).o -c $(SETHOSTENT).c $(CFLAGS) $(SETHOSTNAME): $(SETHOSTNAME).o $(GCC) -o $(SETHOSTNAME) obj/$(SETHOSTNAME).o $(LDFLAGS) $(SETHOSTNAME).o: $(GCC) -o obj/$(SETHOSTNAME).o -c $(SETHOSTNAME).c $(CFLAGS) $(SETNETENT): $(SETNETENT).o $(GCC) -o $(SETNETENT) obj/$(SETNETENT).o $(LDFLAGS) $(SETNETENT).o: $(GCC) -o obj/$(SETNETENT).o -c $(SETNETENT).c $(CFLAGS) $(SETNETGRENT): $(SETNETGRENT).o $(GCC) -o $(SETNETGRENT) obj/$(SETNETGRENT).o $(LDFLAGS) $(SETNETGRENT).o: $(GCC) -o obj/$(SETNETGRENT).o -c $(SETNETGRENT).c $(CFLAGS) $(SETPROTOENT): $(SETPROTOENT).o $(GCC) -o $(SETPROTOENT) obj/$(SETPROTOENT).o $(LDFLAGS) $(SETPROTOENT).o: $(GCC) -o obj/$(SETPROTOENT).o -c $(SETPROTOENT).c $(CFLAGS) $(SETSERVENT): $(SETSERVENT).o $(GCC) -o $(SETSERVENT) obj/$(SETSERVENT).o $(LDFLAGS) $(SETSERVENT).o: $(GCC) -o obj/$(SETSERVENT).o -c $(SETSERVENT).c $(CFLAGS)
#top Makefile.fbsd¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = -DHAVE_GETDOMAINNAME=1 -DHAVE_SETDOMAINNAME=1 -DHAVE_GETHOSTBYNAME2=1 -DNEED_DEF_S6_ADDR_U6ADDR=1 -DHAVE_INET_LNAOF=1 -DHAVE_RES_SEARCH=1 CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing LIBS = LIBDIRS = LDFLAGS = $(LIBDIRS) $(LIBS) RM = rm -f MKDCMD = mkdir -p DN_EXPAND = dn_expand DN_SKIPNAME = dn_skipname ENDHOSTENT = endhostent ENDNETENT = endnetent ENDNETGRENT = endnetgrent ENDPROTOENT = endprotoent ENDSERVENT = endservent FREEADDRINFO= freeaddrinfo GETADDRINFO = getaddrinfo GETDOMAINNAME= getdomainname GETHOSTBYADDR= gethostbyaddr GETHOSTBYNAME2= gethostbyname2 GETHOSTBYNAME= gethostbyname GETHOSTENT = gethostent GETHOSTNAME = gethostname GETNAMEINFO = getnameinfo GETNETBYADDR= getnetbyaddr GETNETBYNAME= getnetbyname GETNETENT = getnetent GETNETGRENT = getnetgrent GETPROTOBYNAME= getprotobyname GETPROTOBYNUMBER= getprotobynumber GETPROTOENT = getprotoent GETSERVBYNAME= getservbyname GETSERVBYPORT= getservbyport GETSERVENT = getservent HSTRERROR = hstrerror HTONL = htonl HTONS = htons INET_ADDR = inet_addr INET_ATON = inet_aton INET_LNAOF = inet_lnaof INET_MAKEADDR= inet_makeaddr INET_NETA = inet_neta INET_NET_NTOP= inet_net_ntop INET_NETOF = inet_netof INET_NET_PTON= inet_net_pton INET_NETWORK= inet_network INET_NSAP_ADDR= inet_nsap_addr INET_NSAP_NTOA= inet_nsap_ntoa INET_NTOA = inet_ntoa INET_NTOP = inet_ntop INET_PTON = inet_pton INNETGR = innetgr NTOHL = ntohl NTOHS = ntohs RES_NCLOSE = res_nclose RES_NMKQUERY= res_nmkquery RES_NSEND = res_nsend RES_SEARCH = res_search SETDOMAINNAME= setdomainname SETHOSTENT = sethostent SETHOSTNAME = sethostname SETNETENT = setnetent SETNETGRENT = setnetgrent SETPROTOENT = setprotoent SETSERVENT = setservent all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(DN_EXPAND) #make: $(DN_SKIPNAME) #make: $(ENDHOSTENT) #make: $(ENDNETENT) #make: $(ENDNETGRENT) #make: $(ENDPROTOENT) #make: $(ENDSERVENT) #make: $(FREEADDRINFO) #make: $(GETADDRINFO) #make: $(GETDOMAINNAME) #make: $(GETHOSTBYADDR) #make: $(GETHOSTBYNAME2) #make: $(GETHOSTBYNAME) #make: $(GETHOSTENT) #make: $(GETHOSTNAME) #make: $(GETNAMEINFO) #make: $(GETNETBYADDR) #make: $(GETNETBYNAME) #make: $(GETNETENT) #make: $(GETNETGRENT) #make: $(GETPROTOBYNAME) #make: $(GETPROTOBYNUMBER) #make: $(GETPROTOENT) #make: $(GETSERVBYNAME) #make: $(GETSERVBYPORT) #make: $(GETSERVENT) #make: $(HSTRERROR) #make: $(HTONL) #make: $(HTONS) #make: $(INET_ADDR) #make: $(INET_ATON) #make: $(INET_LNAOF) #make: $(INET_MAKEADDR) #make: $(INET_NETA) #make: $(INET_NET_NTOP) #make: $(INET_NETOF) #make: $(INET_NET_PTON) #make: $(INET_NETWORK) #make: $(INET_NSAP_ADDR) #make: $(INET_NSAP_NTOA) #make: $(INET_NTOA) #make: $(INET_NTOP) #make: $(INET_PTON) #make: $(INNETGR) #make: $(NTOHL) #make: $(NTOHS) #make: $(RES_NCLOSE) #make: $(RES_NMKQUERY) #make: $(RES_NSEND) #make: $(RES_SEARCH) #make: $(SETDOMAINNAME) #make: $(SETHOSTENT) #make: $(SETHOSTNAME) #make: $(SETNETENT) #make: $(SETNETGRENT) #make: $(SETPROTOENT) #make: $(SETSERVENT) make: $(DN_EXPAND) $(DN_SKIPNAME) $(ENDHOSTENT) $(ENDNETENT) $(ENDNETGRENT) $(ENDPROTOENT) $(ENDSERVENT) $(FREEADDRINFO) $(GETADDRINFO) $(GETDOMAINNAME) $(GETHOSTBYADDR) $(GETHOSTBYNAME2) $(GETHOSTBYNAME) $(GETHOSTENT) $(GETHOSTNAME) $(GETNAMEINFO) $(GETNETBYADDR) $(GETNETBYNAME) $(GETNETENT) $(GETNETGRENT) $(GETPROTOBYNAME) $(GETPROTOBYNUMBER) $(GETPROTOENT) $(GETSERVBYNAME) $(GETSERVBYPORT) $(GETSERVENT) $(HSTRERROR) $(HTONL) $(HTONS) $(INET_ADDR) $(INET_ATON) $(INET_LNAOF) $(INET_MAKEADDR) $(INET_NETA) $(INET_NET_NTOP) $(INET_NETOF) $(INET_NET_PTON) $(INET_NETWORK) $(INET_NSAP_ADDR) $(INET_NSAP_NTOA) $(INET_NTOA) $(INET_NTOP) $(INET_PTON) $(INNETGR) $(NTOHL) $(NTOHS) $(RES_NCLOSE) $(RES_NMKQUERY) $(RES_NSEND) $(RES_SEARCH) $(SETDOMAINNAME) $(SETHOSTENT) $(SETHOSTNAME) $(SETNETENT) $(SETNETGRENT) $(SETPROTOENT) $(SETSERVENT) $(DN_EXPAND): $(DN_EXPAND).o $(GCC) -o $(DN_EXPAND) obj/$(DN_EXPAND).o $(LDFLAGS) $(DN_EXPAND).o: $(GCC) -o obj/$(DN_EXPAND).o -c $(DN_EXPAND).c $(CFLAGS) $(DN_SKIPNAME): $(DN_SKIPNAME).o $(GCC) -o $(DN_SKIPNAME) obj/$(DN_SKIPNAME).o $(LDFLAGS) $(DN_SKIPNAME).o: $(GCC) -o obj/$(DN_SKIPNAME).o -c $(DN_SKIPNAME).c $(CFLAGS) $(ENDHOSTENT): $(ENDHOSTENT).o $(GCC) -o $(ENDHOSTENT) obj/$(ENDHOSTENT).o $(LDFLAGS) $(ENDHOSTENT).o: $(GCC) -o obj/$(ENDHOSTENT).o -c $(ENDHOSTENT).c $(CFLAGS) $(ENDNETENT): $(ENDNETENT).o $(GCC) -o $(ENDNETENT) obj/$(ENDNETENT).o $(LDFLAGS) $(ENDNETENT).o: $(GCC) -o obj/$(ENDNETENT).o -c $(ENDNETENT).c $(CFLAGS) $(ENDNETGRENT): $(ENDNETGRENT).o $(GCC) -o $(ENDNETGRENT) obj/$(ENDNETGRENT).o $(LDFLAGS) $(ENDNETGRENT).o: $(GCC) -o obj/$(ENDNETGRENT).o -c $(ENDNETGRENT).c $(CFLAGS) $(ENDPROTOENT): $(ENDPROTOENT).o $(GCC) -o $(ENDPROTOENT) obj/$(ENDPROTOENT).o $(LDFLAGS) $(ENDPROTOENT).o: $(GCC) -o obj/$(ENDPROTOENT).o -c $(ENDPROTOENT).c $(CFLAGS) $(ENDSERVENT): $(ENDSERVENT).o $(GCC) -o $(ENDSERVENT) obj/$(ENDSERVENT).o $(LDFLAGS) $(ENDSERVENT).o: $(GCC) -o obj/$(ENDSERVENT).o -c $(ENDSERVENT).c $(CFLAGS) $(FREEADDRINFO): $(FREEADDRINFO).o $(GCC) -o $(FREEADDRINFO) obj/$(FREEADDRINFO).o $(LDFLAGS) $(FREEADDRINFO).o: $(GCC) -o obj/$(FREEADDRINFO).o -c $(FREEADDRINFO).c $(CFLAGS) $(GETADDRINFO): $(GETADDRINFO).o $(GCC) -o $(GETADDRINFO) obj/$(GETADDRINFO).o $(LDFLAGS) $(GETADDRINFO).o: $(GCC) -o obj/$(GETADDRINFO).o -c $(GETADDRINFO).c $(CFLAGS) $(GETDOMAINNAME): $(GETDOMAINNAME).o $(GCC) -o $(GETDOMAINNAME) obj/$(GETDOMAINNAME).o $(LDFLAGS) $(GETDOMAINNAME).o: $(GCC) -o obj/$(GETDOMAINNAME).o -c $(GETDOMAINNAME).c $(CFLAGS) $(GETHOSTBYADDR): $(GETHOSTBYADDR).o $(GCC) -o $(GETHOSTBYADDR) obj/$(GETHOSTBYADDR).o $(LDFLAGS) $(GETHOSTBYADDR).o: $(GCC) -o obj/$(GETHOSTBYADDR).o -c $(GETHOSTBYADDR).c $(CFLAGS) $(GETHOSTBYNAME2): $(GETHOSTBYNAME2).o $(GCC) -o $(GETHOSTBYNAME2) obj/$(GETHOSTBYNAME2).o $(LDFLAGS) $(GETHOSTBYNAME2).o: $(GCC) -o obj/$(GETHOSTBYNAME2).o -c $(GETHOSTBYNAME2).c $(CFLAGS) $(GETHOSTBYNAME): $(GETHOSTBYNAME).o $(GCC) -o $(GETHOSTBYNAME) obj/$(GETHOSTBYNAME).o $(LDFLAGS) $(GETHOSTBYNAME).o: $(GCC) -o obj/$(GETHOSTBYNAME).o -c $(GETHOSTBYNAME).c $(CFLAGS) $(GETHOSTENT): $(GETHOSTENT).o $(GCC) -o $(GETHOSTENT) obj/$(GETHOSTENT).o $(LDFLAGS) $(GETHOSTENT).o: $(GCC) -o obj/$(GETHOSTENT).o -c $(GETHOSTENT).c $(CFLAGS) $(GETHOSTNAME): $(GETHOSTNAME).o $(GCC) -o $(GETHOSTNAME) obj/$(GETHOSTNAME).o $(LDFLAGS) $(GETHOSTNAME).o: $(GCC) -o obj/$(GETHOSTNAME).o -c $(GETHOSTNAME).c $(CFLAGS) $(GETNAMEINFO): $(GETNAMEINFO).o $(GCC) -o $(GETNAMEINFO) obj/$(GETNAMEINFO).o $(LDFLAGS) $(GETNAMEINFO).o: $(GCC) -o obj/$(GETNAMEINFO).o -c $(GETNAMEINFO).c $(CFLAGS) $(GETNETBYADDR): $(GETNETBYADDR).o $(GCC) -o $(GETNETBYADDR) obj/$(GETNETBYADDR).o $(LDFLAGS) $(GETNETBYADDR).o: $(GCC) -o obj/$(GETNETBYADDR).o -c $(GETNETBYADDR).c $(CFLAGS) $(GETNETBYNAME): $(GETNETBYNAME).o $(GCC) -o $(GETNETBYNAME) obj/$(GETNETBYNAME).o $(LDFLAGS) $(GETNETBYNAME).o: $(GCC) -o obj/$(GETNETBYNAME).o -c $(GETNETBYNAME).c $(CFLAGS) $(GETNETENT): $(GETNETENT).o $(GCC) -o $(GETNETENT) obj/$(GETNETENT).o $(LDFLAGS) $(GETNETENT).o: $(GCC) -o obj/$(GETNETENT).o -c $(GETNETENT).c $(CFLAGS) $(GETNETGRENT): $(GETNETGRENT).o $(GCC) -o $(GETNETGRENT) obj/$(GETNETGRENT).o $(LDFLAGS) $(GETNETGRENT).o: $(GCC) -o obj/$(GETNETGRENT).o -c $(GETNETGRENT).c $(CFLAGS) $(GETPROTOBYNAME): $(GETPROTOBYNAME).o $(GCC) -o $(GETPROTOBYNAME) obj/$(GETPROTOBYNAME).o $(LDFLAGS) $(GETPROTOBYNAME).o: $(GCC) -o obj/$(GETPROTOBYNAME).o -c $(GETPROTOBYNAME).c $(CFLAGS) $(GETPROTOBYNUMBER): $(GETPROTOBYNUMBER).o $(GCC) -o $(GETPROTOBYNUMBER) obj/$(GETPROTOBYNUMBER).o $(LDFLAGS) $(GETPROTOBYNUMBER).o: $(GCC) -o obj/$(GETPROTOBYNUMBER).o -c $(GETPROTOBYNUMBER).c $(CFLAGS) $(GETPROTOENT): $(GETPROTOENT).o $(GCC) -o $(GETPROTOENT) obj/$(GETPROTOENT).o $(LDFLAGS) $(GETPROTOENT).o: $(GCC) -o obj/$(GETPROTOENT).o -c $(GETPROTOENT).c $(CFLAGS) $(GETSERVBYNAME): $(GETSERVBYNAME).o $(GCC) -o $(GETSERVBYNAME) obj/$(GETSERVBYNAME).o $(LDFLAGS) $(GETSERVBYNAME).o: $(GCC) -o obj/$(GETSERVBYNAME).o -c $(GETSERVBYNAME).c $(CFLAGS) $(GETSERVBYPORT): $(GETSERVBYPORT).o $(GCC) -o $(GETSERVBYPORT) obj/$(GETSERVBYPORT).o $(LDFLAGS) $(GETSERVBYPORT).o: $(GCC) -o obj/$(GETSERVBYPORT).o -c $(GETSERVBYPORT).c $(CFLAGS) $(GETSERVENT): $(GETSERVENT).o $(GCC) -o $(GETSERVENT) obj/$(GETSERVENT).o $(LDFLAGS) $(GETSERVENT).o: $(GCC) -o obj/$(GETSERVENT).o -c $(GETSERVENT).c $(CFLAGS) $(HSTRERROR): $(HSTRERROR).o $(GCC) -o $(HSTRERROR) obj/$(HSTRERROR).o $(LDFLAGS) $(HSTRERROR).o: $(GCC) -o obj/$(HSTRERROR).o -c $(HSTRERROR).c $(CFLAGS) $(HTONL): $(HTONL).o $(GCC) -o $(HTONL) obj/$(HTONL).o $(LDFLAGS) $(HTONL).o: $(GCC) -o obj/$(HTONL).o -c $(HTONL).c $(CFLAGS) $(HTONS): $(HTONS).o $(GCC) -o $(HTONS) obj/$(HTONS).o $(LDFLAGS) $(HTONS).o: $(GCC) -o obj/$(HTONS).o -c $(HTONS).c $(CFLAGS) $(INET_ADDR): $(INET_ADDR).o $(GCC) -o $(INET_ADDR) obj/$(INET_ADDR).o $(LDFLAGS) $(INET_ADDR).o: $(GCC) -o obj/$(INET_ADDR).o -c $(INET_ADDR).c $(CFLAGS) $(INET_ATON): $(INET_ATON).o $(GCC) -o $(INET_ATON) obj/$(INET_ATON).o $(LDFLAGS) $(INET_ATON).o: $(GCC) -o obj/$(INET_ATON).o -c $(INET_ATON).c $(CFLAGS) $(INET_LNAOF): $(INET_LNAOF).o $(GCC) -o $(INET_LNAOF) obj/$(INET_LNAOF).o $(LDFLAGS) $(INET_LNAOF).o: $(GCC) -o obj/$(INET_LNAOF).o -c $(INET_LNAOF).c $(CFLAGS) $(INET_MAKEADDR): $(INET_MAKEADDR).o $(GCC) -o $(INET_MAKEADDR) obj/$(INET_MAKEADDR).o $(LDFLAGS) $(INET_MAKEADDR).o: $(GCC) -o obj/$(INET_MAKEADDR).o -c $(INET_MAKEADDR).c $(CFLAGS) $(INET_NETA): $(INET_NETA).o $(GCC) -o $(INET_NETA) obj/$(INET_NETA).o $(LDFLAGS) $(INET_NETA).o: $(GCC) -o obj/$(INET_NETA).o -c $(INET_NETA).c $(CFLAGS) $(INET_NET_NTOP): $(INET_NET_NTOP).o $(GCC) -o $(INET_NET_NTOP) obj/$(INET_NET_NTOP).o $(LDFLAGS) $(INET_NET_NTOP).o: $(GCC) -o obj/$(INET_NET_NTOP).o -c $(INET_NET_NTOP).c $(CFLAGS) $(INET_NETOF): $(INET_NETOF).o $(GCC) -o $(INET_NETOF) obj/$(INET_NETOF).o $(LDFLAGS) $(INET_NETOF).o: $(GCC) -o obj/$(INET_NETOF).o -c $(INET_NETOF).c $(CFLAGS) $(INET_NET_PTON): $(INET_NET_PTON).o $(GCC) -o $(INET_NET_PTON) obj/$(INET_NET_PTON).o $(LDFLAGS) $(INET_NET_PTON).o: $(GCC) -o obj/$(INET_NET_PTON).o -c $(INET_NET_PTON).c $(CFLAGS) $(INET_NETWORK): $(INET_NETWORK).o $(GCC) -o $(INET_NETWORK) obj/$(INET_NETWORK).o $(LDFLAGS) $(INET_NETWORK).o: $(GCC) -o obj/$(INET_NETWORK).o -c $(INET_NETWORK).c $(CFLAGS) $(INET_NSAP_ADDR): $(INET_NSAP_ADDR).o $(GCC) -o $(INET_NSAP_ADDR) obj/$(INET_NSAP_ADDR).o $(LDFLAGS) $(INET_NSAP_ADDR).o: $(GCC) -o obj/$(INET_NSAP_ADDR).o -c $(INET_NSAP_ADDR).c $(CFLAGS) $(INET_NSAP_NTOA): $(INET_NSAP_NTOA).o $(GCC) -o $(INET_NSAP_NTOA) obj/$(INET_NSAP_NTOA).o $(LDFLAGS) $(INET_NSAP_NTOA).o: $(GCC) -o obj/$(INET_NSAP_NTOA).o -c $(INET_NSAP_NTOA).c $(CFLAGS) $(INET_NTOA): $(INET_NTOA).o $(GCC) -o $(INET_NTOA) obj/$(INET_NTOA).o $(LDFLAGS) $(INET_NTOA).o: $(GCC) -o obj/$(INET_NTOA).o -c $(INET_NTOA).c $(CFLAGS) $(INET_NTOP): $(INET_NTOP).o $(GCC) -o $(INET_NTOP) obj/$(INET_NTOP).o $(LDFLAGS) $(INET_NTOP).o: $(GCC) -o obj/$(INET_NTOP).o -c $(INET_NTOP).c $(CFLAGS) $(INET_PTON): $(INET_PTON).o $(GCC) -o $(INET_PTON) obj/$(INET_PTON).o $(LDFLAGS) $(INET_PTON).o: $(GCC) -o obj/$(INET_PTON).o -c $(INET_PTON).c $(CFLAGS) $(INNETGR): $(INNETGR).o $(GCC) -o $(INNETGR) obj/$(INNETGR).o $(LDFLAGS) $(INNETGR).o: $(GCC) -o obj/$(INNETGR).o -c $(INNETGR).c $(CFLAGS) $(NTOHL): $(NTOHL).o $(GCC) -o $(NTOHL) obj/$(NTOHL).o $(LDFLAGS) $(NTOHL).o: $(GCC) -o obj/$(NTOHL).o -c $(NTOHL).c $(CFLAGS) $(NTOHS): $(NTOHS).o $(GCC) -o $(NTOHS) obj/$(NTOHS).o $(LDFLAGS) $(NTOHS).o: $(GCC) -o obj/$(NTOHS).o -c $(NTOHS).c $(CFLAGS) $(RES_NCLOSE): $(RES_NCLOSE).o $(GCC) -o $(RES_NCLOSE) obj/$(RES_NCLOSE).o $(LDFLAGS) $(RES_NCLOSE).o: $(GCC) -o obj/$(RES_NCLOSE).o -c $(RES_NCLOSE).c $(CFLAGS) $(RES_NMKQUERY): $(RES_NMKQUERY).o $(GCC) -o $(RES_NMKQUERY) obj/$(RES_NMKQUERY).o $(LDFLAGS) $(RES_NMKQUERY).o: $(GCC) -o obj/$(RES_NMKQUERY).o -c $(RES_NMKQUERY).c $(CFLAGS) $(RES_NSEND): $(RES_NSEND).o $(GCC) -o $(RES_NSEND) obj/$(RES_NSEND).o $(LDFLAGS) $(RES_NSEND).o: $(GCC) -o obj/$(RES_NSEND).o -c $(RES_NSEND).c $(CFLAGS) $(RES_SEARCH): $(RES_SEARCH).o $(GCC) -o $(RES_SEARCH) obj/$(RES_SEARCH).o $(LDFLAGS) $(RES_SEARCH).o: $(GCC) -o obj/$(RES_SEARCH).o -c $(RES_SEARCH).c $(CFLAGS) $(SETDOMAINNAME): $(SETDOMAINNAME).o $(GCC) -o $(SETDOMAINNAME) obj/$(SETDOMAINNAME).o $(LDFLAGS) $(SETDOMAINNAME).o: $(GCC) -o obj/$(SETDOMAINNAME).o -c $(SETDOMAINNAME).c $(CFLAGS) $(SETHOSTENT): $(SETHOSTENT).o $(GCC) -o $(SETHOSTENT) obj/$(SETHOSTENT).o $(LDFLAGS) $(SETHOSTENT).o: $(GCC) -o obj/$(SETHOSTENT).o -c $(SETHOSTENT).c $(CFLAGS) $(SETHOSTNAME): $(SETHOSTNAME).o $(GCC) -o $(SETHOSTNAME) obj/$(SETHOSTNAME).o $(LDFLAGS) $(SETHOSTNAME).o: $(GCC) -o obj/$(SETHOSTNAME).o -c $(SETHOSTNAME).c $(CFLAGS) $(SETNETENT): $(SETNETENT).o $(GCC) -o $(SETNETENT) obj/$(SETNETENT).o $(LDFLAGS) $(SETNETENT).o: $(GCC) -o obj/$(SETNETENT).o -c $(SETNETENT).c $(CFLAGS) $(SETNETGRENT): $(SETNETGRENT).o $(GCC) -o $(SETNETGRENT) obj/$(SETNETGRENT).o $(LDFLAGS) $(SETNETGRENT).o: $(GCC) -o obj/$(SETNETGRENT).o -c $(SETNETGRENT).c $(CFLAGS) $(SETPROTOENT): $(SETPROTOENT).o $(GCC) -o $(SETPROTOENT) obj/$(SETPROTOENT).o $(LDFLAGS) $(SETPROTOENT).o: $(GCC) -o obj/$(SETPROTOENT).o -c $(SETPROTOENT).c $(CFLAGS) $(SETSERVENT): $(SETSERVENT).o $(GCC) -o $(SETSERVENT) obj/$(SETSERVENT).o $(LDFLAGS) $(SETSERVENT).o: $(GCC) -o obj/$(SETSERVENT).o -c $(SETSERVENT).c $(CFLAGS)
#top Makefile.sol¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = -D_BOOT=1 -DNEED_DEF_S6_ADDR_S6UN=1 -DHAVE_INET_LNAOF=1 CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing LIBS = -lsocket -lnsl -lresolv LIBDIRS = LDFLAGS = $(LIBDIRS) $(LIBS) RM = rm -f MKDCMD = mkdir -p DN_EXPAND = dn_expand DN_SKIPNAME = dn_skipname ENDHOSTENT = endhostent ENDNETENT = endnetent ENDNETGRENT = endnetgrent ENDPROTOENT = endprotoent ENDSERVENT = endservent FREEADDRINFO= freeaddrinfo GETADDRINFO = getaddrinfo GETDOMAINNAME= getdomainname GETHOSTBYADDR= gethostbyaddr GETHOSTBYNAME2= gethostbyname2 GETHOSTBYNAME= gethostbyname GETHOSTENT = gethostent GETHOSTNAME = gethostname GETNAMEINFO = getnameinfo GETNETBYADDR= getnetbyaddr GETNETBYNAME= getnetbyname GETNETENT = getnetent GETNETGRENT = getnetgrent GETPROTOBYNAME= getprotobyname GETPROTOBYNUMBER= getprotobynumber GETPROTOENT = getprotoent GETSERVBYNAME= getservbyname GETSERVBYPORT= getservbyport GETSERVENT = getservent HSTRERROR = hstrerror HTONL = htonl HTONS = htons INET_ADDR = inet_addr INET_ATON = inet_aton INET_LNAOF = inet_lnaof INET_MAKEADDR= inet_makeaddr INET_NETA = inet_neta INET_NET_NTOP= inet_net_ntop INET_NETOF = inet_netof INET_NET_PTON= inet_net_pton INET_NETWORK= inet_network INET_NSAP_ADDR= inet_nsap_addr INET_NSAP_NTOA= inet_nsap_ntoa INET_NTOA = inet_ntoa INET_NTOP = inet_ntop INET_PTON = inet_pton INNETGR = innetgr NTOHL = ntohl NTOHS = ntohs RES_NCLOSE = res_nclose RES_NMKQUERY= res_nmkquery RES_NSEND = res_nsend RES_SEARCH = res_search SETDOMAINNAME= setdomainname SETHOSTENT = sethostent SETHOSTNAME = sethostname SETNETENT = setnetent SETNETGRENT = setnetgrent SETPROTOENT = setprotoent SETSERVENT = setservent all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(DN_EXPAND) #make: $(DN_SKIPNAME) #make: $(ENDHOSTENT) #make: $(ENDNETENT) #make: $(ENDNETGRENT) #make: $(ENDPROTOENT) #make: $(ENDSERVENT) #make: $(FREEADDRINFO) #make: $(GETADDRINFO) #make: $(GETDOMAINNAME) #make: $(GETHOSTBYADDR) #make: $(GETHOSTBYNAME2) #make: $(GETHOSTBYNAME) #make: $(GETHOSTENT) #make: $(GETHOSTNAME) #make: $(GETNAMEINFO) #make: $(GETNETBYADDR) #make: $(GETNETBYNAME) #make: $(GETNETENT) #make: $(GETNETGRENT) #make: $(GETPROTOBYNAME) #make: $(GETPROTOBYNUMBER) #make: $(GETPROTOENT) #make: $(GETSERVBYNAME) #make: $(GETSERVBYPORT) #make: $(GETSERVENT) #make: $(HSTRERROR) #make: $(HTONL) #make: $(HTONS) #make: $(INET_ADDR) #make: $(INET_ATON) #make: $(INET_LNAOF) #make: $(INET_MAKEADDR) #make: $(INET_NETA) #make: $(INET_NET_NTOP) #make: $(INET_NETOF) #make: $(INET_NET_PTON) #make: $(INET_NETWORK) #make: $(INET_NSAP_ADDR) #make: $(INET_NSAP_NTOA) #make: $(INET_NTOA) #make: $(INET_NTOP) #make: $(INET_PTON) #make: $(INNETGR) #make: $(NTOHL) #make: $(NTOHS) #make: $(RES_NCLOSE) #make: $(RES_NMKQUERY) #make: $(RES_NSEND) #make: $(RES_SEARCH) #make: $(SETDOMAINNAME) #make: $(SETHOSTENT) #make: $(SETHOSTNAME) #make: $(SETNETENT) #make: $(SETNETGRENT) #make: $(SETPROTOENT) #make: $(SETSERVENT) make: $(DN_EXPAND) $(DN_SKIPNAME) $(ENDHOSTENT) $(ENDNETENT) $(ENDNETGRENT) $(ENDPROTOENT) $(ENDSERVENT) $(FREEADDRINFO) $(GETADDRINFO) $(GETDOMAINNAME) $(GETHOSTBYADDR) $(GETHOSTBYNAME2) $(GETHOSTBYNAME) $(GETHOSTENT) $(GETHOSTNAME) $(GETNAMEINFO) $(GETNETBYADDR) $(GETNETBYNAME) $(GETNETENT) $(GETNETGRENT) $(GETPROTOBYNAME) $(GETPROTOBYNUMBER) $(GETPROTOENT) $(GETSERVBYNAME) $(GETSERVBYPORT) $(GETSERVENT) $(HSTRERROR) $(HTONL) $(HTONS) $(INET_ADDR) $(INET_ATON) $(INET_LNAOF) $(INET_MAKEADDR) $(INET_NETA) $(INET_NET_NTOP) $(INET_NETOF) $(INET_NET_PTON) $(INET_NETWORK) $(INET_NSAP_ADDR) $(INET_NSAP_NTOA) $(INET_NTOA) $(INET_NTOP) $(INET_PTON) $(INNETGR) $(NTOHL) $(NTOHS) $(RES_NCLOSE) $(RES_NMKQUERY) $(RES_NSEND) $(RES_SEARCH) $(SETDOMAINNAME) $(SETHOSTENT) $(SETHOSTNAME) $(SETNETENT) $(SETNETGRENT) $(SETPROTOENT) $(SETSERVENT) $(DN_EXPAND): $(DN_EXPAND).o $(GCC) -o $(DN_EXPAND) obj/$(DN_EXPAND).o $(LDFLAGS) $(DN_EXPAND).o: $(GCC) -o obj/$(DN_EXPAND).o -c $(DN_EXPAND).c $(CFLAGS) $(DN_SKIPNAME): $(DN_SKIPNAME).o $(GCC) -o $(DN_SKIPNAME) obj/$(DN_SKIPNAME).o $(LDFLAGS) $(DN_SKIPNAME).o: $(GCC) -o obj/$(DN_SKIPNAME).o -c $(DN_SKIPNAME).c $(CFLAGS) $(ENDHOSTENT): $(ENDHOSTENT).o $(GCC) -o $(ENDHOSTENT) obj/$(ENDHOSTENT).o $(LDFLAGS) $(ENDHOSTENT).o: $(GCC) -o obj/$(ENDHOSTENT).o -c $(ENDHOSTENT).c $(CFLAGS) $(ENDNETENT): $(ENDNETENT).o $(GCC) -o $(ENDNETENT) obj/$(ENDNETENT).o $(LDFLAGS) $(ENDNETENT).o: $(GCC) -o obj/$(ENDNETENT).o -c $(ENDNETENT).c $(CFLAGS) $(ENDNETGRENT): $(ENDNETGRENT).o $(GCC) -o $(ENDNETGRENT) obj/$(ENDNETGRENT).o $(LDFLAGS) $(ENDNETGRENT).o: $(GCC) -o obj/$(ENDNETGRENT).o -c $(ENDNETGRENT).c $(CFLAGS) $(ENDPROTOENT): $(ENDPROTOENT).o $(GCC) -o $(ENDPROTOENT) obj/$(ENDPROTOENT).o $(LDFLAGS) $(ENDPROTOENT).o: $(GCC) -o obj/$(ENDPROTOENT).o -c $(ENDPROTOENT).c $(CFLAGS) $(ENDSERVENT): $(ENDSERVENT).o $(GCC) -o $(ENDSERVENT) obj/$(ENDSERVENT).o $(LDFLAGS) $(ENDSERVENT).o: $(GCC) -o obj/$(ENDSERVENT).o -c $(ENDSERVENT).c $(CFLAGS) $(FREEADDRINFO): $(FREEADDRINFO).o $(GCC) -o $(FREEADDRINFO) obj/$(FREEADDRINFO).o $(LDFLAGS) $(FREEADDRINFO).o: $(GCC) -o obj/$(FREEADDRINFO).o -c $(FREEADDRINFO).c $(CFLAGS) $(GETADDRINFO): $(GETADDRINFO).o $(GCC) -o $(GETADDRINFO) obj/$(GETADDRINFO).o $(LDFLAGS) $(GETADDRINFO).o: $(GCC) -o obj/$(GETADDRINFO).o -c $(GETADDRINFO).c $(CFLAGS) $(GETDOMAINNAME): $(GETDOMAINNAME).o $(GCC) -o $(GETDOMAINNAME) obj/$(GETDOMAINNAME).o $(LDFLAGS) $(GETDOMAINNAME).o: $(GCC) -o obj/$(GETDOMAINNAME).o -c $(GETDOMAINNAME).c $(CFLAGS) $(GETHOSTBYADDR): $(GETHOSTBYADDR).o $(GCC) -o $(GETHOSTBYADDR) obj/$(GETHOSTBYADDR).o $(LDFLAGS) $(GETHOSTBYADDR).o: $(GCC) -o obj/$(GETHOSTBYADDR).o -c $(GETHOSTBYADDR).c $(CFLAGS) $(GETHOSTBYNAME2): $(GETHOSTBYNAME2).o $(GCC) -o $(GETHOSTBYNAME2) obj/$(GETHOSTBYNAME2).o $(LDFLAGS) $(GETHOSTBYNAME2).o: $(GCC) -o obj/$(GETHOSTBYNAME2).o -c $(GETHOSTBYNAME2).c $(CFLAGS) $(GETHOSTBYNAME): $(GETHOSTBYNAME).o $(GCC) -o $(GETHOSTBYNAME) obj/$(GETHOSTBYNAME).o $(LDFLAGS) $(GETHOSTBYNAME).o: $(GCC) -o obj/$(GETHOSTBYNAME).o -c $(GETHOSTBYNAME).c $(CFLAGS) $(GETHOSTENT): $(GETHOSTENT).o $(GCC) -o $(GETHOSTENT) obj/$(GETHOSTENT).o $(LDFLAGS) $(GETHOSTENT).o: $(GCC) -o obj/$(GETHOSTENT).o -c $(GETHOSTENT).c $(CFLAGS) $(GETHOSTNAME): $(GETHOSTNAME).o $(GCC) -o $(GETHOSTNAME) obj/$(GETHOSTNAME).o $(LDFLAGS) $(GETHOSTNAME).o: $(GCC) -o obj/$(GETHOSTNAME).o -c $(GETHOSTNAME).c $(CFLAGS) $(GETNAMEINFO): $(GETNAMEINFO).o $(GCC) -o $(GETNAMEINFO) obj/$(GETNAMEINFO).o $(LDFLAGS) $(GETNAMEINFO).o: $(GCC) -o obj/$(GETNAMEINFO).o -c $(GETNAMEINFO).c $(CFLAGS) $(GETNETBYADDR): $(GETNETBYADDR).o $(GCC) -o $(GETNETBYADDR) obj/$(GETNETBYADDR).o $(LDFLAGS) $(GETNETBYADDR).o: $(GCC) -o obj/$(GETNETBYADDR).o -c $(GETNETBYADDR).c $(CFLAGS) $(GETNETBYNAME): $(GETNETBYNAME).o $(GCC) -o $(GETNETBYNAME) obj/$(GETNETBYNAME).o $(LDFLAGS) $(GETNETBYNAME).o: $(GCC) -o obj/$(GETNETBYNAME).o -c $(GETNETBYNAME).c $(CFLAGS) $(GETNETENT): $(GETNETENT).o $(GCC) -o $(GETNETENT) obj/$(GETNETENT).o $(LDFLAGS) $(GETNETENT).o: $(GCC) -o obj/$(GETNETENT).o -c $(GETNETENT).c $(CFLAGS) $(GETNETGRENT): $(GETNETGRENT).o $(GCC) -o $(GETNETGRENT) obj/$(GETNETGRENT).o $(LDFLAGS) $(GETNETGRENT).o: $(GCC) -o obj/$(GETNETGRENT).o -c $(GETNETGRENT).c $(CFLAGS) $(GETPROTOBYNAME): $(GETPROTOBYNAME).o $(GCC) -o $(GETPROTOBYNAME) obj/$(GETPROTOBYNAME).o $(LDFLAGS) $(GETPROTOBYNAME).o: $(GCC) -o obj/$(GETPROTOBYNAME).o -c $(GETPROTOBYNAME).c $(CFLAGS) $(GETPROTOBYNUMBER): $(GETPROTOBYNUMBER).o $(GCC) -o $(GETPROTOBYNUMBER) obj/$(GETPROTOBYNUMBER).o $(LDFLAGS) $(GETPROTOBYNUMBER).o: $(GCC) -o obj/$(GETPROTOBYNUMBER).o -c $(GETPROTOBYNUMBER).c $(CFLAGS) $(GETPROTOENT): $(GETPROTOENT).o $(GCC) -o $(GETPROTOENT) obj/$(GETPROTOENT).o $(LDFLAGS) $(GETPROTOENT).o: $(GCC) -o obj/$(GETPROTOENT).o -c $(GETPROTOENT).c $(CFLAGS) $(GETSERVBYNAME): $(GETSERVBYNAME).o $(GCC) -o $(GETSERVBYNAME) obj/$(GETSERVBYNAME).o $(LDFLAGS) $(GETSERVBYNAME).o: $(GCC) -o obj/$(GETSERVBYNAME).o -c $(GETSERVBYNAME).c $(CFLAGS) $(GETSERVBYPORT): $(GETSERVBYPORT).o $(GCC) -o $(GETSERVBYPORT) obj/$(GETSERVBYPORT).o $(LDFLAGS) $(GETSERVBYPORT).o: $(GCC) -o obj/$(GETSERVBYPORT).o -c $(GETSERVBYPORT).c $(CFLAGS) $(GETSERVENT): $(GETSERVENT).o $(GCC) -o $(GETSERVENT) obj/$(GETSERVENT).o $(LDFLAGS) $(GETSERVENT).o: $(GCC) -o obj/$(GETSERVENT).o -c $(GETSERVENT).c $(CFLAGS) $(HSTRERROR): $(HSTRERROR).o $(GCC) -o $(HSTRERROR) obj/$(HSTRERROR).o $(LDFLAGS) $(HSTRERROR).o: $(GCC) -o obj/$(HSTRERROR).o -c $(HSTRERROR).c $(CFLAGS) $(HTONL): $(HTONL).o $(GCC) -o $(HTONL) obj/$(HTONL).o $(LDFLAGS) $(HTONL).o: $(GCC) -o obj/$(HTONL).o -c $(HTONL).c $(CFLAGS) $(HTONS): $(HTONS).o $(GCC) -o $(HTONS) obj/$(HTONS).o $(LDFLAGS) $(HTONS).o: $(GCC) -o obj/$(HTONS).o -c $(HTONS).c $(CFLAGS) $(INET_ADDR): $(INET_ADDR).o $(GCC) -o $(INET_ADDR) obj/$(INET_ADDR).o $(LDFLAGS) $(INET_ADDR).o: $(GCC) -o obj/$(INET_ADDR).o -c $(INET_ADDR).c $(CFLAGS) $(INET_ATON): $(INET_ATON).o $(GCC) -o $(INET_ATON) obj/$(INET_ATON).o $(LDFLAGS) $(INET_ATON).o: $(GCC) -o obj/$(INET_ATON).o -c $(INET_ATON).c $(CFLAGS) $(INET_LNAOF): $(INET_LNAOF).o $(GCC) -o $(INET_LNAOF) obj/$(INET_LNAOF).o $(LDFLAGS) $(INET_LNAOF).o: $(GCC) -o obj/$(INET_LNAOF).o -c $(INET_LNAOF).c $(CFLAGS) $(INET_MAKEADDR): $(INET_MAKEADDR).o $(GCC) -o $(INET_MAKEADDR) obj/$(INET_MAKEADDR).o $(LDFLAGS) $(INET_MAKEADDR).o: $(GCC) -o obj/$(INET_MAKEADDR).o -c $(INET_MAKEADDR).c $(CFLAGS) $(INET_NETA): $(INET_NETA).o $(GCC) -o $(INET_NETA) obj/$(INET_NETA).o $(LDFLAGS) $(INET_NETA).o: $(GCC) -o obj/$(INET_NETA).o -c $(INET_NETA).c $(CFLAGS) $(INET_NET_NTOP): $(INET_NET_NTOP).o $(GCC) -o $(INET_NET_NTOP) obj/$(INET_NET_NTOP).o $(LDFLAGS) $(INET_NET_NTOP).o: $(GCC) -o obj/$(INET_NET_NTOP).o -c $(INET_NET_NTOP).c $(CFLAGS) $(INET_NETOF): $(INET_NETOF).o $(GCC) -o $(INET_NETOF) obj/$(INET_NETOF).o $(LDFLAGS) $(INET_NETOF).o: $(GCC) -o obj/$(INET_NETOF).o -c $(INET_NETOF).c $(CFLAGS) $(INET_NET_PTON): $(INET_NET_PTON).o $(GCC) -o $(INET_NET_PTON) obj/$(INET_NET_PTON).o $(LDFLAGS) $(INET_NET_PTON).o: $(GCC) -o obj/$(INET_NET_PTON).o -c $(INET_NET_PTON).c $(CFLAGS) $(INET_NETWORK): $(INET_NETWORK).o $(GCC) -o $(INET_NETWORK) obj/$(INET_NETWORK).o $(LDFLAGS) $(INET_NETWORK).o: $(GCC) -o obj/$(INET_NETWORK).o -c $(INET_NETWORK).c $(CFLAGS) $(INET_NSAP_ADDR): $(INET_NSAP_ADDR).o $(GCC) -o $(INET_NSAP_ADDR) obj/$(INET_NSAP_ADDR).o $(LDFLAGS) $(INET_NSAP_ADDR).o: $(GCC) -o obj/$(INET_NSAP_ADDR).o -c $(INET_NSAP_ADDR).c $(CFLAGS) $(INET_NSAP_NTOA): $(INET_NSAP_NTOA).o $(GCC) -o $(INET_NSAP_NTOA) obj/$(INET_NSAP_NTOA).o $(LDFLAGS) $(INET_NSAP_NTOA).o: $(GCC) -o obj/$(INET_NSAP_NTOA).o -c $(INET_NSAP_NTOA).c $(CFLAGS) $(INET_NTOA): $(INET_NTOA).o $(GCC) -o $(INET_NTOA) obj/$(INET_NTOA).o $(LDFLAGS) $(INET_NTOA).o: $(GCC) -o obj/$(INET_NTOA).o -c $(INET_NTOA).c $(CFLAGS) $(INET_NTOP): $(INET_NTOP).o $(GCC) -o $(INET_NTOP) obj/$(INET_NTOP).o $(LDFLAGS) $(INET_NTOP).o: $(GCC) -o obj/$(INET_NTOP).o -c $(INET_NTOP).c $(CFLAGS) $(INET_PTON): $(INET_PTON).o $(GCC) -o $(INET_PTON) obj/$(INET_PTON).o $(LDFLAGS) $(INET_PTON).o: $(GCC) -o obj/$(INET_PTON).o -c $(INET_PTON).c $(CFLAGS) $(INNETGR): $(INNETGR).o $(GCC) -o $(INNETGR) obj/$(INNETGR).o $(LDFLAGS) $(INNETGR).o: $(GCC) -o obj/$(INNETGR).o -c $(INNETGR).c $(CFLAGS) $(NTOHL): $(NTOHL).o $(GCC) -o $(NTOHL) obj/$(NTOHL).o $(LDFLAGS) $(NTOHL).o: $(GCC) -o obj/$(NTOHL).o -c $(NTOHL).c $(CFLAGS) $(NTOHS): $(NTOHS).o $(GCC) -o $(NTOHS) obj/$(NTOHS).o $(LDFLAGS) $(NTOHS).o: $(GCC) -o obj/$(NTOHS).o -c $(NTOHS).c $(CFLAGS) $(RES_NCLOSE): $(RES_NCLOSE).o $(GCC) -o $(RES_NCLOSE) obj/$(RES_NCLOSE).o $(LDFLAGS) $(RES_NCLOSE).o: $(GCC) -o obj/$(RES_NCLOSE).o -c $(RES_NCLOSE).c $(CFLAGS) $(RES_NMKQUERY): $(RES_NMKQUERY).o $(GCC) -o $(RES_NMKQUERY) obj/$(RES_NMKQUERY).o $(LDFLAGS) $(RES_NMKQUERY).o: $(GCC) -o obj/$(RES_NMKQUERY).o -c $(RES_NMKQUERY).c $(CFLAGS) $(RES_NSEND): $(RES_NSEND).o $(GCC) -o $(RES_NSEND) obj/$(RES_NSEND).o $(LDFLAGS) $(RES_NSEND).o: $(GCC) -o obj/$(RES_NSEND).o -c $(RES_NSEND).c $(CFLAGS) $(RES_SEARCH): $(RES_SEARCH).o $(GCC) -o $(RES_SEARCH) obj/$(RES_SEARCH).o $(LDFLAGS) $(RES_SEARCH).o: $(GCC) -o obj/$(RES_SEARCH).o -c $(RES_SEARCH).c $(CFLAGS) $(SETDOMAINNAME): $(SETDOMAINNAME).o $(GCC) -o $(SETDOMAINNAME) obj/$(SETDOMAINNAME).o $(LDFLAGS) $(SETDOMAINNAME).o: $(GCC) -o obj/$(SETDOMAINNAME).o -c $(SETDOMAINNAME).c $(CFLAGS) $(SETHOSTENT): $(SETHOSTENT).o $(GCC) -o $(SETHOSTENT) obj/$(SETHOSTENT).o $(LDFLAGS) $(SETHOSTENT).o: $(GCC) -o obj/$(SETHOSTENT).o -c $(SETHOSTENT).c $(CFLAGS) $(SETHOSTNAME): $(SETHOSTNAME).o $(GCC) -o $(SETHOSTNAME) obj/$(SETHOSTNAME).o $(LDFLAGS) $(SETHOSTNAME).o: $(GCC) -o obj/$(SETHOSTNAME).o -c $(SETHOSTNAME).c $(CFLAGS) $(SETNETENT): $(SETNETENT).o $(GCC) -o $(SETNETENT) obj/$(SETNETENT).o $(LDFLAGS) $(SETNETENT).o: $(GCC) -o obj/$(SETNETENT).o -c $(SETNETENT).c $(CFLAGS) $(SETNETGRENT): $(SETNETGRENT).o $(GCC) -o $(SETNETGRENT) obj/$(SETNETGRENT).o $(LDFLAGS) $(SETNETGRENT).o: $(GCC) -o obj/$(SETNETGRENT).o -c $(SETNETGRENT).c $(CFLAGS) $(SETPROTOENT): $(SETPROTOENT).o $(GCC) -o $(SETPROTOENT) obj/$(SETPROTOENT).o $(LDFLAGS) $(SETPROTOENT).o: $(GCC) -o obj/$(SETPROTOENT).o -c $(SETPROTOENT).c $(CFLAGS) $(SETSERVENT): $(SETSERVENT).o $(GCC) -o $(SETSERVENT) obj/$(SETSERVENT).o $(LDFLAGS) $(SETSERVENT).o: $(GCC) -o obj/$(SETSERVENT).o -c $(SETSERVENT).c $(CFLAGS)
#top Makefile.beos¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = -DNEED_DEF_S6_ADDR_S6ADDR=1 -DHAVE_INET_LNAOF=1 -DHAVE_RES_SEARCH=1 CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT CFLAGS = $(INCS) -W -O2 -Wall -pedantic LIBS = -lsocket LIBDIRS = -L/boot/system/lib LDFLAGS = $(LIBDIRS) $(LIBS) RM = rm -f MKDCMD = mkdir -p DN_EXPAND = dn_expand DN_SKIPNAME = dn_skipname ENDHOSTENT = endhostent ENDNETENT = endnetent ENDNETGRENT = endnetgrent ENDPROTOENT = endprotoent ENDSERVENT = endservent FREEADDRINFO= freeaddrinfo GETADDRINFO = getaddrinfo GETDOMAINNAME= getdomainname GETHOSTBYADDR= gethostbyaddr GETHOSTBYNAME2= gethostbyname2 GETHOSTBYNAME= gethostbyname GETHOSTENT = gethostent GETHOSTNAME = gethostname GETNAMEINFO = getnameinfo GETNETBYADDR= getnetbyaddr GETNETBYNAME= getnetbyname GETNETENT = getnetent GETNETGRENT = getnetgrent GETPROTOBYNAME= getprotobyname GETPROTOBYNUMBER= getprotobynumber GETPROTOENT = getprotoent GETSERVBYNAME= getservbyname GETSERVBYPORT= getservbyport GETSERVENT = getservent HSTRERROR = hstrerror HTONL = htonl HTONS = htons INET_ADDR = inet_addr INET_ATON = inet_aton INET_LNAOF = inet_lnaof INET_MAKEADDR= inet_makeaddr INET_NETA = inet_neta INET_NET_NTOP= inet_net_ntop INET_NETOF = inet_netof INET_NET_PTON= inet_net_pton INET_NETWORK= inet_network INET_NSAP_ADDR= inet_nsap_addr INET_NSAP_NTOA= inet_nsap_ntoa INET_NTOA = inet_ntoa INET_NTOP = inet_ntop INET_PTON = inet_pton INNETGR = innetgr NTOHL = ntohl NTOHS = ntohs RES_NCLOSE = res_nclose RES_NMKQUERY= res_nmkquery RES_NSEND = res_nsend RES_SEARCH = res_search SETDOMAINNAME= setdomainname SETHOSTENT = sethostent SETHOSTNAME = sethostname SETNETENT = setnetent SETNETGRENT = setnetgrent SETPROTOENT = setprotoent SETSERVENT = setservent all: objdir make objdir: $(MKDCMD) obj/ clean: objdir $(RM) obj/*.o *.o *~ #make: $(DN_EXPAND) #make: $(DN_SKIPNAME) #make: $(ENDHOSTENT) #make: $(ENDNETENT) #make: $(ENDNETGRENT) #make: $(ENDPROTOENT) #make: $(ENDSERVENT) #make: $(FREEADDRINFO) #make: $(GETADDRINFO) #make: $(GETDOMAINNAME) #make: $(GETHOSTBYADDR) #make: $(GETHOSTBYNAME2) #make: $(GETHOSTBYNAME) #make: $(GETHOSTENT) #make: $(GETHOSTNAME) #make: $(GETNAMEINFO) #make: $(GETNETBYADDR) #make: $(GETNETBYNAME) #make: $(GETNETENT) #make: $(GETNETGRENT) #make: $(GETPROTOBYNAME) #make: $(GETPROTOBYNUMBER) #make: $(GETPROTOENT) #make: $(GETSERVBYNAME) #make: $(GETSERVBYPORT) #make: $(GETSERVENT) #make: $(HSTRERROR) #make: $(HTONL) #make: $(HTONS) #make: $(INET_ADDR) #make: $(INET_ATON) #make: $(INET_LNAOF) #make: $(INET_MAKEADDR) #make: $(INET_NETA) #make: $(INET_NET_NTOP) #make: $(INET_NETOF) #make: $(INET_NET_PTON) #make: $(INET_NETWORK) #make: $(INET_NSAP_ADDR) #make: $(INET_NSAP_NTOA) #make: $(INET_NTOA) #make: $(INET_NTOP) #make: $(INET_PTON) #make: $(INNETGR) #make: $(NTOHL) #make: $(NTOHS) #make: $(RES_NCLOSE) #make: $(RES_NMKQUERY) #make: $(RES_NSEND) #make: $(RES_SEARCH) #make: $(SETDOMAINNAME) #make: $(SETHOSTENT) #make: $(SETHOSTNAME) #make: $(SETNETENT) #make: $(SETNETGRENT) #make: $(SETPROTOENT) #make: $(SETSERVENT) make: $(DN_EXPAND) $(DN_SKIPNAME) $(ENDHOSTENT) $(ENDNETENT) $(ENDNETGRENT) $(ENDPROTOENT) $(ENDSERVENT) $(FREEADDRINFO) $(GETADDRINFO) $(GETDOMAINNAME) $(GETHOSTBYADDR) $(GETHOSTBYNAME2) $(GETHOSTBYNAME) $(GETHOSTENT) $(GETHOSTNAME) $(GETNAMEINFO) $(GETNETBYADDR) $(GETNETBYNAME) $(GETNETENT) $(GETNETGRENT) $(GETPROTOBYNAME) $(GETPROTOBYNUMBER) $(GETPROTOENT) $(GETSERVBYNAME) $(GETSERVBYPORT) $(GETSERVENT) $(HSTRERROR) $(HTONL) $(HTONS) $(INET_ADDR) $(INET_ATON) $(INET_LNAOF) $(INET_MAKEADDR) $(INET_NETA) $(INET_NET_NTOP) $(INET_NETOF) $(INET_NET_PTON) $(INET_NETWORK) $(INET_NSAP_ADDR) $(INET_NSAP_NTOA) $(INET_NTOA) $(INET_NTOP) $(INET_PTON) $(INNETGR) $(NTOHL) $(NTOHS) $(RES_NCLOSE) $(RES_NMKQUERY) $(RES_NSEND) $(RES_SEARCH) $(SETDOMAINNAME) $(SETHOSTENT) $(SETHOSTNAME) $(SETNETENT) $(SETNETGRENT) $(SETPROTOENT) $(SETSERVENT) $(DN_EXPAND): $(DN_EXPAND).o $(GCC) -o $(DN_EXPAND) obj/$(DN_EXPAND).o $(LDFLAGS) $(DN_EXPAND).o: $(GCC) -o obj/$(DN_EXPAND).o -c $(DN_EXPAND).c $(CFLAGS) $(DN_SKIPNAME): $(DN_SKIPNAME).o $(GCC) -o $(DN_SKIPNAME) obj/$(DN_SKIPNAME).o $(LDFLAGS) $(DN_SKIPNAME).o: $(GCC) -o obj/$(DN_SKIPNAME).o -c $(DN_SKIPNAME).c $(CFLAGS) $(ENDHOSTENT): $(ENDHOSTENT).o $(GCC) -o $(ENDHOSTENT) obj/$(ENDHOSTENT).o $(LDFLAGS) $(ENDHOSTENT).o: $(GCC) -o obj/$(ENDHOSTENT).o -c $(ENDHOSTENT).c $(CFLAGS) $(ENDNETENT): $(ENDNETENT).o $(GCC) -o $(ENDNETENT) obj/$(ENDNETENT).o $(LDFLAGS) $(ENDNETENT).o: $(GCC) -o obj/$(ENDNETENT).o -c $(ENDNETENT).c $(CFLAGS) $(ENDNETGRENT): $(ENDNETGRENT).o $(GCC) -o $(ENDNETGRENT) obj/$(ENDNETGRENT).o $(LDFLAGS) $(ENDNETGRENT).o: $(GCC) -o obj/$(ENDNETGRENT).o -c $(ENDNETGRENT).c $(CFLAGS) $(ENDPROTOENT): $(ENDPROTOENT).o $(GCC) -o $(ENDPROTOENT) obj/$(ENDPROTOENT).o $(LDFLAGS) $(ENDPROTOENT).o: $(GCC) -o obj/$(ENDPROTOENT).o -c $(ENDPROTOENT).c $(CFLAGS) $(ENDSERVENT): $(ENDSERVENT).o $(GCC) -o $(ENDSERVENT) obj/$(ENDSERVENT).o $(LDFLAGS) $(ENDSERVENT).o: $(GCC) -o obj/$(ENDSERVENT).o -c $(ENDSERVENT).c $(CFLAGS) $(FREEADDRINFO): $(FREEADDRINFO).o $(GCC) -o $(FREEADDRINFO) obj/$(FREEADDRINFO).o $(LDFLAGS) $(FREEADDRINFO).o: $(GCC) -o obj/$(FREEADDRINFO).o -c $(FREEADDRINFO).c $(CFLAGS) $(GETADDRINFO): $(GETADDRINFO).o $(GCC) -o $(GETADDRINFO) obj/$(GETADDRINFO).o $(LDFLAGS) $(GETADDRINFO).o: $(GCC) -o obj/$(GETADDRINFO).o -c $(GETADDRINFO).c $(CFLAGS) $(GETDOMAINNAME): $(GETDOMAINNAME).o $(GCC) -o $(GETDOMAINNAME) obj/$(GETDOMAINNAME).o $(LDFLAGS) $(GETDOMAINNAME).o: $(GCC) -o obj/$(GETDOMAINNAME).o -c $(GETDOMAINNAME).c $(CFLAGS) $(GETHOSTBYADDR): $(GETHOSTBYADDR).o $(GCC) -o $(GETHOSTBYADDR) obj/$(GETHOSTBYADDR).o $(LDFLAGS) $(GETHOSTBYADDR).o: $(GCC) -o obj/$(GETHOSTBYADDR).o -c $(GETHOSTBYADDR).c $(CFLAGS) $(GETHOSTBYNAME2): $(GETHOSTBYNAME2).o $(GCC) -o $(GETHOSTBYNAME2) obj/$(GETHOSTBYNAME2).o $(LDFLAGS) $(GETHOSTBYNAME2).o: $(GCC) -o obj/$(GETHOSTBYNAME2).o -c $(GETHOSTBYNAME2).c $(CFLAGS) $(GETHOSTBYNAME): $(GETHOSTBYNAME).o $(GCC) -o $(GETHOSTBYNAME) obj/$(GETHOSTBYNAME).o $(LDFLAGS) $(GETHOSTBYNAME).o: $(GCC) -o obj/$(GETHOSTBYNAME).o -c $(GETHOSTBYNAME).c $(CFLAGS) $(GETHOSTENT): $(GETHOSTENT).o $(GCC) -o $(GETHOSTENT) obj/$(GETHOSTENT).o $(LDFLAGS) $(GETHOSTENT).o: $(GCC) -o obj/$(GETHOSTENT).o -c $(GETHOSTENT).c $(CFLAGS) $(GETHOSTNAME): $(GETHOSTNAME).o $(GCC) -o $(GETHOSTNAME) obj/$(GETHOSTNAME).o $(LDFLAGS) $(GETHOSTNAME).o: $(GCC) -o obj/$(GETHOSTNAME).o -c $(GETHOSTNAME).c $(CFLAGS) $(GETNAMEINFO): $(GETNAMEINFO).o $(GCC) -o $(GETNAMEINFO) obj/$(GETNAMEINFO).o $(LDFLAGS) $(GETNAMEINFO).o: $(GCC) -o obj/$(GETNAMEINFO).o -c $(GETNAMEINFO).c $(CFLAGS) $(GETNETBYADDR): $(GETNETBYADDR).o $(GCC) -o $(GETNETBYADDR) obj/$(GETNETBYADDR).o $(LDFLAGS) $(GETNETBYADDR).o: $(GCC) -o obj/$(GETNETBYADDR).o -c $(GETNETBYADDR).c $(CFLAGS) $(GETNETBYNAME): $(GETNETBYNAME).o $(GCC) -o $(GETNETBYNAME) obj/$(GETNETBYNAME).o $(LDFLAGS) $(GETNETBYNAME).o: $(GCC) -o obj/$(GETNETBYNAME).o -c $(GETNETBYNAME).c $(CFLAGS) $(GETNETENT): $(GETNETENT).o $(GCC) -o $(GETNETENT) obj/$(GETNETENT).o $(LDFLAGS) $(GETNETENT).o: $(GCC) -o obj/$(GETNETENT).o -c $(GETNETENT).c $(CFLAGS) $(GETNETGRENT): $(GETNETGRENT).o $(GCC) -o $(GETNETGRENT) obj/$(GETNETGRENT).o $(LDFLAGS) $(GETNETGRENT).o: $(GCC) -o obj/$(GETNETGRENT).o -c $(GETNETGRENT).c $(CFLAGS) $(GETPROTOBYNAME): $(GETPROTOBYNAME).o $(GCC) -o $(GETPROTOBYNAME) obj/$(GETPROTOBYNAME).o $(LDFLAGS) $(GETPROTOBYNAME).o: $(GCC) -o obj/$(GETPROTOBYNAME).o -c $(GETPROTOBYNAME).c $(CFLAGS) $(GETPROTOBYNUMBER): $(GETPROTOBYNUMBER).o $(GCC) -o $(GETPROTOBYNUMBER) obj/$(GETPROTOBYNUMBER).o $(LDFLAGS) $(GETPROTOBYNUMBER).o: $(GCC) -o obj/$(GETPROTOBYNUMBER).o -c $(GETPROTOBYNUMBER).c $(CFLAGS) $(GETPROTOENT): $(GETPROTOENT).o $(GCC) -o $(GETPROTOENT) obj/$(GETPROTOENT).o $(LDFLAGS) $(GETPROTOENT).o: $(GCC) -o obj/$(GETPROTOENT).o -c $(GETPROTOENT).c $(CFLAGS) $(GETSERVBYNAME): $(GETSERVBYNAME).o $(GCC) -o $(GETSERVBYNAME) obj/$(GETSERVBYNAME).o $(LDFLAGS) $(GETSERVBYNAME).o: $(GCC) -o obj/$(GETSERVBYNAME).o -c $(GETSERVBYNAME).c $(CFLAGS) $(GETSERVBYPORT): $(GETSERVBYPORT).o $(GCC) -o $(GETSERVBYPORT) obj/$(GETSERVBYPORT).o $(LDFLAGS) $(GETSERVBYPORT).o: $(GCC) -o obj/$(GETSERVBYPORT).o -c $(GETSERVBYPORT).c $(CFLAGS) $(GETSERVENT): $(GETSERVENT).o $(GCC) -o $(GETSERVENT) obj/$(GETSERVENT).o $(LDFLAGS) $(GETSERVENT).o: $(GCC) -o obj/$(GETSERVENT).o -c $(GETSERVENT).c $(CFLAGS) $(HSTRERROR): $(HSTRERROR).o $(GCC) -o $(HSTRERROR) obj/$(HSTRERROR).o $(LDFLAGS) $(HSTRERROR).o: $(GCC) -o obj/$(HSTRERROR).o -c $(HSTRERROR).c $(CFLAGS) $(HTONL): $(HTONL).o $(GCC) -o $(HTONL) obj/$(HTONL).o $(LDFLAGS) $(HTONL).o: $(GCC) -o obj/$(HTONL).o -c $(HTONL).c $(CFLAGS) $(HTONS): $(HTONS).o $(GCC) -o $(HTONS) obj/$(HTONS).o $(LDFLAGS) $(HTONS).o: $(GCC) -o obj/$(HTONS).o -c $(HTONS).c $(CFLAGS) $(INET_ADDR): $(INET_ADDR).o $(GCC) -o $(INET_ADDR) obj/$(INET_ADDR).o $(LDFLAGS) $(INET_ADDR).o: $(GCC) -o obj/$(INET_ADDR).o -c $(INET_ADDR).c $(CFLAGS) $(INET_ATON): $(INET_ATON).o $(GCC) -o $(INET_ATON) obj/$(INET_ATON).o $(LDFLAGS) $(INET_ATON).o: $(GCC) -o obj/$(INET_ATON).o -c $(INET_ATON).c $(CFLAGS) $(INET_LNAOF): $(INET_LNAOF).o $(GCC) -o $(INET_LNAOF) obj/$(INET_LNAOF).o $(LDFLAGS) $(INET_LNAOF).o: $(GCC) -o obj/$(INET_LNAOF).o -c $(INET_LNAOF).c $(CFLAGS) $(INET_MAKEADDR): $(INET_MAKEADDR).o $(GCC) -o $(INET_MAKEADDR) obj/$(INET_MAKEADDR).o $(LDFLAGS) $(INET_MAKEADDR).o: $(GCC) -o obj/$(INET_MAKEADDR).o -c $(INET_MAKEADDR).c $(CFLAGS) $(INET_NETA): $(INET_NETA).o $(GCC) -o $(INET_NETA) obj/$(INET_NETA).o $(LDFLAGS) $(INET_NETA).o: $(GCC) -o obj/$(INET_NETA).o -c $(INET_NETA).c $(CFLAGS) $(INET_NET_NTOP): $(INET_NET_NTOP).o $(GCC) -o $(INET_NET_NTOP) obj/$(INET_NET_NTOP).o $(LDFLAGS) $(INET_NET_NTOP).o: $(GCC) -o obj/$(INET_NET_NTOP).o -c $(INET_NET_NTOP).c $(CFLAGS) $(INET_NETOF): $(INET_NETOF).o $(GCC) -o $(INET_NETOF) obj/$(INET_NETOF).o $(LDFLAGS) $(INET_NETOF).o: $(GCC) -o obj/$(INET_NETOF).o -c $(INET_NETOF).c $(CFLAGS) $(INET_NET_PTON): $(INET_NET_PTON).o $(GCC) -o $(INET_NET_PTON) obj/$(INET_NET_PTON).o $(LDFLAGS) $(INET_NET_PTON).o: $(GCC) -o obj/$(INET_NET_PTON).o -c $(INET_NET_PTON).c $(CFLAGS) $(INET_NETWORK): $(INET_NETWORK).o $(GCC) -o $(INET_NETWORK) obj/$(INET_NETWORK).o $(LDFLAGS) $(INET_NETWORK).o: $(GCC) -o obj/$(INET_NETWORK).o -c $(INET_NETWORK).c $(CFLAGS) $(INET_NSAP_ADDR): $(INET_NSAP_ADDR).o $(GCC) -o $(INET_NSAP_ADDR) obj/$(INET_NSAP_ADDR).o $(LDFLAGS) $(INET_NSAP_ADDR).o: $(GCC) -o obj/$(INET_NSAP_ADDR).o -c $(INET_NSAP_ADDR).c $(CFLAGS) $(INET_NSAP_NTOA): $(INET_NSAP_NTOA).o $(GCC) -o $(INET_NSAP_NTOA) obj/$(INET_NSAP_NTOA).o $(LDFLAGS) $(INET_NSAP_NTOA).o: $(GCC) -o obj/$(INET_NSAP_NTOA).o -c $(INET_NSAP_NTOA).c $(CFLAGS) $(INET_NTOA): $(INET_NTOA).o $(GCC) -o $(INET_NTOA) obj/$(INET_NTOA).o $(LDFLAGS) $(INET_NTOA).o: $(GCC) -o obj/$(INET_NTOA).o -c $(INET_NTOA).c $(CFLAGS) $(INET_NTOP): $(INET_NTOP).o $(GCC) -o $(INET_NTOP) obj/$(INET_NTOP).o $(LDFLAGS) $(INET_NTOP).o: $(GCC) -o obj/$(INET_NTOP).o -c $(INET_NTOP).c $(CFLAGS) $(INET_PTON): $(INET_PTON).o $(GCC) -o $(INET_PTON) obj/$(INET_PTON).o $(LDFLAGS) $(INET_PTON).o: $(GCC) -o obj/$(INET_PTON).o -c $(INET_PTON).c $(CFLAGS) $(INNETGR): $(INNETGR).o $(GCC) -o $(INNETGR) obj/$(INNETGR).o $(LDFLAGS) $(INNETGR).o: $(GCC) -o obj/$(INNETGR).o -c $(INNETGR).c $(CFLAGS) $(NTOHL): $(NTOHL).o $(GCC) -o $(NTOHL) obj/$(NTOHL).o $(LDFLAGS) $(NTOHL).o: $(GCC) -o obj/$(NTOHL).o -c $(NTOHL).c $(CFLAGS) $(NTOHS): $(NTOHS).o $(GCC) -o $(NTOHS) obj/$(NTOHS).o $(LDFLAGS) $(NTOHS).o: $(GCC) -o obj/$(NTOHS).o -c $(NTOHS).c $(CFLAGS) $(RES_NCLOSE): $(RES_NCLOSE).o $(GCC) -o $(RES_NCLOSE) obj/$(RES_NCLOSE).o $(LDFLAGS) $(RES_NCLOSE).o: $(GCC) -o obj/$(RES_NCLOSE).o -c $(RES_NCLOSE).c $(CFLAGS) $(RES_NMKQUERY): $(RES_NMKQUERY).o $(GCC) -o $(RES_NMKQUERY) obj/$(RES_NMKQUERY).o $(LDFLAGS) $(RES_NMKQUERY).o: $(GCC) -o obj/$(RES_NMKQUERY).o -c $(RES_NMKQUERY).c $(CFLAGS) $(RES_NSEND): $(RES_NSEND).o $(GCC) -o $(RES_NSEND) obj/$(RES_NSEND).o $(LDFLAGS) $(RES_NSEND).o: $(GCC) -o obj/$(RES_NSEND).o -c $(RES_NSEND).c $(CFLAGS) $(RES_SEARCH): $(RES_SEARCH).o $(GCC) -o $(RES_SEARCH) obj/$(RES_SEARCH).o $(LDFLAGS) $(RES_SEARCH).o: $(GCC) -o obj/$(RES_SEARCH).o -c $(RES_SEARCH).c $(CFLAGS) $(SETDOMAINNAME): $(SETDOMAINNAME).o $(GCC) -o $(SETDOMAINNAME) obj/$(SETDOMAINNAME).o $(LDFLAGS) $(SETDOMAINNAME).o: $(GCC) -o obj/$(SETDOMAINNAME).o -c $(SETDOMAINNAME).c $(CFLAGS) $(SETHOSTENT): $(SETHOSTENT).o $(GCC) -o $(SETHOSTENT) obj/$(SETHOSTENT).o $(LDFLAGS) $(SETHOSTENT).o: $(GCC) -o obj/$(SETHOSTENT).o -c $(SETHOSTENT).c $(CFLAGS) $(SETHOSTNAME): $(SETHOSTNAME).o $(GCC) -o $(SETHOSTNAME) obj/$(SETHOSTNAME).o $(LDFLAGS) $(SETHOSTNAME).o: $(GCC) -o obj/$(SETHOSTNAME).o -c $(SETHOSTNAME).c $(CFLAGS) $(SETNETENT): $(SETNETENT).o $(GCC) -o $(SETNETENT) obj/$(SETNETENT).o $(LDFLAGS) $(SETNETENT).o: $(GCC) -o obj/$(SETNETENT).o -c $(SETNETENT).c $(CFLAGS) $(SETNETGRENT): $(SETNETGRENT).o $(GCC) -o $(SETNETGRENT) obj/$(SETNETGRENT).o $(LDFLAGS) $(SETNETGRENT).o: $(GCC) -o obj/$(SETNETGRENT).o -c $(SETNETGRENT).c $(CFLAGS) $(SETPROTOENT): $(SETPROTOENT).o $(GCC) -o $(SETPROTOENT) obj/$(SETPROTOENT).o $(LDFLAGS) $(SETPROTOENT).o: $(GCC) -o obj/$(SETPROTOENT).o -c $(SETPROTOENT).c $(CFLAGS) $(SETSERVENT): $(SETSERVENT).o $(GCC) -o $(SETSERVENT) obj/$(SETSERVENT).o $(LDFLAGS) $(SETSERVENT).o: $(GCC) -o obj/$(SETSERVENT).o -c $(SETSERVENT).c $(CFLAGS)
#top Makefile.win¶
SELECT ALL
# Project: Project # Makefile created GCC = gcc INCS = CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing -Wno-long-long -D_FILE_OFFSET_BITS=64 -D_LINUX -D_REENTRANT CFLAGS = $(INCS) -W -O2 -Wall -pedantic -Wstrict-aliasing LIBS = -lwsock32 -lws2_32 LIBDIRS = LDFLAGS = $(LIBDIRS) $(LIBS) RM = del /q /s MKDCMD = mkdir DN_EXPAND = dn_expand DN_SKIPNAME = dn_skipname ENDHOSTENT = endhostent ENDNETENT = endnetent ENDNETGRENT = endnetgrent ENDPROTOENT = endprotoent ENDSERVENT = endservent FREEADDRINFO= freeaddrinfo GETADDRINFO = getaddrinfo GETDOMAINNAME= getdomainname GETHOSTBYADDR= gethostbyaddr GETHOSTBYNAME2= gethostbyname2 GETHOSTBYNAME= gethostbyname GETHOSTENT = gethostent GETHOSTNAME = gethostname GETNAMEINFO = getnameinfo GETNETBYADDR= getnetbyaddr GETNETBYNAME= getnetbyname GETNETENT = getnetent GETNETGRENT = getnetgrent GETPROTOBYNAME= getprotobyname GETPROTOBYNUMBER= getprotobynumber GETPROTOENT = getprotoent GETSERVBYNAME= getservbyname GETSERVBYPORT= getservbyport GETSERVENT = getservent HSTRERROR = hstrerror HTONL = htonl HTONS = htons INET_ADDR = inet_addr INET_ATON = inet_aton INET_LNAOF = inet_lnaof INET_MAKEADDR= inet_makeaddr INET_NETA = inet_neta INET_NET_NTOP= inet_net_ntop INET_NETOF = inet_netof INET_NET_PTON= inet_net_pton INET_NETWORK= inet_network INET_NSAP_ADDR= inet_nsap_addr INET_NSAP_NTOA= inet_nsap_ntoa INET_NTOA = inet_ntoa INET_NTOP = inet_ntop INET_PTON = inet_pton INNETGR = innetgr NTOHL = ntohl NTOHS = ntohs RES_NCLOSE = res_nclose RES_NMKQUERY= res_nmkquery RES_NSEND = res_nsend RES_SEARCH = res_search SETDOMAINNAME= setdomainname SETHOSTENT = sethostent SETHOSTNAME = sethostname SETNETENT = setnetent SETNETGRENT = setnetgrent SETPROTOENT = setprotoent SETSERVENT = setservent all: make objdir: $(MKDCMD) obj\ clean: $(RM) obj\*.o *.o *~ #make: $(DN_EXPAND) #make: $(DN_SKIPNAME) #make: $(ENDHOSTENT) #make: $(ENDNETENT) #make: $(ENDNETGRENT) #make: $(ENDPROTOENT) #make: $(ENDSERVENT) #make: $(FREEADDRINFO) #make: $(GETADDRINFO) #make: $(GETDOMAINNAME) #make: $(GETHOSTBYADDR) #make: $(GETHOSTBYNAME2) #make: $(GETHOSTBYNAME) #make: $(GETHOSTENT) #make: $(GETHOSTNAME) #make: $(GETNAMEINFO) #make: $(GETNETBYADDR) #make: $(GETNETBYNAME) #make: $(GETNETENT) #make: $(GETNETGRENT) #make: $(GETPROTOBYNAME) #make: $(GETPROTOBYNUMBER) #make: $(GETPROTOENT) #make: $(GETSERVBYNAME) #make: $(GETSERVBYPORT) #make: $(GETSERVENT) #make: $(HSTRERROR) #make: $(HTONL) #make: $(HTONS) #make: $(INET_ADDR) #make: $(INET_ATON) #make: $(INET_LNAOF) #make: $(INET_MAKEADDR) #make: $(INET_NETA) #make: $(INET_NET_NTOP) #make: $(INET_NETOF) #make: $(INET_NET_PTON) #make: $(INET_NETWORK) #make: $(INET_NSAP_ADDR) #make: $(INET_NSAP_NTOA) #make: $(INET_NTOA) #make: $(INET_NTOP) #make: $(INET_PTON) #make: $(INNETGR) #make: $(NTOHL) #make: $(NTOHS) #make: $(RES_NCLOSE) #make: $(RES_NMKQUERY) #make: $(RES_NSEND) #make: $(RES_SEARCH) #make: $(SETDOMAINNAME) #make: $(SETHOSTENT) #make: $(SETHOSTNAME) #make: $(SETNETENT) #make: $(SETNETGRENT) #make: $(SETPROTOENT) #make: $(SETSERVENT) make: $(DN_EXPAND) $(DN_SKIPNAME) $(ENDHOSTENT) $(ENDNETENT) $(ENDNETGRENT) $(ENDPROTOENT) $(ENDSERVENT) $(FREEADDRINFO) $(GETADDRINFO) $(GETDOMAINNAME) $(GETHOSTBYADDR) $(GETHOSTBYNAME2) $(GETHOSTBYNAME) $(GETHOSTENT) $(GETHOSTNAME) $(GETNAMEINFO) $(GETNETBYADDR) $(GETNETBYNAME) $(GETNETENT) $(GETNETGRENT) $(GETPROTOBYNAME) $(GETPROTOBYNUMBER) $(GETPROTOENT) $(GETSERVBYNAME) $(GETSERVBYPORT) $(GETSERVENT) $(HSTRERROR) $(HTONL) $(HTONS) $(INET_ADDR) $(INET_ATON) $(INET_LNAOF) $(INET_MAKEADDR) $(INET_NETA) $(INET_NET_NTOP) $(INET_NETOF) $(INET_NET_PTON) $(INET_NETWORK) $(INET_NSAP_ADDR) $(INET_NSAP_NTOA) $(INET_NTOA) $(INET_NTOP) $(INET_PTON) $(INNETGR) $(NTOHL) $(NTOHS) $(RES_NCLOSE) $(RES_NMKQUERY) $(RES_NSEND) $(RES_SEARCH) $(SETDOMAINNAME) $(SETHOSTENT) $(SETHOSTNAME) $(SETNETENT) $(SETNETGRENT) $(SETPROTOENT) $(SETSERVENT) $(DN_EXPAND): $(DN_EXPAND).o $(GCC) -o $(DN_EXPAND) obj/$(DN_EXPAND).o $(LDFLAGS) $(DN_EXPAND).o: $(GCC) -o obj/$(DN_EXPAND).o -c $(DN_EXPAND).c $(CFLAGS) $(DN_SKIPNAME): $(DN_SKIPNAME).o $(GCC) -o $(DN_SKIPNAME) obj/$(DN_SKIPNAME).o $(LDFLAGS) $(DN_SKIPNAME).o: $(GCC) -o obj/$(DN_SKIPNAME).o -c $(DN_SKIPNAME).c $(CFLAGS) $(ENDHOSTENT): $(ENDHOSTENT).o $(GCC) -o $(ENDHOSTENT) obj/$(ENDHOSTENT).o $(LDFLAGS) $(ENDHOSTENT).o: $(GCC) -o obj/$(ENDHOSTENT).o -c $(ENDHOSTENT).c $(CFLAGS) $(ENDNETENT): $(ENDNETENT).o $(GCC) -o $(ENDNETENT) obj/$(ENDNETENT).o $(LDFLAGS) $(ENDNETENT).o: $(GCC) -o obj/$(ENDNETENT).o -c $(ENDNETENT).c $(CFLAGS) $(ENDNETGRENT): $(ENDNETGRENT).o $(GCC) -o $(ENDNETGRENT) obj/$(ENDNETGRENT).o $(LDFLAGS) $(ENDNETGRENT).o: $(GCC) -o obj/$(ENDNETGRENT).o -c $(ENDNETGRENT).c $(CFLAGS) $(ENDPROTOENT): $(ENDPROTOENT).o $(GCC) -o $(ENDPROTOENT) obj/$(ENDPROTOENT).o $(LDFLAGS) $(ENDPROTOENT).o: $(GCC) -o obj/$(ENDPROTOENT).o -c $(ENDPROTOENT).c $(CFLAGS) $(ENDSERVENT): $(ENDSERVENT).o $(GCC) -o $(ENDSERVENT) obj/$(ENDSERVENT).o $(LDFLAGS) $(ENDSERVENT).o: $(GCC) -o obj/$(ENDSERVENT).o -c $(ENDSERVENT).c $(CFLAGS) $(FREEADDRINFO): $(FREEADDRINFO).o $(GCC) -o $(FREEADDRINFO) obj/$(FREEADDRINFO).o $(LDFLAGS) $(FREEADDRINFO).o: $(GCC) -o obj/$(FREEADDRINFO).o -c $(FREEADDRINFO).c $(CFLAGS) $(GETADDRINFO): $(GETADDRINFO).o $(GCC) -o $(GETADDRINFO) obj/$(GETADDRINFO).o $(LDFLAGS) $(GETADDRINFO).o: $(GCC) -o obj/$(GETADDRINFO).o -c $(GETADDRINFO).c $(CFLAGS) $(GETDOMAINNAME): $(GETDOMAINNAME).o $(GCC) -o $(GETDOMAINNAME) obj/$(GETDOMAINNAME).o $(LDFLAGS) $(GETDOMAINNAME).o: $(GCC) -o obj/$(GETDOMAINNAME).o -c $(GETDOMAINNAME).c $(CFLAGS) $(GETHOSTBYADDR): $(GETHOSTBYADDR).o $(GCC) -o $(GETHOSTBYADDR) obj/$(GETHOSTBYADDR).o $(LDFLAGS) $(GETHOSTBYADDR).o: $(GCC) -o obj/$(GETHOSTBYADDR).o -c $(GETHOSTBYADDR).c $(CFLAGS) $(GETHOSTBYNAME2): $(GETHOSTBYNAME2).o $(GCC) -o $(GETHOSTBYNAME2) obj/$(GETHOSTBYNAME2).o $(LDFLAGS) $(GETHOSTBYNAME2).o: $(GCC) -o obj/$(GETHOSTBYNAME2).o -c $(GETHOSTBYNAME2).c $(CFLAGS) $(GETHOSTBYNAME): $(GETHOSTBYNAME).o $(GCC) -o $(GETHOSTBYNAME) obj/$(GETHOSTBYNAME).o $(LDFLAGS) $(GETHOSTBYNAME).o: $(GCC) -o obj/$(GETHOSTBYNAME).o -c $(GETHOSTBYNAME).c $(CFLAGS) $(GETHOSTENT): $(GETHOSTENT).o $(GCC) -o $(GETHOSTENT) obj/$(GETHOSTENT).o $(LDFLAGS) $(GETHOSTENT).o: $(GCC) -o obj/$(GETHOSTENT).o -c $(GETHOSTENT).c $(CFLAGS) $(GETHOSTNAME): $(GETHOSTNAME).o $(GCC) -o $(GETHOSTNAME) obj/$(GETHOSTNAME).o $(LDFLAGS) $(GETHOSTNAME).o: $(GCC) -o obj/$(GETHOSTNAME).o -c $(GETHOSTNAME).c $(CFLAGS) $(GETNAMEINFO): $(GETNAMEINFO).o $(GCC) -o $(GETNAMEINFO) obj/$(GETNAMEINFO).o $(LDFLAGS) $(GETNAMEINFO).o: $(GCC) -o obj/$(GETNAMEINFO).o -c $(GETNAMEINFO).c $(CFLAGS) $(GETNETBYADDR): $(GETNETBYADDR).o $(GCC) -o $(GETNETBYADDR) obj/$(GETNETBYADDR).o $(LDFLAGS) $(GETNETBYADDR).o: $(GCC) -o obj/$(GETNETBYADDR).o -c $(GETNETBYADDR).c $(CFLAGS) $(GETNETBYNAME): $(GETNETBYNAME).o $(GCC) -o $(GETNETBYNAME) obj/$(GETNETBYNAME).o $(LDFLAGS) $(GETNETBYNAME).o: $(GCC) -o obj/$(GETNETBYNAME).o -c $(GETNETBYNAME).c $(CFLAGS) $(GETNETENT): $(GETNETENT).o $(GCC) -o $(GETNETENT) obj/$(GETNETENT).o $(LDFLAGS) $(GETNETENT).o: $(GCC) -o obj/$(GETNETENT).o -c $(GETNETENT).c $(CFLAGS) $(GETNETGRENT): $(GETNETGRENT).o $(GCC) -o $(GETNETGRENT) obj/$(GETNETGRENT).o $(LDFLAGS) $(GETNETGRENT).o: $(GCC) -o obj/$(GETNETGRENT).o -c $(GETNETGRENT).c $(CFLAGS) $(GETPROTOBYNAME): $(GETPROTOBYNAME).o $(GCC) -o $(GETPROTOBYNAME) obj/$(GETPROTOBYNAME).o $(LDFLAGS) $(GETPROTOBYNAME).o: $(GCC) -o obj/$(GETPROTOBYNAME).o -c $(GETPROTOBYNAME).c $(CFLAGS) $(GETPROTOBYNUMBER): $(GETPROTOBYNUMBER).o $(GCC) -o $(GETPROTOBYNUMBER) obj/$(GETPROTOBYNUMBER).o $(LDFLAGS) $(GETPROTOBYNUMBER).o: $(GCC) -o obj/$(GETPROTOBYNUMBER).o -c $(GETPROTOBYNUMBER).c $(CFLAGS) $(GETPROTOENT): $(GETPROTOENT).o $(GCC) -o $(GETPROTOENT) obj/$(GETPROTOENT).o $(LDFLAGS) $(GETPROTOENT).o: $(GCC) -o obj/$(GETPROTOENT).o -c $(GETPROTOENT).c $(CFLAGS) $(GETSERVBYNAME): $(GETSERVBYNAME).o $(GCC) -o $(GETSERVBYNAME) obj/$(GETSERVBYNAME).o $(LDFLAGS) $(GETSERVBYNAME).o: $(GCC) -o obj/$(GETSERVBYNAME).o -c $(GETSERVBYNAME).c $(CFLAGS) $(GETSERVBYPORT): $(GETSERVBYPORT).o $(GCC) -o $(GETSERVBYPORT) obj/$(GETSERVBYPORT).o $(LDFLAGS) $(GETSERVBYPORT).o: $(GCC) -o obj/$(GETSERVBYPORT).o -c $(GETSERVBYPORT).c $(CFLAGS) $(GETSERVENT): $(GETSERVENT).o $(GCC) -o $(GETSERVENT) obj/$(GETSERVENT).o $(LDFLAGS) $(GETSERVENT).o: $(GCC) -o obj/$(GETSERVENT).o -c $(GETSERVENT).c $(CFLAGS) $(HSTRERROR): $(HSTRERROR).o $(GCC) -o $(HSTRERROR) obj/$(HSTRERROR).o $(LDFLAGS) $(HSTRERROR).o: $(GCC) -o obj/$(HSTRERROR).o -c $(HSTRERROR).c $(CFLAGS) $(HTONL): $(HTONL).o $(GCC) -o $(HTONL) obj/$(HTONL).o $(LDFLAGS) $(HTONL).o: $(GCC) -o obj/$(HTONL).o -c $(HTONL).c $(CFLAGS) $(HTONS): $(HTONS).o $(GCC) -o $(HTONS) obj/$(HTONS).o $(LDFLAGS) $(HTONS).o: $(GCC) -o obj/$(HTONS).o -c $(HTONS).c $(CFLAGS) $(INET_ADDR): $(INET_ADDR).o $(GCC) -o $(INET_ADDR) obj/$(INET_ADDR).o $(LDFLAGS) $(INET_ADDR).o: $(GCC) -o obj/$(INET_ADDR).o -c $(INET_ADDR).c $(CFLAGS) $(INET_ATON): $(INET_ATON).o $(GCC) -o $(INET_ATON) obj/$(INET_ATON).o $(LDFLAGS) $(INET_ATON).o: $(GCC) -o obj/$(INET_ATON).o -c $(INET_ATON).c $(CFLAGS) $(INET_LNAOF): $(INET_LNAOF).o $(GCC) -o $(INET_LNAOF) obj/$(INET_LNAOF).o $(LDFLAGS) $(INET_LNAOF).o: $(GCC) -o obj/$(INET_LNAOF).o -c $(INET_LNAOF).c $(CFLAGS) $(INET_MAKEADDR): $(INET_MAKEADDR).o $(GCC) -o $(INET_MAKEADDR) obj/$(INET_MAKEADDR).o $(LDFLAGS) $(INET_MAKEADDR).o: $(GCC) -o obj/$(INET_MAKEADDR).o -c $(INET_MAKEADDR).c $(CFLAGS) $(INET_NETA): $(INET_NETA).o $(GCC) -o $(INET_NETA) obj/$(INET_NETA).o $(LDFLAGS) $(INET_NETA).o: $(GCC) -o obj/$(INET_NETA).o -c $(INET_NETA).c $(CFLAGS) $(INET_NET_NTOP): $(INET_NET_NTOP).o $(GCC) -o $(INET_NET_NTOP) obj/$(INET_NET_NTOP).o $(LDFLAGS) $(INET_NET_NTOP).o: $(GCC) -o obj/$(INET_NET_NTOP).o -c $(INET_NET_NTOP).c $(CFLAGS) $(INET_NETOF): $(INET_NETOF).o $(GCC) -o $(INET_NETOF) obj/$(INET_NETOF).o $(LDFLAGS) $(INET_NETOF).o: $(GCC) -o obj/$(INET_NETOF).o -c $(INET_NETOF).c $(CFLAGS) $(INET_NET_PTON): $(INET_NET_PTON).o $(GCC) -o $(INET_NET_PTON) obj/$(INET_NET_PTON).o $(LDFLAGS) $(INET_NET_PTON).o: $(GCC) -o obj/$(INET_NET_PTON).o -c $(INET_NET_PTON).c $(CFLAGS) $(INET_NETWORK): $(INET_NETWORK).o $(GCC) -o $(INET_NETWORK) obj/$(INET_NETWORK).o $(LDFLAGS) $(INET_NETWORK).o: $(GCC) -o obj/$(INET_NETWORK).o -c $(INET_NETWORK).c $(CFLAGS) $(INET_NSAP_ADDR): $(INET_NSAP_ADDR).o $(GCC) -o $(INET_NSAP_ADDR) obj/$(INET_NSAP_ADDR).o $(LDFLAGS) $(INET_NSAP_ADDR).o: $(GCC) -o obj/$(INET_NSAP_ADDR).o -c $(INET_NSAP_ADDR).c $(CFLAGS) $(INET_NSAP_NTOA): $(INET_NSAP_NTOA).o $(GCC) -o $(INET_NSAP_NTOA) obj/$(INET_NSAP_NTOA).o $(LDFLAGS) $(INET_NSAP_NTOA).o: $(GCC) -o obj/$(INET_NSAP_NTOA).o -c $(INET_NSAP_NTOA).c $(CFLAGS) $(INET_NTOA): $(INET_NTOA).o $(GCC) -o $(INET_NTOA) obj/$(INET_NTOA).o $(LDFLAGS) $(INET_NTOA).o: $(GCC) -o obj/$(INET_NTOA).o -c $(INET_NTOA).c $(CFLAGS) $(INET_NTOP): $(INET_NTOP).o $(GCC) -o $(INET_NTOP) obj/$(INET_NTOP).o $(LDFLAGS) $(INET_NTOP).o: $(GCC) -o obj/$(INET_NTOP).o -c $(INET_NTOP).c $(CFLAGS) $(INET_PTON): $(INET_PTON).o $(GCC) -o $(INET_PTON) obj/$(INET_PTON).o $(LDFLAGS) $(INET_PTON).o: $(GCC) -o obj/$(INET_PTON).o -c $(INET_PTON).c $(CFLAGS) $(INNETGR): $(INNETGR).o $(GCC) -o $(INNETGR) obj/$(INNETGR).o $(LDFLAGS) $(INNETGR).o: $(GCC) -o obj/$(INNETGR).o -c $(INNETGR).c $(CFLAGS) $(NTOHL): $(NTOHL).o $(GCC) -o $(NTOHL) obj/$(NTOHL).o $(LDFLAGS) $(NTOHL).o: $(GCC) -o obj/$(NTOHL).o -c $(NTOHL).c $(CFLAGS) $(NTOHS): $(NTOHS).o $(GCC) -o $(NTOHS) obj/$(NTOHS).o $(LDFLAGS) $(NTOHS).o: $(GCC) -o obj/$(NTOHS).o -c $(NTOHS).c $(CFLAGS) $(RES_NCLOSE): $(RES_NCLOSE).o $(GCC) -o $(RES_NCLOSE) obj/$(RES_NCLOSE).o $(LDFLAGS) $(RES_NCLOSE).o: $(GCC) -o obj/$(RES_NCLOSE).o -c $(RES_NCLOSE).c $(CFLAGS) $(RES_NMKQUERY): $(RES_NMKQUERY).o $(GCC) -o $(RES_NMKQUERY) obj/$(RES_NMKQUERY).o $(LDFLAGS) $(RES_NMKQUERY).o: $(GCC) -o obj/$(RES_NMKQUERY).o -c $(RES_NMKQUERY).c $(CFLAGS) $(RES_NSEND): $(RES_NSEND).o $(GCC) -o $(RES_NSEND) obj/$(RES_NSEND).o $(LDFLAGS) $(RES_NSEND).o: $(GCC) -o obj/$(RES_NSEND).o -c $(RES_NSEND).c $(CFLAGS) $(RES_SEARCH): $(RES_SEARCH).o $(GCC) -o $(RES_SEARCH) obj/$(RES_SEARCH).o $(LDFLAGS) $(RES_SEARCH).o: $(GCC) -o obj/$(RES_SEARCH).o -c $(RES_SEARCH).c $(CFLAGS) $(SETDOMAINNAME): $(SETDOMAINNAME).o $(GCC) -o $(SETDOMAINNAME) obj/$(SETDOMAINNAME).o $(LDFLAGS) $(SETDOMAINNAME).o: $(GCC) -o obj/$(SETDOMAINNAME).o -c $(SETDOMAINNAME).c $(CFLAGS) $(SETHOSTENT): $(SETHOSTENT).o $(GCC) -o $(SETHOSTENT) obj/$(SETHOSTENT).o $(LDFLAGS) $(SETHOSTENT).o: $(GCC) -o obj/$(SETHOSTENT).o -c $(SETHOSTENT).c $(CFLAGS) $(SETHOSTNAME): $(SETHOSTNAME).o $(GCC) -o $(SETHOSTNAME) obj/$(SETHOSTNAME).o $(LDFLAGS) $(SETHOSTNAME).o: $(GCC) -o obj/$(SETHOSTNAME).o -c $(SETHOSTNAME).c $(CFLAGS) $(SETNETENT): $(SETNETENT).o $(GCC) -o $(SETNETENT) obj/$(SETNETENT).o $(LDFLAGS) $(SETNETENT).o: $(GCC) -o obj/$(SETNETENT).o -c $(SETNETENT).c $(CFLAGS) $(SETNETGRENT): $(SETNETGRENT).o $(GCC) -o $(SETNETGRENT) obj/$(SETNETGRENT).o $(LDFLAGS) $(SETNETGRENT).o: $(GCC) -o obj/$(SETNETGRENT).o -c $(SETNETGRENT).c $(CFLAGS) $(SETPROTOENT): $(SETPROTOENT).o $(GCC) -o $(SETPROTOENT) obj/$(SETPROTOENT).o $(LDFLAGS) $(SETPROTOENT).o: $(GCC) -o obj/$(SETPROTOENT).o -c $(SETPROTOENT).c $(CFLAGS) $(SETSERVENT): $(SETSERVENT).o $(GCC) -o $(SETSERVENT) obj/$(SETSERVENT).o $(LDFLAGS) $(SETSERVENT).o: $(GCC) -o obj/$(SETSERVENT).o -c $(SETSERVENT).c $(CFLAGS)
#top Predefined Constants¶
#top AF_FILE¶
Deklaracja stałej
AF_FILE
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
AF_FILE
jest następująca:/* Protocol families. */ #define AF_FILE PF_FILE
#top AF_INET¶
Deklaracja stałej
AF_INET
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
AF_INET
jest następująca:/* Protocol families. */ #define AF_INET PF_INET
#top AF_INET6¶
Deklaracja stałej
AF_INET6
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
AF_INET6
jest następująca:/* Protocol families. */ #define AF_INET6 PF_INET6
#top AF_LOCAL¶
Deklaracja stałej
AF_LOCAL
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
AF_LOCAL
jest następująca:/* Protocol families. */ #define AF_LOCAL PF_LOCAL
#top AF_UNIX¶
Deklaracja stałej
AF_UNIX
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
AF_UNIX
jest następująca:/* Protocol families. */ #define AF_UNIX PF_UNIX
#top AF_UNSPEC¶
Deklaracja stałej
AF_UNSPEC
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
AF_UNSPEC
jest następująca:/* Address families. */ #define AF_UNSPEC PF_UNSPEC
#top HOST_NOT_FOUND¶
Deklaracja stałej
HOST_NOT_FOUND
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja stałej
HOST_NOT_FOUND
jest następująca:/* Possible values left in `h_errno'. *: #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
#top INADDR_ANY¶
Deklaracja stałej
INADDR_ANY
znajduje się w pliku nagłówkowym netinet/in.h
.Deklaracja stałej
INADDR_ANY
jest następująca:/* Address to accept any incoming messages. */ #define INADDR_ANY ((in_addr_t) 0x00000000)
#top NETDB_INTERNAL¶
Deklaracja stałej
NETDB_INTERNAL
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja stałej
<NETDB_INTERNAL
jest następująca:/* Possible values left in `h_errno'. *: #define NETDB_INTERNAL -1 /* See errno. */
#top NETDB_SUCCESS¶
Deklaracja stałej
NETDB_SUCCESS
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja stałej
NETDB_SUCCESS
jest następująca:/* Possible values left in `h_errno'. *: #define NETDB_SUCCESS 0 /* No problem. */
#top NO_ADDRESS¶
Deklaracja stałej
NO_ADDRESS
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja stałej
NO_ADDRESS
jest następująca:/* Possible values left in `h_errno'. *: #define NO_ADDRESS NO_DATA /* No address, look for MX record. */
#top NO_DATA¶
Deklaracja stałej
NO_DATA
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja stałej
NO_DATA
jest następująca:/* Possible values left in `h_errno'. *: #define NO_DATA 4 /* Valid name, no data record of requested type. */
#top NO_RECOVERY¶
Deklaracja stałej
NO_RECOVERY
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja stałej
NO_RECOVERY
jest następująca:/* Possible values left in `h_errno'. *: #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP. */
#top PF_FILE¶
Deklaracja stałej
PF_FILE
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
PF_FILE
jest następująca:/* Protocol families. */ #define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */
#top PF_INET¶
Deklaracja stałej
PF_INET
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
PF_INET
jest następująca:/* Protocol families. */ #define PF_INET 2 /* IP protocol family. */
#top PF_INET6¶
Deklaracja stałej
PF_INET6
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
PF_INET6
jest następująca:/* Protocol families. */ #define PF_INET6 10 /* IP version 6. */
#top PF_LOCAL¶
Deklaracja stałej
PF_LOCAL
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
PF_LOCAL
jest następująca:/* Protocol families. */ #define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
#top PF_UNIX¶
Deklaracja stałej
PF_UNIX
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
PF_UNIX
jest następująca:/* Protocol families. */ #define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */
#top PF_UNSPEC¶
Deklaracja stałej
PF_UNSPEC
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja stałej
PF_UNSPEC
jest następująca:/* Protocol families. */ #define PF_UNSPEC 0 /* Unspecified. */
#top TRY_AGAIN¶
Deklaracja stałej
TRY_AGAIN
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja stałej
TRY_AGAIN
jest następująca:/* Possible values left in `h_errno'. *: #define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL. */
#top Datatypes / MACROS¶
#top __h_errno_location¶
Definicja funkcji
__h_errno_location()
znajduje się w pliku nagłówkowym netdb.h
.Definicja funkcji
__h_errno_location()
jest następująca:/* Function to get address of global `h_errno' variable. *: extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
#top __SOCKADDR_COMMON¶
Definicja typu
__SOCKADDR_COMMON
znajduje się w pliku nagłówkowym bits/sockaddr.h
.Definicja typu
__SOCKADDR_COMMON
jest następująca:/* This macro is used to declare the initial common members of the data types used for socket addresses, `struct sockaddr', `struct sockaddr_in', `struct sockaddr_un', etc. *: #define __SOCKADDR_COMMON(sa_prefix) \ sa_family_t sa_prefix##family
#top __socklen_t¶
Definicja typu
__socklen_t
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__socklen_t
jest następująca:/* Duplicate info from sys/socket.h. */ __STD_TYPE __U32_TYPE __socklen_t;
#top h_errno¶
Definicja zmiennej globalnej
h_errno
znajduje się w pliku nagłówkowym netdb.h
.Definicja zmiennej globalnej
h_errno
jest następująca:/* Error status for non-reentrant lookup functions. We use a macro to access always the thread-specific `h_errno' variable. */ #define h_errno (*__h_errno_location ())
Powiązane:
h_errno, gethostbyaddr(), gethostbyname(), gethostbyname2(), hstrerror(),
Opis:
Globalna zmienna h_errno jest makrem przechowującym informację kodzie ostatniego błędu jaki wystąpił podczas wywoływania funkcji dotyczącej operacji związanej z rozwiązywaniem nazw i adresów. Kod błędu ustawiony w makrze h_errno pozwala poinformować program/użytkownika o przyczynie niepowodzenia ostanio wykonywanej operacji.
#top in_addr_t¶
Definicja struktury
in_addr_t
znajduje się w pliku nagłówkowym netinet/in.h
.Definicja struktury
in_addr_t
jest następująca:/* Internet address. */ typedef uint32_t in_addr_t;
#top in_port_t¶
Definicja struktury
in_port_t
znajduje się w pliku nagłówkowym netinet/in.h
.Definicja struktury
in_port_t
jest następująca:/* Type to represent a port. */ typedef uint16_t in_port_t;
#top sa_family_t¶
Definicja typu
sa_family_t
znajduje się w pliku nagłówkowym bits/sockaddr.h
.Definicja typu
sa_family_t
jest następująca:/* POSIX.1g specifies this type name for the `sa_family' member. */ typedef unsigned short int sa_family_t;
#top size_t¶
Definicja typu
size_t
znajduje się w pliku nagłówkowym /usr/lib/gcc/i386-redhat-linux/4.1.1/include/stddef.h
.Definicja typu
size_t
jest następująca:/* Unsigned type of `sizeof' something. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ #if defined (_STDDEF_H) || defined (__need_size_t) #ifndef __size_t__ /* BeOS */ #ifndef __SIZE_T__ /* Cray Unicos/Mk */ #ifndef _SIZE_T /* in case <sys/types.h> has defined it. */ #ifndef _SYS_SIZE_T_H #ifndef _T_SIZE_ #ifndef _T_SIZE #ifndef __SIZE_T #ifndef _SIZE_T_ #ifndef _BSD_SIZE_T_ #ifndef _SIZE_T_DEFINED_ #ifndef _SIZE_T_DEFINED #ifndef _BSD_SIZE_T_DEFINED_ /* Darwin */ #ifndef _SIZE_T_DECLARED /* FreeBSD 5 */ #ifndef ___int_size_t_h #ifndef _GCC_SIZE_T #ifndef _SIZET_ #ifndef __size_t #define __size_t__ /* BeOS */ #define __SIZE_T__ /* Cray Unicos/Mk */ #define _SIZE_T #define _SYS_SIZE_T_H #define _T_SIZE_ #define _T_SIZE #define __SIZE_T #define _SIZE_T_ #define _BSD_SIZE_T_ #define _SIZE_T_DEFINED_ #define _SIZE_T_DEFINED #define _BSD_SIZE_T_DEFINED_ /* Darwin */ #define _SIZE_T_DECLARED /* FreeBSD 5 */ #define ___int_size_t_h #define _GCC_SIZE_T #define _SIZET_ #if defined (__FreeBSD__) && (__FreeBSD__ >= 5) /* __size_t is a typedef on FreeBSD 5!, must not trash it. */ #else #define __size_t #endif #ifndef __SIZE_TYPE__ #define __SIZE_TYPE__ long unsigned int #endif #if !(defined (__GNUG__) && defined (size_t)) typedef __SIZE_TYPE__ size_t; #ifdef __BEOS__ typedef long ssize_t; #endif /* __BEOS__ */ #endif /* !(defined (__GNUG__) && defined (size_t)) */ #endif /* __size_t */ #endif /* _SIZET_ */ #endif /* _GCC_SIZE_T */ #endif /* ___int_size_t_h */ #endif /* _SIZE_T_DECLARED */ #endif /* _BSD_SIZE_T_DEFINED_ */ #endif /* _SIZE_T_DEFINED */ #endif /* _SIZE_T_DEFINED_ */ #endif /* _BSD_SIZE_T_ */ #endif /* _SIZE_T_ */ #endif /* __SIZE_T */ #endif /* _T_SIZE */ #endif /* _T_SIZE_ */ #endif /* _SYS_SIZE_T_H */ #endif /* _SIZE_T */ #endif /* __SIZE_T__ */ #endif /* __size_t__ */ #undef __need_size_t #endif /* _STDDEF_H or __need_size_t. */
#top socklen_t¶
Definicja typu
socklen_t
znajduje się w pliku nagłówkowym bits/socket.h
.Definicja typu
socklen_t
jest następująca:/* Type for length arguments in socket calls. */ #ifndef __socklen_t_defined typedef __socklen_t socklen_t; # define __socklen_t_defined #endif
#top struct addrinfo¶
Deklaracja struktury
struct addrinfo
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja struktury
struct addrinfo
jest następująca:/* Structure to contain information about address of a service provider. */ struct addrinfo { int ai_flags; /* Input flags. */ int ai_family; /* Protocol family for socket. */ int ai_socktype; /* Socket type. */ int ai_protocol; /* Protocol for socket. */ socklen_t ai_addrlen; :* Length of socket address. */ struct sockaddr *ai_addr; :* Socket address for socket. */ char *ai_canonname; /* Canonical name for service location. */ struct addrinfo *ai_next; :* Pointer to next in list. */ };
#top struct in_addr¶
Deklaracja struktury
struct in_addr
znajduje się w pliku nagłówkowym netinet/in.h
.Deklaracja struktury
struct in_addr
jest następująca:/* Internet address. */ struct in_addr { in_addr_t s_addr; };
#top struct in6_addr¶
Deklaracja struktury
struct in6_addr
znajduje się w pliku nagłówkowym netinet/in.h
.Deklaracja struktury
struct in6_addr
jest następująca:/* IPv6 address */ struct in6_addr { union { uint8_t u6_addr8[16]; uint16_t u6_addr16[8]; uint32_t u6_addr32[4]; } in6_u; #define s6_addr in6_u.u6_addr8 #define s6_addr16 in6_u.u6_addr16 #define s6_addr32 in6_u.u6_addr32 };
#top struct hostent¶
Deklaracja struktury
struct hostent
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja struktury
struct hostent
jest następująca:/* Description of data base entry for a single host. */ struct hostent { char *h_name; /* Official name of host. */ char **h_aliases; /* Alias list. */ int h_addrtype; /* Host address type. */ int h_length; /* Length of address. */ char **h_addr_list; /* List of addresses from name server. */ #define h_addr h_addr_list[0] /* Address, for backward compatibility. */ };
#top struct netent¶
Deklaracja struktury
struct netent
znajduje się w pliku nagłówkowym bits/netdb.h
.Deklaracja struktury
struct netent
jest następująca:/* Description of data base entry for a single network. NOTE: here a poor assumption is made. The network number is expected to fit into an unsigned long int variable. */ struct netent { char *n_name; /* Official name of network. */ char **n_aliases; /* Alias list. */ int n_addrtype; /* Net address type. */ uint32_t n_net; :* Network number. */ };
#top struct protoent¶
Deklaracja struktury
struct protoent
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja struktury
struct protoent
jest następująca:/* Description of data base entry for a single service. */ struct protoent { char *p_name; /* Official protocol name. */ char **p_aliases; /* Alias list. */ int p_proto; /* Protocol number. */ };
#top struct servent¶
Deklaracja struktury
struct servent
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja struktury
struct servent
jest następująca:/* Description of data base entry for a single service. */ struct servent { char *s_name; /* Official service name. */ char **s_aliases; /* Alias list. */ int s_port; /* Port number. */ char *s_proto; /* Protocol to use. */ };
#top struct sockaddr¶
Deklaracja struktury
struct sockaddr
znajduje się w pliku nagłówkowym bits/socket.h
.Deklaracja struktury
struct sockaddr
jest następująca:/* Structure describing a generic socket address. */ struct sockaddr { __SOCKADDR_COMMON (sa_); :* Common data: address family and length. */ char sa_data[14]; /* Address data. */ };
#top struct sockaddr_in¶
Deklaracja struktury
struct sockaddr_in
znajduje się w pliku nagłówkowym netinet/in.h
.Deklaracja struktury
struct sockaddr_in
jest następująca:/* Structure describing an Internet socket address. */ struct sockaddr_in { __SOCKADDR_COMMON (sin_); in_port_t sin_port; :* Port number. */ struct in_addr sin_addr; :* Internet address. */ /* Pad to size of `struct sockaddr'. *: unsigned char sin_zero[sizeof (struct sockaddr) - __SOCKADDR_COMMON_SIZE - sizeof (in_port_t) - sizeof (struct in_addr)]; };
#top struct sockaddr_in6¶
Deklaracja struktury
struct sockaddr_in6
znajduje się w pliku nagłówkowym netinet/in.h
.Deklaracja struktury
struct sockaddr_in6
jest następująca:/* Ditto, for IPv6. */ struct sockaddr_in6 { __SOCKADDR_COMMON (sin6_); in_port_t sin6_port; :* Transport layer port # */ uint32_t sin6_flowinfo; :* IPv6 flow information */ struct in6_addr sin6_addr; :* IPv6 address */ uint32_t sin6_scope_id; :* IPv6 scope-id */ };
#top struct sockaddr_un¶
Deklaracja struktury
struct sockaddr_un
znajduje się w pliku nagłówkowym sys/un.h
.Deklaracja struktury
struct sockaddr_un
jest następująca:/* Structure describing the address of an AF_LOCAL (aka AF_UNIX) socket. */ struct sockaddr_un { __SOCKADDR_COMMON (sun_); char sun_path[108]; /* Path name. */ };
#top uint8_t¶
Definicja typu
uint8_t
znajduje się w pliku nagłówkowym stdint.h
.Definicja typu
uint8_t
jest następująca:/* Unsigned. */ typedef unsigned char uint8_t;
#top uint16_t¶
Definicja typu
uint16_t
znajduje się w pliku nagłówkowym stdint.h
.Definicja typu
uint16_t
jest następująca:/* Unsigned. */ typedef unsigned short int uint16_t;
#top uint32_t¶
Definicja typu
uint32_t
znajduje się w pliku nagłówkowym stdint.h
.Definicja typu
uint32_t
jest następująca:/* Unsigned. */ #ifndef __uint32_t_defined typedef unsigned int uint32_t; # define __uint32_t_defined #endif
#top Network Functions¶
#top endhostent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
endhostent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
endhostent()
jest następująca:/* Close host data base files and clear `stay open' flag. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void endhostent (void);
Powiązane:
endhostent(), gethostent(), sethostent(),
Opis:
Funkcja endhostent() jest używana do zamykania "bazy danych" zawierającej informacje dotyczące hostów przechowywanych w systemie. Informacje dotyczące hostów przechowywane są w pliku tekstowym
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
/etc/hosts
.Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top endnetent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
endnetent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
endnetent()
jest następująca:/* Close network data base files and clear `stay open' flag. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void endnetent (void);
Powiązane:
endnetent(), getnetent(), setnetent(),
Opis:
Funkcja endnetent() jest używana do zamykania "bazy danych" zawierającej informacje dotyczące sieci przechowywanych w systemie. Informacje dotyczące sieci przechowywane są w pliku tekstowym
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
/etc/networks
.Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top endnetgrent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
endnetgrent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
endnetgrent()
jest następująca:/* Free all space allocated by previous `setnetgrent' call. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern void endnetgrent (void);
Powiązane:
endnetgrent(), getnetgrent(), setnetgrent(),
Opis:
Funkcja endnetgrent() jest używana do zamykania "bazy danych" zawierającej informacje dotyczące grup sieci przechowywanych w systemie. Informacje dotyczące grup sieci przechowywane są w pliku tekstowym
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
/etc/netgroup
.Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top endprotoent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
endprotoent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
endprotoent()
jest następująca:/* Close protocol data base files and clear `stay open' flag. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void endprotoent (void);
Powiązane:
endprotoent(), getprotoent(), setprotoent(),
Opis:
Funkcja endprotoent() jest używana do zamykania "bazy danych" zawierającej informacje dotyczące protokołów przechowywanych w systemie. Informacje dotyczące protokołów przechowywane są w pliku tekstowym
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
/etc/protocols
.Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top endservent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
endservent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
endservent()
jest następująca:/* Close service data base files and clear `stay open' flag. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void endservent (void);
Powiązane:
endservent(), getservent(), setservent(),
Opis:
Funkcja endservent() jest używana do zamykania "bazy danych" zawierającej informacje dotyczące usług przechowywanych w systemie. Informacje dotyczące usług przechowywane są w pliku tekstowym
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
/etc/services
.Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top freeaddrinfo¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us
Deklaracja funkcji
freeaddrinfo()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
freeaddrinfo()
jest następująca:/* Free `addrinfo' structure AI including associated storage. */ extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
Powiązane:
gai_strerror(), freeaddrinfo(), getaddrinfo(),
Opis:
Funkcja freeaddrinfo()
Argumenty:
struct addrinfo *__ai -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
Argumenty:
struct addrinfo *__ai -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top gai_strerror¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us
Deklaracja funkcji
gai_strerror()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
gai_strerror()
jest następująca:/* Convert error return from getaddrinfo() to a string. *: extern __const char *gai_strerror (int __ecode) __THROW;
Powiązane:
gai_strerror(), freeaddrinfo(), getaddrinfo(),
Opis:
Funkcja gai_strerror()
Argumenty:
int __ecode -
Zwracana wartość:
const char * -
Argumenty:
int __ecode -
Zwracana wartość:
const char * -
#top getaddrinfo¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us | gnu.org
Deklaracja funkcji
getaddrinfo()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getaddrinfo()
jest następująca:/* Translate name of a service location and/or a service name to set of socket addresses. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int getaddrinfo (__const char *__restrict __name, __const char *__restrict __service, __const struct addrinfo *__restrict __req, struct addrinfo **__restrict __pai);
Powiązane:
gai_strerror(), freeaddrinfo(), getaddrinfo(),
Opis:
Funkcja getaddrinfo()
Argumenty:
const char *__restrict __name -
const char *__restrict __service -
const struct addrinfo *__restrict __req -
struct addrinfo **__restrict __pai -
Zwracana wartość:
int -
Argumenty:
const char *__restrict __name -
const char *__restrict __service -
const struct addrinfo *__restrict __req -
struct addrinfo **__restrict __pai -
Zwracana wartość:
int -
Example:
zawartość pliku
getaddrinfo.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <unistd.h> /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */ /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */ /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */ #include <errno.h> /* for errno constant, error constants, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <sys/socket.h> /* for bits/socket.h, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_PACKET, AF_UNIX, PF_UNIX, AF_FILE, PF_FILE, AF_INET, PF_INET, MSG_OOB, MSG_PEEK, MSG_DONTWAIT, struct msghdr, struct sockaddr, struct osockaddr, */ /* for socket(), bind(), getsockname(), connect(), getpeername(), send(), recv(), sendto(), recvfrom(), sendmsg(), recvmsg(), getsockopt(), setsockopt(), listen(), accept(), shutdown(), sockatmark(), */ #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), gethostbyaddr(), gethostbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { int osock; struct addrinfo addrinfo, *addrlist, *addrptrs; int result; if (argc<4) { printf("Usage: %s <address_family> <hostname> <service>\n", argv[0]); printf("Example\n"); printf(" %s AF_UNSPEC www.example.org http\n", argv[0]); printf(" %s AF_INET www.example.org http\n", argv[0]); printf(" %s AF_INET6 www.example.org http\n", argv[0]); return 0; } if (strncmp(argv[1],"AF_UNSPEC",strlen("AF_UNSPEC"))!=0 && strncmp(argv[1],"AF_INET",strlen("AF_INET"))!=0 && strncmp(argv[1],"AF_INET6",strlen("AF_INET6"))!=0) { printf("%s Bad address family: allowed: AF_UNSPEC, AF_INET, AF_INET6\n", argv[0]); return 1; } memset(&addrinfo, 0, sizeof(struct addrinfo)); addrinfo.ai_family = AF_UNSPEC; /* use AF_INET to IPv4 only, use AF_INET6 to IPv6 only, AF_UNSPEC to IPv4 and IPv6 */ addrinfo.ai_socktype = SOCK_STREAM; if (strncmp(argv[1],"AF_UNSPEC",strlen("AF_UNSPEC"))==0) addrinfo.ai_family = AF_UNSPEC; if (strncmp(argv[1],"AF_INET" ,strlen("AF_INET" ))==0) addrinfo.ai_family = AF_INET; if (strncmp(argv[1],"AF_INET6" ,strlen("AF_INET6" ))==0) addrinfo.ai_family = AF_INET6; printf("%s: result=getaddrinfo(argv[2]=%s, argv[3]=%s, &addrinfo, &addrlist):\n", argv[0], argv[2], argv[3]); result=getaddrinfo(argv[2], argv[3], &addrinfo, &addrlist); printf("%s: result=getaddrinfo(argv[2]=%s, argv[3]=%s, &addrinfo, &addrlist): result=%d\n", argv[0], argv[2], argv[3], result); if (result != 0) { #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) fprintf(stderr, "%s: result=getaddrinfo(argv[2]=%s, argv[3]=%s, &addrinfo, &addrlist): if (result != 0): result=%d:%s\n", argv[0], argv[2], argv[3], result, "gai_strerror(result)"); #else fprintf(stderr, "%s: result=getaddrinfo(argv[2]=%s, argv[3]=%s, &addrinfo, &addrlist): if (result != 0): result=%d:%s\n", argv[0], argv[2], argv[3], result, gai_strerror(result)); #endif exit(1); } osock=-1; /* loop through all the results and connect to the first we can */ for (addrptrs=addrlist; addrptrs!=NULL; addrptrs=addrptrs->ai_next) { printf("%s: addrptrs->ai_flags=%d addrptrs->ai_family=%d addrptrs->ai_socktype=%d addrptrs->ai_protocol=%d addrptrs->ai_addrlen=%u addrptrs->ai_canonname=%s\n", argv[0], addrptrs->ai_flags, addrptrs->ai_family, addrptrs->ai_socktype, addrptrs->ai_protocol, addrptrs->ai_addrlen, addrptrs->ai_canonname); printf("%s: osock=socket(addrptrs->ai_family=%d,addrptrs->ai_socktype=%d,addrptrs->ai_protocol=%d):\n", argv[0], addrptrs->ai_family, addrptrs->ai_socktype, addrptrs->ai_protocol); osock=socket(addrptrs->ai_family, addrptrs->ai_socktype, addrptrs->ai_protocol); printf("%s: osock=socket(addrptrs->ai_family=%d,addrptrs->ai_socktype=%d,addrptrs->ai_protocol=%d): osock=%d\n", argv[0], addrptrs->ai_family, addrptrs->ai_socktype, addrptrs->ai_protocol, osock); if (osock < 0) { fprintf(stderr, "%s: osock=socket(addrptrs->ai_family=%d,addrptrs->ai_socktype=%d,addrptrs->ai_protocol=%d): osock=%d if (osock < 0):\n", argv[0], addrptrs->ai_family, addrptrs->ai_socktype, addrptrs->ai_protocol, osock); continue; } printf("%s: result=connect(osock=%d, addrptrs->ai_addr=%%s, addrptrs->ai_addrlen=%d):\n", argv[0], osock, /*inet_ntoa( ((struct sockaddr_in*)&(addrptrs->ai_addr))->sin_addr ),*/ addrptrs->ai_addrlen); result=connect(osock, addrptrs->ai_addr, addrptrs->ai_addrlen); printf("%s: result=connect(osock=%d, addrptrs->ai_addr=%%s, addrptrs->ai_addrlen=%d): result=%d\n", argv[0], osock, /*inet_ntoa( ((struct sockaddr_in*)&(addrptrs->ai_addr))->sin_addr ),*/ addrptrs->ai_addrlen, result); if (result < 0) { close(osock); osock=-1; fprintf(stderr, "%s: result=connect(osock=%d, addrptrs->ai_addr=%%s, addrptrs->ai_addrlen=%d): result=%d if (result < 0):\n", argv[0], osock, /*inet_ntoa( ((struct sockaddr_in*)&(addrptrs->ai_addr))->sin_addr ),*/ addrptrs->ai_addrlen, result); continue; } else { printf("%s: result=connect(osock=%d, addrptrs->ai_addr=%%s, addrptrs->ai_addrlen=%d): Successfull connected\n", argv[0], osock, /*inet_ntoa( ((struct sockaddr_in*)&(addrptrs->ai_addr))->sin_addr ),*/ addrptrs->ai_addrlen); } break; /* if we get here, we must have connected successfully */ } if (osock<0) { /* looped off the end of the list with no connection */ fprintf(stderr, "%s: failed to connect to '%s'\n", argv[0], argv[2]); exit(2); } if (osock>=0) close(osock); freeaddrinfo(addrlist); /* all done with this structure */ return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/getaddrinfoprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/getaddrinfo <address_family> <hostname> <service> Example /home/local/code/ansiccode/network/getaddrinfo AF_UNSPEC www.example.org http /home/local/code/ansiccode/network/getaddrinfo AF_INET www.example.org http /home/local/code/ansiccode/network/getaddrinfo AF_INET6 www.example.org http
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/getaddrinfo AF_INET www.example.org httprezultat będzie zależny od podanych argumentów wywołania programu:
getaddrinfo: result=getaddrinfo(argv[2]=www.example.org, argv[3]=http, &addrinfo, &addrlist): getaddrinfo: result=getaddrinfo(argv[2]=www.example.org, argv[3]=http, &addrinfo, &addrlist): result=0 getaddrinfo: addrptrs->ai_flags=0 addrptrs->ai_family=2 addrptrs->ai_socktype=1 addrptrs->ai_protocol=6 addrptrs->ai_addrlen=16 addrptrs->ai_canonname=(null) getaddrinfo: osock=socket(addrptrs->ai_family=2,addrptrs->ai_socktype=1,addrptrs->ai_protocol=6): getaddrinfo: osock=socket(addrptrs->ai_family=2,addrptrs->ai_socktype=1,addrptrs->ai_protocol=6): osock=3 getaddrinfo: result=connect(osock=3, addrptrs->ai_addr=0.0.0.0, addrptrs->ai_addrlen=16): getaddrinfo: result=connect(osock=3, addrptrs->ai_addr=0.0.0.0, addrptrs->ai_addrlen=16): result=0 getaddrinfo: result=connect(osock=3, addrptrs->ai_addr=0.0.0.0, addrptrs->ai_addrlen=16): successfull connected
#top getdomainname¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
getdomainname()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
getdomainname()
jest następująca:/* Get and set the NIS (aka YP) domain name, if any. Called just like `gethostname' and `sethostname'. The NIS domain name is usually the empty string when not using NIS. */ extern int getdomainname (char *__name, size_t __len) __THROW __nonnull ((1)) __wur;
Powiązane:
getdomainname(), setdomainname(),
Opis:
Example:
zawartość pliku
getdomainname.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <unistd.h> /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */ /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */ /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */ #include <errno.h> /* for errno constant, error constants, */ int main(int argc, char **argv) { #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #else char buffdata[1024]; int result; #endif if (argc<2) { printf("Usage: %s <domainname>\n", argv[0]); printf("Examples:\n"); printf(" %s localdomain\n", argv[0]); printf(" %s example.org\n", argv[0]); return 0; } #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* getdomainname() is not available on this OS platform !!! */ printf("%s: getdomainname() is not available on this OS platform !!!\n", argv[0]); #else memset(buffdata, 0x00, sizeof(buffdata)); result=getdomainname(buffdata, sizeof(buffdata)); if (result>=0) printf("%s: result=getdomainname(buffdata, sizeof(buffdata)): result=%d if (result>=0): Successful get hostname, buffdata=|%s|\n", argv[0], result, buffdata); else printf("%s: result=getdomainname(buffdata, sizeof(buffdata)): result=%d if (result>=0): \n", argv[0], result); #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* setdomainname() is not available on this OS platform !!! */ printf("%s: setdomainname() is not available on this OS platform !!!\n", argv[0]); #else result=setdomainname(argv[1], strlen(argv[1])); if (result>=0) printf("%s: result=setdomainname(argv[1]=%s, strlen(argv[1])): result=%d if (result>=0): Successful get domainname\n", argv[0], argv[1], result); else printf("%s: result=setdomainname(argv[1]=%s, strlen(argv[1])): result=%d if (result>=0): else: Unable set domainname, Reason: %d:%s\n", argv[0], argv[1], result, errno, strerror(errno)); #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* getdomainname() is not available on this OS platform !!! */ printf("%s: getdomainname() is not available on this OS platform !!!\n", argv[0]); #else memset(buffdata, 0x00, sizeof(buffdata)); result=getdomainname(buffdata, sizeof(buffdata)); if (result>=0) printf("%s: result=getdomainname(buffdata, sizeof(buffdata)): result=%d if (result>=0): Successful get hostname, buffdata=|%s|\n", argv[0], result, buffdata); else printf("%s: result=getdomainname(buffdata, sizeof(buffdata)): result=%d if (result>=0): \n", argv[0], result); #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/getdomainnameprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/getdomainname <domainname> Examples: /home/local/code/ansiccode/network/getdomainname localdomain /home/local/code/ansiccode/network/getdomainname example.org
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/getdomainname localdomainrezultat będzie zależny od podanych argumentów wywołania programu:
getdomainname: result=getdomainname(buffdata, sizeof(buffdata)): result=0 if (result>=0): Successful get hostname, buffdata=|(none)| getdomainname: result=setdomainname(argv[1]=localdomain, strlen(argv[1])): result=-1 if (result>=0): else: Unable set domainname, Reason: 1:Operation not permitted getdomainname: result=getdomainname(buffdata, sizeof(buffdata)): result=0 if (result>=0): Successful get hostname, buffdata=|(none)|
#top gethostbyaddr¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us | gnu.org
Deklaracja funkcji
gethostbyaddr()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
gethostbyaddr()
jest następująca:/* Return entry from host data base which address match ADDR with length LEN and type TYPE. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len, int __type);
Powiązane:
h_errno, gethostbyaddr(), gethostbyname(), gethostbyname2(), hstrerror(),
Opis:
Funkcja gethostbyaddr()
Argumenty:
const void *__addr -
__socklen_t __len -
int __type -
Zwracana wartość:
struct hostent * -
Argumenty:
const void *__addr -
__socklen_t __len -
int __type -
Zwracana wartość:
struct hostent * -
#top gethostbyname¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us | gnu.org
Deklaracja funkcji
gethostbyname()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
gethostbyname()
jest następująca:/* Return entry from host data base for host with NAME. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct hostent *gethostbyname (__const char *__name);
Powiązane:
h_errno, gethostbyaddr(), gethostbyname(), gethostbyname2(), hstrerror(),
Opis:
Example:
zawartość pliku
gethostbyname.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), gethostbyaddr(), gethostbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { struct hostent *hostentptr; struct in_addr inaddr; int ai_family; char buffaddr[16]; int i; if (argc<4) { printf("Usage: %s <address family> <hostname> <hostaddress>\n", argv[0]); printf("Examples:\n"); printf(" %s AF_INET localhost 127.0.0.1\n", argv[0]); printf(" %s AF_UNSPEC www.example.org 93.184.216.119\n", argv[0]); printf(" %s AF_INET www.example.org 93.184.216.119\n", argv[0]); printf(" %s AF_INET6 www.example.org 93.184.216.119\n", argv[0]); return 0; } if (strncmp(argv[1],"AF_UNSPEC",strlen("AF_UNSPEC"))!=0 && strncmp(argv[1],"AF_INET",strlen("AF_INET"))!=0 && strncmp(argv[1],"AF_INET6",strlen("AF_INET6"))!=0) { printf("%s Bad address family: allowed: AF_UNSPEC, AF_INET, AF_INET6\n", argv[0]); return 1; } hostentptr=gethostbyname(argv[2]); if (hostentptr!=NULL) { printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr=%p if (hostentptr!=NULL): Successful gethostbyname().\n", argv[0], argv[2], (void*)hostentptr); if (hostentptr->h_name) printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr->h_name=%s hostentptr->h_addrtype=%d hostentptr->h_length=%d\n", argv[0], argv[2], hostentptr->h_name, hostentptr->h_addrtype, hostentptr->h_length); if (hostentptr->h_aliases) { for (i=0;hostentptr->h_aliases[i]!=0;i++) { printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr->h_aliases[%d]=%s\n", argv[0], argv[2], i, hostentptr->h_aliases[i]); } } if (hostentptr->h_addr_list) { for (i=0;hostentptr->h_addr_list[i]!=0;i++) { memset(buffaddr, 0x00, sizeof(buffaddr)); inet_ntop(PF_INET, hostentptr->h_addr_list[i], buffaddr, sizeof(buffaddr)); printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr->h_addr_list[%d]=%s\n", argv[0], argv[2], i, buffaddr); } } } else { switch (h_errno) { case NETDB_SUCCESS: printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname(), Reason: NETDB_SUCCESS=%d %d:%s\n", argv[0], argv[2], (void*)hostentptr, NETDB_SUCCESS, h_errno, hstrerror(h_errno)); break; case HOST_NOT_FOUND: printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname(), Reason: HOST_NOT_FOUND=%d %d:%s\n", argv[0], argv[2], (void*)hostentptr, HOST_NOT_FOUND, h_errno, hstrerror(h_errno)); break; case TRY_AGAIN: printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname(), Reason: TRY_AGAIN=%d %d:%s\n", argv[0], argv[2], (void*)hostentptr, TRY_AGAIN, h_errno, hstrerror(h_errno)); break; case NO_RECOVERY: printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname(), Reason: NO_RECOVERY=%d %d:%s\n", argv[0], argv[2], (void*)hostentptr, NO_RECOVERY, h_errno, hstrerror(h_errno)); break; case NO_DATA: printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname(), Reason: NO_DATA=%d %d:%s\n", argv[0], argv[2], (void*)hostentptr, NO_DATA, h_errno, hstrerror(h_errno)); break; /*#define NO_ADDRESS NO_DATA - duplicate case value */ /*case NO_ADDRESS: printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname(), Reason: NO_ADDRESS=%d %d:%s\n", argv[0], argv[2], (void*)hostentptr, NO_ADDRESS, h_errno, hstrerror(h_errno)); break;*/ case NETDB_INTERNAL: printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname(), Reason: NETDB_INTERNAL=%d %d:%s\n", argv[0], argv[2], (void*)hostentptr, NETDB_INTERNAL, h_errno, hstrerror(h_errno)); break; default: printf("%s: hostentptr=gethostbyname(argv[2]=%s): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname(), Reason: NETDB:UNKNOWN:ERROR %d:%s\n", argv[0], argv[2], (void*)hostentptr, h_errno, hstrerror(h_errno)); break; } } ai_family = AF_UNSPEC; if (strncmp(argv[1],"AF_UNSPEC",strlen("AF_UNSPEC"))==0) ai_family = AF_UNSPEC; if (strncmp(argv[1],"AF_INET" ,strlen("AF_INET" ))==0) ai_family = AF_INET; if (strncmp(argv[1],"AF_INET6" ,strlen("AF_INET6" ))==0) ai_family = AF_INET6; hostentptr=gethostbyname2(argv[2], ai_family); if (hostentptr!=NULL) { printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): Successful gethostbyname2().\n", argv[0], argv[2], ai_family, (void*)hostentptr); if (hostentptr->h_name) printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr->h_name=%s hostentptr->h_addrtype=%d hostentptr->h_length=%d\n", argv[0], argv[2], ai_family, hostentptr->h_name, hostentptr->h_addrtype, hostentptr->h_length); if (hostentptr->h_aliases) { for (i=0;hostentptr->h_aliases[i]!=0;i++) { printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr->h_aliases[%d]=%s\n", argv[0], argv[2], ai_family, i, hostentptr->h_aliases[i]); } } if (hostentptr->h_addrtype==AF_INET && hostentptr->h_addr_list) { for (i=0;hostentptr->h_addr_list[i]!=0;i++) { memset(buffaddr, 0x00, sizeof(buffaddr)); inet_ntop(PF_INET, hostentptr->h_addr_list[i], buffaddr, sizeof(buffaddr)); printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr->h_addr_list[%d]=%s\n", argv[0], argv[2], ai_family, i, buffaddr); } } if (hostentptr->h_addrtype==AF_INET6 && hostentptr->h_addr_list) { for (i=0;hostentptr->h_addr_list[i]!=0;i++) { memset(buffaddr, 0x00, sizeof(buffaddr)); inet_ntop(PF_INET6, hostentptr->h_addr_list[i], buffaddr, INET6_ADDRSTRLEN); printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr->h_addr_list[%d]=%s\n", argv[0], argv[2], ai_family, i, buffaddr); } } } else { switch (h_errno) { case NETDB_SUCCESS: printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname2(), Reason: NETDB_SUCCESS=%d %d:%s\n", argv[0], argv[2], ai_family, (void*)hostentptr, NETDB_SUCCESS, h_errno, hstrerror(h_errno)); break; case HOST_NOT_FOUND: printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname2(), Reason: HOST_NOT_FOUND=%d %d:%s\n", argv[0], argv[2], ai_family, (void*)hostentptr, HOST_NOT_FOUND, h_errno, hstrerror(h_errno)); break; case TRY_AGAIN: printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname2(), Reason: TRY_AGAIN=%d %d:%s\n", argv[0], argv[2], ai_family, (void*)hostentptr, TRY_AGAIN, h_errno, hstrerror(h_errno)); break; case NO_RECOVERY: printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname2(), Reason: NO_RECOVERY=%d %d:%s\n", argv[0], argv[2], ai_family, (void*)hostentptr, NO_RECOVERY, h_errno, hstrerror(h_errno)); break; case NO_DATA: printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname2(), Reason: NO_DATA=%d %d:%s\n", argv[0], argv[2], ai_family, (void*)hostentptr, NO_DATA, h_errno, hstrerror(h_errno)); break; /*#define NO_ADDRESS NO_DATA - duplicate case value */ /*case NO_ADDRESS: printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname2(), Reason: NO_ADDRESS=%d %d:%s\n", argv[0], argv[2], ai_family, (void*)hostentptr, NO_ADDRESS, h_errno, hstrerror(h_errno)); break;*/ case NETDB_INTERNAL: printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname2(), Reason: NETDB_INTERNAL=%d %d:%s\n", argv[0], argv[2], ai_family, (void*)hostentptr, NETDB_INTERNAL, h_errno, hstrerror(h_errno)); break; default: printf("%s: hostentptr=gethostbyname2(argv[2]=%s, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyname2(), Reason: NETDB:UNKNOWN:ERROR %d:%s\n", argv[0], argv[2], ai_family, (void*)hostentptr, h_errno, hstrerror(h_errno)); break; } } inaddr.s_addr=inet_addr(argv[3]); ai_family=AF_INET; printf("%s: inaddr.s_addr=inet_addr(argv[3]=%s): inaddr.s_addr=%08X ntohl(inaddr.s_addr)=%08X (%d.%d.%d.%d)\n", argv[0], argv[3], inaddr.s_addr, ntohl(inaddr.s_addr), ntohl(inaddr.s_addr)>>24&0xFF, ntohl(inaddr.s_addr)>>16&0xFF, ntohl(inaddr.s_addr)>>8&0xFF, ntohl(inaddr.s_addr)>>0&0xFF); hostentptr=gethostbyaddr((char*)&inaddr, sizeof(struct in_addr), ai_family); if (hostentptr!=NULL) { printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): Successful gethostbyname().\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, (void*)hostentptr); if (hostentptr->h_name) printf("%s: hostentptr=gethostbyaddr(inaddr=%08X): hostentptr->h_name=%s hostentptr->h_addrtype=%d hostentptr->h_length=%d\n", argv[0], inaddr.s_addr, hostentptr->h_name, hostentptr->h_addrtype, hostentptr->h_length); if (hostentptr->h_aliases) { for (i=0;hostentptr->h_aliases[i]!=0;i++) { printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr->h_aliases[%d]=%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, i, hostentptr->h_aliases[i]); } } if (hostentptr->h_addr_list) { for (i=0;hostentptr->h_addr_list[i]!=0;i++) { memset(buffaddr, 0x00, sizeof(buffaddr)); inet_ntop(PF_INET, hostentptr->h_addr_list[i], buffaddr, sizeof(buffaddr)); printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr->h_addr_list[%d]=%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, i, buffaddr); } } } else { switch (h_errno) { case NETDB_SUCCESS: printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyaddr(), Reason: NETDB_SUCCESS=%d %d:%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, (void*)hostentptr, NETDB_SUCCESS, h_errno, hstrerror(h_errno)); break; case HOST_NOT_FOUND: printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyaddr(), Reason: HOST_NOT_FOUND=%d %d:%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, (void*)hostentptr, HOST_NOT_FOUND, h_errno, hstrerror(h_errno)); break; case TRY_AGAIN: printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyaddr(), Reason: TRY_AGAIN=%d %d:%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, (void*)hostentptr, TRY_AGAIN, h_errno, hstrerror(h_errno)); break; case NO_RECOVERY: printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyaddr(), Reason: NO_RECOVERY=%d %d:%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, (void*)hostentptr, NO_RECOVERY, h_errno, hstrerror(h_errno)); break; case NO_DATA: printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyaddr(), Reason: NO_DATA=%d %d:%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, (void*)hostentptr, NO_DATA, h_errno, hstrerror(h_errno)); break; /*#define NO_ADDRESS NO_DATA - duplicate case value */ /*case NO_ADDRESS: printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyaddr(), Reason: NO_ADDRESS=%d %d:%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, (void*)hostentptr, NO_ADDRESS, h_errno, hstrerror(h_errno)); break;*/ case NETDB_INTERNAL: printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyaddr(), Reason: NETDB_INTERNAL=%d %d:%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, (void*)hostentptr, NETDB_INTERNAL, h_errno, hstrerror(h_errno)); break; default: printf("%s: hostentptr=gethostbyaddr(inaddr=%08X, sizeof(struct in_addr)=%lu, ai_family=%d): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostbyaddr(), Reason: NETDB:UNKNOWN:ERROR %d:%s\n", argv[0], inaddr.s_addr, (unsigned long int)sizeof(struct in_addr), ai_family, (void*)hostentptr, h_errno, hstrerror(h_errno)); break; } } return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/gethostbynameprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/gethostbyname <address family> <hostname> <hostaddress> Examples: /home/local/code/ansiccode/network/gethostbyname AF_INET localhost 127.0.0.1 /home/local/code/ansiccode/network/gethostbyname AF_INET www.example.org 93.184.216.119
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/gethostbyname AF_INET localhost 127.0.0.1rezultat będzie zależny od podanych argumentów wywołania programu:
gethostbyname: hostentptr=gethostbyname(argv[2]=localhost): hostentptr=0x481a7c if (hostentptr!=NULL): Successful gethostbyname(). gethostbyname: hostentptr=gethostbyname(argv[2]=localhost): hostentptr->h_name=localhost.localdomain hostentptr->h_addrtype=2 hostentptr->h_length=4 gethostbyname: hostentptr=gethostbyname(argv[2]=localhost): hostentptr->h_aliases[0]=localhost gethostbyname: hostentptr=gethostbyname(argv[2]=localhost): hostentptr->h_aliases[1]=host gethostbyname: hostentptr=gethostbyname(argv[2]=localhost): hostentptr->h_addr_list[0]=127.0.0.1 gethostbyname: hostentptr=gethostbyname2(argv[2]=localhost, ai_family=2): hostentptr=0x481a98 if (hostentptr!=NULL): Successful gethostbyname2(). gethostbyname: hostentptr=gethostbyname2(argv[2]=localhost, ai_family=2): hostentptr->h_name=localhost.localdomain hostentptr->h_addrtype=2 hostentptr->h_length=4 gethostbyname: hostentptr=gethostbyname2(argv[2]=localhost, ai_family=2): hostentptr->h_aliases[0]=localhost gethostbyname: hostentptr=gethostbyname2(argv[2]=localhost, ai_family=2): hostentptr->h_aliases[1]=host gethostbyname: hostentptr=gethostbyname2(argv[2]=localhost, ai_family=2): hostentptr->h_addr_list[0]=127.0.0.1 gethostbyname: sinaddr.s_addr=inet_addr(argv[3]=127.0.0.1): sinaddr.s_addr=0100007F ntohl(sinaddr.s_addr)=7F000001 (127.0.0.1) gethostbyname: hostentptr=gethostbyaddr(sinaddr=0100007F, sizeof(struct in_addr)=4, ai_family=2): hostentptr=0x481a58 if (hostentptr!=NULL): Successful gethostbyname(). gethostbyname: hostentptr=gethostbyaddr(sinaddr=0100007F): hostentptr->h_name=localhost.localdomain hostentptr->h_addrtype=2 hostentptr->h_length=4 gethostbyname: hostentptr=gethostbyaddr(sinaddr=0100007F, sizeof(struct in_addr)=4, ai_family=2): hostentptr->h_aliases[0]=localhost gethostbyname: hostentptr=gethostbyaddr(sinaddr=0100007F, sizeof(struct in_addr)=4, ai_family=2): hostentptr->h_aliases[1]=host gethostbyname: hostentptr=gethostbyaddr(sinaddr=0100007F, sizeof(struct in_addr)=4, ai_family=2): hostentptr->h_addr_list[0]=127.0.0.1
#top gethostbyname2¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
gethostbyname2()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
gethostbyname2()
jest następująca:/* Return entry from host data base for host with NAME. AF must be set to the address type which is `AF_INET' for IPv4 or `AF_INET6' for IPv6. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern struct hostent *gethostbyname2 (__const char *__name, int __af);
Powiązane:
h_errno, gethostbyaddr(), gethostbyname(), gethostbyname2(), hstrerror(),
Opis:
Funkcja gethostbyname2()
Argumenty:
const char *__name -
int __af -
Zwracana wartość:
struct hostent * -
Argumenty:
const char *__name -
int __af -
Zwracana wartość:
struct hostent * -
#top gethostent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
gethostent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
gethostent()
jest następująca:/* Get next entry from host data base file. Open data base if necessary. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct hostent *gethostent (void);
Powiązane:
endhostent(), gethostent(), sethostent(),
Opis:
Funkcja gethostent() zwraca wskaźnik do struktury struct hostent zawierającej informacje dotyczące hostów przechowywanych w systemie. W przypadku gdy w kolejnych wywołaniach funkcji zwrócone zostały już wszystkie informacje dotyczące hostów przechowywanych w systemie zwracany jest wskaźnik NULL.
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
struct hostent * -
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
struct hostent * -
Example:
zawartość pliku
gethostent.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <unistd.h> /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */ /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */ /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */ #include <errno.h> /* for errno constant, error constants, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), gethostbyaddr(), gethostbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { struct hostent *hostentptr; int stayopen; char buffaddr[16]; int i; if (argc<1) { printf("Usage: %s\n", argv[0]); return 0; } stayopen=1; sethostent(stayopen); while (1) { hostentptr=gethostent(); if (hostentptr!=NULL) { printf("%s: hostentptr=gethostent(): hostentptr=%p if (hostentptr!=NULL): Successful gethostent().\n", argv[0], (void*)hostentptr); if (hostentptr->h_name) printf("%s: hostentptr=gethostent(): hostentptr->h_addrtype=%d hostentptr->h_name=%s hostentptr->h_length=%d\n", argv[0], hostentptr->h_addrtype, hostentptr->h_name, hostentptr->h_length); if (hostentptr->h_aliases) { for (i=0;hostentptr->h_aliases[i]!=0;i++) { printf("%s: hostentptr=gethostent(): hostentptr->h_aliases[%d]=%s\n", argv[0], i, hostentptr->h_aliases[i]); } } if (hostentptr->h_addr_list) { for (i=0;hostentptr->h_addr_list[i]!=0;i++) { memset(buffaddr, 0x00, sizeof(buffaddr)); inet_ntop(PF_INET, hostentptr->h_addr_list[i], buffaddr, sizeof(buffaddr)); printf("%s: hostentptr=gethostent(): hostentptr->h_addr_list[%d]=%s\n", argv[0], i, buffaddr); } } } else { printf("%s: hostentptr=gethostent(): hostentptr=%p if (hostentptr!=NULL): else: Unable to gethostent(), Reason: %d:%s\n", argv[0], (void*)hostentptr, h_errno, hstrerror(h_errno)); break; } } endhostent(); return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/gethostentprogram wyświetli stosowne informacje o sposobie działania:
gethostent: hostentptr=gethostent(): hostentptr=0x243ac4 if (hostentptr!=NULL): Successful gethostent(). gethostent: hostentptr=gethostent(): hostentptr->h_addrtype=2 hostentptr->h_name=localhost.localdomain hostentptr->h_length=4 gethostent: hostentptr=gethostent(): hostentptr->h_aliases[0]=localhost gethostent: hostentptr=gethostent(): hostentptr->h_aliases[1]=host gethostent: hostentptr=gethostent(): hostentptr->h_addr_list[0]=127.0.0.1 gethostent: hostentptr=gethostent(): hostentptr=(nil) if (hostentptr!=NULL): else: Unable to gethostent(), Reason: 1:Unknown host
#top gethostname¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us
Deklaracja funkcji
gethostname()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
gethostname()
jest następująca:/* Put the name of the current host in no more than LEN bytes of NAME. The result is null-terminated if LEN is large enough for the full name and the terminator. */ extern int gethostname (char *__name, size_t __len) __THROW __nonnull ((1));
Powiązane:
gethostname(), sethostname(),
Opis:
Example:
zawartość pliku
gethostname.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <unistd.h> /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */ /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */ /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */ #include <errno.h> /* for errno constant, error constants, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ #else #endif int main(int argc, char **argv) { char buffdata[1024]; int result; if (argc<2) { printf("Usage: %s <hostname>\n", argv[0]); printf("Examples:\n"); printf(" %s localhost\n", argv[0]); printf(" %s www.example.org\n", argv[0]); return 0; } memset(buffdata, 0x00, sizeof(buffdata)); result=gethostname(buffdata, sizeof(buffdata)); if (result>=0) printf("%s: result=gethostname(buffdata, sizeof(buffdata)): result=%d if (result>=0): Successful get hostname, buffdata=|%s|\n", argv[0], result, buffdata); else printf("%s: result=gethostname(buffdata, sizeof(buffdata)): result=%d if (result>=0): \n", argv[0], result); #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* sethostname() is not available on this OS platform !!! */ printf("%s: sethostname() is not available on this OS platform !!!\n", argv[0]); #else result=sethostname(argv[1], strlen(argv[1])); if (result>=0) printf("%s: result=sethostname(argv[1]=%s, strlen(argv[1])): result=%d if (result>=0): Successful get hostname\n", argv[0], argv[1], result); else printf("%s: result=sethostname(argv[1]=%s, strlen(argv[1])): result=%d if (result>=0): else: Unable set hostname, Reason: %d:%s\n", argv[0], argv[1], result, errno, strerror(errno)); #endif memset(buffdata, 0x00, sizeof(buffdata)); result=gethostname(buffdata, sizeof(buffdata)); if (result>=0) printf("%s: result=gethostname(buffdata, sizeof(buffdata)): result=%d if (result>=0): Successful get hostname, buffdata=|%s|\n", argv[0], result, buffdata); else printf("%s: result=gethostname(buffdata, sizeof(buffdata)): result=%d if (result>=0): \n", argv[0], result); return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/gethostnameprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/gethostname <hostname> Examples: /home/local/code/ansiccode/network/gethostname localhost /home/local/code/ansiccode/network/gethostname www.example.org
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/gethostname localhostrezultat będzie zależny od podanych argumentów wywołania programu:
gethostname: result=gethostname(buffdata, sizeof(buffdata)): result=0 if (result>=0): Successful get hostname, buffdata=|xnd.nat.wbcd.pl| gethostname: result=sethostname(argv[1]=localhost, strlen(argv[1])): result=-1 if (result>=0): else: Unable set hostname, Reason: 1:Operation not permitted gethostname: result=gethostname(buffdata, sizeof(buffdata)): result=0 if (result>=0): Successful get hostname, buffdata=|xnd.nat.wbcd.pl|
#top getnameinfo¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us
Deklaracja funkcji
getnameinfo()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getnameinfo()
jest następująca:/* Translate a socket address to a location and service name. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int getnameinfo (__const struct sockaddr *__restrict __sa, socklen_t __salen, char *__restrict __host, socklen_t __hostlen, char *__restrict __serv, socklen_t __servlen, unsigned int __flags);
Powiązane:
Opis:
Funkcja getnameinfo()
Argumenty:
const struct sockaddr *__restrict __sa -
socklen_t __salen -
char *__restrict __host -
socklen_t __hostlen -
char *__restrict __serv -
socklen_t __servlen -
unsigned int __flags -
Zwracana wartość:
int -
Argumenty:
const struct sockaddr *__restrict __sa -
socklen_t __salen -
char *__restrict __host -
socklen_t __hostlen -
char *__restrict __serv -
socklen_t __servlen -
unsigned int __flags -
Zwracana wartość:
int -
Example:
zawartość pliku
getnameinfo.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <sys/socket.h> /* for bits/socket.h, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_PACKET, AF_UNIX, PF_UNIX, AF_FILE, PF_FILE, AF_INET, PF_INET, MSG_OOB, MSG_PEEK, MSG_DONTWAIT, struct msghdr, struct sockaddr, struct osockaddr, */ /* for socket(), bind(), getsockname(), connect(), getpeername(), send(), recv(), sendto(), recvfrom(), sendmsg(), recvmsg(), getsockopt(), setsockopt(), listen(), accept(), shutdown(), sockatmark(), */ #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netinet/in.h> /* need in OpenBSD, for in_port_t, in_addr_t, struct in_addr, struct in6_addr, struct sockaddr_in, struct sockaddr_in6, ntohl(), ntohs(), htonl(), htons(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), gethostbyaddr(), gethostbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { char *self; struct sockaddr_in sockipv4addr; struct sockaddr_in6 sockipv6addr; char hostaddr[1024]; char service[20]; int result; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<3) { printf("Usage: %s <ipv4addr> <ipv6addr> <ipport>\n", argv[0]); printf("Examples:\n"); printf(" %s 127.0.0.1 ::1 80\n", argv[0]); return 0; } /* and this call is the same as the inet_aton() call, above: */ memset(&sockipv4addr, 0x00, sizeof(struct sockaddr_in)); memset(&sockipv6addr, 0x00, sizeof(struct sockaddr_in6)); sockipv4addr.sin_family=AF_INET; sockipv4addr.sin_addr.s_addr=inet_addr(argv[1]); sockipv4addr.sin_port=htons(atoi(argv[3])); printf("%s: sockipv4addr.sin_addr.s_addr=inet_addr(argv[1]=%s): sockipv4addr.sin_family=%d sockipv4addr.sin_addr.s_addr=%08X ntohs(sockipv4addr.sin_port=%d)=%d\n", self, argv[1], sockipv4addr.sin_family, (unsigned int)sockipv4addr.sin_addr.s_addr, sockipv4addr.sin_port, ntohs(sockipv4addr.sin_port)); sockipv6addr.sin6_family=AF_INET6; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) result=-1; #else result=inet_pton(AF_INET6, argv[2], &sockipv6addr.sin6_addr); #endif sockipv6addr.sin6_port=htons(atoi(argv[3])); printf("%s: result=inet_pton(AF_INET6=%d, argv[2]=%s, &sockipv6addr.sin6_addr): sockipv6addr.sin6_family=%d sockipv6addr.sin6_addr ntohs(sockipv6addr.sin6_port=%d)=%d\n", self, AF_INET6, argv[1], sockipv6addr.sin6_family, sockipv6addr.sin6_port, ntohs(sockipv6addr.sin6_port)); /* pretend sa is full of good information about the host and port... */ result=getnameinfo((struct sockaddr*)&sockipv4addr, sizeof(struct sockaddr_in), hostaddr, sizeof(hostaddr), service, sizeof(service), 0); printf("%s: getnameinfo((struct sockaddr*)&sockipv4addr, sizeof(struct sockaddr_in)=%lu, hostaddr=%s, sizeof(hostaddr)=%lu, service=%s, sizeof(service)=%lu, 0):\n", self, (unsigned long int)sizeof(struct sockaddr_in), hostaddr, (unsigned long int)sizeof(hostaddr), service, (unsigned long int)sizeof(service)); /* e.g. "www.example.org" */ /* e.g. "http" */ result=getnameinfo((struct sockaddr*)&sockipv6addr, sizeof(struct sockaddr_in6), hostaddr, sizeof(hostaddr), service, sizeof(service), 0); printf("%s: getnameinfo((struct sockaddr*)&sockipv6addr, sizeof(struct sockaddr_in6)=%lu, hostaddr=%s, sizeof(hostaddr)=%lu, service=%s, sizeof(service)=%lu, 0):\n", self, (unsigned long int)sizeof(struct sockaddr_in6), hostaddr, (unsigned long int)sizeof(hostaddr), service, (unsigned long int)sizeof(service)); /* e.g. "www.example.org" */ /* e.g. "http" */ return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/getnameinfoprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/getnameinfo <ipv4addr> <ipv6addr> <ipport> Examples: /home/local/code/ansiccode/network/getnameinfo 127.0.0.1 ::1 80
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/getnameinfo 127.0.0.1 ::1 80rezultat będzie zależny od podanych argumentów wywołania programu:
getnameinfo: sockipv4addr.sin_addr.s_addr=inet_addr(argv[1]=127.0.0.1): sockipv4addr.sin_family=2 sockipv4addr.sin_addr.s_addr=0100007F ntohs(sockipv4addr.sin_port=20480)=80 getnameinfo: result=inet_pton(AF_INET6=10, argv[2]=127.0.0.1, &sockipv6addr.sin6_addr): sockipv6addr.sin6_family=10 sockipv6addr.sin6_addr ntohs(sockipv6addr.sin6_port=20480)=80 getnameinfo: getnameinfo((struct sockaddr*)&sockipv4addr, sizeof(struct sockaddr_in)=16, hostaddr=localhost.localdomain, sizeof(hostaddr)=1024, service=http, sizeof(service)=20, 0): getnameinfo: getnameinfo((struct sockaddr*)&sockipv6addr, sizeof(struct sockaddr_in6)=28, hostaddr=localhost6.localdomain6, sizeof(hostaddr)=1024, service=http, sizeof(service)=20, 0):
#top getnetbyaddr¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
getnetbyaddr()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getnetbyaddr()
jest następująca:/* Return entry from network data base which address match NET and type TYPE. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct netent *getnetbyaddr (uint32_t __net, int __type);
Powiązane:
getnetbyaddr(), getnetbyname(),
Opis:
#top getnetbyname¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
getnetbyname()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getnetbyname()
jest następująca:/* Return entry from network data base for network with NAME. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct netent *getnetbyname (__const char *__name);
Powiązane:
getnetbyaddr(), getnetbyname(),
Opis:
Example:
zawartość pliku
getnetbyname.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, getnetbyname(), getnetbyaddr(), */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), getnetbyaddr(), getnetbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { struct netent *netentptr; uint32_t netaddr; int ai_family; int i; if (argc<4) { printf("Usage: %s <address family> <netname> <netaddress>\n", argv[0]); printf("Examples:\n"); printf(" %s AF_INET default 0.0.0.0\n", argv[0]); printf(" %s AF_INET loopback 127.0.0.0\n", argv[0]); printf(" %s AF_INET link-local 169.254.0.0\n", argv[0]); return 0; } if (strncmp(argv[1],"AF_UNSPEC",strlen("AF_UNSPEC"))!=0 && strncmp(argv[1],"AF_INET",strlen("AF_INET"))!=0 && strncmp(argv[1],"AF_INET6",strlen("AF_INET6"))!=0) { printf("%s Bad address family: allowed: AF_UNSPEC, AF_INET, AF_INET6\n", argv[0]); return 1; } netentptr=getnetbyname(argv[2]); if (netentptr!=NULL) { printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr=%p if (netentptr!=NULL): Successful getnetbyname().\n", argv[0], argv[2], (void*)netentptr); if (netentptr->n_name) printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr->n_name=%s netentptr->n_addrtype=%d netentptr->n_net=%08X (%d.%d.%d.%d)\n", argv[0], argv[2], netentptr->n_name, netentptr->n_addrtype, netentptr->n_net, netentptr->n_net>>24&0xFF, netentptr->n_net>>16&0xFF, netentptr->n_net>>8&0xFF, netentptr->n_net>>0&0xFF); if (netentptr->n_aliases) { for (i=0;netentptr->n_aliases[i]!=0;i++) { printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr->n_aliases[%d]=%s\n", argv[0], argv[2], i, netentptr->n_aliases[i]); } } } else { switch (h_errno) { case NETDB_SUCCESS: printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyname(), Reason: NETDB_SUCCESS=%d %d:%s\n", argv[0], argv[2], (void*)netentptr, NETDB_SUCCESS, h_errno, hstrerror(h_errno)); break; case HOST_NOT_FOUND: printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyname(), Reason: HOST_NOT_FOUND=%d %d:%s\n", argv[0], argv[2], (void*)netentptr, HOST_NOT_FOUND, h_errno, hstrerror(h_errno)); break; case TRY_AGAIN: printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyname(), Reason: TRY_AGAIN=%d %d:%s\n", argv[0], argv[2], (void*)netentptr, TRY_AGAIN, h_errno, hstrerror(h_errno)); break; case NO_RECOVERY: printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyname(), Reason: NO_RECOVERY=%d %d:%s\n", argv[0], argv[2], (void*)netentptr, NO_RECOVERY, h_errno, hstrerror(h_errno)); break; case NO_DATA: printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyname(), Reason: NO_DATA=%d %d:%s\n", argv[0], argv[2], (void*)netentptr, NO_DATA, h_errno, hstrerror(h_errno)); break; /*#define NO_ADDRESS NO_DATA - duplicate case value */ /*case NO_ADDRESS: printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyname(), Reason: NO_ADDRESS=%d %d:%s\n", argv[0], argv[2], (void*)netentptr, NO_ADDRESS, h_errno, hstrerror(h_errno)); break;*/ case NETDB_INTERNAL: printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyname(), Reason: NETDB_INTERNAL=%d %d:%s\n", argv[0], argv[2], (void*)netentptr, NETDB_INTERNAL, h_errno, hstrerror(h_errno)); break; default: printf("%s: netentptr=getnetbyname(argv[2]=%s): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyname(), Reason: %d:%s\n", argv[0], argv[2], (void*)netentptr, h_errno, hstrerror(h_errno)); break; } } ai_family = AF_UNSPEC; if (strncmp(argv[1],"AF_UNSPEC",strlen("AF_UNSPEC"))==0) ai_family = AF_UNSPEC; if (strncmp(argv[1],"AF_INET" ,strlen("AF_INET" ))==0) ai_family = AF_INET; if (strncmp(argv[1],"AF_INET6" ,strlen("AF_INET6" ))==0) ai_family = AF_INET6; netaddr=inet_addr(argv[3]); netentptr=getnetbyaddr(htonl(netaddr), ai_family); if (netentptr!=NULL) { printf("%s: netentptr=getnetbyaddr(htonl(netaddr)=%08X, ai_family=%d): netentptr=%p if (netentptr!=NULL): Successful getnetbyaddr().\n", argv[0], netaddr, ai_family, (void*)netentptr); if (netentptr->n_name) printf("%s: netentptr=getnetbyaddr(htonl(netaddr)=%08X, ai_family=%d): netentptr->n_name=%s netentptr->n_addrtype=%d netentptr->n_net=%08X (%d.%d.%d.%d)\n", argv[0], netaddr, ai_family, netentptr->n_name, netentptr->n_addrtype, netentptr->n_net, netentptr->n_net>>24&0xFF, netentptr->n_net>>16&0xFF, netentptr->n_net>>8&0xFF, netentptr->n_net>>0&0xFF); if (netentptr->n_aliases) { for (i=0;netentptr->n_aliases[i]!=0;i++) { printf("%s: netentptr=getnetbyaddr(netaddr=%08X, ai_family=%d): netentptr->h_aliases[%d]=%s\n", argv[0], netaddr, ai_family, i, netentptr->n_aliases[i]); } } } else { switch (h_errno) { case NETDB_SUCCESS: printf("%s: netentptr=getnetbyaddr(netaddr=%08X, ai_family=%d): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyaddr(), Reason: NETDB_SUCCESS=%d %d:%s\n", argv[0], netaddr, ai_family, (void*)netentptr, NETDB_SUCCESS, h_errno, hstrerror(h_errno)); break; case HOST_NOT_FOUND: printf("%s: netentptr=getnetbyaddr(netaddr=%08X, ai_family=%d): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyaddr(), Reason: HOST_NOT_FOUND=%d %d:%s\n", argv[0], netaddr, ai_family, (void*)netentptr, HOST_NOT_FOUND, h_errno, hstrerror(h_errno)); break; case TRY_AGAIN: printf("%s: netentptr=getnetbyaddr(netaddr=%08X, ai_family=%d): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyaddr(), Reason: TRY_AGAIN=%d %d:%s\n", argv[0], netaddr, ai_family, (void*)netentptr, TRY_AGAIN, h_errno, hstrerror(h_errno)); break; case NO_RECOVERY: printf("%s: netentptr=getnetbyaddr(netaddr=%08X, ai_family=%d): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyaddr(), Reason: NO_RECOVERY=%d %d:%s\n", argv[0], netaddr, ai_family, (void*)netentptr, NO_RECOVERY, h_errno, hstrerror(h_errno)); break; case NO_DATA: printf("%s: netentptr=getnetbyaddr(netaddr=%08X, ai_family=%d): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyaddr(), Reason: NO_DATA=%d %d:%s\n", argv[0], netaddr, ai_family, (void*)netentptr, NO_DATA, h_errno, hstrerror(h_errno)); break; /*#define NO_ADDRESS NO_DATA - duplicate case value */ /*case NO_ADDRESS: printf("%s: netentptr=getnetbyaddr(netaddr=%08X, ai_family=%d): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyaddr(), Reason: NO_ADDRESS=%d %d:%s\n", argv[0], netaddr, ai_family, (void*)netentptr, NO_ADDRESS, h_errno, hstrerror(h_errno)); break;*/ case NETDB_INTERNAL: printf("%s: netentptr=getnetbyaddr(netaddr=%08X, ai_family=%d): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyaddr(), Reason: NETDB_INTERNAL=%d %d:%s\n", argv[0], netaddr, ai_family, (void*)netentptr, NETDB_INTERNAL, h_errno, hstrerror(h_errno)); break; default: printf("%s: netentptr=getnetbyaddr(netaddr=%08X, ai_family=%d): netentptr=%p if (netentptr!=NULL): else: Unable to getnetbyaddr(), Reason: %d:%s\n", argv[0], netaddr, ai_family, (void*)netentptr, h_errno, hstrerror(h_errno)); break; } } return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/getnetbynameprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/getnetbyname <address family> <netname> <netaddress> Examples: /home/local/code/ansiccode/network/getnetbyname AF_INET default 0.0.0.0 /home/local/code/ansiccode/network/getnetbyname AF_INET loopback 127.0.0.0 /home/local/code/ansiccode/network/getnetbyname AF_INET link-local 169.254.0.0
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/getnetbyname AF_INET default 0.0.0.0rezultat będzie zależny od podanych argumentów wywołania programu:
getnetbyname: netentptr=getnetbyname(argv[2]=default): netentptr=0x243b14 if (netentptr!=NULL): Successful getnetbyname(). getnetbyname: netentptr=getnetbyname(argv[2]=default): netentptr->n_name=default netentptr->n_addrtype=2 netentptr->n_net=00000000 (0.0.0.0) getnetbyname: netentptr=getnetbyaddr(htonl(netaddr)=00000000, ai_family=2): netentptr=0x243af4 if (netentptr!=NULL): Successful getnetbyaddr(). getnetbyname: netentptr=getnetbyaddr(htonl(netaddr)=00000000, ai_family=2): netentptr->n_name=default netentptr->n_addrtype=2 netentptr->n_net=00000000 (0.0.0.0)
#top getnetent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
getnetent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getnetent()
jest następująca:/* Get next entry from network data base file. Open data base if necessary. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct netent *getnetent (void);
Powiązane:
endnetent(), getnetent(), setnetent(),
Opis:
Funkcja getnetent() zwraca wskaźnik do struktury struct netent zawierającej informacje dotyczące sieci przechowywanych w systemie. W przypadku gdy w kolejnych wywołaniach funkcji zwrócone zostały już wszystkie informacje dotyczące sieci przechowywanych w systemie zwracany jest wskaźnik NULL.
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
struct netent * -
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
struct netent * -
Example:
zawartość pliku
getnetent.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <unistd.h> /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */ /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */ /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */ #include <errno.h> /* for errno constant, error constants, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), gethostbyaddr(), gethostbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { struct netent *netentptr; int stayopen; int i; if (argc<1) { printf("Usage: %s\n", argv[0]); return 0; } stayopen=1; setnetent(stayopen); while (1) { netentptr=getnetent(); if (netentptr!=NULL) { printf("%s: netentptr=getnetent(): netentptr=%p if (netentptr!=NULL): Successful getnetent().\n", argv[0], (void*)netentptr); if (netentptr->n_name) printf("%s: netentptr=getnetent(): netentptr->n_addrtype=%d netentptr->n_name=%s netentptr->n_net=%u (%d.%d.%d.%d)\n", argv[0], netentptr->n_addrtype, netentptr->n_name, netentptr->n_net, netentptr->n_net>>24&0xFF, netentptr->n_net>>16&0xFF, netentptr->n_net>>8&0xFF, netentptr->n_net>>0&0xFF); if (netentptr->n_aliases) { for (i=0;netentptr->n_aliases[i]!=0;i++) { printf("%s: netentptr=getnetent(): netentptr->n_aliases[%d]=%s\n", argv[0], i, netentptr->n_aliases[i]); } } } else { printf("%s: netentptr=getnetent(): netentptr=%p if (netentptr!=NULL): else: Unable to getnetent(), Reason: %d:%s\n", argv[0], (void*)netentptr, h_errno, hstrerror(h_errno)); break; } } endnetent(); return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/getnetentprogram wyświetli stosowne informacje o sposobie działania:
getnetent: netentptr=getnetent(): netentptr=0x243b2c if (netentptr!=NULL): Successful getnetent(). getnetent: netentptr=getnetent(): netentptr->n_addrtype=2 netentptr->n_name=default netentptr->n_net=0 (0.0.0.0) getnetent: netentptr=getnetent(): netentptr=0x243b2c if (netentptr!=NULL): Successful getnetent(). getnetent: netentptr=getnetent(): netentptr->n_addrtype=2 netentptr->n_name=loopback netentptr->n_net=2130706432 (127.0.0.0) getnetent: netentptr=getnetent(): netentptr=0x243b2c if (netentptr!=NULL): Successful getnetent(). getnetent: netentptr=getnetent(): netentptr->n_addrtype=2 netentptr->n_name=link-local netentptr->n_net=2851995648 (169.254.0.0) getnetent: netentptr=getnetent(): netentptr=(nil) if (netentptr!=NULL): else: Unable to getnetent(), Reason: 1:Unknown host
#top getnetgrent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
getnetgrent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getnetgrent()
jest następująca:/* Get next member of netgroup established by last `setnetgrent' call and return pointers to elements in HOSTP, USERP, and DOMAINP. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern int getnetgrent (char **__restrict __hostp, char **__restrict __userp, char **__restrict __domainp);
Powiązane:
endnetgrent(), getnetgrent(), setnetgrent(),
Opis:
Funkcja getnetgrent() zwraca informacje dotyczące grup sieci przechowywanych w systemie. W przypadku gdy w kolejnych wywołaniach funkcji zwrócone zostały już wszystkie informacje dotyczące grup sieci przechowywanych w systemie wskaźniki ustawiane są na NULL.
Argumenty:
char **__restrict __hostp -
char **__restrict __userp -
char **__restrict __domainp -
Zwracana wartość:
int -
Argumenty:
char **__restrict __hostp -
char **__restrict __userp -
char **__restrict __domainp -
Zwracana wartość:
int -
Example:
zawartość pliku
getnetgrent.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <unistd.h> /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */ /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(), getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */ /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */ #include <errno.h> /* for errno constant, error constants, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ #else #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), gethostbyaddr(), gethostbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #if defined(NEED_NETGROUP_H) #include <netgroup.h> /* need in OpenBSD, for struct netgroup, setnetgrent(), getnetgrent(), endnetgrent(), innetgr(), */ #endif #endif int main(int argc, char **argv) { char *self; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #else char *netgrptrs[3]; int result; #endif self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <netgroup>\n", argv[0]); printf("Examples:\n"); printf(" %s wan\n", argv[0]); printf(" %s machines\n", argv[0]); printf(" %s people\n", argv[0]); printf(" %s netgroup\n", argv[0]); printf("\n"); printf("Configuration of /etc/nsswitch.conf\n"); printf("netgroup: files\n"); printf("\n"); printf("Content of /etc/netgroup\n"); printf("------------------------\n"); printf("wan (gateway , , ) (gateway-ebb , , )\n"); printf("machines (venus, -, star)\n"); printf("people (-, bob, star)\n"); printf("netgroup (hostname, username, domain)\n"); return 0; } #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* setnetgrent() is not available on this OS platform !!! */ /* getnetgrent() is not available on this OS platform !!! */ /* endnetgrent() is not available on this OS platform !!! */ printf("%s: setnetgrent() is not available on this OS platform !!!\n", self); printf("%s: getnetgrent() is not available on this OS platform !!!\n", self); printf("%s: endnetgrent() is not available on this OS platform !!!\n", self); #else setnetgrent(argv[1]); while (1) { result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2); if (result>0) { printf("%s: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): result=%d if (result>0): Successful getnetgrent().\n", self, result); printf("%s: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): netgrptrs[0](hostgroup)=%s, netgrptrs[1](usergroup)=%s, netgrptrs[2](domain)=%s\n", self, netgrptrs[0], netgrptrs[1], netgrptrs[2]); } else { break; } } endnetgrent(); #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
program wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/getnetgrent <netgroup> Examples: /home/local/code/ansiccode/network/getnetgrent wan /home/local/code/ansiccode/network/getnetgrent machines /home/local/code/ansiccode/network/getnetgrent people /home/local/code/ansiccode/network/getnetgrent netgroup Configuration of /etc/nsswitch.conf netgroup: files Content of /etc/netgroup ------------------------ wan (gateway , , ) (gateway-ebb , , ) machines (venus, -, star) people (-, bob, star) netgroup (hostname, username, domain)
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/getnetgrent wan /home/local/code/ansiccode/network/getnetgrent machines /home/local/code/ansiccode/network/getnetgrent people /home/local/code/ansiccode/network/getnetgrent netgrouprezultat będzie zależny od podanych argumentów wywołania programu:
getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): result=1 if (result>0): Successful getnetgrent(). getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): netgrptrs[0](hostgroup)=gateway, netgrptrs[1](usergroup)=(null), netgrptrs[2](domain)=(null) getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): result=1 if (result>0): Successful getnetgrent(). getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): netgrptrs[0](hostgroup)=gateway-ebb, netgrptrs[1](usergroup)=(null), netgrptrs[2](domain)=(null) getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): result=1 if (result>0): Successful getnetgrent(). getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): netgrptrs[0](hostgroup)=venus, netgrptrs[1](usergroup)=-, netgrptrs[2](domain)=star getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): result=1 if (result>0): Successful getnetgrent(). getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): netgrptrs[0](hostgroup)=-, netgrptrs[1](usergroup)=bob, netgrptrs[2](domain)=star getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): result=1 if (result>0): Successful getnetgrent(). getnetgrent: result=getnetgrent(netgrptrs+0, netgrptrs+1, netgrptrs+2): netgrptrs[0](hostgroup)=hostname, netgrptrs[1](usergroup)=username, netgrptrs[2](domain)=domain
#top getprotobyname¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
getprotobyname()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getprotobyname()
jest następująca:/* Return entry from protocol data base for network with NAME. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct protoent *getprotobyname (__const char *__name);
Powiązane:
getprotobyname(), getprotobynumber(),
Opis:
Example:
zawartość pliku
getprotobyname.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, getprotobyname(), getprotobynumber(), */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), getprotobynumber(), getprotobyname(), struct servent, getservent(), getprotobyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { struct protoent *protoentptr; int i; if (argc<3) { printf("Usage: %s <protoname> <protonum>\n", argv[0]); printf("Examples:\n"); printf(" %s icmp 1\n", argv[0]); printf(" %s tcp 6\n", argv[0]); printf(" %s udp 17\n", argv[0]); return 0; } protoentptr=getprotobyname(argv[1]); if (protoentptr!=NULL) { printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr=%p if (protoentptr!=NULL): Successful getprotobyname().\n", argv[0], argv[1], (void*)protoentptr); if (protoentptr->p_name) printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr->p_name=%s protoentptr->p_proto=%d\n", argv[0], argv[1], protoentptr->p_name, protoentptr->p_proto); if (protoentptr->p_aliases) { for (i=0;protoentptr->p_aliases[i]!=0;i++) { printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr->p_aliases[%d]=%s\n", argv[0], argv[1], i, protoentptr->p_aliases[i]); } } } else { switch (h_errno) { case NETDB_SUCCESS: printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobyname(), Reason: NETDB_SUCCESS=%d %d:%s\n", argv[0], argv[1], (void*)protoentptr, NETDB_SUCCESS, h_errno, hstrerror(h_errno)); break; case HOST_NOT_FOUND: printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobyname(), Reason: HOST_NOT_FOUND=%d %d:%s\n", argv[0], argv[1], (void*)protoentptr, HOST_NOT_FOUND, h_errno, hstrerror(h_errno)); break; case TRY_AGAIN: printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobyname(), Reason: TRY_AGAIN=%d %d:%s\n", argv[0], argv[1], (void*)protoentptr, TRY_AGAIN, h_errno, hstrerror(h_errno)); break; case NO_RECOVERY: printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobyname(), Reason: NO_RECOVERY=%d %d:%s\n", argv[0], argv[1], (void*)protoentptr, NO_RECOVERY, h_errno, hstrerror(h_errno)); break; case NO_DATA: printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobyname(), Reason: NO_DATA=%d %d:%s\n", argv[0], argv[1], (void*)protoentptr, NO_DATA, h_errno, hstrerror(h_errno)); break; /*#define NO_ADDRESS NO_DATA - duplicate case value */ /*case NO_ADDRESS: printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobyname(), Reason: NO_ADDRESS=%d %d:%s\n", argv[0], argv[1], (void*)protoentptr, NO_ADDRESS, h_errno, hstrerror(h_errno)); break;*/ case NETDB_INTERNAL: printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobyname(), Reason: NETDB_INTERNAL=%d %d:%s\n", argv[0], argv[1], (void*)protoentptr, NETDB_INTERNAL, h_errno, hstrerror(h_errno)); break; default: printf("%s: protoentptr=getprotobyname(argv[1]=%s): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobyname(), Reason: NETDB:UNKNOWN:ERROR %d:%s\n", argv[0], argv[1], (void*)protoentptr, h_errno, hstrerror(h_errno)); break; } } protoentptr=getprotobynumber(atoi(argv[2])); if (protoentptr!=NULL) { printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr=%p if (protoentptr!=NULL): Successful getprotobyname().\n", argv[0], argv[2], atoi(argv[2]), (void*)protoentptr); if (protoentptr->p_name) printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr->p_name=%s protoentptr->p_proto=%d\n", argv[0], argv[2], atoi(argv[2]), protoentptr->p_name, protoentptr->p_proto); if (protoentptr->p_aliases) { for (i=0;protoentptr->p_aliases[i]!=0;i++) { printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr->p_aliases[%d]=%s\n", argv[0], argv[2], atoi(argv[2]), i, protoentptr->p_aliases[i]); } } } else { switch (h_errno) { case NETDB_SUCCESS: printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobynumber(), Reason: NETDB_SUCCESS=%d %d:%s\n", argv[0], argv[2], atoi(argv[2]), (void*)protoentptr, NETDB_SUCCESS, h_errno, hstrerror(h_errno)); break; case HOST_NOT_FOUND: printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobynumber(), Reason: HOST_NOT_FOUND=%d %d:%s\n", argv[0], argv[2], atoi(argv[2]), (void*)protoentptr, HOST_NOT_FOUND, h_errno, hstrerror(h_errno)); break; case TRY_AGAIN: printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobynumber(), Reason: TRY_AGAIN=%d %d:%s\n", argv[0], argv[2], atoi(argv[2]), (void*)protoentptr, TRY_AGAIN, h_errno, hstrerror(h_errno)); break; case NO_RECOVERY: printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobynumber(), Reason: NO_RECOVERY=%d %d:%s\n", argv[0], argv[2], atoi(argv[2]), (void*)protoentptr, NO_RECOVERY, h_errno, hstrerror(h_errno)); break; case NO_DATA: printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobynumber(), Reason: NO_DATA=%d %d:%s\n", argv[0], argv[2], atoi(argv[2]), (void*)protoentptr, NO_DATA, h_errno, hstrerror(h_errno)); break; /*#define NO_ADDRESS NO_DATA - duplicate case value */ /*case NO_ADDRESS: printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobynumber(), Reason: NO_ADDRESS=%d %d:%s\n", argv[0], argv[2], atoi(argv[2]), (void*)protoentptr, NO_ADDRESS, h_errno, hstrerror(h_errno)); break;*/ case NETDB_INTERNAL: printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobynumber(), Reason: NETDB_INTERNAL=%d %d:%s\n", argv[0], argv[2], atoi(argv[2]), (void*)protoentptr, NETDB_INTERNAL, h_errno, hstrerror(h_errno)); break; default: printf("%s: protoentptr=getprotobynumber(atoi(argv[2]=%s)=%d): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotobynumber(), Reason: NETDB:UNKNOWN:ERROR %d:%s\n", argv[0], argv[2], atoi(argv[2]), (void*)protoentptr, h_errno, hstrerror(h_errno)); break; } } return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/getprotobynameprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/getprotobyname <protoname> <protonum> Examples: /home/local/code/ansiccode/network/getprotobyname icmp 1 /home/local/code/ansiccode/network/getprotobyname tcp 6 /home/local/code/ansiccode/network/getprotobyname udp 17
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/getprotobyname icmp 1 /home/local/code/ansiccode/network/getprotobyname tcp 6 /home/local/code/ansiccode/network/getprotobyname udp 17rezultat będzie zależny od podanych argumentów wywołania programu:
getprotobyname: protoentptr=getprotobyname(argv[1]=icmp): protoentptr=0x243ba4 if (protoentptr!=NULL): Successful getprotobyname(). getprotobyname: protoentptr=getprotobyname(argv[1]=icmp): protoentptr->p_name=icmp protoentptr->p_proto=1 getprotobyname: protoentptr=getprotobyname(argv[1]=icmp): protoentptr->p_aliases[0]=ICMP getprotobyname: protoentptr=getprotobynumber(atoi(argv[2]=1)=1): protoentptr=0x243b60 if (protoentptr!=NULL): Successful getprotobyname(). getprotobyname: protoentptr=getprotobynumber(atoi(argv[2]=1)=1): protoentptr->p_name=icmp protoentptr->p_proto=1 getprotobyname: protoentptr=getprotobynumber(atoi(argv[2]=1)=1): protoentptr->p_aliases[0]=ICMP getprotobyname: protoentptr=getprotobyname(argv[1]=tcp): protoentptr=0x243ba4 if (protoentptr!=NULL): Successful getprotobyname(). getprotobyname: protoentptr=getprotobyname(argv[1]=tcp): protoentptr->p_name=tcp protoentptr->p_proto=6 getprotobyname: protoentptr=getprotobyname(argv[1]=tcp): protoentptr->p_aliases[0]=TCP getprotobyname: protoentptr=getprotobynumber(atoi(argv[2]=6)=6): protoentptr=0x243b60 if (protoentptr!=NULL): Successful getprotobyname(). getprotobyname: protoentptr=getprotobynumber(atoi(argv[2]=6)=6): protoentptr->p_name=tcp protoentptr->p_proto=6 getprotobyname: protoentptr=getprotobynumber(atoi(argv[2]=6)=6): protoentptr->p_aliases[0]=TCP getprotobyname: protoentptr=getprotobyname(argv[1]=udp): protoentptr=0x25dba4 if (protoentptr!=NULL): Successful getprotobyname(). getprotobyname: protoentptr=getprotobyname(argv[1]=udp): protoentptr->p_name=udp protoentptr->p_proto=17 getprotobyname: protoentptr=getprotobyname(argv[1]=udp): protoentptr->p_aliases[0]=UDP getprotobyname: protoentptr=getprotobynumber(atoi(argv[2]=17)=17): protoentptr=0x25db60 if (protoentptr!=NULL): Successful getprotobyname(). getprotobyname: protoentptr=getprotobynumber(atoi(argv[2]=17)=17): protoentptr->p_name=udp protoentptr->p_proto=17 getprotobyname: protoentptr=getprotobynumber(atoi(argv[2]=17)=17): protoentptr->p_aliases[0]=UDP
#top getprotobynumber¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
getprotobynumber()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getprotobynumber()
jest następująca:/* Return entry from protocol data base which number is PROTO. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct protoent *getprotobynumber (int __proto);
Powiązane:
getprotobyname(), getprotobynumber(),
Opis:
#top getprotoent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
getprotoent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getprotoent()
jest następująca:/* Get next entry from protocol data base file. Open data base if necessary. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct protoent *getprotoent (void);
Powiązane:
endprotoent(), getprotoent(), setprotoent(),
Opis:
Funkcja getprotoent() zwraca wskaźnik do struktury struct protoent zawierającej informacje dotyczące protokołów przechowywanych w systemie. W przypadku gdy w kolejnych wywołaniach funkcji zwrócone zostały już wszystkie informacje dotyczące protokołów przechowywanych w systemie zwracany jest wskaźnik NULL.
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
struct protoent * -
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
struct protoent * -
Example:
zawartość pliku
getprotoent.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <unistd.h> /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */ /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */ /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */ #include <errno.h> /* for errno constant, error constants, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), gethostbyaddr(), gethostbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { struct protoent *protoentptr; int stayopen; int i; if (argc<1) { printf("Usage: %s\n", argv[0]); return 0; } stayopen=1; setprotoent(stayopen); while (1) { protoentptr=getprotoent(); if (protoentptr!=NULL) { printf("%s: protoentptr=getprotoent(): protoentptr=%p if (protoentptr!=NULL): Successful getprotoent().\n", argv[0], (void*)protoentptr); if (protoentptr->p_name) printf("%s: protoentptr=getprotoent(): protoentptr->p_name=%s protoentptr->p_proto=%d\n", argv[0], protoentptr->p_name, protoentptr->p_proto); if (protoentptr->p_aliases) { for (i=0;protoentptr->p_aliases[i]!=0;i++) { printf("%s: protoentptr=getprotoent(): protoentptr->p_aliases[%d]=%s\n", argv[0], i, protoentptr->p_aliases[i]); } } } else { printf("%s: protoentptr=getprotoent(): protoentptr=%p if (protoentptr!=NULL): else: Unable to getprotoent(), Reason: %d:%s\n", argv[0], (void*)protoentptr, h_errno, hstrerror(h_errno)); break; } } endprotoent(); return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/getprotoentprogram wyświetli stosowne informacje o sposobie działania:
getprotoent: protoentptr=getprotoent(): protoentptr=0x243b7c if (protoentptr!=NULL): Successful getprotoent(). getprotoent: protoentptr=getprotoent(): protoentptr->p_name=ip protoentptr->p_proto=0 getprotoent: protoentptr=getprotoent(): protoentptr->p_aliases[0]=IP [...] getprotoent: protoentptr=getprotoent(): protoentptr=0x243b7c if (protoentptr!=NULL): Successful getprotoent(). getprotoent: protoentptr=getprotoent(): protoentptr->p_name=icmp protoentptr->p_proto=1 getprotoent: protoentptr=getprotoent(): protoentptr->p_aliases[0]=ICMP getprotoent: protoentptr=getprotoent(): protoentptr=0x243b7c if (protoentptr!=NULL): Successful getprotoent(). getprotoent: protoentptr=getprotoent(): protoentptr->p_name=igmp protoentptr->p_proto=2 getprotoent: protoentptr=getprotoent(): protoentptr->p_aliases[0]=IGMP [...] getprotoent: protoentptr=getprotoent(): protoentptr=0x243b7c if (protoentptr!=NULL): Successful getprotoent(). getprotoent: protoentptr=getprotoent(): protoentptr->p_name=tcp protoentptr->p_proto=6 getprotoent: protoentptr=getprotoent(): protoentptr->p_aliases[0]=TCP [...] getprotoent: protoentptr=getprotoent(): protoentptr=0x243b7c if (protoentptr!=NULL): Successful getprotoent(). getprotoent: protoentptr=getprotoent(): protoentptr->p_name=udp protoentptr->p_proto=17 getprotoent: protoentptr=getprotoent(): protoentptr->p_aliases[0]=UDP [...]
#top getservbyname¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
getservbyname()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getservbyname()
jest następująca:/* Return entry from network data base for network with NAME and protocol PROTO. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct servent *getservbyname (__const char *__name, __const char *__proto);
Powiązane:
getservbyname(), getservbyport(),
Opis:
Funkcja getservbyname()
Argumenty:
const char *__name -
const char *__proto -
Zwracana wartość:
struct servent * -
Argumenty:
const char *__name -
const char *__proto -
Zwracana wartość:
struct servent * -
Example:
zawartość pliku
getservbyname.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, getservbyname(), getservbyport(), */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), getservbyport(), getservbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { struct servent *serventptr; int i; if (argc<4) { printf("Usage: %s <servicename> <serviceport> <service-protocol>\n", argv[0]); printf("Examples:\n"); printf(" %s ssh 22 tcp\n", argv[0]); printf(" %s domain 53 tcp\n", argv[0]); printf(" %s domain 53 udp\n", argv[0]); printf(" %s http 80 tcp\n", argv[0]); printf(" %s snmp 161 udp\n", argv[0]); return 0; } serventptr=getservbyname(argv[1], argv[3]); if (serventptr!=NULL) { printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): Successful getservbyname().\n", argv[0], argv[1], argv[3], (void*)serventptr); if (serventptr->s_name) printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr->s_name=%s ntohs(serventptr->s_port)=%d serventptr->s_proto=%s\n", argv[0], argv[1], argv[3], serventptr->s_name, ntohs(serventptr->s_port), serventptr->s_proto); if (serventptr->s_aliases) { for (i=0;serventptr->s_aliases[i]!=0;i++) { printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr->s_aliases[%d]=%s\n", argv[0], argv[1], argv[3], i, serventptr->s_aliases[i]); } } } else { switch (h_errno) { case NETDB_SUCCESS: printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyname(), Reason: NETDB_SUCCESS=%d %d:%s\n", argv[0], argv[1], argv[3], (void*)serventptr, NETDB_SUCCESS, h_errno, hstrerror(h_errno)); break; case HOST_NOT_FOUND: printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyname(), Reason: HOST_NOT_FOUND=%d %d:%s\n", argv[0], argv[1], argv[3], (void*)serventptr, HOST_NOT_FOUND, h_errno, hstrerror(h_errno)); break; case TRY_AGAIN: printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyname(), Reason: TRY_AGAIN=%d %d:%s\n", argv[0], argv[1], argv[3], (void*)serventptr, TRY_AGAIN, h_errno, hstrerror(h_errno)); break; case NO_RECOVERY: printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyname(), Reason: NO_RECOVERY=%d %d:%s\n", argv[0], argv[1], argv[3], (void*)serventptr, NO_RECOVERY, h_errno, hstrerror(h_errno)); break; case NO_DATA: printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyname(), Reason: NO_DATA=%d %d:%s\n", argv[0], argv[1], argv[3], (void*)serventptr, NO_DATA, h_errno, hstrerror(h_errno)); break; /*#define NO_ADDRESS NO_DATA - duplicate case value */ /*case NO_ADDRESS: printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyname(), Reason: NO_ADDRESS=%d %d:%s\n", argv[0], argv[1], argv[3], (void*)serventptr, NO_ADDRESS, h_errno, hstrerror(h_errno)); break;*/ case NETDB_INTERNAL: printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyname(), Reason: NETDB_INTERNAL=%d %d:%s\n", argv[0], argv[1], argv[3], (void*)serventptr, NETDB_INTERNAL, h_errno, hstrerror(h_errno)); break; default: printf("%s: serventptr=getservbyname(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyname(), Reason: NETDB:UNKNOWN:ERROR %d:%s\n", argv[0], argv[1], argv[3], (void*)serventptr, h_errno, hstrerror(h_errno)); break; } } serventptr=getservbyport(htons(atoi(argv[2])), argv[3]); if (serventptr!=NULL) { printf("%s: serventptr=getservbyport(argv[1]=%s, argv[3]=%s): serventptr=%p if (serventptr!=NULL): Successful getservbyname().\n", argv[0], argv[2], argv[3], (void*)serventptr); if (serventptr->s_name) printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr->s_name=%s ntohs(serventptr->s_port)=%d serventptr->s_proto=%s\n", argv[0], argv[2], argv[3], serventptr->s_name, ntohs(serventptr->s_port), serventptr->s_proto); if (serventptr->s_aliases) { for (i=0;serventptr->s_aliases[i]!=0;i++) { printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr->s_aliases[%d]=%s\n", argv[0], argv[2], argv[3], i, serventptr->s_aliases[i]); } } } else { switch (h_errno) { case NETDB_SUCCESS: printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyport(), Reason: NETDB_SUCCESS=%d %d:%s\n", argv[0], argv[2], argv[3], (void*)serventptr, NETDB_SUCCESS, h_errno, hstrerror(h_errno)); break; case HOST_NOT_FOUND: printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyport(), Reason: HOST_NOT_FOUND=%d %d:%s\n", argv[0], argv[2], argv[3], (void*)serventptr, HOST_NOT_FOUND, h_errno, hstrerror(h_errno)); break; case TRY_AGAIN: printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyport(), Reason: TRY_AGAIN=%d %d:%s\n", argv[0], argv[2], argv[3], (void*)serventptr, TRY_AGAIN, h_errno, hstrerror(h_errno)); break; case NO_RECOVERY: printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyport(), Reason: NO_RECOVERY=%d %d:%s\n", argv[0], argv[2], argv[3], (void*)serventptr, NO_RECOVERY, h_errno, hstrerror(h_errno)); break; case NO_DATA: printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyport(), Reason: NO_DATA=%d %d:%s\n", argv[0], argv[2], argv[3], (void*)serventptr, NO_DATA, h_errno, hstrerror(h_errno)); break; /*#define NO_ADDRESS NO_DATA - duplicate case value */ /*case NO_ADDRESS: printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyport(), Reason: NO_ADDRESS=%d %d:%s\n", argv[0], argv[2], argv[3], (void*)serventptr, NO_ADDRESS, h_errno, hstrerror(h_errno)); break;*/ case NETDB_INTERNAL: printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyport(), Reason: NETDB_INTERNAL=%d %d:%s\n", argv[0], argv[2], argv[3], (void*)serventptr, NETDB_INTERNAL, h_errno, hstrerror(h_errno)); break; default: printf("%s: serventptr=getservbyport(htons(atoi(argv[2]=%s)), argv[3]=%s): serventptr=%p if (serventptr!=NULL): else: Unable to getservbyport(), Reason: NETDB:UNKNOWN:ERROR %d:%s\n", argv[0], argv[2], argv[3], (void*)serventptr, h_errno, hstrerror(h_errno)); break; } } return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/getservbynameprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/getservbyname <servicename> <serviceport> <service-protocol> Examples: /home/local/code/ansiccode/network/getservbyname ssh 22 tcp /home/local/code/ansiccode/network/getservbyname domain 53 tcp /home/local/code/ansiccode/network/getservbyname domain 53 udp /home/local/code/ansiccode/network/getservbyname http 80 tcp /home/local/code/ansiccode/network/getservbyname snmp 161 udp
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/getservbyname ssh 22 tcp /home/local/code/ansiccode/network/getservbyname domain 53 tcp /home/local/code/ansiccode/network/getservbyname domain 53 udp /home/local/code/ansiccode/network/getservbyname http 80 tcp /home/local/code/ansiccode/network/getservbyname snmp 161 udprezultat będzie zależny od podanych argumentów wywołania programu:
getservbyname: serventptr=getservbyname(argv[1]=ssh, argv[3]=tcp): serventptr=0x243bc0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyname(argv[1]=ssh, argv[3]=tcp): serventptr->s_name=ssh ntohs(serventptr->s_port)=22 serventptr->s_proto=tcp getservbyname: serventptr=getservbyport(argv[1]=22, argv[3]=tcp): serventptr=0x243be0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyport(htons(atoi(argv[2]=22)), argv[3]=tcp): serventptr->s_name=ssh ntohs(serventptr->s_port)=22 serventptr->s_proto=tcp getservbyname: serventptr=getservbyname(argv[1]=domain, argv[3]=tcp): serventptr=0x243bc0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyname(argv[1]=domain, argv[3]=tcp): serventptr->s_name=domain ntohs(serventptr->s_port)=53 serventptr->s_proto=tcp getservbyname: serventptr=getservbyport(argv[1]=53, argv[3]=tcp): serventptr=0x243be0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyport(htons(atoi(argv[2]=53)), argv[3]=tcp): serventptr->s_name=domain ntohs(serventptr->s_port)=53 serventptr->s_proto=tcp getservbyname: serventptr=getservbyname(argv[1]=domain, argv[3]=udp): serventptr=0x243bc0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyname(argv[1]=domain, argv[3]=udp): serventptr->s_name=domain ntohs(serventptr->s_port)=53 serventptr->s_proto=udp getservbyname: serventptr=getservbyport(argv[1]=53, argv[3]=udp): serventptr=0x243be0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyport(htons(atoi(argv[2]=53)), argv[3]=udp): serventptr->s_name=domain ntohs(serventptr->s_port)=53 serventptr->s_proto=udp getservbyname: serventptr=getservbyname(argv[1]=http, argv[3]=tcp): serventptr=0x243bc0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyname(argv[1]=http, argv[3]=tcp): serventptr->s_name=http ntohs(serventptr->s_port)=80 serventptr->s_proto=tcp getservbyname: serventptr=getservbyname(argv[1]=http, argv[3]=tcp): serventptr->s_aliases[0]=www getservbyname: serventptr=getservbyname(argv[1]=http, argv[3]=tcp): serventptr->s_aliases[1]=www-http getservbyname: serventptr=getservbyport(argv[1]=80, argv[3]=tcp): serventptr=0x243be0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyport(htons(atoi(argv[2]=80)), argv[3]=tcp): serventptr->s_name=http ntohs(serventptr->s_port)=80 serventptr->s_proto=tcp getservbyname: serventptr=getservbyport(htons(atoi(argv[2]=80)), argv[3]=tcp): serventptr->s_aliases[0]=www getservbyname: serventptr=getservbyport(htons(atoi(argv[2]=80)), argv[3]=tcp): serventptr->s_aliases[1]=www-http getservbyname: serventptr=getservbyname(argv[1]=snmp, argv[3]=udp): serventptr=0x243bc0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyname(argv[1]=snmp, argv[3]=udp): serventptr->s_name=snmp ntohs(serventptr->s_port)=161 serventptr->s_proto=udp getservbyname: serventptr=getservbyport(argv[1]=161, argv[3]=udp): serventptr=0x243be0 if (serventptr!=NULL): Successful getservbyname(). getservbyname: serventptr=getservbyport(htons(atoi(argv[2]=161)), argv[3]=udp): serventptr->s_name=snmp ntohs(serventptr->s_port)=161 serventptr->s_proto=udp
#top getservbyport¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
getservbyport()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getservbyport()
jest następująca:/* Return entry from service data base which matches port PORT and protocol PROTO. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct servent *getservbyport (int __port, __const char *__proto);
Powiązane:
getservbyname(), getservbyport(),
Opis:
Funkcja getservbyport()
Argumenty:
int __port -
const char *__proto -
Zwracana wartość:
struct servent * -
Argumenty:
int __port -
const char *__proto -
Zwracana wartość:
struct servent * -
#top getservent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
getservent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
getservent()
jest następująca:/* Get next entry from service data base file. Open data base if necessary. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct servent *getservent (void);
Powiązane:
endservent(), getservent(), setservent(),
Opis:
Funkcja getservent() zwraca wskaźnik do struktury struct servent zawierającej informacje dotyczące usług przechowywanych w systemie. W przypadku gdy w kolejnych wywołaniach funkcji zwrócone zostały już wszystkie informacje dotyczące usług przechowywanych w systemie zwracany jest wskaźnik NULL.
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
struct servent * -
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
struct servent * -
Example:
zawartość pliku
getservent.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <unistd.h> /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */ /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(). getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */ /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */ #include <errno.h> /* for errno constant, error constants, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), gethostbyaddr(), gethostbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #endif int main(int argc, char **argv) { struct servent *serventptr; int stayopen; int i; if (argc<1) { printf("Usage: %s\n", argv[0]); return 0; } stayopen=1; setservent(stayopen); while (1) { serventptr=getservent(); if (serventptr!=NULL) { printf("%s: serventptr=getservent(): serventptr=%p if (serventptr!=NULL): Successful getservent().\n", argv[0], (void*)serventptr); if (serventptr->s_name) printf("%s: serventptr=getservent(): serventptr->s_name=%s serventptr->s_port=%d serventptr->s_proto=%s\n", argv[0], serventptr->s_name, serventptr->s_port, serventptr->s_proto); if (serventptr->s_aliases) { for (i=0;serventptr->s_aliases[i]!=0;i++) { printf("%s: serventptr=getservent(): serventptr->s_aliases[%d]=%s\n", argv[0], i, serventptr->s_aliases[i]); } } } else { printf("%s: serventptr=getservent(): serventptr=%p if (serventptr!=NULL): else: Unable to getservent(), Reason: %d:%s\n", argv[0], (void*)serventptr, h_errno, hstrerror(h_errno)); break; } } endservent(); return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/getserventprogram wyświetli stosowne informacje o sposobie działania:
[...] getservent: serventptr=getservent(): serventptr->s_name=echo serventptr->s_port=1792 ntohs(serventptr->s_port)=7 serventptr->s_proto=tcp getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). [...] getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=ssh serventptr->s_port=5632 ntohs(serventptr->s_port)=22 serventptr->s_proto=tcp getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=ssh serventptr->s_port=5632 ntohs(serventptr->s_port)=22 serventptr->s_proto=udp [...] getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=smtp serventptr->s_port=6400 ntohs(serventptr->s_port)=25 serventptr->s_proto=tcp getservent: serventptr=getservent(): serventptr->s_aliases[0]=mail getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=smtp serventptr->s_port=6400 ntohs(serventptr->s_port)=25 serventptr->s_proto=udp getservent: serventptr=getservent(): serventptr->s_aliases[0]=mail [...] getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=domain serventptr->s_port=13568 ntohs(serventptr->s_port)=53 serventptr->s_proto=tcp getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=domain serventptr->s_port=13568 ntohs(serventptr->s_port)=53 serventptr->s_proto=udp [...] getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=http serventptr->s_port=20480 ntohs(serventptr->s_port)=80 serventptr->s_proto=tcp getservent: serventptr=getservent(): serventptr->s_aliases[0]=www getservent: serventptr=getservent(): serventptr->s_aliases[1]=www-http getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=http serventptr->s_port=20480 ntohs(serventptr->s_port)=80 serventptr->s_proto=udp getservent: serventptr=getservent(): serventptr->s_aliases[0]=www getservent: serventptr=getservent(): serventptr->s_aliases[1]=www-http getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). [...] getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=ntp serventptr->s_port=31488 ntohs(serventptr->s_port)=123 serventptr->s_proto=tcp getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=ntp serventptr->s_port=31488 ntohs(serventptr->s_port)=123 serventptr->s_proto=udp [...] getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=snmp serventptr->s_port=41216 ntohs(serventptr->s_port)=161 serventptr->s_proto=tcp getservent: serventptr=getservent(): serventptr=0x243c00 if (serventptr!=NULL): Successful getservent(). getservent: serventptr=getservent(): serventptr->s_name=snmp serventptr->s_port=41216 ntohs(serventptr->s_port)=161 serventptr->s_proto=udp [...]
#top hstrerror¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
hstrerror()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
hstrerror()
jest następująca:/* Return string associated with error ERR_NUM. */ extern __const char *hstrerror (int __err_num) __THROW;
Powiązane:
h_errno, gethostbyaddr(), gethostbyname(), gethostbyname2(), hstrerror(),
Opis:
Funkcja hstrerror() zwraca łańcuch znaków (wskaźnik do łańcucha znaków) zawierający tekstowy opis kodu błędu przekazanego w argumencie __errnum.
Argumenty:
int __err_num - kod błędu dla którego zostanie zwrócony łańcuch znaków zawierający tekstowy opis błędu.
Zwracana wartość:
const char * - łańcuch znaków zawierający tekstowy opis błędu dla kodu przekazanego w argumencie __errnum.
Argumenty:
int __err_num - kod błędu dla którego zostanie zwrócony łańcuch znaków zawierający tekstowy opis błędu.
Zwracana wartość:
const char * - łańcuch znaków zawierający tekstowy opis błędu dla kodu przekazanego w argumencie __errnum.
#top htonl¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us
Deklaracja funkcji
htonl()
znajduje się w pliku nagłówkowym netinet/in.h
.Deklaracja funkcji
htonl()
jest następująca:/* Functions to convert between host and network byte order. Please note that these functions normally take `unsigned long int' or `unsigned short int' values as arguments and also return them. But this was a short-sighted decision since on different systems the types may have different representations but the values are always the same. */ extern uint32_t htonl (uint32_t __hostlong) __THROW __attribute__ ((__const__));
Powiązane:
htonl(), htons(), inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton(), ntohl(), ntohs(),
Opis:
Funkcja htonl() (Host TO Network Long)
Argumenty:
uint32_t __hostlong -
Zwracana wartość:
uint32_t -
Argumenty:
uint32_t __hostlong -
Zwracana wartość:
uint32_t -
#top htons¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us
Deklaracja funkcji
htons()
znajduje się w pliku nagłówkowym netinet/in.h
.Deklaracja funkcji
htons()
jest następująca:/* Functions to convert between host and network byte order. Please note that these functions normally take `unsigned long int' or `unsigned short int' values as arguments and also return them. But this was a short-sighted decision since on different systems the types may have different representations but the values are always the same. */ extern uint16_t htons (uint16_t __hostshort) __THROW __attribute__ ((__const__));
Powiązane:
htonl(), htons(), inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton(), ntohl(), ntohs(),
Opis:
Funkcja htons() (Host TO Network Short)
Argumenty:
uint16_t __hostshort -
Zwracana wartość:
uint16_t -
Argumenty:
uint16_t __hostshort -
Zwracana wartość:
uint16_t -
#top inet_addr¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us
Deklaracja funkcji
inet_addr()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_addr()
jest następująca:/* Convert Internet host address from numbers-and-dots notation in CP into binary data in network byte order. */ extern in_addr_t inet_addr (__const char *__cp) __THROW;
Powiązane:
htonl(), htons(), inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton(), ntohl(), ntohs(),
Opis:
Example:
zawartość pliku
inet_addr.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #endif int main(int argc, char **argv) { struct in_addr sin_addr; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #else char chip4addr[INET_ADDRSTRLEN]; char *spipaddr; #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #else struct in6_addr sin6_addr; char chip6addr[INET6_ADDRSTRLEN]; #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #else int result; #endif struct sockaddr_in sockipv4addr; in_addr_t inetipv4addr; int iaport; if (argc<3) { printf("Usage: %s <ipv4addr> <ipv6addr> <ipport>\n", argv[0]); printf("Examples:\n"); printf(" %s 10.2.3.4 2001:db8:8714:3a90::12 22\n", argv[0]); printf(" %s 172.16.3.4 2001:db8:8714:3a90::12 53\n", argv[0]); printf(" %s 192.168.3.4 2001:db8:8714:3a90::12 80\n", argv[0]); printf(" %s 192.0.2.33 2001:db8:8714:3a90::12 443\n", argv[0]); return 0; } #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_aton() is not available on this OS platform !!! */ printf("%s: inet_aton() is not available on this OS platform !!!\n", argv[0]); #else result=inet_aton(argv[1], &sin_addr); /* store IP in antelope */ printf("%s: result=inet_aton(argv[1]=%s, &sin_addr=%08X): result=%d ntohl(sin_addr)=%08X(%d.%d.%d.%d)\n", argv[0], argv[1], sin_addr.s_addr, result, ntohl(sin_addr.s_addr), (unsigned int)ntohl(sin_addr.s_addr)>>24&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>16&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>8&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>0&0xFF); #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_ntoa() is not available on this OS platform !!! */ printf("%s: inet_ntoa() is not available on this OS platform !!!\n", argv[0]); #else spipaddr=inet_ntoa(sin_addr); /* return the IP */ printf("%s: spipaddr=inet_ntoa(sin_addr=%08X): ntohl(sin_addr)=%08X(%d.%d.%d.%d) spipaddr=%s \n", argv[0], sin_addr.s_addr, (unsigned int)ntohl(sin_addr.s_addr), (unsigned int)ntohl(sin_addr.s_addr)>>24&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>16&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>8&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>0&0xFF, spipaddr); /* prints "10.2.3.4" */ #endif /* and this call is the same as the inet_aton() call, above: */ sin_addr.s_addr=inet_addr(argv[1]); printf("%s: sin_addr.s_addr=inet_addr(argv[1]=%s): sin_addr.s_addr=%08X ntohl(sin_addr.s_addr)=%08X(%d.%d.%d.%d)\n", argv[0], argv[1], sin_addr.s_addr, (unsigned int)ntohl(sin_addr.s_addr), (unsigned int)ntohl(sin_addr.s_addr)>>24&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>16&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>8&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>0&0xFF); iaport=atoi(argv[3]); printf("%s: iaport=atoi(argv[3]=%s): iaport=%d\n", argv[0], argv[3], iaport); inetipv4addr=htonl(sin_addr.s_addr); printf("%s: inetipv4addr=htonl(sin_addr.s_addr=%08X): inetipv4addr=%08X(%d.%d.%d.%d)\n", argv[0], sin_addr.s_addr, inetipv4addr, inetipv4addr>>24&0xFF, inetipv4addr>>16&0xFF, inetipv4addr>>8&0xFF, inetipv4addr>>0&0xFF); memset(&sockipv4addr, 0x00, sizeof(struct sockaddr_in)); sockipv4addr.sin_family=AF_INET; sockipv4addr.sin_addr.s_addr=htonl(inetipv4addr); sockipv4addr.sin_port = htons(iaport); printf("%s: sockipv4addr.sin_family=%d sockipv4addr.sin_addr.s_addr=%08X sockipv4addr.sin_port=%d\n", argv[0], sockipv4addr.sin_family, sockipv4addr.sin_addr.s_addr, sockipv4addr.sin_port); printf("%s: sockipv4addr.sin_family=%d ntohl(sockipv4addr.sin_addr.s_addr)=%08X(%d.%d.%d.%d) ntohs(sockipv4addr.sin_port)=%d\n", argv[0], sockipv4addr.sin_family, ntohl(sockipv4addr.sin_addr.s_addr), ntohl(sockipv4addr.sin_addr.s_addr)>>24&0xFF, ntohl(sockipv4addr.sin_addr.s_addr)>>16&0xFF, ntohl(sockipv4addr.sin_addr.s_addr)>>8&0xFF, ntohl(sockipv4addr.sin_addr.s_addr)>>0&0xFF, ntohs(sockipv4addr.sin_port)); /* store this IP address in sa: */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_pton() is not available on this OS platform !!! */ printf("%s: inet_netof() is not available on this OS platform !!!\n", argv[0]); #else result=inet_pton(AF_INET, argv[1], &sin_addr); printf("%s: result=inet_pton(AF_INET=%d, argv[1]=%s, &sin_addr=%08X): sin_addr=%08X(%d.%d.%d.%d) result=%d\n", argv[0], AF_INET, argv[1], sin_addr.s_addr, ntohl(sin_addr.s_addr), (unsigned int)ntohl(sin_addr.s_addr)>>24&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>16&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>8&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>0&0xFF, result); #endif /* now get it back and print it */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_ntop() is not available on this OS platform !!! */ printf("%s: inet_ntop() is not available on this OS platform !!!\n", argv[0]); #else spipaddr=(char*)inet_ntop(AF_INET, &sin_addr, chip4addr, INET_ADDRSTRLEN); printf("%s: spipaddr=inet_ntop(AF_INET=%d, &sin_addr=%08X, chip4addr=%s, INET_ADDRSTRLEN=%d): sin_addr=%08X(%d.%d.%d.%d) spipaddr=%s\n", argv[0], AF_INET, sin_addr.s_addr, chip4addr, INET_ADDRSTRLEN, ntohl(sin_addr.s_addr), (unsigned int)ntohl(sin_addr.s_addr)>>24&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>16&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>8&0xFF, (unsigned int)ntohl(sin_addr.s_addr)>>0&0xFF, spipaddr); /* prints "192.0.2.33" */ #endif /* store this IP address in sa: */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_pton() is not available on this OS platform !!! */ printf("%s: inet_pton() is not available on this OS platform !!!\n", argv[0]); #else result=inet_pton(AF_INET6, argv[2], &sin6_addr); printf("%s: result=inet_pton(AF_INET6=%d, argv[2]=%s, &sin6_addr=%08X.%08X.%08X.%08X): result=%d\n", argv[0], AF_INET6, argv[2], sin6_addr.s6_addr32[0], sin6_addr.s6_addr32[1], sin6_addr.s6_addr32[2], sin6_addr.s6_addr32[3], result); #endif /* now get it back and print it */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_ntop() is not available on this OS platform !!! */ printf("%s: inet_ntop() is not available on this OS platform !!!\n", argv[0]); #else spipaddr=(char*)inet_ntop(AF_INET6, &sin6_addr, chip6addr, INET6_ADDRSTRLEN); printf("%s: spipaddr=inet_ntop(AF_INET6=%d, &sin6_addr=%08X:%08X:%08X:%08X, chip6addr=%s, INET6_ADDRSTRLEN=%d): spipaddr=%s\n", argv[0], AF_INET6, sin6_addr.s6_addr32[0], sin6_addr.s6_addr32[1], sin6_addr.s6_addr32[2], sin6_addr.s6_addr32[3], chip6addr, INET6_ADDRSTRLEN, spipaddr); /* prints "2001:db8:8714:3a90::12" */ #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/inet_addrprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/inet_addr <ipv4addr> <ipv6addr> <ipport> Examples: /home/local/code/ansiccode/network/inet_addr 10.2.3.4 2001:db8:8714:3a90::12 22 /home/local/code/ansiccode/network/inet_addr 172.16.3.4 2001:db8:8714:3a90::12 53 /home/local/code/ansiccode/network/inet_addr 192.168.3.4 2001:db8:8714:3a90::12 80 /home/local/code/ansiccode/network/inet_addr 192.0.2.33 2001:db8:8714:3a90::12 443
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/inet_addr 10.2.3.4 2001:db8:8714:3a90::12 22rezultat będzie zależny od podanych argumentów wywołania programu:
inet_addr: result=inet_aton(argv[1]=10.2.3.4, &sin_addr=0403020A): result=1 ntohl(sin_addr)=0A020304(10.2.3.4) inet_addr: spipaddr=inet_ntoa(sin_addr=0403020A): ntohl(sin_addr)=0A020304(10.2.3.4) spipaddr=10.2.3.4 inet_addr: sin_addr.s_addr=inet_addr(argv[1]=10.2.3.4): sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304(10.2.3.4) inet_addr: iaport=atoi(argv[3]=22): iaport=22 inet_addr: inetipv4addr=htonl(sin_addr.s_addr=0403020A): inetipv4addr=0A020304(10.2.3.4) inet_addr: sockipv4addr.sin_family=2 sockipv4addr.sin_addr.s_addr=0403020A sockipv4addr.sin_port=5632 inet_addr: sockipv4addr.sin_family=2 ntohl(sockipv4addr.sin_addr.s_addr)=0A020304(10.2.3.4) ntohs(sockipv4addr.sin_port)=22 inet_addr: result=inet_pton(AF_INET=2, argv[1]=10.2.3.4, &sin_addr=0403020A): sin_addr=0A020304(10.2.3.4) result=1 inet_addr: spipaddr=inet_ntop(AF_INET=2, &sin_addr=0403020A, chip4addr=10.2.3.4, INET_ADDRSTRLEN=16): sin_addr=0A020304(10.2.3.4) spipaddr=10.2.3.4 inet_addr: result=inet_pton(AF_INET6=10, argv[2]=2001:db8:8714:3a90::12, &sin6_addr=B80D0120.903A1487.00000000.12000000): result=1 inet_addr: spipaddr=inet_ntop(AF_INET6=10, &sin6_addr=B80D0120:903A1487:00000000:12000000, chip6addr=2001:db8:8714:3a90::12, INET6_ADDRSTRLEN=46): spipaddr=2001:db8:8714:3a90::12
#top inet_aton¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us | gnu.org
Deklaracja funkcji
inet_aton()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_aton()
jest następująca:/* Convert Internet host address from numbers-and-dots notation in CP into binary data and store the result in the structure INP. */ extern int inet_aton (__const char *__cp, struct in_addr *__inp) __THROW;
Powiązane:
htonl(), htons(), inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton(), ntohl(), ntohs(),
Opis:
#top inet_lnaof¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
inet_lnaof()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_lnaof()
jest następująca:/* Return the local host address part of the Internet address in IN. */ extern in_addr_t inet_lnaof (struct in_addr __in) __THROW;
Powiązane:
Opis:
Example:
zawartość pliku
inet_lnaof.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdint.h> /* for INT(8|16|32|64)_MIN, INT(8|16|32|64)_MAX, UINT(8|16|32|64)_MAX, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) typedef uint32_t in_addr_t; #endif int main(int argc, char **argv) { struct in_addr sin_addr; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #else in_addr_t inetaddr; #endif if (argc<2) { printf("Usage: %s <ip4addr>\n", argv[0]); printf("Examples:\n"); printf(" %s 10.2.3.4\n", argv[0]); printf(" %s 172.16.3.4\n", argv[0]); printf(" %s 192.2.3.4\n", argv[0]); printf(" %s 178.2.3.4\n", argv[0]); printf(" %s 194.2.3.4\n", argv[0]); return 0; } sin_addr.s_addr = inet_addr(argv[1]); printf("%s: sin_addr.s_addr = inet_addr(argv[1]=%s): sin_addr.s_addr=%08X\n", argv[0], argv[1], (unsigned int)sin_addr.s_addr); #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_lnaof() is not available on this OS platform !!! */ printf("%s: inet_lnaof() is not available on this OS platform !!!\n", argv[0]); #else inetaddr=inet_lnaof(sin_addr); printf("%s: inetaddr=inet_lnaof(sin_addr=%08X): inetaddr=%08X (%d) (%d.%d.%d.%d)\n", argv[0], sin_addr.s_addr, (unsigned int)inetaddr, (unsigned int)inetaddr, (unsigned int)inetaddr>>24&0xFF, (unsigned int)inetaddr>>16&0xF, (unsigned int)inetaddr>>8&0xFF, (unsigned int)inetaddr>>0&0xFF ); #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/inet_lnaofprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/inet_lnaof <ip4addr> Examples: /home/local/code/ansiccode/network/inet_lnaof 10.2.3.4 /home/local/code/ansiccode/network/inet_lnaof 172.16.3.4 /home/local/code/ansiccode/network/inet_lnaof 192.2.3.4 /home/local/code/ansiccode/network/inet_lnaof 178.2.3.4 /home/local/code/ansiccode/network/inet_lnaof 194.2.3.4
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/inet_lnaof 10.2.3.4 /home/local/code/ansiccode/network/inet_lnaof 172.16.3.4 /home/local/code/ansiccode/network/inet_lnaof 192.2.3.4 /home/local/code/ansiccode/network/inet_lnaof 178.2.3.4 /home/local/code/ansiccode/network/inet_lnaof 194.2.3.4rezultat będzie zależny od podanych argumentów wywołania programu:
inet_lnaof: sin_addr.s_addr = inet_addr(argv[1]=10.2.3.4): sin_addr.s_addr=0403020A inet_lnaof: inetaddr=inet_lnaof(sin_addr=0403020A): inetaddr=00020304 (131844) (0.2.3.4) inet_lnaof: sin_addr.s_addr = inet_addr(argv[1]=172.16.3.4): sin_addr.s_addr=040310AC inet_lnaof: inetaddr=inet_lnaof(sin_addr=040310AC): inetaddr=00000304 (772) (0.0.3.4) inet_lnaof: sin_addr.s_addr = inet_addr(argv[1]=192.2.3.4): sin_addr.s_addr=040302C0 inet_lnaof: inetaddr=inet_lnaof(sin_addr=040302C0): inetaddr=00000004 (4) (0.0.0.4) inet_lnaof: sin_addr.s_addr = inet_addr(argv[1]=178.2.3.4): sin_addr.s_addr=040302B2 inet_lnaof: inetaddr=inet_lnaof(sin_addr=040302B2): inetaddr=00000304 (772) (0.0.3.4) inet_lnaof: sin_addr.s_addr = inet_addr(argv[1]=194.2.3.4): sin_addr.s_addr=040302C2 inet_lnaof: inetaddr=inet_lnaof(sin_addr=040302C2): inetaddr=00000004 (4) (0.0.0.4)
#top inet_makeaddr¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
inet_makeaddr()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_makeaddr()
jest następująca:/* Make Internet host address in network byte order by combining the network number NET with the local address HOST. */ extern struct in_addr inet_makeaddr (in_addr_t __net, in_addr_t __host) __THROW;
Powiązane:
Opis:
Funkcja inet_makeaddr()
Argumenty:
in_addr_t __net -
in_addr_t __host -
Zwracana wartość:
struct in_addr -
Argumenty:
in_addr_t __net -
in_addr_t __host -
Zwracana wartość:
struct in_addr -
Example:
zawartość pliku
inet_makeaddr.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */ #include <stdint.h> /* for INT(8|16|32|64)_MIN, INT(8|16|32|64)_MAX, UINT(8|16|32|64)_MAX, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) typedef uint32_t in_addr_t; #endif int main(int argc, char **argv) { struct in_addr sin_addr; in_addr_t inethost; in_addr_t inetaddr; if (argc<3) { printf("Usage: %s <inethost> <inethost>\n", argv[0]); printf("Examples:\n"); printf(" %s 10 131844\n", argv[0]); printf(" %s 44048 772\n", argv[0]); printf(" %s 49154 772\n", argv[0]); printf(" %s 45570 772\n", argv[0]); printf(" %s 49666 772\n", argv[0]); return 0; } inetaddr=atoi(argv[1]); inethost=atoi(argv[2]); sin_addr.s_addr=0x00; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_makeaddr() is not available on this OS platform !!! */ printf("%s: inet_makeaddr() is not available on this OS platform !!!\n", argv[0]); #else sin_addr=inet_makeaddr(inetaddr, inethost); printf("%s sockip4addr=inet_makeaddr(inetaddr=%08X(%d), inethost=%08X(%d)): sin_addr.s_addr=%08X ntohl(sin_addr.s_addr)=%08X (%d.%d.%d.%d)\n", argv[0], inetaddr, inetaddr, inethost, inethost, sin_addr.s_addr, ntohl(sin_addr.s_addr), ntohl(sin_addr.s_addr)>>24&0xFF, ntohl(sin_addr.s_addr)>>16&0xFF, ntohl(sin_addr.s_addr)>>8&0xF, ntohl(sin_addr.s_addr)>>0&0xFF); #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/inet_makeaddrprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/inet_makeaddr <inethost> <inetaddr> Examples: /home/local/code/ansiccode/network/inet_makeaddr 131844 10 /home/local/code/ansiccode/network/inet_makeaddr 772 44048 /home/local/code/ansiccode/network/inet_makeaddr 772 49154 /home/local/code/ansiccode/network/inet_makeaddr 772 45570 /home/local/code/ansiccode/network/inet_makeaddr 772 49666
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/inet_makeaddr 10 131844 /home/local/code/ansiccode/network/inet_makeaddr 44048 772 /home/local/code/ansiccode/network/inet_makeaddr 49154 772 /home/local/code/ansiccode/network/inet_makeaddr 45570 772 /home/local/code/ansiccode/network/inet_makeaddr 49666 772rezultat będzie zależny od podanych argumentów wywołania programu:
inet_makeaddr: sockip4addr=inet_makeaddr(inetaddr=0000000A(10), inethost=00020304(131844)): sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4) inet_makeaddr: sockip4addr=inet_makeaddr(inetaddr=0000AC10(44048), inethost=00000304(772)): sin_addr.s_addr=040310AC ntohl(sin_addr.s_addr)=AC100304 (172.16.3.4) inet_makeaddr: sockip4addr=inet_makeaddr(inetaddr=0000C002(49154), inethost=00000304(772)): sin_addr.s_addr=040302C0 ntohl(sin_addr.s_addr)=C0020304 (192.2.3.4) inet_makeaddr: sockip4addr=inet_makeaddr(inetaddr=0000B202(45570), inethost=00000304(772)): sin_addr.s_addr=040302B2 ntohl(sin_addr.s_addr)=B2020304 (178.2.3.4) inet_makeaddr: sockip4addr=inet_makeaddr(inetaddr=0000C202(49666), inethost=00000304(772)): sin_addr.s_addr=040302C2 ntohl(sin_addr.s_addr)=C2020304 (194.2.3.4)
#top inet_net_ntop¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
inet_net_ntop()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_net_ntop()
jest następująca:/* Convert network number for interface type AF in buffer starting at CP to presentation format. The result will specifiy BITS bits of the number. */ extern char *inet_net_ntop (int __af, __const void *__cp, int __bits, char *__buf, size_t __len) __THROW;
Powiązane:
inet_net_ntop(), inet_net_pton(),
Opis:
Funkcja inet_net_ntop()
Argumenty:
int __af -
const void *__cp -
int __bits -
char *__buf -
size_t __len -
Zwracana wartość:
char * -
Argumenty:
int __af -
const void *__cp -
int __bits -
char *__buf -
size_t __len -
Zwracana wartość:
char * -
Example:
zawartość pliku
inet_net_ntop.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <errno.h> /* for errno constant, error constants, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <sys/socket.h> /* for bits/socket.h, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_PACKET, AF_UNIX, PF_UNIX, AF_FILE, PF_FILE, AF_INET, PF_INET, MSG_OOB, MSG_PEEK, MSG_DONTWAIT, struct msghdr, struct sockaddr, struct osockaddr, */ /* for socket(), bind(), getsockname(), connect(), getpeername(), send(), recv(), sendto(), recvfrom(), sendmsg(), recvmsg(), getsockopt(), setsockopt(), listen(), accept(), shutdown(), sockatmark(), */ #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #endif int main(int argc, char **argv) { char *self; struct in_addr sin_addr; int bits; char charbuff[1024]; char *result; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<3) { printf("Usage: %s <inetaddr> <bits>\n", argv[0]); printf("Examples:\n"); printf(" %s 10.2.3.4 28\n", argv[0]); printf(" %s 10.2.3.4 24\n", argv[0]); printf(" %s 10.2.3.4 20\n", argv[0]); printf(" %s 10.2.3.4 16\n", argv[0]); printf(" %s 10.2.3.4 12\n", argv[0]); printf(" %s 10.2.3.4 8\n", argv[0]); return 0; } memset(charbuff, 0x00, sizeof(charbuff)); sin_addr.s_addr=inet_addr(argv[1]); bits=atoi(argv[2]); result=NULL; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_net_ntop() is not available on this OS platform !!! */ printf("%s: inet_net_ntop() is not available on this OS platform !!!\n", self); #else printf("%s: result=inet_net_ntop(AF_INET=%d, sin_addr.s_addr=%08X ntohl(sin_addr.s_addr)=%08X (%d.%d.%d.%d), bits=%d, charbuff=%s, buffsize=%u):\n", self, AF_INET, sin_addr.s_addr, ntohl(sin_addr.s_addr), ntohl(sin_addr.s_addr)>>24&0xFF, ntohl(sin_addr.s_addr)>>16&0xFF, ntohl(sin_addr.s_addr)>>8&0xFF, ntohl(sin_addr.s_addr)>>0&0xFF, bits, charbuff, (unsigned int)sizeof(charbuff)); result=inet_net_ntop(AF_INET, &sin_addr.s_addr, bits, charbuff, sizeof(charbuff)); if (result!=NULL) printf("%s: result=inet_net_ntop(AF_INET=%d, sin_addr.s_addr=%08X ntohl(sin_addr.s_addr)=%08X (%d.%d.%d.%d), bits=%d, charbuff=%s, buffsize=%u): result=%s if (result!=NULL): Successful inet_net_ntop().\n", self, AF_INET, sin_addr.s_addr, ntohl(sin_addr.s_addr), ntohl(sin_addr.s_addr)>>24&0xFF, ntohl(sin_addr.s_addr)>>16&0xFF, ntohl(sin_addr.s_addr)>>8&0xFF, ntohl(sin_addr.s_addr)>>0&0xFF, bits, charbuff, (unsigned int)sizeof(charbuff), result); else printf("%s: result=inet_net_ntop(AF_INET=%d, sin_addr.s_addr=%08X ntohl(sin_addr.s_addr)=%08X (%d.%d.%d.%d), bits=%d, charbuff=%s, buffsize=%u): result=%s if (result!=NULL): else: Unable to inet_net_ntop(), Reason: %d:%s\n", self, AF_INET, sin_addr.s_addr, ntohl(sin_addr.s_addr), ntohl(sin_addr.s_addr)>>24&0xFF, ntohl(sin_addr.s_addr)>>16&0xFF, ntohl(sin_addr.s_addr)>>8&0xFF, ntohl(sin_addr.s_addr)>>0&0xFF, bits, charbuff, (unsigned int)sizeof(charbuff), result, errno, strerror(errno)); #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/inet_net_ntopprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/inet_net_ntop <inetaddr> <bits> Examples: /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 28 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 24 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 20 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 16 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 12 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 8
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 28 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 24 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 20 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 16 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 12 /home/local/code/ansiccode/network/inet_net_ntop 10.2.3.4 8 /home/local/code/ansiccode/network/inet_net_ntop a.b.c.d erezultat będzie zależny od podanych argumentów wywołania programu:
inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=28, charbuff=, buffsize=1024): inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=28, charbuff=10.2.3.0/28, buffsize=1024): result=10.2.3.0/28 if (result!=NULL): Successful inet_net_ntop(). inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=24, charbuff=, buffsize=1024): inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=24, charbuff=10.2.3/24, buffsize=1024): result=10.2.3/24 if (result!=NULL): Successful inet_net_ntop(). inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=20, charbuff=, buffsize=1024): inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=20, charbuff=10.2.0/20, buffsize=1024): result=10.2.0/20 if (result!=NULL): Successful inet_net_ntop(). inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=16, charbuff=, buffsize=1024): inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=16, charbuff=10.2/16, buffsize=1024): result=10.2/16 if (result!=NULL): Successful inet_net_ntop(). inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=12, charbuff=, buffsize=1024): inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=12, charbuff=10.0/12, buffsize=1024): result=10.0/12 if (result!=NULL): Successful inet_net_ntop(). inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=8, charbuff=, buffsize=1024): inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4), bits=8, charbuff=10/8, buffsize=1024): result=10/8 if (result!=NULL): Successful inet_net_ntop(). inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=FFFFFFFF ntohl(sin_addr.s_addr)=FFFFFFFF (255.255.255.255), bits=0, charbuff=, buffsize=1024): inet_net_ntop: result=inet_net_ntop(AF_INET=2, sin_addr.s_addr=FFFFFFFF ntohl(sin_addr.s_addr)=FFFFFFFF (255.255.255.255), bits=0, charbuff=0/0, buffsize=1024): result=0/0 if (result!=NULL): Successful inet_net_ntop().
#top inet_net_pton¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
inet_net_pton()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_net_pton()
jest następująca:/* Convert network number for interface type AF from presentation in buffer starting at CP to network format and store result int buffer starting at BUF of size LEN. */ extern int inet_net_pton (int __af, __const char *__cp, void *__buf, size_t __len) __THROW;
Powiązane:
inet_net_ntop(), inet_net_pton(),
Opis:
Funkcja inet_net_pton()
Argumenty:
int __af -
const char *__cp -
void *__buf -
size_t __len -
Zwracana wartość:
int -
Argumenty:
int __af -
const char *__cp -
void *__buf -
size_t __len -
Zwracana wartość:
int -
#top inet_neta¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
inet_neta()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_neta()
jest następująca:/* Format a network number NET into presentation format and place result in buffer starting at BUF with length of LEN bytes. */ extern char *inet_neta (in_addr_t __net, char *__buf, size_t __len) __THROW;
Powiązane:
Opis:
Funkcja inet_neta()
Argumenty:
in_addr_t __net -
char *__buf -
size_t __len -
Zwracana wartość:
char * -
Argumenty:
in_addr_t __net -
char *__buf -
size_t __len -
Zwracana wartość:
char * -
Example:
zawartość pliku
inet_neta.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkdtemp(), system(), realpath(), abs(), llabs(), getloadavg() */ #include <stdint.h> /* for INT(8|16|32|64)_MIN, INT(8|16|32|64)_MAX, UINT(8|16|32|64)_MAX, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) typedef uint32_t in_addr_t; #endif int main(int argc, char **argv) { char *self; in_addr_t inetaddr; char buffaddr[1024]; char *buffptrs; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <network>\n", argv[0]); printf("Examples:\n"); printf(" %s 10\n", argv[0]); printf(" %s 131844\n", argv[0]); printf(" %s 44048\n", argv[0]); printf(" %s 49154\n", argv[0]); printf(" %s 45570\n", argv[0]); printf(" %s 49666\n", argv[0]); printf(" %s 772\n", argv[0]); return 0; } inetaddr=atoi(argv[1]); printf("%s: inetaddr=atoi(argv[1]=%s): inetaddr=%u\n", self, argv[1], inetaddr); memset(buffaddr, 0x00, sizeof(buffaddr)); buffptrs=NULL; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_neta() is not available on this OS platform !!! */ printf("%s: inet_neta() is not available on this OS platform !!!\n", self); #else buffptrs=inet_neta(inetaddr, buffaddr, sizeof(buffaddr)); printf("%s: buffptrs=inet_neta(inetaddr=%u, buffaddr=%s, sizeof(buffaddr)=%u): buffptrs=%s\n", self, inetaddr, buffaddr, sizeof(buffaddr), buffptrs); #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/inet_netaprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/inet_neta <network> Examples: /home/local/code/ansiccode/network/inet_neta 10 /home/local/code/ansiccode/network/inet_neta 131844 /home/local/code/ansiccode/network/inet_neta 44048 /home/local/code/ansiccode/network/inet_neta 49154 /home/local/code/ansiccode/network/inet_neta 45570 /home/local/code/ansiccode/network/inet_neta 49666 /home/local/code/ansiccode/network/inet_neta 772
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/inet_neta 10 /home/local/code/ansiccode/network/inet_neta 131844 /home/local/code/ansiccode/network/inet_neta 44048 /home/local/code/ansiccode/network/inet_neta 49154 /home/local/code/ansiccode/network/inet_neta 45570 /home/local/code/ansiccode/network/inet_neta 49666 /home/local/code/ansiccode/network/inet_neta 772rezultat będzie zależny od podanych argumentów wywołania programu:
inet_neta: inetaddr=atoi(argv[1]=10): inetaddr=10 inet_neta: buffptrs=inet_neta(inetaddr=10, buffaddr=10, sizeof(buffaddr)=1024): buffptrs=10 inet_neta: inetaddr=atoi(argv[1]=131844): inetaddr=131844 inet_neta: buffptrs=inet_neta(inetaddr=131844, buffaddr=2.3.4, sizeof(buffaddr)=1024): buffptrs=2.3.4 inet_neta: inetaddr=atoi(argv[1]=44048): inetaddr=44048 inet_neta: buffptrs=inet_neta(inetaddr=44048, buffaddr=172.16, sizeof(buffaddr)=1024): buffptrs=172.16 inet_neta: inetaddr=atoi(argv[1]=49154): inetaddr=49154 inet_neta: buffptrs=inet_neta(inetaddr=49154, buffaddr=192.2, sizeof(buffaddr)=1024): buffptrs=192.2 inet_neta: inetaddr=atoi(argv[1]=45570): inetaddr=45570 inet_neta: buffptrs=inet_neta(inetaddr=45570, buffaddr=178.2, sizeof(buffaddr)=1024): buffptrs=178.2 inet_neta: inetaddr=atoi(argv[1]=49666): inetaddr=49666 inet_neta: buffptrs=inet_neta(inetaddr=49666, buffaddr=194.2, sizeof(buffaddr)=1024): buffptrs=194.2 inet_neta: inetaddr=atoi(argv[1]=772): inetaddr=772 inet_neta: buffptrs=inet_neta(inetaddr=772, buffaddr=3.4, sizeof(buffaddr)=1024): buffptrs=3.4
#top inet_netof¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
inet_netof()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_netof()
jest następująca:/* Return network number part of the Internet address IN. */ extern in_addr_t inet_netof (struct in_addr __in) __THROW;
Powiązane:
Opis:
Example:
zawartość pliku
inet_netof.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */ #include <stdint.h> /* for INT(8|16|32|64)_MIN, INT(8|16|32|64)_MAX, UINT(8|16|32|64)_MAX, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) typedef uint32_t in_addr_t; #endif int main(int argc, char **argv) { char *self; struct in_addr sin_addr; in_addr_t inetaddr; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<2) { printf("Usage: %s <ipv4addr>\n", argv[0]); printf("Examples:\n"); printf(" %s 10.2.3.4\n", argv[0]); printf(" %s 172.16.3.4\n", argv[0]); printf(" %s 192.2.3.4\n", argv[0]); printf(" %s 178.2.3.4\n", argv[0]); printf(" %s 194.2.3.4\n", argv[0]); return 0; } sin_addr.s_addr = inet_addr(argv[1]); printf("%s: sin_addr.s_addr = inet_addr(argv[1]=%s): sin_addr.s_addr=%08X(%u.%u.%u.%u)\n", self, argv[1], (unsigned int)sin_addr.s_addr, ntohl(sin_addr.s_addr)>>24&0xFF, ntohl(sin_addr.s_addr)>>16&0xFF, ntohl(sin_addr.s_addr)>>8&0xFF, ntohl(sin_addr.s_addr)>>0&0xFF); inetaddr=0; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_netof() is not available on this OS platform !!! */ printf("%s: inet_netof() is not available on this OS platform !!!\n", self); #else inetaddr=inet_netof(sin_addr); printf("%s: inetaddr=inet_netof(sin_addr=%08X(%u.%u.%u.%u)): inetaddr=%08X ntohl(sin_addr.s_addr)=%08X (%u.%u.%u.%u)\n", self, sin_addr.s_addr, ntohl(sin_addr.s_addr), ntohl(sin_addr.s_addr)>>24&0xFF, ntohl(sin_addr.s_addr)>>16&0xFF, ntohl(sin_addr.s_addr)>>8&0xFF, ntohl(sin_addr.s_addr)>>0&0xFF, inetaddr, (unsigned int)inetaddr>>24&0xFF, (unsigned int)inetaddr>>16&0xFF, (unsigned int)inetaddr>>8&0xFF, (unsigned int)inetaddr>>0&0xFF); #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/inet_netofprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/inet_netof <ipv4addr> Examples: /home/local/code/ansiccode/network/inet_netof 10.2.3.4 /home/local/code/ansiccode/network/inet_netof 172.16.3.4 /home/local/code/ansiccode/network/inet_netof 192.2.3.4 /home/local/code/ansiccode/network/inet_netof 178.2.3.4 /home/local/code/ansiccode/network/inet_netof 194.2.3.4
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/inet_netof 10.2.3.4 /home/local/code/ansiccode/network/inet_netof 172.16.3.4 /home/local/code/ansiccode/network/inet_netof 192.2.3.4 /home/local/code/ansiccode/network/inet_netof 178.2.3.4 /home/local/code/ansiccode/network/inet_netof 194.2.3.4rezultat będzie zależny od podanych argumentów wywołania programu:
inet_netof: sin_addr.s_addr = inet_addr(argv[1]=10.2.3.4): sin_addr.s_addr=0403020A ntohl(sin_addr.s_addr)=0A020304 (10.2.3.4) inet_netof: inetaddr=inet_netof(sin_addr=0403020A(10.2.3.4)): inetaddr=0000000A (0.0.0.10) inet_netof: sin_addr.s_addr = inet_addr(argv[1]=172.16.3.4): sin_addr.s_addr=040310AC ntohl(sin_addr.s_addr)=AC100304 (172.16.3.4) inet_netof: inetaddr=inet_netof(sin_addr=040310AC(172.16.3.4)): inetaddr=0000AC10 (0.0.172.16) inet_netof: sin_addr.s_addr = inet_addr(argv[1]=192.2.3.4): sin_addr.s_addr=040302C0 ntohl(sin_addr.s_addr)=C0020304 (192.2.3.4) inet_netof: inetaddr=inet_netof(sin_addr=040302C0(192.2.3.4)): inetaddr=00C00203 (0.192.2.3) inet_netof: sin_addr.s_addr = inet_addr(argv[1]=178.2.3.4): sin_addr.s_addr=040302B2 ntohl(sin_addr.s_addr)=B2020304 (178.2.3.4) inet_netof: inetaddr=inet_netof(sin_addr=040302B2(178.2.3.4)): inetaddr=0000B202 (0.0.178.2) inet_netof: sin_addr.s_addr = inet_addr(argv[1]=194.2.3.4): sin_addr.s_addr=040302C2 ntohl(sin_addr.s_addr)=C2020304 (194.2.3.4) inet_netof: inetaddr=inet_netof(sin_addr=040302C2(194.2.3.4)): inetaddr=00C20203 (0.194.2.3)
#top inet_network¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
inet_network()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_network()
jest następująca:/* Extract the network number in network byte order from the address in numbers-and-dots natation starting at CP. */ extern in_addr_t inet_network (__const char *__cp) __THROW;
Powiązane:
Opis:
Example:
zawartość pliku
inet_network.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdint.h> /* for INT(8|16|32|64)_MIN, INT(8|16|32|64)_MAX, UINT(8|16|32|64)_MAX, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #endif #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) typedef uint32_t in_addr_t; #endif int main(int argc, char **argv) { in_addr_t inetaddr; if (argc<2) { printf("Usage: %s <network>\n", argv[0]); printf("Examples:\n"); printf(" %s 10.0.0.0\n", argv[0]); printf(" %s 10.2.4.4\n", argv[0]); printf(" %s 172.16.0.0\n", argv[0]); printf(" %s 172.16.3.4\n", argv[0]); printf(" %s 192.168.0.0\n", argv[0]); printf(" %s 192.168.3.4\n", argv[0]); return 0; } inetaddr=0; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_network() is not available on this OS platform !!! */ printf("%s: inet_network() is not available on this OS platform !!!\n", argv[0]); #else inetaddr=inet_network(argv[1]); printf("%s inetaddr=inet_network(argv[1]=%s): inetaddr=%08X (%d.%d.%d.%d)\n", argv[0], argv[1], inetaddr, inetaddr>>24&0xFF, inetaddr>>16&0xFF, inetaddr>>8&0xFF, (unsigned int)inetaddr>>0&0xFF); #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/inet_networkprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/inet_network <network> Examples: /home/local/code/ansiccode/network/inet_network 10.0.0.0 /home/local/code/ansiccode/network/inet_network 10.2.4.4 /home/local/code/ansiccode/network/inet_network 172.16.0.0 /home/local/code/ansiccode/network/inet_network 172.16.3.4 /home/local/code/ansiccode/network/inet_network 192.168.0.0 /home/local/code/ansiccode/network/inet_network 192.168.3.4
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/inet_network 10.0.0.0 /home/local/code/ansiccode/network/inet_network 10.2.4.4 /home/local/code/ansiccode/network/inet_network 172.16.0.0 /home/local/code/ansiccode/network/inet_network 172.16.3.4 /home/local/code/ansiccode/network/inet_network 192.168.0.0 /home/local/code/ansiccode/network/inet_network 192.168.3.4rezultat będzie zależny od podanych argumentów wywołania programu:
inet_neta: inetaddr=atoi(argv[1]=10): inetaddr=10 inet_neta: buffptrs=inet_neta(inetaddr=10, buffaddr=10, sizeof(buffaddr)=1024): buffptrs=10 inet_neta: inetaddr=atoi(argv[1]=131844): inetaddr=131844 inet_neta: buffptrs=inet_neta(inetaddr=131844, buffaddr=2.3.4, sizeof(buffaddr)=1024): buffptrs=2.3.4 inet_neta: inetaddr=atoi(argv[1]=44048): inetaddr=44048 inet_neta: buffptrs=inet_neta(inetaddr=44048, buffaddr=172.16, sizeof(buffaddr)=1024): buffptrs=172.16 inet_neta: inetaddr=atoi(argv[1]=49154): inetaddr=49154 inet_neta: buffptrs=inet_neta(inetaddr=49154, buffaddr=192.2, sizeof(buffaddr)=1024): buffptrs=192.2 inet_neta: inetaddr=atoi(argv[1]=45570): inetaddr=45570 inet_neta: buffptrs=inet_neta(inetaddr=45570, buffaddr=178.2, sizeof(buffaddr)=1024): buffptrs=178.2 inet_neta: inetaddr=atoi(argv[1]=49666): inetaddr=49666 inet_neta: buffptrs=inet_neta(inetaddr=49666, buffaddr=194.2, sizeof(buffaddr)=1024): buffptrs=194.2 inet_neta: inetaddr=atoi(argv[1]=772): inetaddr=772 inet_neta: buffptrs=inet_neta(inetaddr=772, buffaddr=3.4, sizeof(buffaddr)=1024): buffptrs=3.4
#top inet_nsap_addr¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
inet_nsap_addr()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_nsap_addr()
jest następująca:/* Convert ASCII representation in hexadecimal form of the Internet address to binary form and place result in buffer of length LEN starting at BUF. */ extern unsigned int inet_nsap_addr (__const char *__cp, unsigned char *__buf, int __len) __THROW;
Powiązane:
inet_nsap_addr(), inet_nsap_ntoa(),
Opis:
Funkcja inet_nsap_addr()
Argumenty:
const char *__cp -
unsigned char *__buf -
int __len -
Zwracana wartość:
unsigned int -
Argumenty:
const char *__cp -
unsigned char *__buf -
int __len -
Zwracana wartość:
unsigned int -
Example:
zawartość pliku
inet_nsap_addr.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <stdlib.h> /* for RAND_MAX, EXIT_FAILURE, EXIT_SUCCESS, MB_CUR_MAX, atoi(), atol(), atoll(), atof(), strtod(), strtof(), strtold(), strtol(), strtoul(), strtoq(), strtouq(), strtoll(), strtoull(), */ /* for sys/types.h, malloc.h replaced by stdlib.h, random(), srandom(), rand(), srand(), abort(), atexit(), on_exit(), exit(), getenv(), */ /* for putenv(), setenv(), clearenv(), mktemp(), mkstemp(), mkdtemp(), system(), realpath(), abs(), labs(), llabs(), getloadavg(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ /* for struct fd_set, FD_SET, FD_ZERO, FD_ISSET, struct timeval, struct hostent, struct linger, struct netent, struct servent, struct protoent, */ /* for struct WSAData, WSADATA, struct sockaddr, WSAStartup(), WSACleanup(), WSASetLastError(), WSAGetLastError(), */ /* for htonl(), ntohl(), htons(), ntohs(), select(), */ #include <ws2tcpip.h> /* for winsock2.h, for (typedef struct) INTERFACE_INFO, SIO_GET_INTERFACE_LIST, ifaddr */ #else #include <arpa/inet.h> /* for netinet/in.h, in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), inet_ntoa(), inet_pton(), inet_ntop(), inet_aton(), inet_neta(), inet_net_ntop(), inet_net_pton(), */ #endif int main(int argc, char **argv) { char *self; unsigned char buffdata[16]; unsigned int addrsize; char ipv4data[16]; char *ipv4ptrs; unsigned int result; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<6) { printf("Usage: %s <ipv4addr> <ipv4oct1> <ipv4oct2> <ipv4oct3> <ipv4oct4>\n", argv[0]); printf("Examples:\n"); printf(" %s 0A020304 10 2 3 4\n", argv[0]); printf(" %s AC100304 172 16 3 4\n", argv[0]); printf(" %s C0020304 192 2 3 4\n", argv[0]); printf(" %s B2B1B0AF 178 177 176 175\n", argv[0]); printf(" %s C2C3C4C5 194 195 196 197\n", argv[0]); printf(" %s 0A.02.03.04 10 2 3 4\n", argv[0]); printf(" %s AC.10.03.04 172 16 3 4\n", argv[0]); printf(" %s C0.02.03.04 192 2 3 4\n", argv[0]); printf(" %s B2.B1.B0.AF 178 177 176 175\n", argv[0]); printf(" %s C2.C3.C4.C5 194 195 196 197\n", argv[0]); return 0; } memset(buffdata, 0x00, sizeof(buffdata)); result=0; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_nsap_addr() is not available on this OS platform !!! */ printf("%s: inet_nsap_addr() is not available on this OS platform !!!\n", self); #else result=inet_nsap_addr(argv[1], buffdata, sizeof(buffdata)); printf("%s: result=inet_nsap_addr(argv[1]=%s, buffdata[0.1.2.3]=%u.%u.%u.%u, sizeof(buffdata)=%u): result=%u\n", self, argv[1], (unsigned char)buffdata[0], (unsigned char)buffdata[1], (unsigned char)buffdata[2], (unsigned char)buffdata[3], sizeof(buffdata), result); #endif memset(buffdata, 0x00, sizeof(buffdata)); buffdata[0]=atoi(argv[2]); buffdata[1]=atoi(argv[3]); buffdata[2]=atoi(argv[4]); buffdata[3]=atoi(argv[5]); addrsize=4; memset(ipv4data, 0x00, sizeof(ipv4data)); ipv4ptrs=NULL; #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) /* inet_nsap_ntoa() is not available on this OS platform !!! */ printf("%s: inet_nsap_ntoa() is not available on this OS platform !!!\n", self); #else ipv4ptrs=inet_nsap_ntoa(addrsize, buffdata, ipv4data); printf("%s: ipv4ptrs=inet_nsap_ntoa(addrsize=%d, buffdata[0.1.2.3]=%u.%u.%u.%u, ipv4data=%s): ipv4ptrs=%s\n", self, addrsize, (unsigned char)buffdata[0], (unsigned char)buffdata[1], (unsigned char)buffdata[2], (unsigned char)buffdata[3], ipv4data, ipv4ptrs); #endif return 0; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/inet_nsap_addrprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/inet_nsap_addr <ipv4addr> <ipv4oct1> <ipv4oct2> <ipv4oct3> <ipv4oct4> Examples: /home/local/code/ansiccode/network/inet_nsap_addr 0A020304 10 2 3 4 /home/local/code/ansiccode/network/inet_nsap_addr AC100304 172 16 3 4 /home/local/code/ansiccode/network/inet_nsap_addr C0020304 192 2 3 4 /home/local/code/ansiccode/network/inet_nsap_addr B2B1B0AF 178 177 176 175 /home/local/code/ansiccode/network/inet_nsap_addr C2C3C4C5 194 195 196 197 /home/local/code/ansiccode/network/inet_nsap_addr 0A.02.03.04 10 2 3 4 /home/local/code/ansiccode/network/inet_nsap_addr AC.10.03.04 172 16 3 4 /home/local/code/ansiccode/network/inet_nsap_addr C0.02.03.04 192 2 3 4 /home/local/code/ansiccode/network/inet_nsap_addr B2.B1.B0.AF 178 177 176 175 /home/local/code/ansiccode/network/inet_nsap_addr C2.C3.C4.C5 194 195 196 197
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/inet_nsap_addr 0A020304 10 2 3 4 /home/local/code/ansiccode/network/inet_nsap_addr AC100304 172 16 3 4 /home/local/code/ansiccode/network/inet_nsap_addr C0020304 192 2 3 4 /home/local/code/ansiccode/network/inet_nsap_addr B2B1B0AF 178 177 176 175 /home/local/code/ansiccode/network/inet_nsap_addr C2C3C4C5 194 195 196 197 /home/local/code/ansiccode/network/inet_nsap_addr 0A.02.03.04 10 2 3 4 /home/local/code/ansiccode/network/inet_nsap_addr AC.10.03.04 172 16 3 4 /home/local/code/ansiccode/network/inet_nsap_addr C0.02.03.04 192 2 3 4 /home/local/code/ansiccode/network/inet_nsap_addr B2.B1.B0.AF 178 177 176 175 /home/local/code/ansiccode/network/inet_nsap_addr C2.C3.C4.C5 194 195 196 197rezultat będzie zależny od podanych argumentów wywołania programu:
inet_nsap_addr: result=inet_nsap_addr(argv[1]=0A020304, buffdata[0.1.2.3]=10.2.3.4, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=10.2.3.4, ipv4data=0A.0203.04): ipv4ptrs=0A.0203.04 inet_nsap_addr: result=inet_nsap_addr(argv[1]=AC100304, buffdata[0.1.2.3]=172.16.3.4, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=172.16.3.4, ipv4data=AC.1003.04): ipv4ptrs=AC.1003.04 inet_nsap_addr: result=inet_nsap_addr(argv[1]=C0020304, buffdata[0.1.2.3]=192.2.3.4, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=192.2.3.4, ipv4data=C0.0203.04): ipv4ptrs=C0.0203.04 inet_nsap_addr: result=inet_nsap_addr(argv[1]=B2B1B0AF, buffdata[0.1.2.3]=178.177.176.175, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=178.177.176.175, ipv4data=B2.B1B0.AF): ipv4ptrs=B2.B1B0.AF inet_nsap_addr: result=inet_nsap_addr(argv[1]=C2C3C4C5, buffdata[0.1.2.3]=194.195.196.197, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=194.195.196.197, ipv4data=C2.C3C4.C5): ipv4ptrs=C2.C3C4.C5 inet_nsap_addr: result=inet_nsap_addr(argv[1]=0A.02.03.04, buffdata[0.1.2.3]=10.2.3.4, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=10.2.3.4, ipv4data=0A.0203.04): ipv4ptrs=0A.0203.04 inet_nsap_addr: result=inet_nsap_addr(argv[1]=AC.10.03.04, buffdata[0.1.2.3]=172.16.3.4, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=172.16.3.4, ipv4data=AC.1003.04): ipv4ptrs=AC.1003.04 inet_nsap_addr: result=inet_nsap_addr(argv[1]=C0.02.03.04, buffdata[0.1.2.3]=192.2.3.4, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=192.2.3.4, ipv4data=C0.0203.04): ipv4ptrs=C0.0203.04 inet_nsap_addr: result=inet_nsap_addr(argv[1]=B2.B1.B0.AF, buffdata[0.1.2.3]=178.177.176.175, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=178.177.176.175, ipv4data=B2.B1B0.AF): ipv4ptrs=B2.B1B0.AF inet_nsap_addr: result=inet_nsap_addr(argv[1]=C2.C3.C4.C5, buffdata[0.1.2.3]=194.195.196.197, sizeof(buffdata)=16): result=4 inet_nsap_addr: ipv4ptrs=inet_nsap_ntoa(addrsize=4, buffdata[0.1.2.3]=194.195.196.197, ipv4data=C2.C3C4.C5): ipv4ptrs=C2.C3C4.C5
#top inet_nsap_ntoa¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
inet_nsap_ntoa()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_nsap_ntoa()
jest następująca:/* Convert internet address in binary form in LEN bytes starting at CP a presentation form and place result in BUF. */ extern char *inet_nsap_ntoa (int __len, __const unsigned char *__cp, char *__buf) __THROW;
Powiązane:
inet_nsap_addr(), inet_nsap_ntoa(),
Opis:
Funkcja inet_nsap_ntoa()
Argumenty:
int __len -
const unsigned char *__cp -
char *__buf -
Zwracana wartość:
char * -
Argumenty:
int __len -
const unsigned char *__cp -
char *__buf -
Zwracana wartość:
char * -
#top inet_ntoa¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us | gnu.org
Deklaracja funkcji
inet_ntoa()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_ntoa()
jest następująca:/* Convert Internet number in IN to ASCII representation. The return value is a pointer to an internal array containing the string. */ extern char *inet_ntoa (struct in_addr __in) __THROW;
Powiązane:
htonl(), htons(), inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton(), ntohl(), ntohs(),
Opis:
#top inet_ntop¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us | gnu.org
Deklaracja funkcji
inet_ntop()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_ntop()
jest następująca:/* Convert a Internet address in binary network format for interface type AF in buffer starting at CP to presentation form and place result in buffer of length LEN astarting at BUF. */ extern __const char *inet_ntop (int __af, __const void *__restrict __cp, char *__restrict __buf, socklen_t __len) __THROW;
Powiązane:
htonl(), htons(), inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton(), ntohl(), ntohs(),
Opis:
Funkcja inet_ntop()
Argumenty:
int __af -
const void *__restrict __cp -
char *__restrict __buf -
socklen_t __len -
Zwracana wartość:
const char * -
Argumenty:
int __af -
const void *__restrict __cp -
char *__restrict __buf -
socklen_t __len -
Zwracana wartość:
const char * -
#top inet_pton¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us | gnu.org
Deklaracja funkcji
inet_pton()
znajduje się w pliku nagłówkowym arpa/inet.h
.Deklaracja funkcji
inet_pton()
jest następująca:/* Convert from presentation format of an Internet number in buffer starting at CP to the binary network format and store result for interface type AF in buffer starting at BUF. */ extern int inet_pton (int __af, __const char *__restrict __cp, void *__restrict __buf) __THROW;
Powiązane:
htonl(), htons(), inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton(), ntohl(), ntohs(),
Opis:
Funkcja inet_pton()
Argumenty:
int __af -
const char *__restrict __cp -
void *__restrict __buf -
Zwracana wartość:
int -
Argumenty:
int __af -
const char *__restrict __cp -
void *__restrict __buf -
Zwracana wartość:
int -
#top innetgr¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
innetgr()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
innetgr()
jest następująca:/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN). This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern int innetgr (__const char *__netgroup, __const char *__host, __const char *__user, __const char *domain);
Powiązane:
Opis:
Funkcja innetgr()
Argumenty:
const char *__netgroup -
const char *__host -
const char *__user -
const char *domain -
Zwracana wartość:
int -
Argumenty:
const char *__netgroup -
const char *__host -
const char *__user -
const char *domain -
Zwracana wartość:
int -
Example:
zawartość pliku
innetgr.c
SELECT ALL
#define _GNU_SOURCE 1 /* for environ defined in unistd.h, to avoid warning implicit declaration of function basename, which defined in string.h */ #include <stdio.h> /* for FILE, va_list, EOF, SEEK_SET, SEEK_CUR, SEEK_END, stdin, stdout, stderr, remove(), rename(), tmpfile(), tmpnam(), tempnam(), fclose(), */ /* fflush(), fopen(), freopen(), fprintf(), printf(), snprintf(), scanf(), sscanf(), fgetc(), getc(), getchar(), fputc(), putc(), putchar(), */ /* fgets(), gets(), fputs(), puts(), fread(), fwrite(), fseek(), ftell(), rewind(), feof(), ferror(), fileno(), popen(), pclose(), */ #include <string.h> /* for memcpy(), memmove(), memset(), memcmp(), memchr(), memrchr(), str[n]cpy(), str[n]cat(), str[n]cmp(), strcoll(), str[n]dup(), strchr(), strrchr(), strstr(), */ /* strtok(), strcasestr(), memmem(), mempcpy(), str[n]len(), strerror(), bcopy(), bzero(), strcasecmp(), strsep(), basename(), */ #include <unistd.h> /* for R_OK, W_OK, X_OK, F_OK, environ, access(), lseek(), close(), read(), write(), pipe(), alarm(), sleep(), ualarm(), usleep(), pause(), chown(), chdir(), getcwd(), */ /* for exec[...](), nice(), getpid(), getppid(), setpgid(), setsid(), getsid(), getuid(), geteuid(), getgid(), getegid(), setuid(), seteuid(), setgid(), setegid(), fork(), */ /* for link(), symlink(), readlink(), unlink(), rmdir(), getlogin(), setlogin(), gethostname(), sethostname(), daemon(), chroot(), getpass(), [f]sync(), [f]truncate(), syscall(), */ #include <errno.h> /* for errno constant, error constants, */ #if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include <winsock.h> /* for SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, AF_INET, PF_INET, socket(), connect(), send(), recv(), sendto(), recvfrom(), shutdown(), */ /* for bind(), listen(), accept(), getsockname(), getsockopt(), setsockopt(), */ /* for in_addr_t, INADDR_ANY, INADDR_NONE, INADDR_BROADCAST, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_ICMP, IPPROTO_RAW, */ /* for struct sockaddr_in, struct in_addr, inet_addr(), struct hostent, gethostbyname(), gethostbyaddr(), */ #else #include <netdb.h> /* for herror(), hstrerror(), struct hostent, gethostent(), gethostbyaddr(), gethostbyname(), struct servent, getservent(), getservbyname(), getservbyport(), */ /* for struct protoent, getprotobyname(), getprotobynumber(), struct addrinfo, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, getaddrinfo(), freeaddrinfo(), getnameinfo(), */ #if defined(NEED_NETGROUP_H) #include <netgroup.h> /* need in OpenBSD, for struct netgroup, setnetgrent(), getnetgrent(), endnetgrent(), innetgr(), */ #endif #endif int main(int argc, char **argv) { char *self; char *args1, *args2, *args3, *args4; int result; self=strrchr(argv[0], '/'); if (self!=NULL) self++; else self=argv[0]; if (argc<5) { printf("Usage: %s <netgroup>\n", argv[0]); printf("Examples:\n"); printf(" %s netgroup hostname username domain\n", argv[0]); printf(" %s netgroup hostaaaa username domain\n", argv[0]); printf(" %s netgroup hostname useraaaa domain\n", argv[0]); printf(" %s netgroup hostname username domaaa\n", argv[0]); printf(" %s netgroup hostname \"\" \"\"\n", argv[0]); printf(" %s netgroup \"\" username \"\"\n", argv[0]); printf(" %s netgroup \"\" \"\" domain\n", argv[0]); printf(" %s netgroup host user dm\n", argv[0]); printf(" %s wan gateway \"\" \"\"\n", argv[0]); printf(" %s wan gateway user \"\"\n", argv[0]); printf(" %s wan gateway \"\" domain\n", argv[0]); printf(" %s wan gateway user domain\n", argv[0]); printf("\n"); printf("Configuration of /etc/nsswitch.conf\n"); printf("netgroup: files\n"); printf("\n"); printf("Content of /etc/netgroup\n"); printf("------------------------\n"); printf("wan (gateway , , ) (gateway-ebb , , )\n"); printf("machines (venus, -, star)\n"); printf("people (-, bob, star)\n"); printf("netgroup (hostname, username, domain)\n"); return 0; } if (strlen(argv[1])>0) args1=argv[1]; else args1=NULL; if (strlen(argv[2])>0) args2=argv[2]; else args2=NULL; if (strlen(argv[3])>0) args3=argv[3]; else args3=NULL; if (strlen(argv[4])>0) args4=argv[4]; else args4=NULL; result=innetgr(args1, args2, args3, args4); if (result>0) printf("%s: result=innetgr(args1=%s, args2=%s, args3=%s, args4=%s): result=%d if (result>=0): NETGROUP contains the triple (HOST,USER,DOMAIN).\n", self, args1, args2, args3, args4, result); else printf("%s: result=innetgr(args1=%s, args2=%s, args3=%s, args4=%s): result=%d if (result>=0): else: NETGROUP does not contains the triple (HOST,USER,DOMAIN).\n", self, args1, args2, args3, args4, result); return 1; }
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
/home/local/code/ansiccode/network/innetgrprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/ansiccode/network/innetgr <netgroup> Examples: /home/local/code/ansiccode/network/innetgr netgroup hostname username domain /home/local/code/ansiccode/network/innetgr netgroup hostaaaa username domain /home/local/code/ansiccode/network/innetgr netgroup hostname useraaaa domain /home/local/code/ansiccode/network/innetgr netgroup hostname username domaaa /home/local/code/ansiccode/network/innetgr netgroup hostname "" "" /home/local/code/ansiccode/network/innetgr netgroup "" username "" /home/local/code/ansiccode/network/innetgr netgroup "" "" domain /home/local/code/ansiccode/network/innetgr netgroup host user dm /home/local/code/ansiccode/network/innetgr wan gateway "" "" /home/local/code/ansiccode/network/innetgr wan gateway user "" /home/local/code/ansiccode/network/innetgr wan gateway "" domain /home/local/code/ansiccode/network/innetgr wan gateway user domain Configuration of /etc/nsswitch.conf netgroup: files Content of /etc/netgroup ------------------------ wan (gateway , , ) (gateway-ebb , , ) machines (venus, -, star) people (-, bob, star) netgroup (hostname, username, domain)
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/ansiccode/network/innetgr netgroup hostname username domain /home/local/code/ansiccode/network/innetgr netgroup hostaaaa username domain /home/local/code/ansiccode/network/innetgr netgroup hostname useraaaa domain /home/local/code/ansiccode/network/innetgr netgroup hostname username domaaa /home/local/code/ansiccode/network/innetgr netgroup hostname "" "" /home/local/code/ansiccode/network/innetgr netgroup "" username "" /home/local/code/ansiccode/network/innetgr netgroup "" "" domain /home/local/code/ansiccode/network/innetgr netgroup host user dm /home/local/code/ansiccode/network/innetgr wan gateway "" "" /home/local/code/ansiccode/network/innetgr wan gateway user "" /home/local/code/ansiccode/network/innetgr wan gateway "" domain /home/local/code/ansiccode/network/innetgr wan gateway user domainrezultat będzie zależny od podanych argumentów wywołania programu:
innetgr: result=innetgr(args1=netgroup, args2=hostname, args3=username, args4=domain): result=1 if (result>=0): NETGROUP contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=netgroup, args2=hostaaaa, args3=username, args4=domain): result=0 if (result>=0): else: NETGROUP does not contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=netgroup, args2=hostname, args3=useraaaa, args4=domain): result=0 if (result>=0): else: NETGROUP does not contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=netgroup, args2=hostname, args3=username, args4=domaaa): result=0 if (result>=0): else: NETGROUP does not contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=netgroup, args2=hostname, args3=(null), args4=(null)): result=1 if (result>=0): NETGROUP contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=netgroup, args2=(null), args3=username, args4=(null)): result=1 if (result>=0): NETGROUP contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=netgroup, args2=(null), args3=(null), args4=domain): result=1 if (result>=0): NETGROUP contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=netgroup, args2=host, args3=user, args4=dm): result=0 if (result>=0): else: NETGROUP does not contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=wan, args2=gateway, args3=(null), args4=(null)): result=1 if (result>=0): NETGROUP contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=wan, args2=gateway, args3=user, args4=(null)): result=1 if (result>=0): NETGROUP contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=wan, args2=gateway, args3=(null), args4=domain): result=1 if (result>=0): NETGROUP contains the triple (HOST,USER,DOMAIN). innetgr: result=innetgr(args1=wan, args2=gateway, args3=user, args4=domain): result=1 if (result>=0): NETGROUP contains the triple (HOST,USER,DOMAIN).
#top ntohl¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us
Deklaracja funkcji
ntohl()
znajduje się w pliku nagłówkowym netinet/in.h
.Deklaracja funkcji
ntohl()
jest następująca:/* Functions to convert between host and network byte order. Please note that these functions normally take `unsigned long int' or `unsigned short int' values as arguments and also return them. But this was a short-sighted decision since on different systems the types may have different representations but the values are always the same. */ extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__));
Powiązane:
htonl(), htons(), inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton(), ntohl(), ntohs(),
Opis:
#top ntohs¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | beej.us
Deklaracja funkcji
ntohs()
znajduje się w pliku nagłówkowym netinet/in.h
.Deklaracja funkcji
ntohs()
jest następująca:/* Functions to convert between host and network byte order. Please note that these functions normally take `unsigned long int' or `unsigned short int' values as arguments and also return them. But this was a short-sighted decision since on different systems the types may have different representations but the values are always the same. */ extern uint16_t ntohs (uint16_t __netshort) __THROW __attribute__ ((__const__));
Powiązane:
htonl(), htons(), inet_addr(), inet_aton(), inet_ntoa(), inet_ntop(), inet_pton(), ntohl(), ntohs(),
Opis:
Funkcja ntohs() (Network TO Host Short)
Argumenty:
uint16_t __netshort -
Zwracana wartość:
uint16_t -
Argumenty:
uint16_t __netshort -
Zwracana wartość:
uint16_t -
#top setdomainname¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
setdomainname()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
setdomainname()
jest następująca:/* Get and set the NIS (aka YP) domain name, if any. Called just like `gethostname' and `sethostname'. The NIS domain name is usually the empty string when not using NIS. */ extern int setdomainname (__const char *__name, size_t __len) __THROW __nonnull ((1)) __wur;
Powiązane:
getdomainname(), setdomainname(),
Opis:
#top sethostent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
sethostent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
sethostent()
jest następująca:/* Open host data base files and mark them as staying open even after a later search if STAY_OPEN is non-zero. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void sethostent (int __stay_open);
Powiązane:
endhostent(), gethostent(), sethostent(),
Opis:
Funkcja sethostent() jest używana do 'przewijania' do początku (jest równoważna do fseek(file, 0, 0)) "bazy danych" zawierającej informacje dotyczące hostów przechowywanych w systemie. Informacje dotyczące hostów przechowywane są w pliku tekstowym
Argumenty:
int __stay_open -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
/etc/hosts
.Argumenty:
int __stay_open -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top sethostname¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
sethostname()
znajduje się w pliku nagłówkowym unistd.h
.Deklaracja funkcji
sethostname()
jest następująca:/* Set the name of the current host to NAME, which is LEN bytes long. This call is restricted to the super-user. */ extern int sethostname (__const char *__name, size_t __len) __THROW __nonnull ((1)) __wur;
Powiązane:
gethostname(), sethostname()
Opis:
#top setnetent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
setnetent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
setnetent()
jest następująca:/* Open network data base files and mark them as staying open even after a later search if STAY_OPEN is non-zero. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void setnetent (int __stay_open);
Powiązane:
endnetent(), getnetent(), setnetent(),
Opis:
Funkcja setnetent() jest używana do 'przewijania' do początku (jest równoważna do fseek(file, 0, 0)) "bazy danych" zawierającej informacje dotyczące sieci przechowywanych w systemie. Informacje dotyczące sieci przechowywane są w pliku tekstowym
Argumenty:
int __stay_open -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
/etc/networks
.Argumenty:
int __stay_open -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top setnetgrent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
setnetgrent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
setnetgrent()
jest następująca:/* Establish network group NETGROUP for enumeration. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern int setnetgrent (__const char *__netgroup);
Powiązane:
endnetgrent(), getnetgrent(), setnetgrent(),
Opis:
Funkcja setnetgrent() jest używana do 'przewijania' do początku (jest równoważna do fseek(file, 0, 0)) "bazy danych" zawierającej informacje dotyczące grup sieci przechowywanych w systemie. Informacje dotyczące grup sieci przechowywane są w pliku tekstowym
Argumenty:
const char *__netgroup -
Zwracana wartość:
int -
/etc/netgroup
.Argumenty:
const char *__netgroup -
Zwracana wartość:
int -
#top setprotoent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
setprotoent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
setprotoent()
jest następująca:/* Open protocol data base files and mark them as staying open even after a later search if STAY_OPEN is non-zero. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void setprotoent (int __stay_open);
Powiązane:
endprotoent(), getprotoent(), setprotoent(),
Opis:
Funkcja setprotoent() jest używana do 'przewijania' do początku (jest równoważna do fseek(file, 0, 0)) "bazy danych" zawierającej informacje dotyczące protokołów przechowywanych w systemie. Informacje dotyczące protokołów przechowywane są w pliku tekstowym
Argumenty:
int __stay_open -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
/etc/protocols
.Argumenty:
int __stay_open -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top setservent¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org | gnu.org
Deklaracja funkcji
setservent()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
setservent()
jest następująca:/* Open service data base files and mark them as staying open even after a later search if STAY_OPEN is non-zero. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void setservent (int __stay_open);
Powiązane:
endservent(), getservent(), setservent(),
Opis:
Funkcja setservent() jest używana do 'przewijania' do początku (jest równoważna do fseek(file, 0, 0)) "bazy danych" zawierającej informacje dotyczące usług przechowywanych w systemie. Informacje dotyczące usług przechowywane są w pliku tekstowym
Argumenty:
int __stay_open -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
/etc/services
.Argumenty:
int __stay_open -
Zwracana wartość:
Funkcja nie zwraca żadnej wartości.
#top Resolv¶
#top Resolv Predefined Constants¶
#top MAXDNSRCH¶
Deklaracja stałej
MAXDNSRCH
znajduje się w pliku nagłówkowym resolv.h
.Deklaracja stałej
MAXDNSRCH
jest następująca:/* * Global defines and variables for resolver stub. */ # define MAXDNSRCH 6 /* max # domains in search path */
#top MAXNS¶
Deklaracja stałej
MAXNS
znajduje się w pliku nagłówkowym resolv.h
.Deklaracja stałej
MAXNS
jest następująca:/* * Global defines and variables for resolver stub. */ # define MAXNS 3 /* max # name servers we'll track */
#top MAXRESOLVSORT¶
Deklaracja stałej
MAXRESOLVSORT
znajduje się w pliku nagłówkowym resolv.h
.Deklaracja stałej
MAXRESOLVSORT
jest następująca:/* * Global defines and variables for resolver stub. */ # define MAXRESOLVSORT 10 /* number of net to sort on */
#top Resolv Datatypes / MACROS¶
#top __u_char¶
Definicja typu
__u_char
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__u_char
jest następująca:/* Convenience types. */ typedef unsigned char __u_char;
#top __u_int¶
Definicja typu
__u_int
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__u_int
jest następująca:/* Convenience types. */ typedef unsigned int __u_int;
#top __u_long¶
Definicja typu
__u_long
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__u_long
jest następująca:/* Convenience types. */ typedef unsigned long int __u_long;
#top __u_short¶
Definicja typu
__u_short
znajduje się w pliku nagłówkowym bits/types.h
.Definicja typu
__u_short
jest następująca:/* Convenience types. */ typedef unsigned short int __u_short;
#top res_send_qhook¶
Definicja funkcji
res_send_qhook
znajduje się w pliku nagłówkowym resolv.h
.Definicja funkcji
res_send_qhook
jest następująca:typedef res_sendhookact (*res_send_qhook) (struct sockaddr_in * const *ns, const u_char **query, int *querylen, u_char *ans, int anssiz, int *resplen);
#top res_send_rhook¶
Definicja funkcji
res_send_rhook
znajduje się w pliku nagłówkowym resolv.h
.Definicja funkcji
res_send_rhook
jest następująca:typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *ns, const u_char *query, int querylen, u_char *ans, int anssiz, int *resplen);
#top res_state¶
Definicja struktury
res_state
znajduje się w pliku nagłówkowym resolv.h
.Definicja struktury
res_state
jest następująca:typedef struct __res_state *res_state;
#top struct __res_state¶
Definicja struktury
struct __res_state
znajduje się w pliku nagłówkowym resolv.h
.Definicja struktury
struct __res_state
jest następująca:struct __res_state { int retrans; /* retransmition time interval */ int retry; /* number of times to retransmit */ u_long options; :* option flags - see below. */ int nscount; /* number of name servers */ struct sockaddr_in nsaddr_list[MAXNS]; :* address of name server */ # define nsaddr nsaddr_list[0] /* for backward compatibility */ u_short id; :* current message id */ char *dnsrch[MAXDNSRCH+1]; :* components of domain to search */ char defdname[256]; /* default domain (deprecated) */ u_long pfcode; :* RES_PRF_ flags - see below. */ unsigned ndots:4; /* threshold for initial abs. query */ unsigned nsort:4; /* number of elements in sort_list[] */ char unused[3]; struct { struct in_addr addr; u_int32_t mask; } sort_list[MAXRESOLVSORT]; res_send_qhook qhook; :* query hook */ res_send_rhook rhook; :* response hook */ int res_h_errno; /* last one set for this context */ int _vcsock; /* PRIVATE: for res_send VC i/o */ u_int _flags; :* PRIVATE: see below */ union { char pad[52]; /* On an i386 this means 512b total. */ struct { u_int16_t nscount; u_int16_t nsmap[MAXNS]; int nssocks[MAXNS]; u_int16_t nscount6; u_int16_t nsinit; struct sockaddr_in6 *nsaddrs[MAXNS]; #ifdef _LIBC unsigned long long int initstamp __attribute__((packed)); #else unsigned int _initstamp[2]; #endif } _ext; } _u; };
#top u_char¶
Definicja typu
u_char
znajduje się w pliku nagłówkowym sys/types.h
.Definicja typu
u_char
jest następująca:#ifdef __USE_BSD # ifndef __u_char_defined typedef __u_char u_char; [...] # define __u_char_defined # endif #endif
#top u_int¶
Definicja typu
u_int
znajduje się w pliku nagłówkowym sys/types.h
.Definicja typu
u_int
jest następująca:#ifdef __USE_BSD [...] typedef __u_int u_int; [...] # endif #endif
#top u_int16_t¶
Definicja typu
u_int16_t
znajduje się w pliku nagłówkowym sys/types.h
.Definicja typu
u_int16_t
jest następująca:/* But these were defined by ISO C without the first `_'. */ typedef unsigned short int u_int16_t;
#top u_int32_t¶
Definicja typu
u_int32_t
znajduje się w pliku nagłówkowym sys/types.h
.Definicja typu
u_int32_t
jest następująca:/* But these were defined by ISO C without the first `_'. */ typedef unsigned int u_int32_t;
#top u_long¶
Definicja typu
u_long
znajduje się w pliku nagłówkowym sys/types.h
.Definicja typu
u_long
jest następująca:#ifdef __USE_BSD [...] typedef __u_long u_long; [...] # endif #endif
#top u_short¶
Definicja typu
u_short
znajduje się w pliku nagłówkowym sys/types.h
.Definicja typu
u_short
jest następująca:#ifdef __USE_BSD [...] typedef __u_short u_short; [...] # endif #endif
#top Resolv Functions¶
#top dn_expand¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
dn_expand()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
dn_expand()
jest następująca:#define dn_expand __dn_expand int dn_expand (const u_char *, const u_char *, const u_char *, char *, int) __THROW;
Powiązane:
dn_expand(), dn_skipname(), res_nclose(), res_nmkquery(), res_nsend(), res_search()
Opis:
Funkcja dn_expand()
Argumenty:
const u_char * -
const u_char * -
const u_char * -
char * -
int -
Zwracana wartość:
int -
Argumenty:
const u_char * -
const u_char * -
const u_char * -
char * -
int -
Zwracana wartość:
int -
#top dn_skipname¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
dn_skipname()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
dn_skipname()
jest następująca:#define dn_skipname __dn_skipname int dn_skipname (const u_char *, const u_char *) __THROW;
Powiązane:
dn_expand(), dn_skipname(), res_nclose(), res_nmkquery(), res_nsend(), res_search()
Opis:
#top res_nclose¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
res_nclose()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
res_nclose()
jest następująca:#define res_nclose __res_nclose void res_nclose (res_state) __THROW;
Powiązane:
dn_expand(), dn_skipname(), res_nclose(), res_nmkquery(), res_nsend(), res_search()
Opis:
#top res_ninit¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
res_ninit()
znajduje się w pliku nagłówkowym resolv.h
.Deklaracja funkcji
res_ninit()
jest następująca:#define res_init __res_init int res_init (void) __THROW;
Powiązane:
dn_expand(), dn_skipname(), res_nclose(), res_nmkquery(), res_nsend(), res_search()
Opis:
Funkcja res_ninit()
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
int -
Argumenty:
Funkcja nie przyjmuje żadnych argumentów.
Zwracana wartość:
int -
#top res_nmkquery¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
res_nmkquery()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
res_nmkquery()
jest następująca:#define res_nmkquery __res_nmkquery int res_nmkquery (res_state, int, const char *, int, int, const u_char *, int, const u_char *, u_char *, int) __THROW;
Powiązane:
dn_expand(), dn_skipname(), res_nclose(), res_nmkquery(), res_nsend(), res_search()
Opis:
Funkcja res_nmkquery()
Argumenty:
res_state -
int -
const char * -
int -
int -
const u_char * -
int -
const u_char * -
u_char * -
int -
Zwracana wartość:
int -
Argumenty:
res_state -
int -
const char * -
int -
int -
const u_char * -
int -
const u_char * -
u_char * -
int -
Zwracana wartość:
int -
Example:
zawartość pliku
res_nmkquery.c
SELECT ALL
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
program wyświetli informacje o sposobie uruchamiania programu:
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
rezultat będzie zależny od podanych argumentów wywołania programu:
#top res_nsend¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
res_nsend()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
res_nsend()
jest następująca:#define res_nsend __res_nsend int res_nsend (res_state, const u_char *, int, u_char *, int) __THROW;
Powiązane:
dn_expand(), dn_skipname(), res_nclose(), res_nmkquery(), res_nsend(), res_search()
Opis:
Funkcja res_nsend()
Argumenty:
res_state -
const u_char * -
int -
u_char * -
int -
Zwracana wartość:
int -
Argumenty:
res_state -
const u_char * -
int -
u_char * -
int -
Zwracana wartość:
int -
#top res_search¶
Documentacja online: pubs.opengroup.org | www.cplusplus.com | pl.wikibooks.org
Deklaracja funkcji
res_search()
znajduje się w pliku nagłówkowym netdb.h
.Deklaracja funkcji
res_search()
jest następująca:#define res_search __res_search int res_search (const char *, int, int, u_char *, int) __THROW;
Powiązane:
dn_expand(), dn_skipname(), res_nclose(), res_nmkquery(), res_nsend(), res_search(),
Opis:
Example:
zawartość pliku
res_search.c
SELECT ALL
program należy skompilować komendą make (jako argument należy podać plik
Makefile
zależny od systemu operacyjnego, domyślnie make próbuje użyć pliku Makefile
):make clean all # system Linux make -f Makefile clean all # system Linux make -f Makefile.obsd clean all # system OpenBSD make -f Makefile.fbsd clean all # system FreeBSD make -f Makefile.sol clean all # system Solaris make -f Makefile.beos clean all # system BeOS make -f Makefile.win clean all # system Windows
a następnie uruchomić bez argumentów:
program wyświetli informacje o sposobie uruchamiania programu:
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
rezultat będzie zależny od podanych argumentów wywołania programu:
Zmodyfikowany ostatnio: 2015/10/01 19:46:11 (9 lat temu),
textsize: 367 kB,
htmlsize: 558 kB
Zapraszam do komentowania, zgłaszania sugestii, propozycji, własnych przykładów, ...
Dodaj komentarzKomentarze użytkowników