PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <termios.h>
#include <unistd.h>
Go to the source code of this file.
Macros | |
#define | _GNU_SOURCE 1 |
Functions | |
static void | fail_io (const char *msg,...) |
Prints MSG, formatting as with printf(), plus an error message based on errno, and exits. More... | |
static void | make_noncanon (int fd, int vmin, int vtime) |
If FD is a terminal, configures it for noncanonical input mode with VMIN and VTIME set as indicated. More... | |
static void | make_nonblocking (int fd, bool nonblocking) |
Make FD non-blocking if NONBLOCKING is true, or blocking if NONBLOCKING is false. More... | |
static bool | handle_error (ssize_t retval, int *fd, bool fd_is_sock, const char *call) |
Handle a read or write on *FD, which is the socket if FD_IS_SOCK is true, that returned end-of-file or error indication RETVAL. More... | |
static void | relay (int sock) |
Copies data from stdin to SOCK and from SOCK to stdout until no more data can be read or written. More... | |
static void | sigchld_handler (int signo __attribute__((unused))) |
int | main (int argc __attribute__((unused)), char *argv[]) |
#define _GNU_SOURCE 1 |
Definition at line 1 of file squish-unix.c.
|
static |
Prints MSG, formatting as with printf(), plus an error message based on errno, and exits.
Definition at line 31 of file squish-unix.c.
References exit(), EXIT_FAILURE, msg(), va_end, and va_start.
Referenced by handle_error(), main(), make_nonblocking(), make_noncanon(), and relay().
Handle a read or write on *FD, which is the socket if FD_IS_SOCK is true, that returned end-of-file or error indication RETVAL.
The system call is named CALL, for use in error messages. Returns true if processing may continue, false if we're all done.
Definition at line 86 of file squish-unix.c.
References fail_io().
Referenced by relay().
int main | ( | int argc | __attribute__(unused), |
char * | argv[] | ||
) |
Definition at line 241 of file squish-unix.c.
References close(), EXIT_FAILURE, fail_io(), make_nonblocking(), memset(), NULL, offsetof, relay(), sigchld_handler(), signal(), strlen(), and strncpy.
|
static |
Make FD non-blocking if NONBLOCKING is true, or blocking if NONBLOCKING is false.
Definition at line 67 of file squish-unix.c.
References fail_io().
Referenced by main(), and relay().
|
static |
If FD is a terminal, configures it for noncanonical input mode with VMIN and VTIME set as indicated.
If FD is not a terminal, has no effect.
Definition at line 49 of file squish-unix.c.
References fail_io().
Referenced by relay().
|
static |
Copies data from stdin to SOCK and from SOCK to stdout until no more data can be read or written.
Definition at line 105 of file squish-unix.c.
References buf, exit(), fail_io(), handle_error(), make_nonblocking(), make_noncanon(), memmove(), memset(), NULL, read(), STDIN_FILENO, STDOUT_FILENO, and write().
Referenced by main().
|
static |
Definition at line 235 of file squish-unix.c.
Referenced by main().