- Use the included S-Lang again, since we include a better version now.
[midnight-commander.git] / src / utilunix.c
bloba819c006b2e7aff013b7a3ee8a27b76163ac101d
1 /* Various utilities - Unix variants
2 Copyright (C) 1994, 1995, 1996 the Free Software Foundation.
3 Written 1994, 1995, 1996 by:
4 Miguel de Icaza, Janne Kukonlehto, Dugan Porter,
5 Jakub Jelinek, Mauricio Plaza.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #include <config.h>
22 #include <stdio.h>
23 #include <sys/types.h>
24 #ifdef HAVE_UNISTD_H
25 # include <unistd.h>
26 #endif
27 #include <signal.h> /* my_system */
28 #include <limits.h> /* INT_MAX */
29 #include <sys/stat.h>
30 #include <stdarg.h>
31 #include <errno.h> /* my_system */
32 #include <string.h>
33 #include <ctype.h>
34 #ifdef HAVE_SYS_IOCTL_H
35 # include <sys/ioctl.h>
36 #endif
38 #include "global.h"
39 #include "fsusage.h"
40 #include "mountlist.h"
41 #include "dialog.h" /* message() */
42 #include "../vfs/vfs.h" /* mc_read() */
44 struct sigaction startup_handler;
46 /* uid of the MC user */
47 static uid_t current_user_uid = -1;
48 /* List of the gids of the user */
49 static GTree *current_user_gid = NULL;
51 /* Helper function to compare 2 gids */
52 static gint
53 mc_gid_compare (gconstpointer v, gconstpointer v2)
55 return ((GPOINTER_TO_UINT(v) > GPOINTER_TO_UINT(v2)) ? 1 :
56 (GPOINTER_TO_UINT(v) < GPOINTER_TO_UINT(v2)) ? -1 : 0);
59 /* Helper function to delete keys of the gids tree */
60 static gint
61 mc_gid_destroy (gpointer key, gpointer value, gpointer data)
63 g_free (value);
65 return FALSE;
68 /* This function initialize global GTree with the gids of groups,
69 to which user belongs. Tree also store corresponding string
70 with the name of the group.
71 FIXME: Do we need this names at all? If not, we can simplify
72 initialization by eliminating g_strdup's.
74 void init_groups (void)
76 int i;
77 struct passwd *pwd;
78 struct group *grp;
80 current_user_uid = getuid ();
81 pwd = getpwuid (current_user_uid);
82 g_return_if_fail (pwd != NULL);
84 current_user_gid = g_tree_new (mc_gid_compare);
86 /* Put user's primary group first. */
87 if ((grp = getgrgid (pwd->pw_gid)) != NULL) {
88 g_tree_insert (current_user_gid,
89 GUINT_TO_POINTER ((int) grp->gr_gid),
90 g_strdup (grp->gr_name));
93 setgrent ();
94 while ((grp = getgrent ()) != NULL) {
95 for (i = 0; grp->gr_mem[i]; i++) {
96 if (!strcmp (pwd->pw_name, grp->gr_mem[i]) &&
97 !g_tree_lookup (current_user_gid,
98 GUINT_TO_POINTER ((int) grp->gr_gid))) {
99 g_tree_insert (current_user_gid,
100 GUINT_TO_POINTER ((int) grp->gr_gid),
101 g_strdup (grp->gr_name));
102 break;
106 endgrent ();
109 /* Return the index of the permissions triplet */
111 get_user_permissions (struct stat *buf) {
113 if (buf->st_uid == current_user_uid || current_user_uid == 0)
114 return 0;
116 if (current_user_gid && g_tree_lookup (current_user_gid,
117 GUINT_TO_POINTER((int) buf->st_gid)))
118 return 1;
120 return 2;
123 /* Completely destroys the gids tree */
124 void
125 destroy_groups (void)
127 g_tree_traverse (current_user_gid, mc_gid_destroy, G_POST_ORDER, NULL);
128 g_tree_destroy (current_user_gid);
131 #define UID_CACHE_SIZE 200
132 #define GID_CACHE_SIZE 30
134 typedef struct {
135 int index;
136 char *string;
137 } int_cache;
139 static int_cache uid_cache [UID_CACHE_SIZE];
140 static int_cache gid_cache [GID_CACHE_SIZE];
142 static char *i_cache_match (int id, int_cache *cache, int size)
144 int i;
146 for (i = 0; i < size; i++)
147 if (cache [i].index == id)
148 return cache [i].string;
149 return 0;
152 static void i_cache_add (int id, int_cache *cache, int size, char *text,
153 int *last)
155 if (cache [*last].string)
156 g_free (cache [*last].string);
157 cache [*last].string = g_strdup (text);
158 cache [*last].index = id;
159 *last = ((*last)+1) % size;
162 char *get_owner (int uid)
164 struct passwd *pwd;
165 static char ibuf [10];
166 char *name;
167 static int uid_last;
169 if ((name = i_cache_match (uid, uid_cache, UID_CACHE_SIZE)) != NULL)
170 return name;
172 pwd = getpwuid (uid);
173 if (pwd){
174 i_cache_add (uid, uid_cache, UID_CACHE_SIZE, pwd->pw_name, &uid_last);
175 return pwd->pw_name;
177 else {
178 g_snprintf (ibuf, sizeof (ibuf), "%d", uid);
179 return ibuf;
183 char *get_group (int gid)
185 struct group *grp;
186 static char gbuf [10];
187 char *name;
188 static int gid_last;
190 if ((name = i_cache_match (gid, gid_cache, GID_CACHE_SIZE)) != NULL)
191 return name;
193 grp = getgrgid (gid);
194 if (grp){
195 i_cache_add (gid, gid_cache, GID_CACHE_SIZE, grp->gr_name, &gid_last);
196 return grp->gr_name;
197 } else {
198 g_snprintf (gbuf, sizeof (gbuf), "%d", gid);
199 return gbuf;
203 /* Since ncurses uses a handler that automatically refreshes the */
204 /* screen after a SIGCONT, and we don't want this behavior when */
205 /* spawning a child, we save the original handler here */
206 void save_stop_handler (void)
208 sigaction (SIGTSTP, NULL, &startup_handler);
211 int my_system (int flags, const char *shell, const char *command)
213 struct sigaction ignore, save_intr, save_quit, save_stop;
214 pid_t pid;
215 int status = 0;
217 ignore.sa_handler = SIG_IGN;
218 sigemptyset (&ignore.sa_mask);
219 ignore.sa_flags = 0;
221 sigaction (SIGINT, &ignore, &save_intr);
222 sigaction (SIGQUIT, &ignore, &save_quit);
224 /* Restore the original SIGTSTP handler, we don't want ncurses' */
225 /* handler messing the screen after the SIGCONT */
226 sigaction (SIGTSTP, &startup_handler, &save_stop);
228 if ((pid = fork ()) < 0){
229 fprintf (stderr, "\n\nfork () = -1\n");
230 return -1;
232 if (pid == 0){
233 signal (SIGINT, SIG_DFL);
234 signal (SIGQUIT, SIG_DFL);
235 signal (SIGTSTP, SIG_DFL);
236 signal (SIGCHLD, SIG_DFL);
238 if (flags & EXECUTE_AS_SHELL)
239 execl (shell, shell, "-c", command, NULL);
240 else
241 execlp (shell, shell, command, NULL);
243 _exit (127); /* Exec error */
244 } else {
245 while (waitpid (pid, &status, 0) < 0)
246 if (errno != EINTR){
247 status = -1;
248 break;
251 sigaction (SIGINT, &save_intr, NULL);
252 sigaction (SIGQUIT, &save_quit, NULL);
253 sigaction (SIGTSTP, &save_stop, NULL);
255 #ifdef SCO_FLAVOR
256 waitpid(-1, NULL, WNOHANG);
257 #endif /* SCO_FLAVOR */
259 return WEXITSTATUS(status);
262 /* Returns a newly allocated string, if directory does not exist, return 0 */
263 char *tilde_expand (const char *directory)
265 struct passwd *passwd;
266 const char *p;
267 char *name;
269 if (*directory != '~')
270 return g_strdup (directory);
272 directory++;
274 p = strchr (directory, PATH_SEP);
276 /* d = "~" or d = "~/" */
277 if (!(*directory) || (*directory == PATH_SEP)){
278 passwd = getpwuid (geteuid ());
279 p = (*directory == PATH_SEP) ? directory+1 : "";
280 } else {
281 if (!p){
282 passwd = getpwnam (directory);
283 } else {
284 name = g_malloc (p - directory + 1);
285 strncpy (name, directory, p - directory);
286 name [p - directory] = 0;
287 passwd = getpwnam (name);
288 g_free (name);
292 /* If we can't figure the user name, return NULL */
293 if (!passwd)
294 return 0;
296 return g_strconcat (passwd->pw_dir, PATH_SEP_STR, p, NULL);
301 * Return the directory where mc should keep its temporary files.
302 * This directory is (in Bourne shell terms) "${TMPDIR=/tmp}-$USER"
303 * When called the first time, the directory is created if needed.
304 * The first call should be done early, since we are using fprintf()
305 * and not message() to report possible problems.
307 const char *
308 mc_tmpdir (void)
310 static char tmpdir[64];
311 const char *sys_tmp;
312 struct passwd *pwd;
314 if (*tmpdir)
315 return tmpdir;
317 sys_tmp = getenv ("TMPDIR");
318 if (!sys_tmp) {
319 sys_tmp = TMPDIR_DEFAULT;
322 pwd = getpwuid (getuid ());
323 g_snprintf (tmpdir, sizeof (tmpdir), "%s/mc-%s", sys_tmp,
324 pwd->pw_name);
325 canonicalize_pathname (tmpdir);
327 /* No recursion or VFS here. If $TMPDIR is missing, exit. */
328 if (mkdir (tmpdir, 0700) != 0 && errno != EEXIST) {
329 fprintf (stderr, _("Cannot create temporary directory %s: %s\n"),
330 tmpdir, unix_error_string (errno));
331 exit (1);
334 return tmpdir;
338 /* Pipes are guaranteed to be able to hold at least 4096 bytes */
339 /* More than that would be unportable */
340 #define MAX_PIPE_SIZE 4096
342 static int error_pipe[2]; /* File descriptors of error pipe */
343 static int old_error; /* File descriptor of old standard error */
345 /* Creates a pipe to hold standard error for a later analysis. */
346 /* The pipe can hold 4096 bytes. Make sure no more is written */
347 /* or a deadlock might occur. */
348 void open_error_pipe (void)
350 if (pipe (error_pipe) < 0){
351 message (0, _(" Warning "), _(" Pipe failed "));
353 old_error = dup (2);
354 if(old_error < 0 || close(2) || dup (error_pipe[1]) != 2){
355 message (0, _(" Warning "), _(" Dup failed "));
356 close (error_pipe[0]);
357 close (error_pipe[1]);
359 close (error_pipe[1]);
363 * Returns true if an error was displayed
364 * error: -1 - ignore errors, 0 - display warning, 1 - display error
365 * text is prepended to the error message from the pipe
368 close_error_pipe (int error, char *text)
370 char *title;
371 char msg[MAX_PIPE_SIZE];
372 int len = 0;
374 if (error)
375 title = MSG_ERROR;
376 else
377 title = _(" Warning ");
378 if (old_error >= 0){
379 close (2);
380 dup (old_error);
381 close (old_error);
382 len = read (error_pipe[0], msg, MAX_PIPE_SIZE);
384 if (len >= 0)
385 msg[len] = 0;
386 close (error_pipe[0]);
388 if (error < 0)
389 return 0; /* Just ignore error message */
390 if (text == NULL){
391 if (len <= 0)
392 return 0; /* Nothing to show */
394 /* Show message from pipe */
395 message (error, title, "%s", msg);
396 } else {
397 /* Show given text and possible message from pipe */
398 message (error, title, " %s \n %s ", text, msg);
400 return 1;
403 /* Checks for messages in the error pipe,
404 * closes the pipe and displays an error box if needed
406 void check_error_pipe (void)
408 char error[MAX_PIPE_SIZE];
409 int len = 0;
410 if (old_error >= 0){
411 while (len < MAX_PIPE_SIZE)
413 fd_set select_set;
414 struct timeval timeout;
415 FD_ZERO (&select_set);
416 FD_SET (error_pipe[0], &select_set);
417 timeout.tv_sec = 0;
418 timeout.tv_usec = 0;
419 select (error_pipe[0] + 1, &select_set, 0, 0, &timeout);
420 if (!FD_ISSET (error_pipe[0], &select_set))
421 break;
422 read (error_pipe[0], error + len, 1);
423 len ++;
425 error[len] = 0;
426 close (error_pipe[0]);
428 if (len > 0)
429 message (0, _(" Warning "), "%s", error);
432 static struct sigaction ignore, save_intr, save_quit, save_stop;
434 /* INHANDLE is a result of some mc_open call to any vfs, this function
435 returns a normal handle (to be used with read) of a pipe for reading
436 of the output of COMMAND with arguments ... (must include argv[0] as
437 well) which gets as its input at most INLEN bytes from the INHANDLE
438 using mc_read. You have to call mc_doublepclose to close the returned
439 handle afterwards. If INLEN is -1, we read as much as we can :) */
440 int mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...)
442 int pipe0 [2], pipe1 [2];
443 pid_t pid;
445 #define closepipes() close(pipe0[0]);close(pipe0[1]);close(pipe1[0]);close(pipe1[1])
447 pipe (pipe0); pipe (pipe1);
448 ignore.sa_handler = SIG_IGN;
449 sigemptyset (&ignore.sa_mask);
450 ignore.sa_flags = 0;
452 sigaction (SIGINT, &ignore, &save_intr);
453 sigaction (SIGQUIT, &ignore, &save_quit);
454 sigaction (SIGTSTP, &startup_handler, &save_stop);
456 switch (pid = fork ()) {
457 case -1:
458 closepipes ();
459 return -1;
460 case 0: {
461 sigaction (SIGINT, &save_intr, NULL);
462 sigaction (SIGQUIT, &save_quit, NULL);
463 switch (pid = fork ()) {
464 case -1:
465 closepipes ();
466 _exit (1);
467 case 0: {
468 #define MAXARGS 16
469 int argno;
470 char *args[MAXARGS];
471 va_list ap;
472 int nulldevice;
474 nulldevice = open ("/dev/null", O_WRONLY);
475 close (0);
476 dup (pipe0 [0]);
477 close (1);
478 dup (pipe1 [1]);
479 close (2);
480 dup (nulldevice);
481 close (nulldevice);
482 closepipes ();
483 va_start (ap, command);
484 argno = 0;
485 while ((args[argno++] = va_arg(ap, char *)) != NULL)
486 if (argno == (MAXARGS - 1)) {
487 args[argno] = NULL;
488 break;
490 va_end (ap);
491 execvp (command, args);
493 /* If we are here exec has failed */
494 _exit (0);
496 default:
498 char buffer [8192];
499 int i;
501 close (pipe0 [0]);
502 close (pipe1 [0]);
503 close (pipe1 [1]);
504 while ((i = mc_read (inhandle, buffer,
505 (inlen == -1 || inlen > 8192)
506 ? 8192 : inlen)) > 0) {
507 write (pipe0 [1], buffer, i);
508 if (inlen != -1) {
509 inlen -= i;
510 if (!inlen)
511 break;
514 close (inhandle);
515 close (pipe0 [1]);
516 while (waitpid (pid, &i, 0) < 0)
517 if (errno != EINTR)
518 break;
520 _exit (i);
524 default:
525 *the_pid = pid;
526 break;
528 close (pipe0 [0]);
529 close (pipe0 [1]);
530 close (pipe1 [1]);
531 return pipe1 [0];
534 int mc_doublepclose (int pipe, pid_t pid)
536 int status = 0;
538 close (pipe);
539 waitpid (pid, &status, 0);
540 #ifdef SCO_FLAVOR
541 waitpid (-1, NULL, WNOHANG);
542 #endif /* SCO_FLAVOR */
543 sigaction (SIGINT, &save_intr, NULL);
544 sigaction (SIGQUIT, &save_quit, NULL);
545 sigaction (SIGTSTP, &save_stop, NULL);
547 return status;
550 /* Canonicalize path, and return a new path. Do everything in situ.
551 The new path differs from path in:
552 Multiple `/'s are collapsed to a single `/'.
553 Leading `./'s and trailing `/.'s are removed.
554 Trailing `/'s are removed.
555 Non-leading `../'s and trailing `..'s are handled by removing
556 portions of the path. */
557 char *canonicalize_pathname (char *path)
559 int i, start;
560 char stub_char;
562 if (!*path)
563 return path;
565 stub_char = (*path == PATH_SEP) ? PATH_SEP : '.';
567 /* Walk along path looking for things to compact. */
568 i = 0;
569 while (path[i]) {
571 while (path[i] && path[i] != PATH_SEP)
572 i++;
574 start = i++;
576 /* If we didn't find any slashes, then there is nothing left to do. */
577 if (!path[start])
578 break;
580 #if defined(__QNX__) && !defined(__QNXNTO__)
582 ** QNX accesses the directories of nodes on its peer-to-peer
583 ** network (Qnet) by prefixing their directories with "//[nid]".
584 ** We don't want to collapse two '/'s if they're at the start
585 ** of the path, followed by digits, and ending with a '/'.
587 if (start == 0 && path[1] == PATH_SEP) {
588 char *p = path + 2;
589 char *q = strchr (p, PATH_SEP);
591 if (q > p) {
592 *q = 0;
593 if (!strcspn (p, "0123456789")) {
594 start = q - path;
595 i = start + 1;
597 *q = PATH_SEP;
600 #endif
602 /* Handle multiple `/'s in a row. */
603 while (path[i] == PATH_SEP)
604 i++;
606 if ((start + 1) != i) {
607 strcpy (path + start + 1, path + i);
608 i = start + 1;
611 /* Check for trailing `/'. */
612 if (start && !path[i]) {
613 zero_last:
614 path[--i] = '\0';
615 break;
618 /* Check for `../', `./' or trailing `.' by itself. */
619 if (path[i] == '.') {
620 /* Handle trailing `.' by itself. */
621 if (!path[i + 1])
622 goto zero_last;
624 /* Handle `./'. */
625 if (path[i + 1] == PATH_SEP) {
626 strcpy (path + i, path + i + 1);
627 i = start;
628 continue;
631 /* Handle `../' or trailing `..' by itself.
632 Remove the previous ?/ part with the exception of
633 ../, which we should leave intact. */
634 if (path[i + 1] == '.'
635 && (path[i + 2] == PATH_SEP || !path[i + 2])) {
636 while (--start > -1 && path[start] != PATH_SEP);
637 if (!strncmp (path + start + 1, "../", 3))
638 continue;
639 strcpy (path + start + 1, path + i + 2);
640 i = start;
641 continue;
646 if (!*path) {
647 *path = stub_char;
648 path[1] = '\0';
650 return path;
653 #ifdef SCO_FLAVOR
654 int gettimeofday( struct timeval * tv, struct timezone * tz)
656 struct timeb tb;
657 struct tm * l;
659 ftime( &tb );
660 if (errno == EFAULT)
661 return -1;
662 l = localtime(&tb.time);
663 tv->tv_sec = l->tm_sec;
664 tv->tv_usec = (long) tb.millitm;
665 return 0;
667 #endif /* SCO_FLAVOR */
669 #ifdef HAVE_GET_PROCESS_STATS
670 # include <sys/procstats.h>
672 int gettimeofday (struct timeval *tp, void *tzp)
674 return get_process_stats(tp, PS_SELF, 0, 0);
676 #endif /* HAVE_GET_PROCESS_STATS */
678 #ifndef HAVE_PUTENV
680 /* The following piece of code was copied from the GNU C Library */
681 /* And is provided here for nextstep who lacks putenv */
683 extern char **environ;
685 #ifndef HAVE_GNU_LD
686 #define __environ environ
687 #endif
690 /* Put STRING, which is of the form "NAME=VALUE", in the environment. */
692 putenv (const char *string)
694 const char *const name_end = strchr (string, '=');
695 register size_t size;
696 register char **ep;
698 if (name_end == NULL){
699 /* Remove the variable from the environment. */
700 size = strlen (string);
701 for (ep = __environ; *ep != NULL; ++ep)
702 if (!strncmp (*ep, string, size) && (*ep)[size] == '='){
703 while (ep[1] != NULL){
704 ep[0] = ep[1];
705 ++ep;
707 *ep = NULL;
708 return 0;
712 size = 0;
713 for (ep = __environ; *ep != NULL; ++ep)
714 if (!strncmp (*ep, string, name_end - string) &&
715 (*ep)[name_end - string] == '=')
716 break;
717 else
718 ++size;
720 if (*ep == NULL){
721 static char **last_environ = NULL;
722 char **new_environ = g_new (char *, size + 2);
723 if (new_environ == NULL)
724 return -1;
725 (void) memcpy ((void *) new_environ, (void *) __environ,
726 size * sizeof (char *));
727 new_environ[size] = (char *) string;
728 new_environ[size + 1] = NULL;
729 if (last_environ != NULL)
730 g_free ((void *) last_environ);
731 last_environ = new_environ;
732 __environ = new_environ;
734 else
735 *ep = (char *) string;
737 return 0;
739 #endif /* !HAVE_PUTENV */
741 #ifdef SCO_FLAVOR
742 /* Define this only for SCO */
743 #ifdef USE_NETCODE
744 #ifndef HAVE_SOCKETPAIR
747 The code for s_pipe function is adapted from Section 7.9
748 of the "UNIX Network Programming" by W. Richard Stevens,
749 published by Prentice Hall, ISBN 0-13-949876-1
750 (c) 1990 by P T R Prentice Hall
752 It is used to implement socketpair function for SVR3 systems
753 that lack it.
756 #include <sys/types.h>
757 #include <sys/stream.h> /* defines queue_t */
758 #include <stropts.h> /* defines struct strtdinsert */
760 #define SPX_DEVICE "/dev/spx"
761 #define S_PIPE_HANDLE_ERRNO 1
762 /* if the above is defined to 1, we will attempt to
763 save and restore errno to indicate failure
764 reason to the caller;
765 Please note that this will not work in environments
766 where errno is not just an integer
769 #if S_PIPE_HANDLE_ERRNO
770 #include <errno.h>
771 /* This is for "extern int errno;" */
772 #endif
774 /* s_pipe returns 0 if OK, -1 on error */
775 /* two file descriptors are returned */
776 static int s_pipe(int fd[2])
778 struct strfdinsert ins; /* stream I_FDINSERT ioctl format */
779 queue_t *pointer;
780 #if S_PIPE_HANDLE_ERRNO
781 int err_save;
782 #endif
784 * First open the stream clone device "dev/spx" twice,
785 * obtaining the two file descriptors
788 if ( (fd[0] = open(SPX_DEVICE, O_RDWR)) < 0)
789 return -1;
790 if ( (fd[1] = open(SPX_DEVICE, O_RDWR)) < 0) {
791 #if S_PIPE_HANDLE_ERRNO
792 err_save = errno;
793 #endif
794 close(fd[0]);
795 #if S_PIPE_HANDLE_ERRNO
796 errno = err_save;
797 #endif
798 return -1;
802 * Now link these two stream together with an I_FDINSERT ioctl.
805 ins.ctlbuf.buf = (char *) &pointer; /* no control information, just the pointer */
806 ins.ctlbuf.maxlen = sizeof pointer;
807 ins.ctlbuf.len = sizeof pointer;
808 ins.databuf.buf = (char *) 0; /* no data to be sent */
809 ins.databuf.maxlen = 0;
810 ins.databuf.len = -1; /* magic: must be -1 rather than 0 for stream pipes */
812 ins.fildes = fd[1]; /* the fd to connect with fd[0] */
813 ins.flags = 0; /* nonpriority message */
814 ins.offset = 0; /* offset of pointer in control buffer */
816 if (ioctl(fd[0], I_FDINSERT, (char *) &ins) < 0) {
817 #if S_PIPE_HANDLE_ERRNO
818 err_save = errno;
819 #endif
820 close(fd[0]);
821 close(fd[1]);
822 #if S_PIPE_HANDLE_ERRNO
823 errno = err_save;
824 #endif
825 return -1;
827 /* all is OK if we came here, indicate success */
828 return 0;
831 int socketpair(int dummy1, int dummy2, int dummy3, int fd[2])
833 return s_pipe(fd);
836 #endif /* ifndef HAVE_SOCKETPAIR */
837 #endif /* ifdef USE_NETCODE */
838 #endif /* SCO_FLAVOR */