mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Add curl example (#42)
make -j8 o//examples/curl.com o//examples/curl.com http://justine.lol/ape.html
This commit is contained in:
parent
667ab245fe
commit
2c15efc249
29 changed files with 208 additions and 153 deletions
|
@ -1,15 +1,34 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_DNS_DNS_H_
|
||||
#define COSMOPOLITAN_LIBC_DNS_DNS_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
#include "libc/dns/resolvconf.h"
|
||||
#include "libc/sock/sock.h"
|
||||
|
||||
#define DNS_PORT 53
|
||||
#define DNS_NAME_MAX 253
|
||||
#define DNS_PORT 53
|
||||
#define DNS_NAME_MAX 253
|
||||
#define DNS_LABEL_MAX 63
|
||||
|
||||
struct sockaddr;
|
||||
struct sockaddr_in;
|
||||
struct ResolvConf;
|
||||
#define EAI_SUCCESS 0
|
||||
#define EAI_BADFLAGS -1
|
||||
#define EAI_NONAME -2
|
||||
#define EAI_AGAIN -3
|
||||
#define EAI_FAIL -4
|
||||
#define EAI_NODATA -5
|
||||
#define EAI_FAMILY -6
|
||||
#define EAI_SOCKTYPE -7
|
||||
#define EAI_SERVICE -8
|
||||
#define EAI_ADDRFAMILY -9
|
||||
#define EAI_MEMORY -10
|
||||
#define EAI_OVERFLOW -12
|
||||
#define EAI_SYSTEM -11
|
||||
#define EAI_ALLDONE -103
|
||||
#define EAI_CANCELED -101
|
||||
#define EAI_IDN_ENCODE -105
|
||||
#define EAI_INPROGRESS -100
|
||||
#define EAI_INTR -104
|
||||
#define EAI_NOTCANCELED -102
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct addrinfo {
|
||||
int32_t ai_flags; /* AI_XXX */
|
||||
|
|
|
@ -17,30 +17,51 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dns/dns.h"
|
||||
#include "libc/sysv/consts/eai.h"
|
||||
|
||||
/**
|
||||
* Turns getaddrinfo() return code into string.
|
||||
*/
|
||||
const char *eai2str(int code) {
|
||||
if (code == EAI_ADDRFAMILY) return "ADDRFAMILY";
|
||||
if (code == EAI_AGAIN) return "AGAIN";
|
||||
if (code == EAI_ALLDONE) return "ALLDONE";
|
||||
if (code == EAI_BADFLAGS) return "BADFLAGS";
|
||||
if (code == EAI_CANCELED) return "CANCELED";
|
||||
if (code == EAI_FAIL) return "FAIL";
|
||||
if (code == EAI_FAMILY) return "FAMILY";
|
||||
if (code == EAI_IDN_ENCODE) return "ENCODE";
|
||||
if (code == EAI_INPROGRESS) return "INPROGRESS";
|
||||
if (code == EAI_INTR) return "INTR";
|
||||
if (code == EAI_MEMORY) return "MEMORY";
|
||||
if (code == EAI_NODATA) return "NODATA";
|
||||
if (code == EAI_NONAME) return "NONAME";
|
||||
if (code == EAI_NOTCANCELED) return "NOTCANCELED";
|
||||
if (code == EAI_OVERFLOW) return "OVERFLOW";
|
||||
if (code == EAI_SERVICE) return "SERVICE";
|
||||
if (code == EAI_SOCKTYPE) return "SOCKTYPE";
|
||||
if (code == EAI_SUCCESS) return "SUCCESS";
|
||||
if (code == EAI_SYSTEM) return "SYSTEM";
|
||||
return "???";
|
||||
switch (code) {
|
||||
case EAI_ADDRFAMILY:
|
||||
return "ADDRFAMILY";
|
||||
case EAI_AGAIN:
|
||||
return "AGAIN";
|
||||
case EAI_ALLDONE:
|
||||
return "ALLDONE";
|
||||
case EAI_BADFLAGS:
|
||||
return "BADFLAGS";
|
||||
case EAI_CANCELED:
|
||||
return "CANCELED";
|
||||
case EAI_FAIL:
|
||||
return "FAIL";
|
||||
case EAI_FAMILY:
|
||||
return "FAMILY";
|
||||
case EAI_IDN_ENCODE:
|
||||
return "ENCODE";
|
||||
case EAI_INPROGRESS:
|
||||
return "INPROGRESS";
|
||||
case EAI_INTR:
|
||||
return "INTR";
|
||||
case EAI_MEMORY:
|
||||
return "MEMORY";
|
||||
case EAI_NODATA:
|
||||
return "NODATA";
|
||||
case EAI_NONAME:
|
||||
return "NONAME";
|
||||
case EAI_NOTCANCELED:
|
||||
return "NOTCANCELED";
|
||||
case EAI_OVERFLOW:
|
||||
return "OVERFLOW";
|
||||
case EAI_SERVICE:
|
||||
return "SERVICE";
|
||||
case EAI_SOCKTYPE:
|
||||
return "SOCKTYPE";
|
||||
case EAI_SUCCESS:
|
||||
return "SUCCESS";
|
||||
case EAI_SYSTEM:
|
||||
return "SYSTEM";
|
||||
default:
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/ai.h"
|
||||
#include "libc/sysv/consts/eai.h"
|
||||
#include "libc/sysv/consts/inaddr.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_DNS_RESOLVCONF_H_
|
||||
#define COSMOPOLITAN_LIBC_DNS_RESOLVCONF_H_
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct FILE;
|
||||
struct sockaddr_in;
|
||||
|
||||
struct Nameservers {
|
||||
size_t i, n;
|
||||
struct sockaddr_in *p;
|
||||
|
|
|
@ -1833,29 +1833,6 @@ syscon gai AI_NUMERICSERV 0x0400 0x1000 8 0x10 0x10 8
|
|||
syscon gai AI_ALL 0x10 0x0100 0x0100 0 0 0x0100
|
||||
syscon gai AI_V4MAPPED 8 0x0800 0x0800 0 0 0x0800
|
||||
|
||||
# getaddrinfo() return codes
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD NetBSD XENIX Commentary
|
||||
syscon eai EAI_SUCCESS 0 0 0 0 0 0
|
||||
syscon eai EAI_BADFLAGS -1 3 3 -1 -1 0x2726
|
||||
syscon eai EAI_NONAME -2 8 8 -2 -2 0x2af9
|
||||
syscon eai EAI_AGAIN -3 2 2 -3 -3 0x2afa
|
||||
syscon eai EAI_FAIL -4 4 4 -4 -4 0x2afb
|
||||
syscon eai EAI_FAMILY -6 5 5 -6 -6 0x273f
|
||||
syscon eai EAI_MEMORY -10 6 6 -10 -10 0x2747
|
||||
syscon eai EAI_SERVICE -8 9 9 -8 -8 0x277d
|
||||
syscon eai EAI_SOCKTYPE -7 10 10 -7 -7 0x273c
|
||||
syscon eai EAI_NODATA -5 7 0 -5 -5 0x2af9
|
||||
syscon eai EAI_OVERFLOW -12 14 14 -14 -14 -12
|
||||
syscon eai EAI_SYSTEM -11 11 11 -11 -11 -11
|
||||
syscon eai EAI_ADDRFAMILY -9 1 0 -9 -9 -9
|
||||
syscon eai EAI_ALLDONE -103 -103 -103 -103 -103 -103 # copying from linux
|
||||
syscon eai EAI_CANCELED -101 -101 -101 -101 -101 -101 # copying from linux
|
||||
syscon eai EAI_IDN_ENCODE -105 -105 -105 -105 -105 -105 # copying from linux
|
||||
syscon eai EAI_INPROGRESS -100 -100 -100 -100 -100 -100 # copying from linux
|
||||
syscon eai EAI_INTR -104 -104 -104 -104 -104 -104 # copying from linux
|
||||
syscon eai EAI_NOTCANCELED -102 -102 -102 -102 -102 -102 # copying from linux
|
||||
|
||||
syscon misc BLK_BYTECOUNT 2 2 2 2 2 0 # unix consensus
|
||||
syscon misc BLK_EOF 0x40 0x40 0x40 0x40 0x40 0 # unix consensus
|
||||
syscon misc BLK_EOR 0x80 0x80 0x80 0x80 0x80 0 # unix consensus
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_ADDRFAMILY,-9,1,0,-9,-9,-9
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_AGAIN,-3,2,2,-3,-3,0x2afa
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_ALLDONE,-103,-103,-103,-103,-103,-103
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_BADFLAGS,-1,3,3,-1,-1,0x2726
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_CANCELED,-101,-101,-101,-101,-101,-101
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_FAIL,-4,4,4,-4,-4,0x2afb
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_FAMILY,-6,5,5,-6,-6,0x273f
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_IDN_ENCODE,-105,-105,-105,-105,-105,-105
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_INPROGRESS,-100,-100,-100,-100,-100,-100
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_INTR,-104,-104,-104,-104,-104,-104
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_MEMORY,-10,6,6,-10,-10,0x2747
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_NODATA,-5,7,0,-5,-5,0x2af9
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_NONAME,-2,8,8,-2,-2,0x2af9
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_NOTCANCELED,-102,-102,-102,-102,-102,-102
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_OVERFLOW,-12,14,14,-14,-14,-12
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_SERVICE,-8,9,9,-8,-8,0x277d
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_SOCKTYPE,-7,10,10,-7,-7,0x273c
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_SUCCESS,0,0,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon eai,EAI_SYSTEM,-11,11,11,-11,-11,-11
|
|
@ -1,49 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_EAI_H_
|
||||
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_EAI_H_
|
||||
#include "libc/runtime/symbolic.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const long EAI_ADDRFAMILY;
|
||||
extern const long EAI_AGAIN;
|
||||
extern const long EAI_ALLDONE;
|
||||
extern const long EAI_BADFLAGS;
|
||||
extern const long EAI_CANCELED;
|
||||
extern const long EAI_FAIL;
|
||||
extern const long EAI_FAMILY;
|
||||
extern const long EAI_IDN_ENCODE;
|
||||
extern const long EAI_INPROGRESS;
|
||||
extern const long EAI_INTR;
|
||||
extern const long EAI_MEMORY;
|
||||
extern const long EAI_NODATA;
|
||||
extern const long EAI_NONAME;
|
||||
extern const long EAI_NOTCANCELED;
|
||||
extern const long EAI_OVERFLOW;
|
||||
extern const long EAI_SERVICE;
|
||||
extern const long EAI_SOCKTYPE;
|
||||
extern const long EAI_SYSTEM;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
||||
#define EAI_ADDRFAMILY SYMBOLIC(EAI_ADDRFAMILY)
|
||||
#define EAI_AGAIN SYMBOLIC(EAI_AGAIN)
|
||||
#define EAI_ALLDONE SYMBOLIC(EAI_ALLDONE)
|
||||
#define EAI_BADFLAGS SYMBOLIC(EAI_BADFLAGS)
|
||||
#define EAI_CANCELED SYMBOLIC(EAI_CANCELED)
|
||||
#define EAI_FAIL SYMBOLIC(EAI_FAIL)
|
||||
#define EAI_FAMILY SYMBOLIC(EAI_FAMILY)
|
||||
#define EAI_IDN_ENCODE SYMBOLIC(EAI_IDN_ENCODE)
|
||||
#define EAI_INPROGRESS SYMBOLIC(EAI_INPROGRESS)
|
||||
#define EAI_INTR SYMBOLIC(EAI_INTR)
|
||||
#define EAI_MEMORY SYMBOLIC(EAI_MEMORY)
|
||||
#define EAI_NODATA SYMBOLIC(EAI_NODATA)
|
||||
#define EAI_NONAME SYMBOLIC(EAI_NONAME)
|
||||
#define EAI_NOTCANCELED SYMBOLIC(EAI_NOTCANCELED)
|
||||
#define EAI_OVERFLOW SYMBOLIC(EAI_OVERFLOW)
|
||||
#define EAI_SERVICE SYMBOLIC(EAI_SERVICE)
|
||||
#define EAI_SOCKTYPE SYMBOLIC(EAI_SOCKTYPE)
|
||||
#define EAI_SUCCESS LITERALLY(0)
|
||||
#define EAI_SYSTEM SYMBOLIC(EAI_SYSTEM)
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_EAI_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue