mirror of https://github.com/mkerrisk/man-pages
s/-/\\-/
This commit is contained in:
parent
bb38b71d15
commit
29059a6548
10
man2/bind.2
10
man2/bind.2
|
@ -282,20 +282,20 @@ main(int argc, char *argv[])
|
|||
socklen_t peer_addr_size;
|
||||
|
||||
sfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sfd == -1)
|
||||
if (sfd == \-1)
|
||||
die("socket");
|
||||
|
||||
memset(&my_addr, 0, sizeof(struct sockaddr_un));
|
||||
/* Clear structure */
|
||||
my_addr.sun_family = AF_UNIX;
|
||||
strncpy(my_addr.sun_path, MY_SOCK_PATH,
|
||||
sizeof(my_addr.sun_path) - 1);
|
||||
sizeof(my_addr.sun_path) \- 1);
|
||||
|
||||
if (bind(sfd, (struct sockaddr *) &my_addr,
|
||||
sizeof(struct sockaddr_un)) == -1)
|
||||
sizeof(struct sockaddr_un)) == \-1)
|
||||
die("bind");
|
||||
|
||||
if (listen(sfd, LISTEN_BACKLOG) == -1)
|
||||
if (listen(sfd, LISTEN_BACKLOG) == \-1)
|
||||
die("listen");
|
||||
|
||||
/* Now we can accept incoming connections one
|
||||
|
@ -304,7 +304,7 @@ main(int argc, char *argv[])
|
|||
peer_addr_size = sizeof(struct sockaddr_un);
|
||||
cfd = accept(sfd, (struct sockaddr *) &peer_addr,
|
||||
&peer_addr_size)
|
||||
if (cfd == -1)
|
||||
if (cfd == \-1)
|
||||
die("accept");
|
||||
|
||||
/* Code to deal with incoming connection(s)... */
|
||||
|
|
|
@ -168,7 +168,7 @@ static void
|
|||
handler(int sig, siginfo_t *si, void *unused)
|
||||
{
|
||||
printf("Got SIGSEGV at address: 0x%lx\\n",
|
||||
(long) si->si_addr);
|
||||
(long) si\->si_addr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -182,11 +182,11 @@ main(int argc, char *argv[])
|
|||
sa.sa_flags = SA_SIGINFO;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_sigaction = handler;
|
||||
if (sigaction(SIGSEGV, &sa, NULL) == -1)
|
||||
if (sigaction(SIGSEGV, &sa, NULL) == \-1)
|
||||
die("sigaction");
|
||||
|
||||
pagesize = sysconf(_SC_PAGE_SIZE);
|
||||
if (pagesize == -1)
|
||||
if (pagesize == \-1)
|
||||
die("sysconf");
|
||||
|
||||
/* Allocate a buffer aligned on a page boundary;
|
||||
|
@ -199,7 +199,7 @@ main(int argc, char *argv[])
|
|||
printf("Start of region: 0x%lx\\n", (long) buffer);
|
||||
|
||||
if (mprotect(buffer + pagesize * 2, pagesize,
|
||||
PROT_NONE) == -1)
|
||||
PROT_NONE) == \-1)
|
||||
die("mprotect");
|
||||
|
||||
for (p = buffer ; ; )
|
||||
|
|
10
man2/pipe.2
10
man2/pipe.2
|
@ -93,10 +93,16 @@ main(int argc, char *argv[])
|
|||
|
||||
assert(argc == 2);
|
||||
|
||||
if (pipe(pfd) == -1) { perror("pipe"); exit(EXIT_FAILURE); }
|
||||
if (pipe(pfd) == \-1) {
|
||||
perror("pipe");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cpid = fork();
|
||||
if (cpid == -1) { perror("fork"); exit(EXIT_FAILURE); }
|
||||
if (cpid == \-1) {
|
||||
perror("fork");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (cpid == 0) { /* Child reads from pipe */
|
||||
close(pfd[1]); /* Close unused write end */
|
||||
|
|
|
@ -403,7 +403,7 @@ main(int argc, char *argv[])
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (stat(argv[1], &sb) == -1) {
|
||||
if (stat(argv[1], &sb) == \-1) {
|
||||
perror("stat");
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ main(int argc, char *argv[])
|
|||
default: printf("unknown?\\n"); break;
|
||||
}
|
||||
|
||||
printf("I-node number: %ld\\n", (long) sb.st_ino);
|
||||
printf("I\-node number: %ld\\n", (long) sb.st_ino);
|
||||
|
||||
printf("Mode: %lo (octal)\\n",
|
||||
(unsigned long) sb.st_mode);
|
||||
|
|
|
@ -147,7 +147,7 @@ main(void)
|
|||
|
||||
osnamelth = sizeof(osname);
|
||||
|
||||
if (syscall(SYS__sysctl, &args) == -1) {
|
||||
if (syscall(SYS__sysctl, &args) == \-1) {
|
||||
perror("_sysctl");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ main(int argc, char *argv[])
|
|||
assert(argc == 2);
|
||||
|
||||
fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (fd == -1) {
|
||||
if (fd == \-1) {
|
||||
perror("open");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ main(int argc, char *argv[])
|
|||
perror("splice");
|
||||
break;
|
||||
}
|
||||
len -= slen;
|
||||
len \-= slen;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
|
|
10
man2/wait.2
10
man2/wait.2
|
@ -516,11 +516,11 @@ The following shell session demonstrates the use of the program:
|
|||
$ ./a.out &
|
||||
Child PID is 32360
|
||||
[1] 32359
|
||||
$ kill -STOP 32360
|
||||
$ kill \-STOP 32360
|
||||
stopped by signal 19
|
||||
$ kill -CONT 32360
|
||||
$ kill \-CONT 32360
|
||||
continued
|
||||
$ kill -TERM 32360
|
||||
$ kill \-TERM 32360
|
||||
killed by signal 15
|
||||
[1]+ Done ./a.out
|
||||
$
|
||||
|
@ -537,7 +537,7 @@ main(int argc, char *argv[])
|
|||
int status;
|
||||
|
||||
cpid = fork();
|
||||
if (cpid == -1) {
|
||||
if (cpid == \-1) {
|
||||
perror("fork");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ main(int argc, char *argv[])
|
|||
} else { /* Code executed by parent */
|
||||
do {
|
||||
w = waitpid(cpid, &status, WUNTRACED | WCONTINUED);
|
||||
if (w == -1) {
|
||||
if (w == \-1) {
|
||||
perror("waitpid");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ program:
|
|||
.nf
|
||||
.in +0.25i
|
||||
|
||||
$ cc -rdynamic prog.c -o prog
|
||||
$ cc \-rdynamic prog.c \-o prog
|
||||
$ ./prog 3
|
||||
backtrace() returned 8 addresses
|
||||
./prog(myfunc3+0x5c) [0x80487f0]
|
||||
|
@ -221,7 +221,7 @@ void
|
|||
myfunc(int ncalls)
|
||||
{
|
||||
if (ncalls > 1)
|
||||
myfunc(ncalls - 1);
|
||||
myfunc(ncalls \- 1);
|
||||
else
|
||||
myfunc2();
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "%s num-calls\\n", argv[0]);
|
||||
fprintf(stderr, "%s num\-calls\\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
12
man3/cmsg.3
12
man3/cmsg.3
|
@ -171,8 +171,8 @@ int received_ttl;
|
|||
for (cmsg = CMSG_FIRSTHDR(&msgh);
|
||||
cmsg != NULL;
|
||||
cmsg = CMSG_NXTHDR(&msgh,cmsg)) {
|
||||
if (cmsg->cmsg_level == IPPROTO_IP
|
||||
&& cmsg->cmsg_type == IP_TTL) {
|
||||
if (cmsg\->cmsg_level == IPPROTO_IP
|
||||
&& cmsg\->cmsg_type == IP_TTL) {
|
||||
ttlptr = (int *) CMSG_DATA(cmsg);
|
||||
received_ttl = *ttlptr;
|
||||
break;
|
||||
|
@ -202,14 +202,14 @@ int *fdptr;
|
|||
msg.msg_control = buf;
|
||||
msg.msg_controllen = sizeof buf;
|
||||
cmsg = CMSG_FIRSTHDR(&msg);
|
||||
cmsg->cmsg_level = SOL_SOCKET;
|
||||
cmsg->cmsg_type = SCM_RIGHTS;
|
||||
cmsg->cmsg_len = CMSG_LEN(sizeof(int) * NUM_FD);
|
||||
cmsg\->cmsg_level = SOL_SOCKET;
|
||||
cmsg\->cmsg_type = SCM_RIGHTS;
|
||||
cmsg\->cmsg_len = CMSG_LEN(sizeof(int) * NUM_FD);
|
||||
/* Initialize the payload: */
|
||||
fdptr = (int *) CMSG_DATA(cmsg);
|
||||
memcpy(fdptr, myfds, NUM_FD * sizeof(int));
|
||||
/* Sum of the length of all control messages in the buffer: */
|
||||
msg.msg_controllen = cmsg->cmsg_len;
|
||||
msg.msg_controllen = cmsg\->cmsg_len;
|
||||
.ta
|
||||
.fi
|
||||
.RE
|
||||
|
|
|
@ -169,12 +169,12 @@ callback(struct dl_phdr_info *info, size_t size, void *data)
|
|||
{
|
||||
int j;
|
||||
|
||||
printf("name=%s (%d segments)\\n", info->dlpi_name,
|
||||
info->dlpi_phnum);
|
||||
printf("name=%s (%d segments)\\n", info\->dlpi_name,
|
||||
info\->dlpi_phnum);
|
||||
|
||||
for (j = 0; j < info->dlpi_phnum; j++)
|
||||
for (j = 0; j < info\->dlpi_phnum; j++)
|
||||
printf("\\t\\t header %2d: address=%10p\\n", j,
|
||||
(void *) (info->dlpi_addr + info->dlpi_phdr[j].p_vaddr));
|
||||
(void *) (info\->dlpi_addr + info\->dlpi_phdr[j].p_vaddr));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -419,7 +419,7 @@ main(int argc, char **argv)
|
|||
/* Writing: cosine = (double (*)(double)) dlsym(handle, "cos");
|
||||
would seem more natural, but the C99 standard leaves
|
||||
casting from "void *" to a function pointer undefined.
|
||||
The assignment used below is the POSIX.1-2003 (Technical
|
||||
The assignment used below is the POSIX.1\-2003 (Technical
|
||||
Corrigendum 1) workaround; see the Rationale for the
|
||||
POSIX specification of dlsym(). */
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
s = fprintf(out, "%d ", v * v);
|
||||
if (s == -1)
|
||||
if (s == \-1)
|
||||
die("fprintf");
|
||||
}
|
||||
fclose(in);
|
||||
|
|
|
@ -242,9 +242,9 @@ main(void)
|
|||
{
|
||||
long class = MM_PRINT | MM_SOFT | MM_OPSYS | MM_RECOVER;
|
||||
int err;
|
||||
err = fmtmsg(class, "util-linux:mount", MM_ERROR,
|
||||
err = fmtmsg(class, "util\-linux:mount", MM_ERROR,
|
||||
"unknown mount option", "See mount(8).",
|
||||
"util-linux:mount:017");
|
||||
"util\-linux:mount:017");
|
||||
switch (err) {
|
||||
case MM_OK:
|
||||
break;
|
||||
|
@ -266,8 +266,8 @@ main(void)
|
|||
.PP
|
||||
The output should be:
|
||||
.nf
|
||||
util-linux:mount: ERROR: unknown mount option
|
||||
TO FIX: See mount(8). util-linux:mount:017
|
||||
util\-linux:mount: ERROR: unknown mount option
|
||||
TO FIX: See mount(8). util\-linux:mount:017
|
||||
.fi
|
||||
and after
|
||||
.nf
|
||||
|
|
|
@ -344,13 +344,13 @@ static int
|
|||
display_info(const char *fpath, const struct stat *sb,
|
||||
int tflag, struct FTW *ftwbuf)
|
||||
{
|
||||
printf("%-3s %2d %7lld %-40s %d %s\\n",
|
||||
printf("%\-3s %2d %7lld %\-40s %d %s\\n",
|
||||
(tflag == FTW_D) ? "d" : (tflag == FTW_DNR) ? "dnr" :
|
||||
(tflag == FTW_DP) ? "dp" : (tflag == FTW_F) ? "f" :
|
||||
(tflag == FTW_DP) ? "dp" : (tflag == FTW_SL) ? "sl" :
|
||||
(tflag == FTW_SLN) ? "sln" : "???",
|
||||
ftwbuf->level, (long long) sb->st_size,
|
||||
fpath, ftwbuf->base, fpath + ftwbuf->base);
|
||||
ftwbuf\->level, (long long) sb\->st_size,
|
||||
fpath, ftwbuf\->base, fpath + ftwbuf\->base);
|
||||
return 0; /* To tell nftw() to continue */
|
||||
}
|
||||
|
||||
|
|
|
@ -499,13 +499,13 @@ main(int argc, char *argv[])
|
|||
If socket(2) (or bind(2)) fails, we (close the socket
|
||||
and) try the next address. */
|
||||
|
||||
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||
sfd = socket(rp->ai_family, rp->ai_socktype,
|
||||
rp->ai_protocol);
|
||||
if (sfd == -1)
|
||||
for (rp = result; rp != NULL; rp = rp\->ai_next) {
|
||||
sfd = socket(rp\->ai_family, rp\->ai_socktype,
|
||||
rp\->ai_protocol);
|
||||
if (sfd == \-1)
|
||||
continue;
|
||||
|
||||
if (bind(sfd, rp->ai_addr, rp->ai_addrlen) == 0)
|
||||
if (bind(sfd, rp\->ai_addr, rp\->ai_addrlen) == 0)
|
||||
break; /* Success */
|
||||
|
||||
close(sfd);
|
||||
|
@ -524,7 +524,7 @@ main(int argc, char *argv[])
|
|||
peer_addr_len = sizeof(struct sockaddr_storage);
|
||||
nread = recvfrom(sfd, buf, BUF_SIZE, 0,
|
||||
(struct sockaddr *) &peer_addr, &peer_addr_len);
|
||||
if (nread == -1)
|
||||
if (nread == \-1)
|
||||
continue; /* Ignore failed request */
|
||||
|
||||
char host[NI_MAXHOST], service[NI_MAXSERV];
|
||||
|
@ -596,13 +596,13 @@ main(int argc, char *argv[])
|
|||
If socket() (or connect()) fails, we (close the socket
|
||||
and) try the next address. */
|
||||
|
||||
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||
sfd = socket(rp->ai_family, rp->ai_socktype,
|
||||
rp->ai_protocol);
|
||||
if (sfd == -1)
|
||||
for (rp = result; rp != NULL; rp = rp\->ai_next) {
|
||||
sfd = socket(rp\->ai_family, rp\->ai_socktype,
|
||||
rp\->ai_protocol);
|
||||
if (sfd == \-1)
|
||||
continue;
|
||||
|
||||
if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1)
|
||||
if (connect(sfd, rp\->ai_addr, rp\->ai_addrlen) != \-1)
|
||||
break; /* Success */
|
||||
|
||||
close(sfd);
|
||||
|
@ -615,7 +615,7 @@ main(int argc, char *argv[])
|
|||
|
||||
freeaddrinfo(result); /* No longer needed */
|
||||
|
||||
/* Send remaining command-line arguments as separate
|
||||
/* Send remaining command\-line arguments as separate
|
||||
datagrams, and read responses from server */
|
||||
|
||||
for (j = 3; j < argc; j++) {
|
||||
|
@ -634,7 +634,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
nread = read(sfd, buf, BUF_SIZE);
|
||||
if (nread == -1) {
|
||||
if (nread == \-1) {
|
||||
perror("read");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -146,11 +146,11 @@ main(void)
|
|||
i = getgrent_r(&grp, buf, BUFLEN, &grpp);
|
||||
if (i)
|
||||
break;
|
||||
printf("%s (%d):", grpp->gr_name, grpp->gr_gid);
|
||||
printf("%s (%d):", grpp\->gr_name, grpp\->gr_gid);
|
||||
for (i = 0; ; i++) {
|
||||
if (grpp->gr_mem[i] == NULL)
|
||||
if (grpp\->gr_mem[i] == NULL)
|
||||
break;
|
||||
printf(" %s", grpp->gr_mem[i]);
|
||||
printf(" %s", grpp\->gr_mem[i]);
|
||||
}
|
||||
printf("\en");
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ main(void)
|
|||
if (pw == NULL)
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
if (getgrouplist(user, pw->pw_gid, NULL, &ng) < 0) {
|
||||
if (getgrouplist(user, pw\->pw_gid, NULL, &ng) < 0) {
|
||||
groups = (gid_t *) malloc(ng * sizeof (gid_t));
|
||||
getgrouplist(user, pw->pw_gid, groups, &ng);
|
||||
getgrouplist(user, pw\->pw_gid, groups, &ng);
|
||||
}
|
||||
|
||||
for (i = 0; i < ng; i++)
|
||||
|
|
|
@ -205,7 +205,7 @@ a particular address family.
|
|||
struct sockaddr *sa; /* input */
|
||||
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
|
||||
|
||||
if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf,
|
||||
if (getnameinfo(sa, sa\->sa_len, hbuf, sizeof(hbuf), sbuf,
|
||||
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0)
|
||||
printf("host=%s, serv=%s\en", hbuf, sbuf);
|
||||
.fi
|
||||
|
@ -219,7 +219,7 @@ reverse address mapping.
|
|||
struct sockaddr *sa; /* input */
|
||||
char hbuf[NI_MAXHOST];
|
||||
|
||||
if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf),
|
||||
if (getnameinfo(sa, sa\->sa_len, hbuf, sizeof(hbuf),
|
||||
NULL, 0, NI_NAMEREQD))
|
||||
printf("could not resolve hostname");
|
||||
else
|
||||
|
@ -250,7 +250,7 @@ RFC\ 2553, March 1999.
|
|||
Tatsuya Jinmei and Atsushi Onoe,
|
||||
.IR "An Extension of Format for IPv6 Scoped Addresses" ,
|
||||
internet draft, work in progress.
|
||||
ftp://ftp.ietf.org/internet-drafts/draft-ietf-ipngwg-scopedaddr-format-02.txt
|
||||
ftp://ftp.ietf.org/internet\-drafts/draft\-ietf\-ipngwg\-scopedaddr\-format\-02.txt
|
||||
.LP
|
||||
Craig Metz,
|
||||
.IR "Protocol Independence Using the Sockets API" ,
|
||||
|
|
|
@ -346,7 +346,7 @@ main(int argc, char *argv[])
|
|||
nsecs = 0;
|
||||
tfnd = 0;
|
||||
flags = 0;
|
||||
while ((opt = getopt(argc, argv, "nt:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "nt:")) != \-1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
flags = 1;
|
||||
|
@ -356,7 +356,7 @@ main(int argc, char *argv[])
|
|||
tfnd = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\\n",
|
||||
fprintf(stderr, "Usage: %s [\-t nsecs] [\-n] name\\n",
|
||||
argv[1]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ main(int argc, char **argv)
|
|||
case '1':
|
||||
case '2':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf("digits occur in two different argv-elements.\\n");
|
||||
printf("digits occur in two different argv\-elements.\\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf("option %c\\n", c);
|
||||
break;
|
||||
|
@ -452,7 +452,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (optind < argc) {
|
||||
printf("non-option ARGV-elements: ");
|
||||
printf("non\-option ARGV\-elements: ");
|
||||
while (optind < argc)
|
||||
printf("%s ", argv[optind++]);
|
||||
printf("\\n");
|
||||
|
|
|
@ -148,8 +148,8 @@ main(void)
|
|||
i = getpwent_r(&pw, buf, BUFLEN, &pwp);
|
||||
if (i)
|
||||
break;
|
||||
printf("%s (%d)\etHOME %s\etSHELL %s\en", pwp->pw_name,
|
||||
pwp->pw_uid, pwp->pw_dir, pwp->pw_shell);
|
||||
printf("%s (%d)\etHOME %s\etSHELL %s\en", pwp\->pw_name,
|
||||
pwp\->pw_uid, pwp\->pw_dir, pwp\->pw_shell);
|
||||
}
|
||||
endpwent();
|
||||
exit(EXIT_SUCCESS);
|
||||
|
|
|
@ -122,7 +122,7 @@ overwrites any commas it finds in the string
|
|||
.RI * optionp ,
|
||||
that string must be writable; it cannot be a string constant.
|
||||
.SH EXAMPLE
|
||||
The following program excepts suboptions following a "-o" option.
|
||||
The following program excepts suboptions following a "\-o" option.
|
||||
|
||||
.nf
|
||||
#define _XOPEN_SOURCE 500
|
||||
|
@ -152,7 +152,7 @@ int main(int argc, char **argv)
|
|||
char *name = NULL;
|
||||
int errfnd = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "o:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "o:")) != \-1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
subopts = optarg;
|
||||
|
@ -198,7 +198,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (errfnd || argc == 1) {
|
||||
fprintf(stderr, "\\nUsage: %s -o <suboptstring>\\n", argv[0]);
|
||||
fprintf(stderr, "\\nUsage: %s \-o <suboptstring>\\n", argv[0]);
|
||||
fprintf(stderr, "suboptions are 'ro', 'rw', "
|
||||
"and 'name=<value>'\\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
@ -177,7 +177,7 @@ char *data[] = { "alpha", "bravo", "charlie", "delta",
|
|||
"echo", "foxtrot", "golf", "hotel", "india", "juliet",
|
||||
"kilo", "lima", "mike", "november", "oscar", "papa",
|
||||
"quebec", "romeo", "sierra", "tango", "uniform",
|
||||
"victor", "whisky", "x-ray", "yankee", "zulu"
|
||||
"victor", "whisky", "x\-ray", "yankee", "zulu"
|
||||
};
|
||||
|
||||
int
|
||||
|
@ -206,7 +206,7 @@ main(void)
|
|||
e.key = data[i];
|
||||
ep = hsearch(e, FIND);
|
||||
printf("%9.9s \-> %9.9s:%d\\n", e.key,
|
||||
ep ? ep\->key : "NULL", ep ? (int)(ep->data) : 0);
|
||||
ep ? ep\->key : "NULL", ep ? (int)(ep\->data) : 0);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ func1(void)
|
|||
{
|
||||
printf("func1: started\\n");
|
||||
printf("func1: swapcontext(&uctx_func1, &uctx_func2)\\n");
|
||||
if (swapcontext(&uctx_func1, &uctx_func2) == -1)
|
||||
if (swapcontext(&uctx_func1, &uctx_func2) == \-1)
|
||||
die("swapcontext");
|
||||
printf("func1: returning\\n");
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ func2(void)
|
|||
{
|
||||
printf("func2: started\\n");
|
||||
printf("func2: swapcontext(&uctx_func2, &uctx_func1)\\n");
|
||||
if (swapcontext(&uctx_func2, &uctx_func1) == -1)
|
||||
if (swapcontext(&uctx_func2, &uctx_func1) == \-1)
|
||||
die("swapcontext");
|
||||
printf("func2: returning\\n");
|
||||
}
|
||||
|
@ -160,14 +160,14 @@ main(int argc, char *argv[])
|
|||
char func1_stack[16384];
|
||||
char func2_stack[16384];
|
||||
|
||||
if (getcontext(&uctx_func1) == -1)
|
||||
if (getcontext(&uctx_func1) == \-1)
|
||||
die("getcontext");
|
||||
uctx_func1.uc_stack.ss_sp = func1_stack;
|
||||
uctx_func1.uc_stack.ss_size = sizeof(func1_stack);
|
||||
uctx_func1.uc_link = &uctx_main;
|
||||
makecontext(&uctx_func1, func1, 0);
|
||||
|
||||
if (getcontext(&uctx_func2) == -1)
|
||||
if (getcontext(&uctx_func2) == \-1)
|
||||
die("getcontext");
|
||||
uctx_func2.uc_stack.ss_sp = func2_stack;
|
||||
uctx_func2.uc_stack.ss_size = sizeof(func2_stack);
|
||||
|
@ -176,7 +176,7 @@ main(int argc, char *argv[])
|
|||
makecontext(&uctx_func2, func2, 0);
|
||||
|
||||
printf("main: swapcontext(&uctx_main, &uctx_func2)\\n");
|
||||
if (swapcontext(&uctx_main, &uctx_func2) == -1)
|
||||
if (swapcontext(&uctx_main, &uctx_func2) == \-1)
|
||||
die("swapcontext");
|
||||
|
||||
printf("main: exiting\\n");
|
||||
|
|
|
@ -215,12 +215,15 @@ tfunc(union sigval sv)
|
|||
|
||||
/* Determine max. msg size; allocate buffer to receive msg */
|
||||
|
||||
if (mq_getattr(mqdes, &attr) == -1) die("mq_getattr");
|
||||
if (mq_getattr(mqdes, &attr) == \-1)
|
||||
die("mq_getattr");
|
||||
buf = malloc(attr.mq_msgsize);
|
||||
if (buf == NULL) die("malloc");
|
||||
if (buf == NULL)
|
||||
die("malloc");
|
||||
|
||||
nr = mq_receive(mqdes, buf, attr.mq_msgsize, NULL);
|
||||
if (nr == -1) die("mq_receive");
|
||||
if (nr == \-1)
|
||||
die("mq_receive");
|
||||
|
||||
printf("Read %ld bytes from MQ\\n", (long) nr);
|
||||
free(buf);
|
||||
|
@ -236,13 +239,15 @@ main(int argc, char *argv[])
|
|||
assert(argc == 2);
|
||||
|
||||
mqdes = mq_open(argv[1], O_RDONLY);
|
||||
if (mqdes == (mqd_t) -1) die("mq_open");
|
||||
if (mqdes == (mqd_t) \-1)
|
||||
die("mq_open");
|
||||
|
||||
not.sigev_notify = SIGEV_THREAD;
|
||||
not.sigev_notify_function = tfunc;
|
||||
not.sigev_notify_attributes = NULL;
|
||||
not.sigev_value.sival_ptr = &mqdes; /* Arg. to thread func. */
|
||||
if (mq_notify(mqdes, ¬) == -1) die("mq_notify");
|
||||
if (mq_notify(mqdes, ¬) == \-1)
|
||||
die("mq_notify");
|
||||
|
||||
pause(); /* Process will be terminated by thread function */
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ main(int argc, char *argv[])
|
|||
|
||||
assert(argc > 1);
|
||||
|
||||
qsort(&argv[1], argc - 1, sizeof(char *), cmpstringp);
|
||||
qsort(&argv[1], argc \- 1, sizeof(char *), cmpstringp);
|
||||
|
||||
for (j = 1; j < argc; j++)
|
||||
puts(argv[j]);
|
||||
|
|
|
@ -239,8 +239,8 @@ LIST_INSERT_HEAD(&head, n1, entries);
|
|||
n2 = malloc(sizeof(struct entry)); /* Insert after. */
|
||||
LIST_INSERT_AFTER(n1, n2, entries);
|
||||
/* Forward traversal. */
|
||||
for (np = head.lh_first; np != NULL; np = np->entries.le_next)
|
||||
np-> ...
|
||||
for (np = head.lh_first; np != NULL; np = np\->entries.le_next)
|
||||
np\-> ...
|
||||
|
||||
while (head.lh_first != NULL) /* Delete. */
|
||||
LIST_REMOVE(head.lh_first, entries);
|
||||
|
|
|
@ -107,7 +107,7 @@ is applied to the string given in the program's command-line argument.
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2 || strcmp(argv[1], "--help") == 0) {
|
||||
if (argc != 2 || strcmp(argv[1], "\-\-help") == 0) {
|
||||
fprintf(stderr, "%s response\\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ main(void)
|
|||
memset((char *) &name, 0, sizeof(name));
|
||||
sethostent(1);
|
||||
hent = gethostbyname(servername);
|
||||
memcpy((char *) &name.sin_addr, hent->h_addr, hent->h_length);
|
||||
memcpy((char *) &name.sin_addr, hent\->h_addr, hent\->h_length);
|
||||
|
||||
ret = rtime(&name, &time1, use_tcp ? NULL : &timeout);
|
||||
if (ret < 0)
|
||||
|
|
|
@ -104,9 +104,9 @@ Creating a rtnetlink message to set the MTU of a device:
|
|||
req.if.ifi_index = INTERFACE_INDEX;
|
||||
req.if.ifi_change = 0xffffffff; /* ???*/
|
||||
rta = (struct rtattr *)(((char *) &req) +
|
||||
NLMSG_ALIGN(n->nlmsg_len));
|
||||
rta->rta_type = IFLA_MTU;
|
||||
rta->rta_len = sizeof(unsigned int);
|
||||
NLMSG_ALIGN(n\->nlmsg_len));
|
||||
rta\->rta_type = IFLA_MTU;
|
||||
rta\->rta_len = sizeof(unsigned int);
|
||||
req.n.nlmsg_len = NLMSG_ALIGN(req.n.nlmsg_len) +
|
||||
RTA_LENGTH(sizeof(mtu));
|
||||
memcpy(RTA_DATA(rta), &mtu, sizeof(mtu));
|
||||
|
|
|
@ -193,10 +193,10 @@ handler(int sig)
|
|||
int sval;
|
||||
|
||||
printf("sem_post() from handler\\n");
|
||||
if (sem_post(&sem) == -1)
|
||||
if (sem_post(&sem) == \-1)
|
||||
die("sem_post");
|
||||
|
||||
if (sem_getvalue(&sem, &sval) == -1)
|
||||
if (sem_getvalue(&sem, &sval) == \-1)
|
||||
die("sem_getvalue");
|
||||
printf("sem_getvalue() from handler; value = %d\\n", sval);
|
||||
} /* handler */
|
||||
|
@ -208,9 +208,9 @@ main(int argc, char *argv[])
|
|||
struct timespec ts;
|
||||
int s;
|
||||
|
||||
assert(argc == 3); /* Usage: ./a.out alarm-secs wait-secs */
|
||||
assert(argc == 3); /* Usage: ./a.out alarm\-secs wait\-secs */
|
||||
|
||||
if (sem_init(&sem, 0, 0) == -1)
|
||||
if (sem_init(&sem, 0, 0) == \-1)
|
||||
die("sem_init");
|
||||
|
||||
/* Establish SIGALRM handler; set alarm timer using argv[1] */
|
||||
|
@ -218,7 +218,7 @@ main(int argc, char *argv[])
|
|||
sa.sa_handler = handler;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &sa, NULL) == -1)
|
||||
if (sigaction(SIGALRM, &sa, NULL) == \-1)
|
||||
die("sigaction");
|
||||
|
||||
alarm(atoi(argv[1]));
|
||||
|
@ -226,17 +226,17 @@ main(int argc, char *argv[])
|
|||
/* Calculate relative interval as current time plus
|
||||
number of seconds given argv[2] */
|
||||
|
||||
if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
|
||||
if (clock_gettime(CLOCK_REALTIME, &ts) == \-1)
|
||||
die("clock_gettime");
|
||||
ts.tv_sec += atoi(argv[2]);
|
||||
|
||||
printf("main() about to call sem_timedwait()\\n");
|
||||
while ((s = sem_timedwait(&sem, &ts)) == -1 && errno == EINTR)
|
||||
while ((s = sem_timedwait(&sem, &ts)) == \-1 && errno == EINTR)
|
||||
continue; /* Restart when interrupted by handler */
|
||||
|
||||
/* Check what happened */
|
||||
|
||||
if (s == -1) {
|
||||
if (s == \-1) {
|
||||
if (errno == ETIMEDOUT)
|
||||
printf("sem_timedwait() timed out\\n");
|
||||
else
|
||||
|
|
|
@ -126,7 +126,7 @@ main(void)
|
|||
al = getaliasent();
|
||||
if (al == NULL)
|
||||
break;
|
||||
printf("Name: %s\\n", al->alias_name);
|
||||
printf("Name: %s\\n", al\->alias_name);
|
||||
}
|
||||
if (errno) {
|
||||
perror("reading alias");
|
||||
|
|
|
@ -98,7 +98,7 @@ and then read the byte of data at the mark:
|
|||
break;
|
||||
|
||||
s = read(fd, buf, BUF_LEN) <= 0);
|
||||
if (s == -1)
|
||||
if (s == \-1)
|
||||
perror("read");
|
||||
if (s <= 0)
|
||||
break;
|
||||
|
|
|
@ -366,7 +366,7 @@ main(void)
|
|||
struct tm tm;
|
||||
char buf[255];
|
||||
|
||||
strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
|
||||
strptime("2001\-11\-12 18:31:01", "%Y\-%m\-%d %H:%M:%S", &tm);
|
||||
strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm);
|
||||
puts(buf);
|
||||
exit(EXIT_SUCCESS);
|
||||
|
|
|
@ -160,7 +160,7 @@ main(int argc, char *argv[])
|
|||
subtoken = strtok_r(str2, argv[3], &saveptr2);
|
||||
if (subtoken == NULL)
|
||||
break;
|
||||
printf("\t --> %s\\n", subtoken);
|
||||
printf("\t \-\-> %s\\n", subtoken);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,13 +173,13 @@ An example of the output produced by this program is the following:
|
|||
.nf
|
||||
$ ./a.out 'a/bbb///cc;xxx:yyy:' ':;' '/'
|
||||
1: a/bbb///cc
|
||||
--> a
|
||||
--> bbb
|
||||
--> cc
|
||||
\-\-> a
|
||||
\-\-> bbb
|
||||
\-\-> cc
|
||||
2: xxx
|
||||
--> xxx
|
||||
\-\-> xxx
|
||||
3: yyy
|
||||
--> yyy
|
||||
\-\-> yyy
|
||||
.fi
|
||||
.SH "SEE ALSO"
|
||||
.BR index (3),
|
||||
|
|
|
@ -403,16 +403,16 @@ in order to reliably track acknowledgements.
|
|||
.nf
|
||||
struct nlmsghdr *nh; /* The nlmsghdr with payload to send. */
|
||||
struct sockaddr_nl sa;
|
||||
struct iovec iov = { (void *) nh, nh->nlmsg_len };
|
||||
struct iovec iov = { (void *) nh, nh\->nlmsg_len };
|
||||
struct msghdr msg;
|
||||
|
||||
msg = { (void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0 };
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.nl_family = AF_NETLINK;
|
||||
nh->nlmsg_pid = 0;
|
||||
nh->nlmsg_seq = ++sequence_number;
|
||||
nh\->nlmsg_pid = 0;
|
||||
nh\->nlmsg_seq = ++sequence_number;
|
||||
/* Request an ack from kernel by setting NLM_F_ACK. */
|
||||
nh->nlmsg_flags |= NLM_F_ACK;
|
||||
nh\->nlmsg_flags |= NLM_F_ACK;
|
||||
|
||||
sendmsg(fd, &msg, 0);
|
||||
.fi
|
||||
|
|
Loading…
Reference in New Issue