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
|
$NetBSD: patch-ag,v 1.1.1.1 1998/12/03 15:08:53 frueauf Exp $
--- xispdial.c.orig Mon Oct 26 05:35:01 1998
+++ xispdial.c Tue Dec 1 03:01:28 1998
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <varargs.h>
+#include <sys/param.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
@@ -93,13 +94,13 @@
{
char emsg[MSGLEN_ERR];
-#ifndef SUNOS5x
+#ifdef HAVE_STRERROR
+ sprintf(emsg, "xispdial: %s: %s\n", msg, strerror(errno));
+#else
if (errno < sys_nerr)
sprintf(emsg, "xispdial: %s: %s\n", msg, sys_errlist[errno]);
else
sprintf(emsg, "xispdial: %s: error #%d\n", msg, errno);
-#else
- sprintf(emsg, "xispdial: %s: %s\n", msg, strerror(errno));
#endif
fputs(emsg, stderr);
if (pipeFD) close(pipeFD);
@@ -121,10 +122,12 @@
if (!S_ISFIFO(st.st_mode)) /* is it a FIFO? */
doErr("namedPipe: stat"); /* nope, still not right! */
}
-#ifndef SUNOS5x
- fd = open(fname, O_WRONLY|O_NDELAY); /* yes, open it for writing */
-#else
+#ifdef SUNOS5x
fd = open(fname, O_WRONLY|O_NONBLOCK); /* yes, open it for writing */
+#elif (defined(BSD) && BSD >= 199306)
+ fd = open(fname, O_WRONLY|O_NONBLOCK); /* yes, open it for writing */
+#else
+ fd = open(fname, O_WRONLY|O_NDELAY); /* yes, open it for writing */
#endif
if (fd < 0) /* error means no process has */
doErr("namedPipe: open"); /* opened it for reading */
@@ -145,11 +148,11 @@
va_start(ap); /* start variable arg list */
fmt = va_arg(ap, char*); /* first string is format */
-#ifndef SUNOS41x
- iw = vsprintf(msg, fmt, ap); /* pass rest to vsprintf() */
-#else
+#ifdef BROKEN_VSPRINTF
vsprintf(msg, fmt, ap);
iw = strlen(msg);
+#else
+ iw = vsprintf(msg, fmt, ap); /* pass rest to vsprintf() */
#endif
va_end(ap); /* end variable arg list */
bw = write(pipeFD, msg, strlen(msg)); /* write buffer to pipe */
@@ -255,19 +258,19 @@
for (p=param; *p;) { /* scan the line */
if (*p == '\\') { /* if a '\\' is found */
if (escape) { /* if auto escaping selected */
-#ifndef SUNOS41x
- memmove(p+1, p, zlen); /* increase string len by 1 */
+#ifdef SUNOS41x
+ bcopy(p, p+1, zlen) /* increase string len by 1 */;
#else /* by duplicating the string */
- bcopy(p, p+1, zlen); /* contents starting from */
+ memmove(p+1, p, zlen); /* contents starting from */
#endif /* next character position */
*p = '\\'; /* insert an extra '\\' */
p += 2; /* skip the next '\\' */
}
else { /* deletion of '\\'s desired */
-#ifndef SUNOS41x
- memmove(p, p+1, zlen); /* decrease string len by 1 */
+#ifdef SUNOS41x
+ bcopy(p+1, p, zlen); /* decrease string len by 1 */
#else
- bcopy(p+1, p, zlen);
+ memmove(p, p+1, zlen);
#endif
}
}
|