* clear out some warnings by gcc 9.3.1.
[alpine.git] / pico / osdep / popen.c
blob575929a6794219367582b7cf82d9320b622cbb3e
1 #if !defined(lint) && !defined(DOS)
2 static char rcsid[] = "$Id: popen.c 761 2007-10-23 22:35:18Z hubert@u.washington.edu $";
3 #endif
5 /*
6 * ========================================================================
7 * Copyright 2006 University of Washington
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * ========================================================================
18 #include <system.h>
19 #include <general.h>
20 #include "../estruct.h"
26 * P_open - run the given command in a sub-shell returning a file pointer
27 * from which to read the output
29 * note:
30 * For OS's other than unix, you will have to rewrite this function.
31 * Hopefully it'll be easy to exec the command into a temporary file,
32 * and return a file pointer to that opened file or something.
34 int
35 P_open(char *s)
37 #if HAVE_POPEN
38 extern FIOINFO g_pico_fio;
40 g_pico_fio.flags = FIOINFO_READ;
41 g_pico_fio.name = "pipe";
43 if((g_pico_fio.fp = popen(s, "r")) != NULL)
44 return(FIOSUC);
46 return(FIOERR);
47 #else
48 /* Windows never did this, but piping has been done elsewhere */
49 return(0);
50 #endif
56 * P_close - close the given descriptor
59 void
60 P_close(void)
62 #if HAVE_PCLOSE
63 extern FIOINFO g_pico_fio;
65 if(g_pico_fio.fp)
66 (void) pclose(g_pico_fio.fp);
67 #endif