Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/col/col.c
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
#endif | #endif | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/capsicum.h> | #include <sys/capsicum.h> | ||||
#include <capsicum_helpers.h> | |||||
#include <err.h> | #include <err.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <locale.h> | #include <locale.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <termios.h> | #include <termios.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | main(int argc, char **argv) | ||||
int extra_lines; /* # of lines above first line */ | int extra_lines; /* # of lines above first line */ | ||||
int cur_col; /* current column */ | int cur_col; /* current column */ | ||||
int cur_line; /* line number of current position */ | int cur_line; /* line number of current position */ | ||||
int max_line; /* max value of cur_line */ | int max_line; /* max value of cur_line */ | ||||
int this_line; /* line l points to */ | int this_line; /* line l points to */ | ||||
int nflushd_lines; /* number of lines that were flushed */ | int nflushd_lines; /* number of lines that were flushed */ | ||||
int adjust, opt, warned, width; | int adjust, opt, warned, width; | ||||
const char *errstr; | const char *errstr; | ||||
cap_rights_t rights; | |||||
unsigned long cmd; | |||||
(void)setlocale(LC_CTYPE, ""); | (void)setlocale(LC_CTYPE, ""); | ||||
cap_rights_init(&rights, CAP_FSTAT, CAP_READ); | if (caph_limit_stdio() == -1) | ||||
if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) | err(1, "unable to limit stdio"); | ||||
err(1, "unable to limit rights for stdin"); | |||||
cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE, CAP_IOCTL); | |||||
if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) | |||||
err(1, "unable to limit rights for stdout"); | |||||
cmd = TIOCGETA; /* required by isatty(3) in printf(3) */ | |||||
if (cap_ioctls_limit(STDOUT_FILENO, &cmd, 1) < 0 && errno != ENOSYS) | |||||
err(1, "unable to limit ioctls for stdout"); | |||||
if (cap_enter() < 0 && errno != ENOSYS) | if (cap_enter() < 0 && errno != ENOSYS) | ||||
err(1, "unable to enter capability mode"); | err(1, "unable to enter capability mode"); | ||||
max_bufd_lines = 256; | max_bufd_lines = 256; | ||||
compress_spaces = 1; /* compress spaces into tabs */ | compress_spaces = 1; /* compress spaces into tabs */ | ||||
while ((opt = getopt(argc, argv, "bfhl:px")) != -1) | while ((opt = getopt(argc, argv, "bfhl:px")) != -1) | ||||
switch (opt) { | switch (opt) { | ||||
▲ Show 20 Lines • Show All 440 Lines • Show Last 20 Lines |