Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Typedefs | Functions
getaddrinfo.c File Reference
`#include "ruby/config.h"`
`#include <sys/types.h>`
`#include <sys/param.h>`
`#include <sys/socket.h>`
`#include <netinet/in.h>`
`#include <netdb.h>`
`#include <unistd.h>`
`#include <string.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <stddef.h>`
`#include <ctype.h>`
`#include "addrinfo.h"`
`#include "sockport.h"`

Go to the source code of this file.

## Data Structures
struct | sockinet
struct | afd

## Macros
#define | SUCCESS 0
#define | ANY 0
#define | YES 1
#define | NO 0
#define | N_INET 0
#define | PTON_MAX 4
#define | GET_CANONNAME(ai, str)
#define | GET_AI(ai, afd, addr, port)
#define | ERR(err) { error = (err); goto bad; }

## Typedefs
typedef int | socklen_t

## Functions
char * | gai_strerror (int ecode)
void | freeaddrinfo (struct addrinfo *ai)
int | getaddrinfo (const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res)

## Macro Definition Documentation

## ◆ ANY

#define ANY 0

Definition at line 90 of file getaddrinfo.c.

## ◆ ERR

#define ERR | ( |  | err | ) | { error = (err); goto bad; }

Definition at line 200 of file getaddrinfo.c.

## ◆ GET_AI

#define GET_AI | ( |  | ai,
|  |  | afd,
|  |  | addr,
|  |  | port
| ) |  |

Value:
{\
char *p;\
if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\
((afd)->a_socklen)))\
== NULL) {\
error = EAI_MEMORY;\
goto free;\
}\
memcpy((ai), pai, sizeof(struct addrinfo));\
(ai)->ai_addr = (struct sockaddr *)((ai) + 1);\
(ai)->ai_family = (afd)->a_af;\
(ai)->ai_addrlen = (afd)->a_socklen;\
INIT_SOCKADDR((ai)->ai_addr, (afd)->a_af, (afd)->a_socklen);\
((struct sockinet *)(ai)->ai_addr)->si_port = (port);\
p = (char *)((ai)->ai_addr);\
memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\
}

Definition at line 182 of file getaddrinfo.c.

## ◆ GET_CANONNAME

#define GET_CANONNAME | ( |  | ai,
|  |  | str
| ) |  |

Value:
if (pai->ai_flags & AI_CANONNAME) {\
if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\
strcpy((ai)->ai_canonname, (str));\
} else {\
error = EAI_MEMORY;\
goto free;\
}\
}

Definition at line 172 of file getaddrinfo.c.

## ◆ N_INET

#define N_INET 0

## ◆ NO

#define NO 0

Definition at line 92 of file getaddrinfo.c.

## ◆ PTON_MAX

#define PTON_MAX 4

Definition at line 142 of file getaddrinfo.c.

## ◆ SUCCESS

#define SUCCESS 0

Definition at line 89 of file getaddrinfo.c.

## ◆ YES

#define YES 1

Definition at line 91 of file getaddrinfo.c.

## Typedef Documentation

## ◆ socklen_t

typedef int socklen_t

Definition at line 83 of file getaddrinfo.c.

## Function Documentation

## ◆ freeaddrinfo()

void freeaddrinfo | ( | struct addrinfo * | ai | ) |

Definition at line 216 of file getaddrinfo.c.

References addrinfo::ai_canonname, addrinfo::ai_next, free, and NULL.

Referenced by rb_freeaddrinfo().

## ◆ gai_strerror()

char* gai_strerror | ( | int | ecode | ) |

Definition at line 207 of file getaddrinfo.c.

References EAI_MAX.

## ◆ getaddrinfo()

int getaddrinfo | ( | const char * | hostname,
|  | const char * | servname,
|  | const struct addrinfo * | hints,
|  | struct addrinfo ** | res
| ) |  |

Definition at line 272 of file getaddrinfo.c.

References error, getenv, i, NULL, PTON_MAX, and top.

sockinet::si_port
u_short si_port
Definition: getaddrinfo.c:111
AI_CANONNAME
#define AI_CANONNAME
Definition: addrinfo.h:97
malloc
void * malloc(size_t) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)) __attribute__((__alloc_size__(1)))
sockinet
Definition: getaddrinfo.c:108
NULL
#define NULL
Definition: _sdbm.c:101
strlen
size_t strlen(const char *)
EAI_MEMORY
#define EAI_MEMORY
Definition: addrinfo.h:83
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
free
#define free(x)
Definition: dln.c:52
addrinfo
Definition: addrinfo.h:131