URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/trunk/newlib-1.10.0/newlib/libc/unix
- from Rev 1010 to Rev 1765
- ↔ Reverse comparison
Rev 1010 → Rev 1765
/sigset.c
0,0 → 1,61
#include <signal.h> |
#include <errno.h> |
|
#ifdef SIG_SETMASK /* easier than trying to remove from Makefile */ |
|
#undef sigemptyset |
int |
sigemptyset (sigset_t * set) |
{ |
*set = (sigset_t) 0; |
return 0; |
} |
|
int |
sigfillset (sigset_t * set) |
{ |
*set = ~((sigset_t) 0); |
return 0; |
} |
|
#undef sigaddset |
int |
sigaddset (sigset_t * set, int signo) |
{ |
if (signo >= NSIG || signo <= 0) |
{ |
errno = EINVAL; |
return -1; |
} |
*set |= 1 << (signo - 1); |
return 0; |
} |
|
int |
sigdelset (sigset_t * set, int signo) |
{ |
if (signo >= NSIG || signo <= 0) |
{ |
errno = EINVAL; |
return -1; |
} |
*set &= ~(1 << (signo - 1)); |
return 0; |
} |
|
int |
sigismember (const sigset_t * set, int signo) |
{ |
if (signo >= NSIG || signo <= 0) |
{ |
errno = EINVAL; |
return -1; |
} |
|
if (*set & (1 << (signo - 1))) |
return 1; |
else |
return 0; |
} |
|
#endif /* SIG_SETMASK */ |
/Makefile.in
0,0 → 1,370
# Makefile.in generated automatically by automake 1.4 from Makefile.am |
|
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. |
# This Makefile.in is free software; the Free Software Foundation |
# gives unlimited permission to copy and/or distribute it, |
# with or without modifications, as long as this notice is preserved. |
|
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without |
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
# PARTICULAR PURPOSE. |
|
|
|
SHELL = @SHELL@ |
|
srcdir = @srcdir@ |
top_srcdir = @top_srcdir@ |
VPATH = @srcdir@ |
prefix = @prefix@ |
exec_prefix = @exec_prefix@ |
|
bindir = @bindir@ |
sbindir = @sbindir@ |
libexecdir = @libexecdir@ |
datadir = @datadir@ |
sysconfdir = @sysconfdir@ |
sharedstatedir = @sharedstatedir@ |
localstatedir = @localstatedir@ |
libdir = @libdir@ |
infodir = @infodir@ |
mandir = @mandir@ |
includedir = @includedir@ |
oldincludedir = /usr/include |
|
DESTDIR = |
|
pkgdatadir = $(datadir)/@PACKAGE@ |
pkglibdir = $(libdir)/@PACKAGE@ |
pkgincludedir = $(includedir)/@PACKAGE@ |
|
top_builddir = .. |
|
ACLOCAL = @ACLOCAL@ |
AUTOCONF = @AUTOCONF@ |
AUTOMAKE = @AUTOMAKE@ |
AUTOHEADER = @AUTOHEADER@ |
|
INSTALL = @INSTALL@ |
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) |
INSTALL_DATA = @INSTALL_DATA@ |
INSTALL_SCRIPT = @INSTALL_SCRIPT@ |
transform = @program_transform_name@ |
|
NORMAL_INSTALL = : |
PRE_INSTALL = : |
POST_INSTALL = : |
NORMAL_UNINSTALL = : |
PRE_UNINSTALL = : |
POST_UNINSTALL = : |
host_alias = @host_alias@ |
host_triplet = @host@ |
AR = @AR@ |
AS = @AS@ |
CC = @CC@ |
CPP = @CPP@ |
CRT0 = @CRT0@ |
DLLTOOL = @DLLTOOL@ |
EXEEXT = @EXEEXT@ |
LDFLAGS = @LDFLAGS@ |
LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ |
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ |
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ |
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ |
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ |
LIBC_SYS_LIB = @LIBC_SYS_LIB@ |
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ |
LIBTOOL = @LIBTOOL@ |
LN_S = @LN_S@ |
MAINT = @MAINT@ |
MAKEINFO = @MAKEINFO@ |
NEWLIB_CFLAGS = @NEWLIB_CFLAGS@ |
OBJDUMP = @OBJDUMP@ |
PACKAGE = @PACKAGE@ |
RANLIB = @RANLIB@ |
VERSION = @VERSION@ |
aext = @aext@ |
libm_machine_dir = @libm_machine_dir@ |
machine_dir = @machine_dir@ |
newlib_basedir = @newlib_basedir@ |
oext = @oext@ |
sys_dir = @sys_dir@ |
|
AUTOMAKE_OPTIONS = cygnus |
|
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) |
|
LIB_SOURCES = \ |
getpass.c sigset.c getpwent.c ttyname.c getut.c getlogin.c getcwd.c |
|
|
libunix_la_LDFLAGS = -Xcompiler -nostdlib |
|
@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = @USE_LIBTOOL_TRUE@libunix.la |
@USE_LIBTOOL_TRUE@libunix_la_SOURCES = @USE_LIBTOOL_TRUE@$(LIB_SOURCES) |
@USE_LIBTOOL_TRUE@noinst_DATA = @USE_LIBTOOL_TRUE@objectlist.awk.in |
@USE_LIBTOOL_FALSE@noinst_DATA = |
@USE_LIBTOOL_FALSE@noinst_LIBRARIES = @USE_LIBTOOL_FALSE@lib.a |
@USE_LIBTOOL_FALSE@lib_a_SOURCES = @USE_LIBTOOL_FALSE@$(LIB_SOURCES) |
|
CHEWOUT_FILES = |
|
SUFFIXES = .def |
|
CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str |
|
TARGETDOC = ../tmp.texi |
|
CLEANFILES = $(CHEWOUT_FILES) *.ref |
mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs |
CONFIG_CLEAN_FILES = |
LIBRARIES = $(noinst_LIBRARIES) |
|
|
DEFS = @DEFS@ -I. -I$(srcdir) |
CPPFLAGS = @CPPFLAGS@ |
LIBS = @LIBS@ |
lib_a_LIBADD = |
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = getpass.o sigset.o getpwent.o \ |
@USE_LIBTOOL_FALSE@ttyname.o getut.o getlogin.o getcwd.o |
LTLIBRARIES = $(noinst_LTLIBRARIES) |
|
libunix_la_LIBADD = |
@USE_LIBTOOL_TRUE@libunix_la_OBJECTS = getpass.lo sigset.lo getpwent.lo \ |
@USE_LIBTOOL_TRUE@ttyname.lo getut.lo getlogin.lo getcwd.lo |
CFLAGS = @CFLAGS@ |
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
CCLD = $(CC) |
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ |
DATA = $(noinst_DATA) |
|
DIST_COMMON = Makefile.am Makefile.in |
|
|
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) |
|
TAR = gtar |
GZIP_ENV = --best |
SOURCES = $(lib_a_SOURCES) $(libunix_la_SOURCES) |
OBJECTS = $(lib_a_OBJECTS) $(libunix_la_OBJECTS) |
|
all: all-redirect |
.SUFFIXES: |
.SUFFIXES: .S .c .def .lo .o .s |
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/../../Makefile.shared |
cd $(top_srcdir) && $(AUTOMAKE) --cygnus unix/Makefile |
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
cd $(top_builddir) \ |
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status |
|
|
mostlyclean-noinstLIBRARIES: |
|
clean-noinstLIBRARIES: |
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) |
|
distclean-noinstLIBRARIES: |
|
maintainer-clean-noinstLIBRARIES: |
|
.c.o: |
$(COMPILE) -c $< |
|
.s.o: |
$(COMPILE) -c $< |
|
.S.o: |
$(COMPILE) -c $< |
|
mostlyclean-compile: |
-rm -f *.o core *.core |
|
clean-compile: |
|
distclean-compile: |
-rm -f *.tab.c |
|
maintainer-clean-compile: |
|
.c.lo: |
$(LIBTOOL) --mode=compile $(COMPILE) -c $< |
|
.s.lo: |
$(LIBTOOL) --mode=compile $(COMPILE) -c $< |
|
.S.lo: |
$(LIBTOOL) --mode=compile $(COMPILE) -c $< |
|
mostlyclean-libtool: |
-rm -f *.lo |
|
clean-libtool: |
-rm -rf .libs _libs |
|
distclean-libtool: |
|
maintainer-clean-libtool: |
|
lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES) |
-rm -f lib.a |
$(AR) cru lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD) |
$(RANLIB) lib.a |
|
mostlyclean-noinstLTLIBRARIES: |
|
clean-noinstLTLIBRARIES: |
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) |
|
distclean-noinstLTLIBRARIES: |
|
maintainer-clean-noinstLTLIBRARIES: |
|
libunix.la: $(libunix_la_OBJECTS) $(libunix_la_DEPENDENCIES) |
$(LINK) $(libunix_la_LDFLAGS) $(libunix_la_OBJECTS) $(libunix_la_LIBADD) $(LIBS) |
|
tags: TAGS |
|
ID: $(HEADERS) $(SOURCES) $(LISP) |
list='$(SOURCES) $(HEADERS)'; \ |
unique=`for i in $$list; do echo $$i; done | \ |
awk ' { files[$$0] = 1; } \ |
END { for (i in files) print i; }'`; \ |
here=`pwd` && cd $(srcdir) \ |
&& mkid -f$$here/ID $$unique $(LISP) |
|
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) |
tags=; \ |
here=`pwd`; \ |
list='$(SOURCES) $(HEADERS)'; \ |
unique=`for i in $$list; do echo $$i; done | \ |
awk ' { files[$$0] = 1; } \ |
END { for (i in files) print i; }'`; \ |
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ |
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) |
|
mostlyclean-tags: |
|
clean-tags: |
|
distclean-tags: |
-rm -f TAGS ID |
|
maintainer-clean-tags: |
|
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) |
|
subdir = unix |
|
distdir: $(DISTFILES) |
@for file in $(DISTFILES); do \ |
if test -f $$file; then d=.; else d=$(srcdir); fi; \ |
if test -d $$d/$$file; then \ |
cp -pr $$d/$$file $(distdir)/$$file; \ |
else \ |
test -f $(distdir)/$$file \ |
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \ |
|| cp -p $$d/$$file $(distdir)/$$file || :; \ |
fi; \ |
done |
info-am: |
info: info-am |
dvi-am: |
dvi: dvi-am |
check-am: |
check: check-am |
installcheck-am: |
installcheck: installcheck-am |
install-info-am: |
install-info: install-info-am |
install-exec-am: |
install-exec: install-exec-am |
|
install-data-am: |
install-data: install-data-am |
|
install-am: all-am |
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am |
install: install-am |
uninstall-am: |
uninstall: uninstall-am |
all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) |
all-redirect: all-am |
install-strip: |
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install |
installdirs: |
|
|
mostlyclean-generic: |
|
clean-generic: |
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) |
|
distclean-generic: |
-rm -f Makefile $(CONFIG_CLEAN_FILES) |
-rm -f config.cache config.log stamp-h stamp-h[0-9]* |
|
maintainer-clean-generic: |
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ |
mostlyclean-libtool mostlyclean-noinstLTLIBRARIES \ |
mostlyclean-tags mostlyclean-generic |
|
mostlyclean: mostlyclean-am |
|
clean-am: clean-noinstLIBRARIES clean-compile clean-libtool \ |
clean-noinstLTLIBRARIES clean-tags clean-generic \ |
mostlyclean-am |
|
clean: clean-am |
|
distclean-am: distclean-noinstLIBRARIES distclean-compile \ |
distclean-libtool distclean-noinstLTLIBRARIES \ |
distclean-tags distclean-generic clean-am |
-rm -f libtool |
|
distclean: distclean-am |
|
maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ |
maintainer-clean-compile maintainer-clean-libtool \ |
maintainer-clean-noinstLTLIBRARIES \ |
maintainer-clean-tags maintainer-clean-generic \ |
distclean-am |
@echo "This command is intended for maintainers to use;" |
@echo "it deletes files that may require special tools to rebuild." |
|
maintainer-clean: maintainer-clean-am |
|
.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ |
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ |
mostlyclean-compile distclean-compile clean-compile \ |
maintainer-clean-compile mostlyclean-libtool distclean-libtool \ |
clean-libtool maintainer-clean-libtool mostlyclean-noinstLTLIBRARIES \ |
distclean-noinstLTLIBRARIES clean-noinstLTLIBRARIES \ |
maintainer-clean-noinstLTLIBRARIES tags mostlyclean-tags distclean-tags \ |
clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ |
check-am installcheck-am installcheck install-info-am install-info \ |
install-exec-am install-exec install-data-am install-data install-am \ |
install uninstall-am uninstall all-redirect all-am all installdirs \ |
mostlyclean-generic distclean-generic clean-generic \ |
maintainer-clean-generic clean mostlyclean distclean maintainer-clean |
|
|
objectlist.awk.in: $(noinst_LTLIBRARIES) |
-rm -f objectlist.awk.in |
for i in `ls *.lo` ; \ |
do \ |
echo $$i `pwd`/$$i >> objectlist.awk.in ; \ |
done |
|
.c.def: |
$(CHEW) < $< > $*.def 2> $*.ref |
touch stmp-def |
|
# No doc for unix. |
doc: |
|
# Tell versions [3.59,3.63) of GNU make to not export all variables. |
# Otherwise a system limit (for SysV at least) may be exceeded. |
.NOEXPORT: |
/ttyname.c
0,0 → 1,86
/* |
* Copyright (c) 1988 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
|
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "@(#)ttyname.c 5.10 (Berkeley) 5/6/91"; |
#endif /* LIBC_SCCS and not lint */ |
|
#include <sys/types.h> |
#include <sys/stat.h> |
#include <fcntl.h> |
#include <dirent.h> |
#include <termios.h> |
#include <unistd.h> |
#include <string.h> |
#include <paths.h> |
#include <_syslist.h> |
|
static char buf[sizeof (_PATH_DEV) + MAXNAMLEN] = _PATH_DEV; |
|
char * |
ttyname (fd) |
int fd; |
{ |
struct stat sb; |
struct termios tty; |
struct dirent *dirp; |
DIR *dp; |
struct stat dsb; |
char *rval; |
|
/* Must be a terminal. */ |
if (tcgetattr (fd, &tty) < 0) |
return NULL; |
|
/* Must be a character device. */ |
if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode)) |
return NULL; |
|
if ((dp = _opendir (_PATH_DEV)) == NULL) |
return NULL; |
|
for (rval = NULL; dirp = _readdir (dp);) |
{ |
if (dirp->d_ino != sb.st_ino) |
continue; |
strcpy (buf + sizeof (_PATH_DEV) - 1, dirp->d_name); |
if (stat (buf, &dsb) || sb.st_dev != dsb.st_dev || |
sb.st_ino != dsb.st_ino) |
continue; |
(void) _closedir (dp); |
rval = buf; |
break; |
} |
(void) _closedir (dp); |
return rval; |
} |
/getpass.c
0,0 → 1,103
/* |
* Copyright (c) 1988 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
|
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "@(#)getpass.c 5.9 (Berkeley) 5/6/91"; |
#endif /* LIBC_SCCS and not lint */ |
|
#include <stdio.h> |
#include <unistd.h> |
#include <pwd.h> |
#include <sys/termios.h> |
#include <sys/signal.h> |
#include <_syslist.h> |
|
#ifndef _PATH_PASSWD |
#define _PATH_PASSWD "/etc/passwd" |
#endif |
|
#ifndef _PASSWORD_LEN |
#define _PASSWORD_LEN 128 /* max length, not counting NULL */ |
#endif |
|
char * |
getpass (prompt) |
const char *prompt; |
{ |
struct termios term; |
register int ch; |
register char *p; |
FILE *fp, *outfp; |
long omask; |
int echo; |
static char buf[_PASSWORD_LEN + 1]; |
|
/* |
* read and write to /dev/tty if possible; else read from |
* stdin and write to stderr. |
*/ |
|
if ((outfp = fp = fopen ("/dev/tty", "w+")) == NULL) |
{ |
outfp = stderr; |
fp = stdin; |
} |
/* |
* note - blocking signals isn't necessarily the |
* right thing, but we leave it for now. |
*/ |
omask = sigblock (sigmask (SIGINT) | sigmask (SIGTSTP)); |
(void) tcgetattr (fileno (fp), &term); |
echo = (term.c_lflag & ECHO); |
if (echo) |
{ |
term.c_lflag &= ~ECHO; |
(void) tcsetattr (fileno (fp), TCSAFLUSH, &term); |
} |
(void) fputs (prompt, outfp); |
rewind (outfp); /* implied flush */ |
for (p = buf; (ch = getc (fp)) != EOF && ch != '\n';) |
if (p < buf + _PASSWORD_LEN) |
*p++ = ch; |
*p = '\0'; |
(void) _write (fileno (outfp), "\n", 1); |
if (echo) |
{ |
term.c_lflag |= ECHO; |
tcsetattr (fileno (fp), TCSAFLUSH, &term); |
} |
(void) sigsetmask (omask); |
if (fp != stdin) |
(void) fclose (fp); |
return buf; |
} |
/Makefile.am
0,0 → 1,39
## Process this file with automake to generate Makefile.in |
|
AUTOMAKE_OPTIONS = cygnus |
|
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) |
|
LIB_SOURCES = \ |
getpass.c sigset.c getpwent.c ttyname.c getut.c getlogin.c getcwd.c |
|
libunix_la_LDFLAGS = -Xcompiler -nostdlib |
|
if USE_LIBTOOL |
noinst_LTLIBRARIES = libunix.la |
libunix_la_SOURCES = $(LIB_SOURCES) |
noinst_DATA = objectlist.awk.in |
else |
noinst_LIBRARIES = lib.a |
lib_a_SOURCES = $(LIB_SOURCES) |
noinst_DATA = |
endif # USE_LIBTOOL |
|
include $(srcdir)/../../Makefile.shared |
|
CHEWOUT_FILES = |
|
SUFFIXES = .def |
|
CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str |
|
.c.def: |
$(CHEW) < $< > $*.def 2> $*.ref |
touch stmp-def |
|
TARGETDOC = ../tmp.texi |
|
# No doc for unix. |
doc: |
|
CLEANFILES = $(CHEWOUT_FILES) *.ref |
/getlogin.c
0,0 → 1,42
#include <string.h> |
#include <unistd.h> |
#include <sys/types.h> |
#include <utmp.h> |
#include <fcntl.h> |
#include <_syslist.h> |
|
char * |
getlogin () |
{ |
int utmp_fd; |
struct utmp utmp_buf; |
static char buf[10]; |
extern char *ttyname (); |
char *tty; |
|
if (((tty = ttyname (0)) == 0) |
|| ((tty = ttyname (1)) == 0) |
|| ((tty = ttyname (2)) == 0)) |
return 0; |
|
if ((utmp_fd = _open (UTMP_FILE, O_RDONLY)) == -1) |
return 0; |
|
if (!strncmp (tty, "/dev/", 5)) |
tty += 5; |
|
while (_read (utmp_fd, &utmp_buf, sizeof (utmp_buf)) == sizeof (utmp_buf)) |
{ |
if (!strncmp (tty, utmp_buf.ut_line, sizeof (utmp_buf.ut_line)) |
&& utmp_buf.ut_type == USER_PROCESS) |
{ |
_close (utmp_fd); |
memset (buf, 0, sizeof (buf)); |
strncpy (buf, utmp_buf.ut_user, sizeof (utmp_buf.ut_user)); |
return buf; |
} |
} |
|
_close (utmp_fd); |
return 0; |
} |
/getut.c
0,0 → 1,86
#include <stdlib.h> |
#include <string.h> |
#include <fcntl.h> |
#include <unistd.h> |
#include <utmp.h> |
#include <_syslist.h> |
#include <_ansi.h> |
|
static int utmp_fd = -2; |
static char *utmp_file = UTMP_FILE; |
|
static struct utmp utmp_data; |
|
void |
setutent () |
{ |
if (utmp_fd == -2) |
{ |
utmp_fd = _open (utmp_file, O_RDONLY); |
} |
_lseek (utmp_fd, 0, SEEK_SET); |
} |
|
void |
endutent () |
{ |
_close (utmp_fd); |
utmp_fd = -2; |
} |
|
void |
utmpname (_CONST char *file) |
{ |
utmp_file = strdup (file); |
} |
|
struct utmp * |
getutent () |
{ |
if (utmp_fd == -2) |
setutent (); |
if (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) < sizeof (utmp_data)) |
return 0; |
return &utmp_data; |
} |
|
struct utmp * |
getutid (struct utmp *id) |
{ |
while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data)) |
{ |
switch (id->ut_type) |
{ |
case RUN_LVL: |
case BOOT_TIME: |
case OLD_TIME: |
case NEW_TIME: |
if (id->ut_type == utmp_data.ut_type) |
return &utmp_data; |
case INIT_PROCESS: |
case LOGIN_PROCESS: |
case USER_PROCESS: |
case DEAD_PROCESS: |
if (id->ut_id == utmp_data.ut_id) |
return &utmp_data; |
default: |
abort (); |
} |
} |
return 0; |
} |
|
struct utmp * |
getutline (struct utmp *line) |
{ |
while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data)) |
{ |
if ((utmp_data.ut_type == LOGIN_PROCESS || |
utmp_data.ut_type == USER_PROCESS) && |
!strncmp (utmp_data.ut_line, line->ut_line, |
sizeof (utmp_data.ut_line))) |
return &utmp_data; |
} |
|
return 0; |
} |
/getcwd.c
0,0 → 1,265
/* |
* Copyright (c) 1989, 1991 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
|
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "@(#)getcwd.c 5.11 (Berkeley) 2/24/91"; |
#endif /* LIBC_SCCS and not lint */ |
|
#include <sys/stat.h> |
#include <errno.h> |
#include <dirent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <unistd.h> |
#include <reent.h> |
#include <_syslist.h> |
|
#define bcopy(a,b,c) memmove (b,a,c) |
|
#define ISDOT(dp) \ |
(dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \ |
(dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) |
|
#ifndef _REENT_ONLY |
|
char * |
getcwd (pt, size) |
char *pt; |
size_t size; |
{ |
register struct dirent *dp; |
register DIR *dir; |
register dev_t dev; |
register ino_t ino; |
register int first; |
register char *bpt, *bup; |
struct stat s; |
dev_t root_dev; |
ino_t root_ino; |
size_t ptsize, upsize; |
int save_errno; |
char *ept, *eup, *up; |
|
/* |
* If no buffer specified by the user, allocate one as necessary. |
* If a buffer is specified, the size has to be non-zero. The path |
* is built from the end of the buffer backwards. |
*/ |
|
if (pt) |
{ |
ptsize = 0; |
if (!size) |
{ |
errno = EINVAL; |
return (char *) NULL; |
} |
ept = pt + size; |
} |
else |
{ |
if (!(pt = (char *) malloc (ptsize = 1024 - 4))) |
{ |
return (char *) NULL; |
} |
ept = pt + ptsize; |
} |
bpt = ept - 1; |
*bpt = '\0'; |
|
/* |
* Allocate bytes (1024 - malloc space) for the string of "../"'s. |
* Should always be enough (it's 340 levels). If it's not, allocate |
* as necessary. Special * case the first stat, it's ".", not "..". |
*/ |
|
if (!(up = (char *) malloc (upsize = 1024 - 4))) |
{ |
goto err; |
} |
eup = up + MAXPATHLEN; |
bup = up; |
up[0] = '.'; |
up[1] = '\0'; |
|
/* Save root values, so know when to stop. */ |
if (stat ("/", &s)) |
goto err; |
root_dev = s.st_dev; |
root_ino = s.st_ino; |
|
errno = 0; /* XXX readdir has no error return. */ |
|
for (first = 1;; first = 0) |
{ |
/* Stat the current level. */ |
if (_stat (up, &s)) |
goto err; |
|
/* Save current node values. */ |
ino = s.st_ino; |
dev = s.st_dev; |
|
/* Check for reaching root. */ |
if (root_dev == dev && root_ino == ino) |
{ |
*--bpt = '/'; |
/* |
* It's unclear that it's a requirement to copy the |
* path to the beginning of the buffer, but it's always |
* been that way and stuff would probably break. |
*/ |
(void) bcopy (bpt, pt, ept - bpt); |
free (up); |
return pt; |
} |
|
/* |
* Build pointer to the parent directory, allocating memory |
* as necessary. Max length is 3 for "../", the largest |
* possible component name, plus a trailing NULL. |
*/ |
|
if (bup + 3 + MAXNAMLEN + 1 >= eup) |
{ |
if (!(up = (char *) realloc (up, upsize *= 2))) |
{ |
goto err; |
} |
bup = up; |
eup = up + upsize; |
} |
*bup++ = '.'; |
*bup++ = '.'; |
*bup = '\0'; |
|
/* Open and stat parent directory. */ |
if (!(dir = _opendir (up)) || _fstat (__dirfd (dir), &s)) |
goto err; |
|
/* Add trailing slash for next directory. */ |
*bup++ = '/'; |
|
/* |
* If it's a mount point, have to stat each element because |
* the inode number in the directory is for the entry in the |
* parent directory, not the inode number of the mounted file. |
*/ |
|
save_errno = 0; |
if (s.st_dev == dev) |
{ |
for (;;) |
{ |
if (!(dp = _readdir (dir))) |
goto notfound; |
if (dp->d_ino == ino) |
break; |
} |
} |
else |
for (;;) |
{ |
if (!(dp = _readdir (dir))) |
goto notfound; |
if (ISDOT (dp)) |
continue; |
bcopy (dp->d_name, bup, strlen (dp->d_name) + 1); |
|
/* Save the first error for later. */ |
if (stat (up, &s)) |
{ |
if (!save_errno) |
save_errno = errno; |
errno = 0; |
continue; |
} |
if (s.st_dev == dev && s.st_ino == ino) |
break; |
} |
|
/* |
* Check for length of the current name, preceding slash, |
* leading slash. |
*/ |
|
if (bpt - pt <= strlen (dp->d_name) + (first ? 1 : 2)) |
{ |
size_t len, off; |
|
if (!ptsize) |
{ |
errno = ERANGE; |
goto err; |
} |
off = bpt - pt; |
len = ept - bpt; |
if (!(pt = (char *) realloc (pt, ptsize *= 2))) |
{ |
goto err; |
} |
bpt = pt + off; |
ept = pt + ptsize; |
(void) bcopy (bpt, ept - len, len); |
bpt = ept - len; |
} |
if (!first) |
*--bpt = '/'; |
bpt -= strlen (dp->d_name); |
bcopy (dp->d_name, bpt, strlen (dp->d_name)); |
(void) _closedir (dir); |
|
/* Truncate any file name. */ |
*bup = '\0'; |
} |
|
notfound: |
/* |
* If readdir set errno, use it, not any saved error; otherwise, |
* didn't find the current directory in its parent directory, set |
* errno to ENOENT. |
*/ |
|
if (!errno) |
errno = save_errno ? save_errno : ENOENT; |
/* FALLTHROUGH */ |
|
err: |
if (ptsize) |
free (pt); |
free (up); |
return (char *) NULL; |
} |
|
#endif /* _REENT_ONLY */ |
getcwd.c
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: getpwent.c
===================================================================
--- getpwent.c (nonexistent)
+++ getpwent.c (revision 1765)
@@ -0,0 +1,127 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+static struct passwd pw_passwd; /* password structure */
+static FILE *passwd_fp;
+
+static char logname[8];
+static char password[1024];
+static char gecos[1024];
+static char dir[1024];
+static char shell[1024];
+
+struct passwd *
+getpwnam (name)
+ const char *name;
+{
+ FILE *fp;
+ char buf[1024];
+
+ if ((fp = fopen ("/etc/passwd", "r")) == NULL)
+ {
+ return NULL;
+ }
+
+ while (fgets (buf, sizeof (buf), fp))
+ {
+ sscanf (buf, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%s\n",
+ logname, password, &pw_passwd.pw_uid,
+ &pw_passwd.pw_gid, gecos,
+ dir, shell);
+ pw_passwd.pw_name = logname;
+ pw_passwd.pw_passwd = password;
+ pw_passwd.pw_comment = "";
+ pw_passwd.pw_gecos = gecos;
+ pw_passwd.pw_dir = dir;
+ pw_passwd.pw_shell = shell;
+
+ if (!strcmp (logname, name))
+ {
+ fclose (fp);
+ return &pw_passwd;
+ }
+ }
+ fclose (fp);
+ return NULL;
+}
+
+struct passwd *
+getpwuid (uid_t uid)
+{
+ FILE *fp;
+ char buf[1024];
+
+ if ((fp = fopen ("/etc/passwd", "r")) == NULL)
+ {
+ return NULL;
+ }
+
+ while (fgets (buf, sizeof (buf), fp))
+ {
+ sscanf (buf, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%s\n",
+ logname, password, &pw_passwd.pw_uid,
+ &pw_passwd.pw_gid, gecos,
+ dir, shell);
+ pw_passwd.pw_name = logname;
+ pw_passwd.pw_passwd = password;
+ pw_passwd.pw_comment = "";
+ pw_passwd.pw_gecos = gecos;
+ pw_passwd.pw_dir = dir;
+ pw_passwd.pw_shell = shell;
+
+ if (uid == pw_passwd.pw_uid)
+ {
+ fclose (fp);
+ return &pw_passwd;
+ }
+ }
+ fclose (fp);
+ return NULL;
+}
+
+struct passwd *
+getpwent ()
+{
+ char buf[1024];
+
+ if (passwd_fp == NULL)
+ return NULL;
+
+ if (fgets (buf, sizeof (buf), passwd_fp) == NULL)
+ return NULL;
+
+ sscanf (buf, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%s\n",
+ logname, password, &pw_passwd.pw_uid,
+ &pw_passwd.pw_gid, gecos,
+ dir, shell);
+ pw_passwd.pw_name = logname;
+ pw_passwd.pw_passwd = password;
+ pw_passwd.pw_comment = "";
+ pw_passwd.pw_gecos = gecos;
+ pw_passwd.pw_dir = dir;
+ pw_passwd.pw_shell = shell;
+
+ return &pw_passwd;
+}
+
+void
+setpwent ()
+{
+ if (passwd_fp != NULL)
+ fclose (passwd_fp);
+
+ passwd_fp = fopen ("/etc/passwd", "r");
+}
+
+void
+endpwent ()
+{
+ if (passwd_fp != NULL)
+ fclose (passwd_fp);
+}