Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
proxy/csapp.h at master · lixf/proxy · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
lixf
proxy
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
proxy
/
csapp.h
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
168 lines (145 loc) · 5.45 KB
master
Breadcrumbs
proxy
/
csapp.h
Copy path
Top
File metadata and controls
Code
Blame
168 lines (145 loc) · 5.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* $begin csapp.h */
#ifndef
__CSAPP_H__
#define
__CSAPP_H__
#include
<stdio.h>
#include
<stdlib.h>
#include
<unistd.h>
#include
<string.h>
#include
<ctype.h>
#include
<setjmp.h>
#include
<signal.h>
#include
<sys/time.h>
#include
<sys/types.h>
#include
<sys/wait.h>
#include
<sys/stat.h>
#include
<fcntl.h>
#include
<sys/mman.h>
#include
<errno.h>
#include
<math.h>
#include
<pthread.h>
#include
<semaphore.h>
#include
<sys/socket.h>
#include
<netdb.h>
#include
<netinet/in.h>
#include
<arpa/inet.h>
/* Default file permissions are DEF_MODE & ~DEF_UMASK */
/* $begin createmasks */
#define
DEF_MODE
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH
#define
DEF_UMASK
S_IWGRP|S_IWOTH
/* $end createmasks */
/* Simplifies calls to bind(), connect(), and accept() */
/* $begin sockaddrdef */
typedef
struct
sockaddr
SA
;
/* $end sockaddrdef */
/* Persistent state for the robust I/O (Rio) package */
/* $begin rio_t */
#define
RIO_BUFSIZE
8192
typedef
struct
{
int
rio_fd
;
/* descriptor for this internal buf */
int
rio_cnt
;
/* unread bytes in internal buf */
char
*
rio_bufptr
;
/* next unread byte in internal buf */
char
rio_buf
[
RIO_BUFSIZE
];
/* internal buffer */
}
rio_t
;
/* $end rio_t */
/* External variables */
extern
int
h_errno
;
/* defined by BIND for DNS errors */
extern
char
*
*
environ
;
/* defined by libc */
/* Misc constants */
#define
MAXLINE
8192
/* max text line length */
#define
MAXBUF
8192
/* max I/O buffer size */
#define
LISTENQ
1024
/* second argument to listen() */
/* Our own error-handling functions */
void
unix_error
(
char
*
msg
);
void
posix_error
(
int
code
,
char
*
msg
);
void
dns_error
(
char
*
msg
);
void
app_error
(
char
*
msg
);
/* Process control wrappers */
pid_t
Fork
(
void
);
void
Execve
(
const
char
*
filename
,
char
*
const
argv
[],
char
*
const
envp
[]);
pid_t
Wait
(
int
*
status
);
pid_t
Waitpid
(
pid_t
pid
,
int
*
iptr
,
int
options
);
void
Kill
(
pid_t
pid
,
int
signum
);
unsigned
int
Sleep
(
unsigned
int
secs
);
void
Pause
(
void
);
unsigned
int
Alarm
(
unsigned
int
seconds
);
void
Setpgid
(
pid_t
pid
,
pid_t
pgid
);
pid_t
Getpgrp
();
/* Signal wrappers */
typedef
void
handler_t
(
int
);
handler_t
*
Signal
(
int
signum
,
handler_t
*
handler
);
void
Sigprocmask
(
int
how
,
const
sigset_t
*
set
,
sigset_t
*
oldset
);
void
Sigemptyset
(
sigset_t
*
set
);
void
Sigfillset
(
sigset_t
*
set
);
void
Sigaddset
(
sigset_t
*
set
,
int
signum
);
void
Sigdelset
(
sigset_t
*
set
,
int
signum
);
int
Sigismember
(
const
sigset_t
*
set
,
int
signum
);
/* Unix I/O wrappers */
int
Open
(
const
char
*
pathname
,
int
flags
,
mode_t
mode
);
ssize_t
Read
(
int
fd
,
void
*
buf
,
size_t
count
);
ssize_t
Write
(
int
fd
,
const
void
*
buf
,
size_t
count
);
off_t
Lseek
(
int
fildes
,
off_t
offset
,
int
whence
);
void
Close
(
int
fd
);
int
Select
(
int
n
,
fd_set
*
readfds
,
fd_set
*
writefds
,
fd_set
*
exceptfds
,
struct
timeval
*
timeout
);
int
Dup2
(
int
fd1
,
int
fd2
);
void
Stat
(
const
char
*
filename
,
struct
stat
*
buf
);
void
Fstat
(
int
fd
,
struct
stat
*
buf
) ;
/* Memory mapping wrappers */
void
*
Mmap
(
void
*
addr
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
off_t
offset
);
void
Munmap
(
void
*
start
,
size_t
length
);
/* Standard I/O wrappers */
void
Fclose
(
FILE
*
fp
);
FILE
*
Fdopen
(
int
fd
,
const
char
*
type
);
char
*
Fgets
(
char
*
ptr
,
int
n
,
FILE
*
stream
);
FILE
*
Fopen
(
const
char
*
filename
,
const
char
*
mode
);
void
Fputs
(
const
char
*
ptr
,
FILE
*
stream
);
size_t
Fread
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FILE
*
stream
);
void
Fwrite
(
const
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FILE
*
stream
);
/* Dynamic storage allocation wrappers */
void
*
Malloc
(
size_t
size
);
void
*
Realloc
(
void
*
ptr
,
size_t
size
);
void
*
Calloc
(
size_t
nmemb
,
size_t
size
);
void
Free
(
void
*
ptr
);
/* Sockets interface wrappers */
int
Socket
(
int
domain
,
int
type
,
int
protocol
);
void
Setsockopt
(
int
s
,
int
level
,
int
optname
,
const
void
*
optval
,
int
optlen
);
void
Bind
(
int
sockfd
,
struct
sockaddr
*
my_addr
,
int
addrlen
);
void
Listen
(
int
s
,
int
backlog
);
int
Accept
(
int
s
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
);
void
Connect
(
int
sockfd
,
struct
sockaddr
*
serv_addr
,
int
addrlen
);
/* DNS wrappers */
struct
hostent
*
Gethostbyname
(
const
char
*
name
);
struct
hostent
*
Gethostbyaddr
(
const
char
*
addr
,
int
len
,
int
type
);
/* Pthreads thread control wrappers */
void
Pthread_create
(
pthread_t
*
tidp
,
pthread_attr_t
*
attrp
,
void
*
(
*
routine
)(
void
*
),
void
*
argp
);
void
Pthread_join
(
pthread_t
tid
,
void
*
*
thread_return
);
void
Pthread_cancel
(
pthread_t
tid
);
void
Pthread_detach
(
pthread_t
tid
);
void
Pthread_exit
(
void
*
retval
);
pthread_t
Pthread_self
(
void
);
void
Pthread_once
(
pthread_once_t
*
once_control
,
void
(
*
init_function
)());
/* POSIX semaphore wrappers */
void
Sem_init
(
sem_t
*
sem
,
int
pshared
,
unsigned
int
value
);
void
P
(
sem_t
*
sem
);
void
V
(
sem_t
*
sem
);
/* Rio (Robust I/O) package */
ssize_t
rio_readn
(
int
fd
,
void
*
usrbuf
,
size_t
n
);
ssize_t
rio_writen
(
int
fd
,
void
*
usrbuf
,
size_t
n
);
void
rio_readinitb
(
rio_t
*
rp
,
int
fd
);
ssize_t
rio_readnb
(
rio_t
*
rp
,
void
*
usrbuf
,
size_t
n
);
ssize_t
rio_readlineb
(
rio_t
*
rp
,
void
*
usrbuf
,
size_t
maxlen
);
/* Wrappers for Rio package */
ssize_t
Rio_readn
(
int
fd
,
void
*
usrbuf
,
size_t
n
);
void
Rio_writen
(
int
fd
,
void
*
usrbuf
,
size_t
n
);
void
Rio_readinitb
(
rio_t
*
rp
,
int
fd
);
ssize_t
Rio_readnb
(
rio_t
*
rp
,
void
*
usrbuf
,
size_t
n
);
ssize_t
Rio_readlineb
(
rio_t
*
rp
,
void
*
usrbuf
,
size_t
maxlen
);
/* Client/server helper functions */
int
open_clientfd
(
char
*
hostname
,
int
portno
);
int
open_listenfd
(
int
portno
);
/* Wrappers for client/server helper functions */
int
Open_clientfd
(
char
*
hostname
,
int
port
);
int
Open_listenfd
(
int
port
);
#endif
/* __CSAPP_H__ */
/* $end csapp.h */
You can’t perform that action at this time.