forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiTermFileDescriptorServerShared.h
64 lines (50 loc) · 2.77 KB
/
iTermFileDescriptorServerShared.h
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
//
// iTermFileDescriptorServerShared.h
// iTerm2
//
// Created by George Nachman on 11/26/19.
//
#ifndef iTermFileDescriptorServerShared_h
#define iTermFileDescriptorServerShared_h
#include <stdio.h>
#include <sys/socket.h>
#include "DebugLogging.h"
typedef union {
struct cmsghdr cm;
char control[CMSG_SPACE(sizeof(int))];
} iTermFileDescriptorControlMessage;
void iTermFileDescriptorServerLog(char *format, ...);
int iTermFileDescriptorServerAcceptAndClose(int socketFd);
int iTermFileDescriptorServerAccept(int socketFd);
void SetRunningServer(void);
ssize_t iTermFileDescriptorServerSendMessageAndFileDescriptor(int connectionFd,
void *buffer,
size_t bufferSize,
int fdToSend);
ssize_t iTermFileDescriptorServerWriteLengthAndBuffer(int connectionFd,
void *buffer,
size_t bufferSize,
int *errorOut);
ssize_t iTermFileDescriptorServerWriteLengthAndBufferAndFileDescriptor(int connectionFd,
void *buffer,
size_t bufferSize,
int fdToSend,
int *errorOut);
ssize_t iTermFileDescriptorServerWrite(int fd, void *buffer, size_t bufferSize);
// For use on a pipe or other non-socket
ssize_t iTermFileDescriptorClientWrite(int fd, const void *buffer, size_t bufferSize);
// Takes an array of file descriptors and its length as input. `results` should be an array of
// equal length. On return, the readable FDs will have the corresponding value in `results` set to
// true. Takes care of EINTR. Return value is number of readable FDs.
int iTermSelect(int *fds, int count, int *results, int wantErrors);
// Like iTermSelect but selects for writing.
int iTermSelectForWriting(int *fds, int count, int *results, int wantErrors);
// Create a socket and listen on it. Returns the socket's file descriptor.
// This is used for connecting a client and server prior to fork.
// Follow it with a call to iTermFileDescriptorServerAcceptAndClose().
int iTermFileDescriptorServerSocketBindListen(const char *path);
// Acquire an advisory lock. If successful, returns a file descriptor >= 0.
// If the lock could not be acquired, returns -1.
// You can release the lock by closing the file descriptor.
int iTermAcquireAdvisoryLock(const char *path);
#endif /* iTermFileDescriptorServerShared_h */