$NetBSD: patch-af,v 1.1.1.1 1998/12/03 15:08:53 frueauf Exp $

--- xisp.c.orig	Mon Oct 26 05:35:01 1998
+++ xisp.c	Tue Dec  1 04:02:05 1998
@@ -299,13 +299,13 @@
 {
 	char emsg[MSGLEN_ERR+1];
 
-#ifndef SUNOS5x
+#ifdef HAVE_STRERROR
+	sprintf(emsg, "xISP: %s: %s\n", msg, strerror(errno));
+#else
 	if (errno < sys_nerr)
 		sprintf(emsg, "xISP: %s: %s\n", msg, sys_errlist[errno]);
 	else
 		sprintf(emsg, "xISP: %s: error #%d\n", msg, errno);
-#else
-	sprintf(emsg, "xISP: %s: %s\n", msg, strerror(errno));
 #endif
 	fputs(emsg, stderr);
 	exit(1);
@@ -497,13 +497,20 @@
 					global.pipePath, global.pipePath);
 			exit(1);
 		}
+#if (defined(BSD) && BSD >= 199306)
+		if (mkfifo(Pipe, 0600))				/* directory is OK, so */
+			doErr("namedPipe: mkfifo");			/* create the FIFO node */
+#else
 		if (mknod(Pipe, S_IFIFO+0600, 0))		/* directory is OK, so */
 			doErr("namedPipe: mknod");			/* create the FIFO node */
+#endif
 	}
-#ifndef SUNOS5x
-	fd = open(fname, O_RDONLY|O_NDELAY);		/* and open it for reading */
-#else
+#ifdef SUNOS5x
+	fd = open(fname, O_RDONLY|O_NONBLOCK);		/* and open it for reading */
+#elif (defined(BSD) && BSD >= 199306)
 	fd = open(fname, O_RDONLY|O_NONBLOCK);		/* and open it for reading */
+#else
+	fd = open(fname, O_RDONLY|O_NDELAY);		/* and open it for reading */
 #endif
 	if (fd < 0)									/* bail out on error */
 		doErr("namedPipe: open");
@@ -568,11 +575,11 @@
 
 	va_start(ap);								/* start variable arg list */
 	fmt = va_arg(ap, char*);					/* first string is format */
-#ifndef SUNOS41x
-	bw = vsprintf(btmp, fmt, ap);				/* pass the rest to vsprintf */
-#else
+#ifdef BROKEN_VSPRINTF
 	vsprintf(btmp, fmt, ap);
 	bw = strlen(btmp);
+#else
+	bw = vsprintf(btmp, fmt, ap);				/* pass the rest to vsprintf */
 #endif
 	va_end(ap);									/* end variable arg list */
 	if ((tot+bw) < (MSGLEN_BROWSER-1))			/* do we have space for new? */
@@ -959,7 +966,7 @@
    allow_detached is set, then init's PID (i.e., 1) is also considered
    a valid parent PID. */
 
-#if !defined(SUNOS41x) && !defined(SUNOS5x)
+#if !defined(SUNOS41x) && !defined(SUNOS5x) && !(defined(BSD) && BSD >= 199306)
 int procPID(char *procname, int parentPID, int allow_detached)
 {
 	DIR *procd;
@@ -1015,6 +1022,8 @@
 
 #ifdef SUNOS41x
 	infofp = popen("/bin/ps -aclxw", "r");		/* open proc info stream */
+#elif (defined(BSD) && BSD >= 199306)
+	infofp = popen("/bin/ps -aclxw", "r");		/* open proc info stream */
 #else
 	infofp = popen("/bin/ps -el", "r");			/* open proc info stream */
 #endif
@@ -1026,6 +1035,10 @@
 		if (sscanf(psLine, "%*s %*s %d %d %*s"
 				" %*s %*s %*s %*s %*s %*s %*s"
 				" %*s %s", &pid, &ppid, name))
+#elif (defined(BSD) && BSD >= 199306)
+		if (sscanf(psLine, "%*s %d %d %*s"
+				" %*s %*s %*s %*s %*s %*s %*s"
+				" %*s %s", &pid, &ppid, name))
 #else
 		if (sscanf(psLine, "%*s %*s %*s %d %d"
 				" %*s %*s %*s %*s %*s %*s %*s"
@@ -1358,11 +1371,11 @@
 
 	va_start(ap);
 	fmt = va_arg(ap, char*);
-#ifndef SUNOS41x
-	bw = vsprintf(buf, fmt, ap);
-#else
+#ifdef BROKEN_VSPRINTF
 	vsprintf(buf, fmt, ap);
 	bw = strlen(buf);
+#else
+	bw = vsprintf(buf, fmt, ap);
 #endif
 	va_end(ap);
 	fl_addto_browser(fd_logInfo->costBrowser, buf);
@@ -1650,10 +1663,10 @@
 	strcat(res, "...");
 	len += 3;
 	while (swidth > hsize && len > 3) {
-#ifndef SUNOS41x
-		memmove(&res[len-5], &res[len-3], 4);
-#else
+#ifdef SUNOS41x
 		bcopy(&res[len-3], &res[len-5], 4);
+#else
+		memmove(&res[len-5], &res[len-3], 4);
 #endif
 		len = strlen(res);
 		swidth = fl_get_string_width(FL_NORMAL_STYLE, FL_NORMAL_SIZE,
@@ -2370,10 +2383,10 @@
 			if (dialWait) dialWait = 0;			/* no more waiting */
 		}
 		else if (br < 0) {						/* read failed */
-#ifndef SUNOS41x
-			if (errno != EAGAIN)				/* pipe output unavailable? */
+#ifdef SUNOS41x
+			if (errno != EWOULDBLOCK)			/* pipe output unavailable? */
 #else
-			if (errno != EWOULDBLOCK)
+			if (errno != EAGAIN)
 #endif
 				doErr("doBUpdate: read");		/* no, abort with diagnostic */
 			fl_set_timer(btimer, BU_INTERVAL);	/* yes, restart timer */
@@ -2430,10 +2443,10 @@
 			fl_set_timer(btimer, BU_INTERVAL);	/* and restart timer */
 		}
 		else if (br < 0) {						/* read failed */
-#ifndef SUNOS41x
-			if (errno != EAGAIN)				/* pipe output unavailable? */
+#ifdef SUNOS41x
+			if (errno != EWOULDBLOCK)			/* pipe output unavailable? */
 #else
-			if (errno != EWOULDBLOCK)
+			if (errno != EAGAIN)
 #endif
 				doErr("doBUpdate: read");		/* no, abort with diagnostic */
 			fl_set_timer(btimer, BU_INTERVAL);	/* yes, restart timer */
@@ -2476,10 +2489,10 @@
 			fl_set_timer(btimer, BU_INTERVAL);	/* and restart timer */
 		}
 		else if (br < 0) {						/* read failed */
-#ifndef SUNOS41x
-			if (errno != EAGAIN)				/* pipe output unavailable? */
+#ifdef SUNOS41x
+			if (errno != EWOULDBLOCK)			/* pipe output unavailable? */
 #else
-			if (errno != EWOULDBLOCK)
+			if (errno != EAGAIN)
 #endif
 				doErr("doBUpdate: read");		/* no, abort with diagnostic */
 			fl_set_timer(btimer, BU_INTERVAL);	/* yes, restart timer */
@@ -3590,10 +3603,10 @@
 	if (a->cur < global.numISPs) {
 		p_dest = &xispOptions[a->cur];
 		p_src = &xispOptions[(a->cur)+1];
-#ifndef SUNOS41x
-		memmove(p_dest, p_src, (global.numISPs-(a->cur))*sizeof(xisprc_t));
-#else
+#ifdef SUNOS41x
 		bcopy(p_src, p_dest, (global.numISPs-(a->cur))*sizeof(xisprc_t));
+#else
+		memmove(p_dest, p_src, (global.numISPs-(a->cur))*sizeof(xisprc_t));
 #endif
 	}
 	else
@@ -5330,10 +5343,10 @@
 	if (sPTT < (global.numPTTs-1)) {
 		p_dest = &ptt[sPTT];
 		p_src = &ptt[sPTT+1];
-#ifndef SUNOS41x
-		memmove(p_dest, p_src, (global.numPTTs-sPTT-1)*sizeof(ptt_t));
-#else
+#ifdef SUNOS41x
 		bcopy(p_src, p_dest, (global.numPTTs-sPTT-1)*sizeof(ptt_t));
+#else
+		memmove(p_dest, p_src, (global.numPTTs-sPTT-1)*sizeof(ptt_t));
 #endif
 	}
 	else {
@@ -6710,10 +6723,10 @@
 	fontSelect();									/* select desired fonts */
 	(void) pppdVersion();							/* check pppd version */
 
-#ifndef SUNOS41x
-	atexit(exitCleanup);							/* register cleanup proc */
-#else
+#ifdef SUNOS41x
 	on_exit(exitCleanup, 0);
+#else
+	atexit(exitCleanup);							/* register cleanup proc */
 #endif
 	recordPID();									/* check/write PID file */
 
