* cygwin.din: Export endusershell, getusershell and setusershell.
* syscalls.cc (getusershell): New function. (setusershell): Ditto. (endusershell): Ditto. * include/cygwin/version.h: Bump API minor number.
This commit is contained in:
parent
6c73e54252
commit
24efca1401
|
@ -1,3 +1,11 @@
|
|||
2003-09-08 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* cygwin.din: Export endusershell, getusershell and setusershell.
|
||||
* syscalls.cc (getusershell): New function.
|
||||
(setusershell): Ditto.
|
||||
(endusershell): Ditto.
|
||||
* include/cygwin/version.h: Bump API minor number.
|
||||
|
||||
2003-09-08 Nicholas Wourms <nwourms@netscape.net>
|
||||
|
||||
* cygwin.din: Export argz_add argz_add_sep argz_append argz_count
|
||||
|
|
|
@ -289,6 +289,7 @@ cygwin32_detach_dll = cygwin_detach_dll
|
|||
cygwin_dll_init
|
||||
endprotoent = cygwin_endprotoent
|
||||
endservent = cygwin_endservent
|
||||
endusershell
|
||||
gethostbyaddr = cygwin_gethostbyaddr
|
||||
gethostbyname = cygwin_gethostbyname
|
||||
_gethostname = cygwin_gethostname
|
||||
|
@ -302,6 +303,7 @@ getservbyport = cygwin_getservbyport
|
|||
getservent = cygwin_getservent
|
||||
getsockname = cygwin_getsockname
|
||||
getsockopt = cygwin_getsockopt
|
||||
getusershell
|
||||
herror = cygwin_herror
|
||||
hstrerror = cygwin_hstrerror
|
||||
inet_addr = cygwin_inet_addr
|
||||
|
@ -335,6 +337,7 @@ cygwin_set_impersonation_token
|
|||
setprotoent = cygwin_setprotoent
|
||||
setservent = cygwin_setservent
|
||||
setsockopt = cygwin_setsockopt
|
||||
setusershell
|
||||
shutdown = cygwin_shutdown
|
||||
socket = cygwin_socket
|
||||
cygwin_split_path
|
||||
|
|
|
@ -211,16 +211,17 @@ details. */
|
|||
89: Export __mempcpy
|
||||
90: Export _fopen64
|
||||
91: Export argz_add argz_add_sep argz_append argz_count argz_create
|
||||
argz_create_sep argz_delete argz_extract argz_insert
|
||||
argz_next argz_replace argz_stringify envz_add envz_entry
|
||||
envz_get envz_merge envz_remove envz_strip
|
||||
argz_create_sep argz_delete argz_extract argz_insert
|
||||
argz_next argz_replace argz_stringify envz_add envz_entry
|
||||
envz_get envz_merge envz_remove envz_strip
|
||||
92: Export getusershell, setusershell, eetusershell
|
||||
|
||||
*/
|
||||
|
||||
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
||||
|
||||
#define CYGWIN_VERSION_API_MAJOR 0
|
||||
#define CYGWIN_VERSION_API_MINOR 91
|
||||
#define CYGWIN_VERSION_API_MINOR 92
|
||||
|
||||
/* There is also a compatibity version number associated with the
|
||||
shared memory regions. It is incremented when incompatible
|
||||
|
|
|
@ -30,6 +30,8 @@ details. */
|
|||
#include <process.h>
|
||||
#include <utmp.h>
|
||||
#include <sys/uio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <setjmp.h>
|
||||
|
@ -2897,3 +2899,67 @@ long gethostid(void)
|
|||
|
||||
return hostid;
|
||||
}
|
||||
|
||||
#define ETC_SHELLS "/etc/shells"
|
||||
static int shell_index;
|
||||
static FILE *shell_fp;
|
||||
|
||||
extern "C" char *
|
||||
getusershell ()
|
||||
{
|
||||
/* List of default shells if no /etc/shells exists, defined as on Linux.
|
||||
FIXME: SunOS has a far longer list, containing all shells which
|
||||
might be shipped with the OS. Should we do the same for the Cygwin
|
||||
distro, adding bash, tcsh, ksh, pdksh and zsh? */
|
||||
static NO_COPY const char *def_shells[] = {
|
||||
"/bin/sh",
|
||||
"/bin/csh",
|
||||
"/usr/bin/sh",
|
||||
"/usr/bin/csh",
|
||||
NULL
|
||||
};
|
||||
static char buf[MAX_PATH];
|
||||
int ch, buf_idx;
|
||||
|
||||
if (!shell_fp && !(shell_fp = fopen (ETC_SHELLS, "rt")))
|
||||
{
|
||||
if (def_shells[shell_index])
|
||||
return strcpy (buf, def_shells[shell_index++]);
|
||||
return NULL;
|
||||
}
|
||||
/* Skip white space characters. */
|
||||
while ((ch = getc (shell_fp)) != EOF && isspace (ch))
|
||||
;
|
||||
/* Get each non-whitespace character as part of the shell path as long as
|
||||
it fits in buf. */
|
||||
for (buf_idx = 0;
|
||||
ch != EOF && !isspace (ch) && buf_idx < MAX_PATH;
|
||||
buf_idx++, ch = getc (shell_fp))
|
||||
buf[buf_idx] = ch;
|
||||
/* Skip any trailing non-whitespace character not fitting in buf. If the
|
||||
path is longer than MAX_PATH, it's invalid anyway. */
|
||||
while (ch != EOF && !isspace (ch))
|
||||
ch = getc (shell_fp);
|
||||
if (buf_idx)
|
||||
{
|
||||
buf[buf_idx] = '\0';
|
||||
return buf;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
setusershell ()
|
||||
{
|
||||
if (shell_fp)
|
||||
fseek (shell_fp, 0L, SEEK_SET);
|
||||
shell_index = 0;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
endusershell ()
|
||||
{
|
||||
if (shell_fp)
|
||||
fclose (shell_fp);
|
||||
shell_index = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue