diff options
author | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
---|---|---|
committer | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
commit | 7c478bd95313f5f23a4c958a745db2134aa03244 (patch) | |
tree | c871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/ucblib | |
download | illumos-joyent-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz |
OpenSolaris Launch
Diffstat (limited to 'usr/src/ucblib')
184 files changed, 19935 insertions, 0 deletions
diff --git a/usr/src/ucblib/Makefile b/usr/src/ucblib/Makefile new file mode 100644 index 0000000000..eb72813393 --- /dev/null +++ b/usr/src/ucblib/Makefile @@ -0,0 +1,63 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +#ident "%Z%%M% %I% %E% SMI" +# +# Copyright 1989-1997,2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ucblib/Makefile +# + +# libbc is special. It depends on libucb and must be built after libucb. +SUBDIRS= libucb librpcsoc libdbm libtermcap +# libcurses needs libtermcap and libucb +SUBDIRS2= libcurses +sparc_SUBDIR= ../lib/libbc +BWOSDIRS= + +all:= TARGET= all +install:= TARGET= install +clean:= TARGET= clean +clobber:= TARGET= clobber +lint:= TARGET= lint + +.KEEP_STATE: + +.PARALLEL: $(SUBDIRS) + +all install clean clobber: $(SUBDIRS) .WAIT $(SUBDIRS2) .WAIT $($(MACH)_SUBDIR) + +bwos: $(BWOSDIRS) .WAIT $(SUBDIRS) .WAIT $(SUBDIRS2) .WAIT $($(MACH)_SUBDIR) + +install_h: + +$(BWOSDIRS) $(SUBDIRS) $(SUBDIRS2) $($(MACH)_SUBDIR) : FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: + +# +# Cross-reference customization: Tweak XRINCDIRS so that cross-reference +# include paths prefer UCB headers. +# +XRINCDIRS = ../ucbhead diff --git a/usr/src/ucblib/Makefile.ucb b/usr/src/ucblib/Makefile.ucb new file mode 100644 index 0000000000..e1b60f0428 --- /dev/null +++ b/usr/src/ucblib/Makefile.ucb @@ -0,0 +1,34 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include $(SRC)/lib/Makefile.lib + +# +# Tweak XRINCDIRS so that cross-reference include paths prefer UCB headers. +# +XRINCDIRS = ../../ucbhead diff --git a/usr/src/ucblib/Makefile.ucbtarg b/usr/src/ucblib/Makefile.ucbtarg new file mode 100644 index 0000000000..89e8cdcbe0 --- /dev/null +++ b/usr/src/ucblib/Makefile.ucbtarg @@ -0,0 +1,35 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +#ident "%Z%%M% %I% %E% SMI" +# +# Copyright (c) 1989 by Sun Microsystems, Inc. +# +# ucblib/Makefile.ucbtarg +# +# included to define local library targets +# + +# install rules +$(ROOTLIBDIR): + $(INS.dir) + diff --git a/usr/src/ucblib/libcurses/Makefile b/usr/src/ucblib/libcurses/Makefile new file mode 100644 index 0000000000..53f9d7d216 --- /dev/null +++ b/usr/src/ucblib/libcurses/Makefile @@ -0,0 +1,53 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# The builds occur in ISA subdirectories. +# + +include ../Makefile.ucb + +SUBDIRS = spec .WAIT $(MACH) $(BUILD64) $(MACH64) + +# conditional assignments +install := TARGET= install +clean := TARGET= clean +clobber := TARGET= clobber +lint := TARGET= lint + +.KEEP_STATE: + +all install clean clobber lint: $(SUBDIRS) + +$(MACH) $(MACH64) spec: FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: + +# +# Cross-reference customization: include curses.ext in the cross-reference. +# +XRADD = curses.ext diff --git a/usr/src/ucblib/libcurses/Makefile.com b/usr/src/ucblib/libcurses/Makefile.com new file mode 100644 index 0000000000..58f1fb012a --- /dev/null +++ b/usr/src/ucblib/libcurses/Makefile.com @@ -0,0 +1,107 @@ +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libcurses/Makefile.com +# + +LIBRARY= libcurses.a +VERS= .1 + +OBJECTS= \ + addch.o \ + addstr.o \ + box.o \ + clear.o \ + clrtobot.o \ + clrtoeol.o \ + cr_put.o \ + cr_tty.o \ + curses.o \ + delch.o \ + deleteln.o \ + delwin.o \ + endwin.o \ + erase.o \ + fullname.o \ + getch.o \ + getstr.o \ + id_subwins.o \ + idlok.o \ + initscr.o \ + insch.o \ + insertln.o \ + longname.o \ + move.o \ + mvprintw.o \ + mvscanw.o \ + mvwin.o \ + newwin.o \ + overlay.o \ + overwrite.o \ + printw.o \ + putchar.o \ + refresh.o \ + scanw.o \ + scroll.o \ + standout.o \ + toucholap.o \ + touchwin.o \ + tstp.o \ + unctrl.o + +# include library definitions +include $(SRC)/lib/Makefile.lib + +ROOTLIBDIR= $(ROOT)/usr/ucblib +ROOTLIBDIR64= $(ROOT)/usr/ucblib/$(MACH64) + +MAPFILE= $(MAPDIR)/mapfile +SRCS= $(OBJECTS:%.o=../%.c) + +LIBS = $(DYNLIB) $(LINTLIB) + +LINTSRC= $(LINTLIB:%.ln=%) +ROOTLINTDIR= $(ROOTLIBDIR) +ROOTLINTDIR64= $(ROOTLIBDIR)/$(MACH64) +ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%) +ROOTLINT64= $(LINTSRC:%=$(ROOTLINTDIR64)/%) + +# install rule for lint source file target +$(ROOTLINTDIR)/%: ../% + $(INS.file) +$(ROOTLINTDIR64)/%: ../% + $(INS.file) + +$(LINTLIB):= SRCS=../llib-lcurses + +CFLAGS += $(CCVERBOSE) +CFLAGS64 += $(CCVERBOSE) +DYNFLAGS += +DYNFLAGS32 = -M$(MAPFILE) -R/usr/ucblib +DYNFLAGS64 = -M$(MAPFILE) -R/usr/ucblib/$(MACH64) +LDLIBS += -ltermcap -lucb -lc + +CPPFLAGS = -I$(ROOT)/usr/ucbinclude -I../../../lib/libc/inc $(CPPFLAGS.master) + +.KEEP_STATE: + +all: $(LIBS) + +lint: lintcheck + +$(DYNLIB): $(MAPFILE) + +$(MAPFILE): + @cd $(MAPDIR); $(MAKE) mapfile + +# +# Include library targets +# +include $(SRC)/lib/Makefile.targ + +objs/%.o pics/%.o: ../%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) diff --git a/usr/src/ucblib/libcurses/addch.c b/usr/src/ucblib/libcurses/addch.c new file mode 100644 index 0000000000..69259a02e3 --- /dev/null +++ b/usr/src/ucblib/libcurses/addch.c @@ -0,0 +1,120 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifndef lint +static char +sccsid[] = "@(#)addch.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* forward declaration */ +static void set_ch(WINDOW *, int, int, int); + +/* + * This routine adds the character to the current position + */ + +int +waddch(WINDOW *win, char c) +{ + int x, y; + int newx; + + x = win->_curx; + y = win->_cury; +#ifdef FULLDEBUG + fprintf(outf, "ADDCH('%c') at (%d, %d)\n", c, y, x); +#endif + switch (c) { + case '\t': + for (newx = x + (8 - (x & 07)); x < newx; x++) + if (waddch(win, ' ') == ERR) + return (ERR); + return (OK); + + default: +#ifdef FULLDEBUG + fprintf(outf, "ADDCH: 1: y = %d, x = %d, firstch = %d," + " lastch = %d\n", y, x, win->_firstch[y], + win->_lastch[y]); +#endif + if (win->_flags & _STANDOUT) + c |= _STANDOUT; + set_ch(win, y, x, c); + win->_y[y][x++] = c; + if (x >= win->_maxx) { + x = 0; +newline: + if (++y >= win->_maxy) + if (win->_scroll) { + (void) scroll(win); + --y; + } + else + return (ERR); + } +#ifdef FULLDEBUG + fprintf(outf, "ADDCH: 2: y = %d, x = %d, firstch = %d," + " lastch = %d\n", y, x, win->_firstch[y], + win->_lastch[y]); +#endif + break; + case '\n': + (void) wclrtoeol(win); + if (!NONL) + x = 0; + goto newline; + case '\r': + x = 0; + break; + case '\b': + if (--x < 0) + x = 0; + break; + } + win->_curx = (short)x; + win->_cury = (short)y; + return (OK); +} + +/* + * set_ch: + * Set the first and last change flags for this window. + */ + +static void +set_ch(WINDOW *win, int y, int x, int ch) +{ +#ifdef FULLDEBUG + fprintf(outf, "SET_CH(%0.2o, %d, %d)\n", win, y, x); +#endif + if (win->_y[y][x] != ch) { + x += win->_ch_off; + if (win->_firstch[y] == _NOCHANGE) + win->_firstch[y] = win->_lastch[y] = (short)x; + else if (x < win->_firstch[y]) + win->_firstch[y] = (short)x; + else if (x > win->_lastch[y]) + win->_lastch[y] = (short)x; +#ifdef FULLDEBUG + fprintf(outf, "SET_CH: change gives f/l: %d/%d [%d/%d]\n", + win->_firstch[y], win->_lastch[y], + win->_firstch[y] - win->_ch_off, + win->_lastch[y] - win->_ch_off); +#endif + } +} diff --git a/usr/src/ucblib/libcurses/addstr.c b/usr/src/ucblib/libcurses/addstr.c new file mode 100644 index 0000000000..cc2da496a6 --- /dev/null +++ b/usr/src/ucblib/libcurses/addstr.c @@ -0,0 +1,40 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)addstr.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * This routine adds a string starting at (_cury,_curx) + */ + +int +waddstr(WINDOW *win, char *str) +{ +#ifdef DEBUG + fprintf(outf, "WADDSTR(\"%s\")\n", str); +#endif + while (*str) + if (waddch(win, *str++) == ERR) + return (ERR); + return (OK); +} diff --git a/usr/src/ucblib/libcurses/amd64/Makefile b/usr/src/ucblib/libcurses/amd64/Makefile new file mode 100644 index 0000000000..55925aa48f --- /dev/null +++ b/usr/src/ucblib/libcurses/amd64/Makefile @@ -0,0 +1,39 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +MAPDIR= ../spec/amd64 +include ../Makefile.com +include ../../../lib/Makefile.lib.64 + +DYNFLAGS += $(DYNFLAGS64) +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) \ + -L $(ROOT)/usr/ucblib/$(MACH64) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) diff --git a/usr/src/ucblib/libcurses/box.c b/usr/src/ucblib/libcurses/box.c new file mode 100644 index 0000000000..048efc80a3 --- /dev/null +++ b/usr/src/ucblib/libcurses/box.c @@ -0,0 +1,51 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)box.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * This routine draws a box around the given window with "vert" + * as the vertical delimiting char, and "hor", as the horizontal one. + */ + +int +box(WINDOW *win, char vert, char hor) +{ + int i; + int endy, endx; + char *fp, *lp; + + endx = win->_maxx; + endy = win->_maxy - 1; + fp = win->_y[0]; + lp = win->_y[endy]; + for (i = 0; i < endx; i++) + fp[i] = lp[i] = hor; + endx--; + for (i = 0; i <= endy; i++) + win->_y[i][0] = (win->_y[i][endx] = vert); + if (!win->_scroll && (win->_flags&_SCROLLWIN)) + fp[0] = fp[endx] = lp[0] = lp[endx] = ' '; + (void) touchwin(win); + return (OK); +} diff --git a/usr/src/ucblib/libcurses/clear.c b/usr/src/ucblib/libcurses/clear.c new file mode 100644 index 0000000000..489563e19c --- /dev/null +++ b/usr/src/ucblib/libcurses/clear.c @@ -0,0 +1,36 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)clear.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * This routine clears the window. + */ + +int +wclear(WINDOW *win) +{ + (void) werase(win); + win->_clear = TRUE; + return (OK); +} diff --git a/usr/src/ucblib/libcurses/clrtobot.c b/usr/src/ucblib/libcurses/clrtobot.c new file mode 100644 index 0000000000..ff284ab2c8 --- /dev/null +++ b/usr/src/ucblib/libcurses/clrtobot.c @@ -0,0 +1,56 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)clrtobot.c 1.7 88/02/08 SMI"; /* from UCB 5.2 85/10/24 */ +#endif /* not lint */ + +#include <stddef.h> +#include "curses.ext" + +/* + * This routine erases everything on the window. + */ + +int +wclrtobot(WINDOW *win) +{ + int y; + char *sp, *end, *maxx; + int startx; + ptrdiff_t minx; + + startx = win->_curx; + for (y = win->_cury; y < win->_maxy; y++) { + minx = _NOCHANGE; + end = &win->_y[y][win->_maxx]; + for (sp = &win->_y[y][startx]; sp < end; sp++) + if (*sp != ' ') { + maxx = sp; + if (minx == _NOCHANGE) + minx = sp - win->_y[y]; + *sp = ' '; + } + if (minx != _NOCHANGE) + (void) touchline(win, y, (int)minx, + (int)(maxx - &win->_y[y][0])); + startx = 0; + } + return (OK); +} diff --git a/usr/src/ucblib/libcurses/clrtoeol.c b/usr/src/ucblib/libcurses/clrtoeol.c new file mode 100644 index 0000000000..51450a7c44 --- /dev/null +++ b/usr/src/ucblib/libcurses/clrtoeol.c @@ -0,0 +1,62 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)clrtoeol.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include <stddef.h> +#include "curses.ext" + +/* + * This routine clears up to the end of line + */ + +int +wclrtoeol(WINDOW *win) +{ + char *sp, *end; + int y, x; + char *maxx; + ptrdiff_t minx; + + y = win->_cury; + x = win->_curx; + end = &win->_y[y][win->_maxx]; + minx = _NOCHANGE; + maxx = &win->_y[y][x]; + for (sp = maxx; sp < end; sp++) + if (*sp != ' ') { + maxx = sp; + if (minx == _NOCHANGE) + minx = sp - win->_y[y]; + *sp = ' '; + } + /* + * update firstch and lastch for the line + */ + (void) touchline(win, y, win->_curx, win->_maxx - 1); + +#ifdef DEBUG + fprintf(outf, "CLRTOEOL: minx = %d, maxx = %d, firstch = %d," + " lastch = %d\n", minx, maxx - win->_y[y], win->_firstch[y], + win->_lastch[y]); +#endif + return (OK); +} diff --git a/usr/src/ucblib/libcurses/cr_put.c b/usr/src/ucblib/libcurses/cr_put.c new file mode 100644 index 0000000000..ba71354053 --- /dev/null +++ b/usr/src/ucblib/libcurses/cr_put.c @@ -0,0 +1,418 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)cr_put.c 1.7 89/03/27 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include <string.h> +#include "curses.ext" +#include <term.h> + +#define HARDTABS 8 + +/* forward declarations */ + +/* should be static, but we may have prior application-dependency, sigh! */ +void fgoto(void); +int plodput(char); +int plod(int); +int tabcol(int, int); + +/* + * Terminal driving and line formatting routines. + * Basic motion optimizations are done here as well + * as formatting of lines (printing of control characters, + * line numbering and the like). + */ + +/* + * Sync the position of the output cursor. + * Most work here is rounding for terminal boundaries getting the + * column position implied by wraparound or the lack thereof and + * rolling up the screen to get destline on the screen. + */ + +static int outcol, outline, destcol, destline; + +WINDOW *_win; + +int +mvcur(int ly, int lx, int y, int x) +{ +#ifdef DEBUG + fprintf(outf, "MVCUR: moving cursor from (%d,%d) to (%d,%d)\n", + ly, lx, y, x); +#endif + destcol = x; + destline = y; + outcol = lx; + outline = ly; + fgoto(); + return (OK); +} + +void +fgoto(void) +{ + char *cgp; + int l, c; + + if (destcol >= COLS) { + destline += destcol / COLS; + destcol %= COLS; + } + if (outcol >= COLS) { + l = (outcol + 1) / COLS; + outline += l; + outcol %= COLS; + if (AM == 0) { + while (l > 0) { + if (_pfast) + if (CR) + (void) _puts(CR); + else + (void) _putchar('\r'); + if (NL) + (void) _puts(NL); + else + (void) _putchar('\n'); + l--; + } + outcol = 0; + } + if (outline > LINES - 1) { + destline -= outline - (LINES - 1); + outline = LINES - 1; + } + } + if (destline >= LINES) { + l = destline; + destline = LINES - 1; + if (outline < LINES - 1) { + c = destcol; + if (_pfast == 0 && !CA) + destcol = 0; + fgoto(); + destcol = c; + } + while (l >= LINES) { + /* + * The following linefeed (or simulation thereof) + * is supposed to scroll up the screen, since we + * are on the bottom line. We make the assumption + * that linefeed will scroll. If ns is in the + * capability list this won't work. We should + * probably have an sc capability but sf will + * generally take the place if it works. + * + * Superbee glitch: in the middle of the screen we + * have to use esc B (down) because linefeed screws up + * in "Efficient Paging" (what a joke) mode (which is + * essential in some SB's because CRLF mode puts garbage + * in at end of memory), but you must use linefeed to + * scroll since down arrow won't go past memory end. + * I turned this off after recieving Paul Eggert's + * Superbee description which wins better. + */ + if (NL /* && !XB */ && _pfast) + (void) _puts(NL); + else + (void) _putchar('\n'); + l--; + if (_pfast == 0) + outcol = 0; + } + } + if (destline < outline && !(CA || UP)) + destline = outline; + if (CA) { + cgp = tgoto(CM, destcol, destline); + if (plod((int)strlen(cgp)) > 0) + (void) plod(0); + else + (void) tputs(cgp, 0, _putchar); + } + else + (void) plod(0); + outline = destline; + outcol = destcol; +} + +/* + * Move (slowly) to destination. + * Hard thing here is using home cursor on really deficient terminals. + * Otherwise just use cursor motions, hacking use of tabs and overtabbing + * and backspace. + */ + +static int plodcnt, plodflg; + +int +plodput(char c) +{ + if (plodflg) + plodcnt--; + else + (void) _putchar(c); + return (OK); +} + +int +plod(int cnt) +{ + int i, j, k; + int soutcol, soutline; + + plodcnt = plodflg = cnt; + soutcol = outcol; + soutline = outline; + /* + * Consider homing and moving down/right from there, vs moving + * directly with local motions to the right spot. + */ + if (HO) { + /* + * i is the cost to home and tab/space to the right to + * get to the proper column. This assumes ND space costs + * 1 char. So i+destcol is cost of motion with home. + */ + if (GT) + i = (destcol / HARDTABS) + (destcol % HARDTABS); + else + i = destcol; + /* + * j is cost to move locally without homing + */ + if (destcol >= outcol) { /* if motion is to the right */ + j = destcol / HARDTABS - outcol / HARDTABS; + if (GT && j) + j += destcol % HARDTABS; + else + j = destcol - outcol; + } + else + /* leftward motion only works if we can backspace. */ + if (outcol - destcol <= i && (BS || BC)) + i = j = outcol - destcol; + /* cheaper to backspace */ + else + j = i + 1; /* impossibly expensive */ + + /* k is the absolute value of vertical distance */ + k = outline - destline; + if (k < 0) + k = -k; + j += k; + + /* + * Decision. We may not have a choice if no UP. + */ + if (i + destline < j || (!UP && destline < outline)) { + /* + * Cheaper to home. Do it now and pretend it's a + * regular local motion. + */ + (void) tputs(HO, 0, plodput); + outcol = outline = 0; + } else if (LL) { + /* + * Quickly consider homing down and moving from there. + * Assume cost of LL is 2. + */ + k = (LINES - 1) - destline; + if (i + k + 2 < j && (k <= 0 || UP)) { + (void) tputs(LL, 0, plodput); + outcol = 0; + outline = LINES - 1; + } + } + } + else + /* + * No home and no up means it's impossible. + */ + if (!UP && destline < outline) + return (-1); + if (GT) + i = destcol % HARDTABS + destcol / HARDTABS; + else + i = destcol; +/* + * if (BT && outcol > destcol && + * (j = (((outcol+7) & ~7) - destcol - 1) >> 3)) { + * j *= (k = (int)strlen(BT)); + * if ((k += (destcol&7)) > 4) + * j += 8 - (destcol&7); + * else + * j += k; + * } + * else + */ + j = outcol - destcol; + /* + * If we will later need a \n which will turn into a \r\n by + * the system or the terminal, then don't bother to try to \r. + */ + if ((NONL || !_pfast) && outline < destline) + goto dontcr; + /* + * If the terminal will do a \r\n and there isn't room for it, + * then we can't afford a \r. + */ + if (NC && outline >= destline) + goto dontcr; + /* + * If it will be cheaper, or if we can't back up, then send + * a return preliminarily. + */ + if (j > i + 1 || outcol > destcol && !BS && !BC) { + /* + * BUG: this doesn't take the (possibly long) length + * of CR into account. + */ + if (CR) + (void) tputs(CR, 0, plodput); + else + (void) plodput('\r'); + if (NC) { + if (NL) + (void) tputs(NL, 0, plodput); + else + (void) plodput('\n'); + outline++; + } + outcol = 0; + } +dontcr: + while (outline < destline) { + outline++; + if (NL) + (void) tputs(NL, 0, plodput); + else + (void) plodput('\n'); + if (plodcnt < 0) + goto out; + if (NONL || _pfast == 0) + outcol = 0; + } + if (BT) + k = (int)strlen(BT); + while (outcol > destcol) { + if (plodcnt < 0) + goto out; +/* + * if (BT && outcol - destcol > k + 4) { + * (void) tputs(BT, 0, plodput); + * outcol--; + * outcol &= ~7; + * continue; + * } + */ + outcol--; + if (BC) + (void) tputs(BC, 0, plodput); + else + (void) plodput('\b'); + } + while (outline > destline) { + outline--; + (void) tputs(UP, 0, plodput); + if (plodcnt < 0) + goto out; + } + if (GT && destcol - outcol > 1) { + for (;;) { + i = tabcol(outcol, HARDTABS); + if (i > destcol) + break; + if (TA) + (void) tputs(TA, 0, plodput); + else + (void) plodput('\t'); + outcol = i; + } + if (destcol - outcol > 4 && i < COLS && (BC || BS)) { + if (TA) + (void) tputs(TA, 0, plodput); + else + (void) plodput('\t'); + outcol = i; + while (outcol > destcol) { + outcol--; + if (BC) + (void) tputs(BC, 0, plodput); + else + (void) plodput('\b'); + } + } + } + while (outcol < destcol) { + /* + * move one char to the right. We don't use ND space + * because it's better to just print the char we are + * moving over. + */ + if (_win != NULL) + if (plodflg) /* avoid a complex calculation */ + plodcnt--; + else { + i = curscr->_y[outline][outcol]; + if ((i&_STANDOUT) == (curscr->_flags&_STANDOUT)) + (void) _putchar(i & 0177); + else + goto nondes; + } + else +nondes: + if (ND) + (void) tputs(ND, 0, plodput); + else + (void) plodput(' '); + outcol++; + if (plodcnt < 0) + goto out; + } +out: + if (plodflg) { + outcol = soutcol; + outline = soutline; + } + return (plodcnt); +} + +/* + * Return the column number that results from being in column col and + * hitting a tab, where tabs are set every ts columns. Work right for + * the case where col > COLS, even if ts does not divide COLS. + */ + +int +tabcol(int col, int ts) +{ + int offset; + + if (col >= COLS) { + offset = COLS * (col / COLS); + col -= offset; + } + else + offset = 0; + return (col + ts - (col % ts) + offset); +} diff --git a/usr/src/ucblib/libcurses/cr_tty.c b/usr/src/ucblib/libcurses/cr_tty.c new file mode 100644 index 0000000000..a7983d9d9f --- /dev/null +++ b/usr/src/ucblib/libcurses/cr_tty.c @@ -0,0 +1,226 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)cr_tty.c 1.7 88/02/08 SMI"; /* from UCB 5.2 85/11/08 */ +#endif /* not lint */ + +/* + * Terminal initialization routines. + */ + +#include <unistd.h> +#include <string.h> +#include <sgtty.h> +#include "curses.ext" +#include <term.h> + +/* forward declaration */ +void zap(void); + +static bool *sflags[] = { + &AM, &BS, &DA, &DB, &EO, &HC, &HZ, &IN, &MI, + &MS, &NC, &NS, &OS, &UL, &XB, &XN, &XT, &XS, + &XX + }; + +static char *_PC, + **sstrs[] = { + &AL, &BC, &BT, &CD, &CE, &CL, &CM, &CR, &CS, + &DC, &DL, &DM, &DO, &ED, &EI, &K0, &K1, &K2, + &K3, &K4, &K5, &K6, &K7, &K8, &K9, &HO, &IC, + &IM, &IP, &KD, &KE, &KH, &KL, &KR, &KS, &KU, + &LL, &MA, &ND, &NL, &_PC, &RC, &SC, &SE, &SF, + &SO, &SR, &TA, &TE, &TI, &UC, &UE, &UP, &US, + &VB, &VS, &VE, &AL_PARM, &DL_PARM, &UP_PARM, + &DOWN_PARM, &LEFT_PARM, &RIGHT_PARM, + }; + +char _tspace[2048]; /* Space for capability strings */ + +static char *aoftspace; /* Address of _tspace for relocation */ + +static int destcol, destline; + +/* + * This routine does terminal type initialization routines, and + * calculation of flags at entry. It is almost entirely stolen from + * Bill Joy's ex version 2.6. + */ +short ospeed = -1; + +int +gettmode(void) +{ + if (gtty(_tty_ch, &_tty) < 0) + return (ERR); + savetty(); + if (stty(_tty_ch, &_tty) < 0) + _tty.sg_flags = _res_flg; + ospeed = _tty.sg_ospeed; + _res_flg = _tty.sg_flags; + UPPERCASE = (_tty.sg_flags & LCASE) != 0; + GT = ((_tty.sg_flags & XTABS) == 0); + NONL = ((_tty.sg_flags & CRMOD) == 0); + _tty.sg_flags &= ~XTABS; + (void) stty(_tty_ch, &_tty); +#ifdef DEBUG + fprintf(outf, "GETTMODE: UPPERCASE = %s\n", UPPERCASE ? "TRUE":"FALSE"); + fprintf(outf, "GETTMODE: GT = %s\n", GT ? "TRUE" : "FALSE"); + fprintf(outf, "GETTMODE: NONL = %s\n", NONL ? "TRUE" : "FALSE"); + fprintf(outf, "GETTMODE: ospeed = %d\n", ospeed); +#endif + return (OK); +} + +int +setterm(char *type) +{ + int unknown; + static char genbuf[1024]; +#ifdef TIOCGWINSZ + struct winsize win; +#endif + +#ifdef DEBUG + fprintf(outf, "SETTERM(\"%s\")\n", type); + fprintf(outf, "SETTERM: LINES = %d, COLS = %d\n", LINES, COLS); +#endif + if (type[0] == '\0') + type = "xx"; + unknown = FALSE; + if (tgetent(genbuf, type) != 1) { + unknown++; + (void) strcpy(genbuf, "xx|dumb:"); + } +#ifdef DEBUG + fprintf(outf, "SETTERM: tty = %s\n", type); +#endif +#ifdef TIOCGWINSZ + if (ioctl(_tty_ch, TIOCGWINSZ, &win) >= 0) { + if (LINES == 0) + LINES = win.ws_row; + if (COLS == 0) + COLS = win.ws_col; + } +#endif + + if (LINES == 0) + LINES = tgetnum("li"); + if (LINES <= 5) + LINES = 24; + + if (COLS == 0) + COLS = tgetnum("co"); + if (COLS <= 4) + COLS = 80; + +#ifdef DEBUG + fprintf(outf, "SETTERM: LINES = %d, COLS = %d\n", LINES, COLS); +#endif + aoftspace = _tspace; + zap(); /* get terminal description */ + + /* + * Handle funny termcap capabilities + */ + if (CS && SC && RC) AL = DL = ""; + if (AL_PARM && AL == NULL) AL = ""; + if (DL_PARM && DL == NULL) DL = ""; + if (IC && IM == NULL) IM = ""; + if (IC && EI == NULL) EI = ""; + if (!GT) BT = NULL; /* If we can't tab, we can't backtab either */ + + if (tgoto(CM, destcol, destline)[0] == 'O') + CA = FALSE, CM = 0; + else + CA = TRUE; + + PC = _PC ? _PC[0] : FALSE; + aoftspace = _tspace; + (void) strncpy(ttytype, longname(genbuf, type), sizeof (ttytype) - 1); + ttytype[sizeof (ttytype) - 1] = '\0'; + if (unknown) + return (ERR); + return (OK); +} + +/* + * This routine gets all the terminal flags from the termcap database + */ + +void +zap(void) +{ + char *namp; + bool **fp; + char ***sp; +#ifdef DEBUG + char *cp; +#endif + + namp = "ambsdadbeohchzinmimsncnsosulxbxnxtxsxx"; + fp = sflags; + do { + *(*fp++) = tgetflag(namp); +#ifdef DEBUG + fprintf(outf, "%2.2s = %s\n", namp, *fp[-1] ? "TRUE" : "FALSE"); +#endif + namp += 2; + } while (*namp); + namp = "albcbtcdceclcmcrcsdcdldmdoedeik0k1k2k3k4k5k6k7k8k9" + "hoicimipkdkekhklkrkskullmandnlpcrcscsesfsosrtatet" + "iucueupusvbvsveALDLUPDOLERI"; + sp = sstrs; + do { + *(*sp++) = tgetstr(namp, &aoftspace); +#ifdef DEBUG + fprintf(outf, "%2.2s = %s", + namp, *sp[-1] == NULL ? "NULL\n" : "\""); + if (*sp[-1] != NULL) { + for (cp = *sp[-1]; *cp; cp++) + fprintf(outf, "%s", unctrl(*cp)); + fprintf(outf, "\"\n"); + } +#endif + namp += 2; + } while (*namp); + if (XS) + SO = SE = NULL; + else { + if (tgetnum("sg") > 0) + SO = NULL; + if (tgetnum("ug") > 0) + US = NULL; + if (!SO && US) { + SO = US; + SE = UE; + } + } +} + +/* + * return a capability from termcap + */ + +char * +getcap(char *name) +{ + return (tgetstr(name, &aoftspace)); +} diff --git a/usr/src/ucblib/libcurses/curses.c b/usr/src/ucblib/libcurses/curses.c new file mode 100644 index 0000000000..1f906071ee --- /dev/null +++ b/usr/src/ucblib/libcurses/curses.c @@ -0,0 +1,65 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifndef lint +static char +sccsid[] = "@(#)curses.c 1.8 88/02/08 SMI"; /* from UCB 5.2 85/11/08 */ +#endif /* not lint */ + +/* + * Define global variables + * + */ + +#include <curses.h> + +bool _echoit = TRUE, /* set if stty indicates ECHO */ + _rawmode = FALSE, /* set if stty indicates RAW mode */ + My_term = FALSE, /* set if user specifies terminal type */ + _endwin = FALSE; /* set if endwin has been called */ + +char ttytype[50]; /* long name of tty */ +char *Def_term = "unknown"; /* default terminal type */ + +int _tty_ch = 1, /* file channel which is a tty */ + LINES, /* number of lines allowed on screen */ + COLS, /* number of columns allowed on screen */ + _res_flg; /* sgtty flags for reseting later */ + +WINDOW *stdscr = NULL, + *curscr = NULL; + +#ifdef DEBUG +FILE *outf; /* debug output file */ +#endif + +SGTTY _tty; /* tty modes */ + +bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, XB, XN, + XT, XS, XX; +char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, *DM, + *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, *K7, *K8, + *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, *KR, *KS, *KU, + *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, *SO, *SR, *TA, *TE, + *TI, *UC, *UE, *UP, *US, *VB, *VS, *VE, *AL_PARM, *DL_PARM, + *UP_PARM, *DOWN_PARM, *LEFT_PARM, *RIGHT_PARM; +char PC; + +/* + * From the tty modes... + */ + +bool GT, NONL, UPPERCASE, normtty, _pfast; diff --git a/usr/src/ucblib/libcurses/curses.ext b/usr/src/ucblib/libcurses/curses.ext new file mode 100644 index 0000000000..5e50d279d3 --- /dev/null +++ b/usr/src/ucblib/libcurses/curses.ext @@ -0,0 +1,61 @@ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * External variables for the curses library + */ + +/*LINTLIBRARY*/ + +#include "file64.h" +#include <curses.h> +#include <stdio.h> +#include <stdarg.h> + +extern bool _echoit, _rawmode, My_term, _endwin; + +extern char ttytype[50], *_unctrl[]; + +extern int _tty_ch, LINES, COLS; + +extern SGTTY _tty; + + +/* these are only for building libcurses */ +/* but, they could have been used by existing applications */ +extern int _sprintw(WINDOW *, char *, va_list); +extern int _putchar(char); +extern int _sscans(WINDOW *, char *, va_list); +extern void _swflags_(WINDOW *); +extern void _set_subwin_(WINDOW *, WINDOW *); +extern void _id_subwins(WINDOW *); + +/* this could have been used by existing applications */ +extern void tstp(void); +extern int gettmode(void); + +/* this one should be in /usr/include/term.h __STDC__, it is a bug there */ +extern char *tgoto(char *, int, int); + +#ifdef DEBUG +#define outf _outf + +FILE *outf; +#endif + +/* inter-library dependency */ + +extern int _doscan(FILE *, const char *, va_list); diff --git a/usr/src/ucblib/libcurses/delch.c b/usr/src/ucblib/libcurses/delch.c new file mode 100644 index 0000000000..285e740b93 --- /dev/null +++ b/usr/src/ucblib/libcurses/delch.c @@ -0,0 +1,45 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)delch.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * This routine performs an insert-char on the line, leaving + * (_cury,_curx) unchanged. + */ + +int +wdelch(WINDOW *win) +{ + char *temp1, *temp2; + char *end; + + end = &win->_y[win->_cury][win->_maxx - 1]; + temp1 = &win->_y[win->_cury][win->_curx]; + temp2 = temp1 + 1; + while (temp1 < end) + *temp1++ = *temp2++; + *temp1 = ' '; + (void) touchline(win, win->_cury, win->_curx, win->_maxx - 1); + return (OK); +} diff --git a/usr/src/ucblib/libcurses/deleteln.c b/usr/src/ucblib/libcurses/deleteln.c new file mode 100644 index 0000000000..6bcaa55bf1 --- /dev/null +++ b/usr/src/ucblib/libcurses/deleteln.c @@ -0,0 +1,60 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)deleteln.c 1.8 89/08/24 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" +#include <string.h> + +/* + * This routine deletes a line from the screen. It leaves + * (_cury,_curx) unchanged. + */ + +int +wdeleteln(WINDOW *win) +{ + char *temp; + int y; + char *end; + +#ifdef DEBUG + fprintf(outf, "DELETELN(%0.2o)\n", win); +#endif + temp = win->_y[win->_cury]; + for (y = win->_cury; y < win->_maxy - 1; y++) { + if (win->_orig == NULL) + win->_y[y] = win->_y[y + 1]; + else + (void) memmove(win->_y[y], win->_y[y+1], win->_maxx); + (void) touchline(win, y, 0, win->_maxx - 1); + } + if (win->_orig == NULL) + win->_y[y] = temp; + else + temp = win->_y[y]; + for (end = &temp[win->_maxx]; temp < end; ) + *temp++ = ' '; + (void) touchline(win, y, 0, win->_maxx - 1); + if (win->_orig == NULL) + _id_subwins(win); + return (OK); +} diff --git a/usr/src/ucblib/libcurses/delwin.c b/usr/src/ucblib/libcurses/delwin.c new file mode 100644 index 0000000000..483bb5d28e --- /dev/null +++ b/usr/src/ucblib/libcurses/delwin.c @@ -0,0 +1,67 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)delwin.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" +#include <malloc.h> + +/* + * This routine deletes a window and releases it back to the system. + */ + +int +delwin(WINDOW *win) +{ + int i; + WINDOW *wp, *np; + + if (win->_orig == NULL) { + /* + * If we are the original window, delete the space for + * all the subwindows, and the array of space as well. + */ + for (i = 0; i < win->_maxy && win->_y[i]; i++) + free(win->_y[i]); + free(win->_firstch); + free(win->_lastch); + wp = win->_nextp; + while (wp != win) { + np = wp->_nextp; + (void) delwin(wp); + wp = np; + } + } else { + /* + * If we are a subwindow, take ourselves out of the + * list. NOTE: if we are a subwindow, the minimum list + * is orig followed by this subwindow, so there are + * always at least two windows in the list. + */ + for (wp = win->_nextp; wp->_nextp != win; wp = wp->_nextp) + continue; + wp->_nextp = win->_nextp; + } + free(win->_y); + free(win); + + return (OK); +} diff --git a/usr/src/ucblib/libcurses/endwin.c b/usr/src/ucblib/libcurses/endwin.c new file mode 100644 index 0000000000..1af7e7c578 --- /dev/null +++ b/usr/src/ucblib/libcurses/endwin.c @@ -0,0 +1,47 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)endwin.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +/* + * Clean things up before exiting + */ + +#include <sgtty.h> +#include <malloc.h> +#include "curses.ext" +#include <term.h> + +int +endwin(void) +{ + resetty(); + (void) _puts(VE); + (void) _puts(TE); + if (curscr) { + if (curscr->_flags & _STANDOUT) { + (void) _puts(SE); + curscr->_flags &= ~_STANDOUT; + } + _endwin = TRUE; + } + return (OK); +} diff --git a/usr/src/ucblib/libcurses/erase.c b/usr/src/ucblib/libcurses/erase.c new file mode 100644 index 0000000000..b3511b82bf --- /dev/null +++ b/usr/src/ucblib/libcurses/erase.c @@ -0,0 +1,58 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)erase.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include <stddef.h> +#include "curses.ext" + +/* + * This routine erases everything on the window. + */ + +int +werase(WINDOW *win) +{ + int y; + char *sp, *end, *start, *maxx; + ptrdiff_t minx; + +#ifdef DEBUG + fprintf(outf, "WERASE(%0.2o)\n", win); +#endif + for (y = 0; y < win->_maxy; y++) { + minx = _NOCHANGE; + start = win->_y[y]; + end = &start[win->_maxx]; + for (sp = start; sp < end; sp++) + if (*sp != ' ') { + maxx = sp; + if (minx == _NOCHANGE) + minx = sp - start; + *sp = ' '; + } + if (minx != _NOCHANGE) + (void) touchline(win, y, (int)minx, + (int)(maxx - win->_y[y])); + } + win->_curx = win->_cury = 0; + return (OK); +} diff --git a/usr/src/ucblib/libcurses/fullname.c b/usr/src/ucblib/libcurses/fullname.c new file mode 100644 index 0000000000..3066a99c6e --- /dev/null +++ b/usr/src/ucblib/libcurses/fullname.c @@ -0,0 +1,47 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)fullname.c 1.3 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +/* + * This routine fills in "def" with the full name of the terminal. + * This is assumed to be the last name in the list of aliases. + */ + +char * +fullname(char *bp, char *def) +{ + char *cp; + + *def = 0; /* in case no name */ + + while (*bp && *bp != ':') { + cp = def; /* start of answer */ + while (*bp && *bp != ':' && *bp != '|') { + *cp++ = *bp++; /* copy name over */ + } + *cp = 0; /* zero end of name */ + if (*bp == '|') { + bp++; /* skip over '|' if that is case */ + } + } + return (def); +} diff --git a/usr/src/ucblib/libcurses/getch.c b/usr/src/ucblib/libcurses/getch.c new file mode 100644 index 0000000000..30c179462d --- /dev/null +++ b/usr/src/ucblib/libcurses/getch.c @@ -0,0 +1,59 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)getch.c 1.9 88/02/08 SMI"; /* from UCB 5.3 86/04/16 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * This routine reads in a character from the window. + */ + +int +wgetch(WINDOW *win) +{ + bool weset = FALSE; + char inp; + + if (!win->_scroll && (win->_flags&_FULLWIN) && + win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1) + return (ERR); +#ifdef DEBUG + fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n", + _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F'); +#endif + if (_echoit && !_rawmode) { + cbreak(); + weset++; + } + inp = getchar(); +#ifdef DEBUG + fprintf(outf, "WGETCH got '%s'\n", unctrl(inp)); +#endif + if (_echoit) { + (void) mvwaddch(curscr, win->_cury + win->_begy, + win->_curx + win->_begx, inp); + (void) waddch(win, inp); + } + if (weset) + nocbreak(); + return ((int)inp); +} diff --git a/usr/src/ucblib/libcurses/getstr.c b/usr/src/ucblib/libcurses/getstr.c new file mode 100644 index 0000000000..6223067049 --- /dev/null +++ b/usr/src/ucblib/libcurses/getstr.c @@ -0,0 +1,42 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)getstr.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * This routine gets a string starting at (_cury,_curx) + * + */ + +int +wgetstr(WINDOW *win, char *str) +{ + while ((*str = wgetch(win)) != ERR && *str != '\n') + str++; + if (*str == ERR) { + *str = '\0'; + return (ERR); + } + *str = '\0'; + return (OK); +} diff --git a/usr/src/ucblib/libcurses/i386/Makefile b/usr/src/ucblib/libcurses/i386/Makefile new file mode 100644 index 0000000000..9557263181 --- /dev/null +++ b/usr/src/ucblib/libcurses/i386/Makefile @@ -0,0 +1,38 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libcurses/i386/Makefile + +MAPDIR= ../spec/i386 +include ../Makefile.com + +DYNFLAGS += $(DYNFLAGS32) +BUILD.SO= $(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/ucblib $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/libcurses/id_subwins.c b/usr/src/ucblib/libcurses/id_subwins.c new file mode 100644 index 0000000000..909af66a68 --- /dev/null +++ b/usr/src/ucblib/libcurses/id_subwins.c @@ -0,0 +1,51 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)id_subwins.c 1.3 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * _id_subwins: + * Re-sync the pointers to _y for all the subwindows. + */ + +void +_id_subwins(WINDOW *orig) +{ + WINDOW *win; + int realy; + int y, oy; + + realy = orig->_begy + orig->_cury; + for (win = orig->_nextp; win != orig; win = win->_nextp) { + /* + * If the window ends before our current position, + * don't need to do anything. + */ + if (win->_begy + win->_maxy <= realy) + continue; + + oy = orig->_cury; + for (y = realy - win->_begy; y < win->_maxy; y++, oy++) + win->_y[y] = &orig->_y[oy][win->_ch_off]; + } +} diff --git a/usr/src/ucblib/libcurses/idlok.c b/usr/src/ucblib/libcurses/idlok.c new file mode 100644 index 0000000000..4858ea8684 --- /dev/null +++ b/usr/src/ucblib/libcurses/idlok.c @@ -0,0 +1,40 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)idlok.c 1.3 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * idlok: + * Turn on and off using insert/deleteln sequences for the given + * window. + */ + +int +idlok(WINDOW *win, bool bf) +{ + if (bf) + win->_flags |= _IDLINE; + else + win->_flags &= ~_IDLINE; + return (OK); +} diff --git a/usr/src/ucblib/libcurses/initscr.c b/usr/src/ucblib/libcurses/initscr.c new file mode 100644 index 0000000000..609205c98f --- /dev/null +++ b/usr/src/ucblib/libcurses/initscr.c @@ -0,0 +1,78 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)initscr.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" +#include <term.h> +#include <stdlib.h> +#include <signal.h> + +/* + * This routine initializes the current and standard screen. + */ + +WINDOW * +initscr(void) +{ + char *sp; + +#ifdef DEBUG + fprintf(outf, "INITSCR()\n"); +#endif + if (My_term) + (void) setterm(Def_term); + else { + (void) gettmode(); + if ((sp = getenv("TERM")) == NULL) + sp = Def_term; + (void) setterm(sp); +#ifdef DEBUG + fprintf(outf, "INITSCR: term = %s\n", sp); +#endif + } + (void) _puts(TI); + (void) _puts(VS); +#ifdef SIGTSTP + (void) signal(SIGTSTP, (void(*)(int))tstp); +#endif + if (curscr != NULL) { +#ifdef DEBUG + fprintf(outf, "INITSCR: curscr = 0%o\n", curscr); +#endif + (void) delwin(curscr); + } +#ifdef DEBUG + fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); +#endif + if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) + return (ERR); + clearok(curscr, TRUE); + curscr->_flags &= ~_FULLLINE; + if (stdscr != NULL) { +#ifdef DEBUG + fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr); +#endif + (void) delwin(stdscr); + } + stdscr = newwin(LINES, COLS, 0, 0); + return (stdscr); +} diff --git a/usr/src/ucblib/libcurses/insch.c b/usr/src/ucblib/libcurses/insch.c new file mode 100644 index 0000000000..7526e7f5c8 --- /dev/null +++ b/usr/src/ucblib/libcurses/insch.c @@ -0,0 +1,53 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)insch.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * This routine performs an insert-char on the line, leaving + * (_cury,_curx) unchanged. + */ + +int +winsch(WINDOW *win, char c) +{ + char *temp1, *temp2; + char *end; + + end = &win->_y[win->_cury][win->_curx]; + temp1 = &win->_y[win->_cury][win->_maxx - 1]; + temp2 = temp1 - 1; + while (temp1 > end) + *temp1-- = *temp2--; + *temp1 = c; + (void) touchline(win, win->_cury, win->_curx, win->_maxx - 1); + if (win->_cury == LINES - 1 && win->_y[LINES-1][COLS-1] != ' ') + if (win->_scroll) { + (void) wrefresh(win); + (void) scroll(win); + win->_cury--; + } + else + return (ERR); + return (OK); +} diff --git a/usr/src/ucblib/libcurses/insertln.c b/usr/src/ucblib/libcurses/insertln.c new file mode 100644 index 0000000000..e26d657d78 --- /dev/null +++ b/usr/src/ucblib/libcurses/insertln.c @@ -0,0 +1,61 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)insertln.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" +#include <string.h> + +/* + * This routine performs an insert-line on the window, leaving + * (_cury,_curx) unchanged. + */ + +int +winsertln(WINDOW *win) +{ + char *temp; + int y; + char *end; + +#ifdef DEBUG + fprintf(outf, "INSERTLN(%0.2o)\n", win); +#endif + if (win->_orig == NULL) + temp = win->_y[win->_maxy - 1]; + for (y = win->_maxy - 1; y > win->_cury; --y) { + if (win->_orig == NULL) + win->_y[y] = win->_y[y - 1]; + else + (void) memmove(win->_y[y], win->_y[y-1], win->_maxx); + (void) touchline(win, y, 0, win->_maxx - 1); + } + if (win->_orig == NULL) + win->_y[y] = temp; + else + temp = win->_y[y]; + for (end = &temp[win->_maxx]; temp < end; ) + *temp++ = ' '; + (void) touchline(win, y, 0, win->_maxx - 1); + if (win->_orig == NULL) + _id_subwins(win); + return (OK); +} diff --git a/usr/src/ucblib/libcurses/llib-lcurses b/usr/src/ucblib/libcurses/llib-lcurses new file mode 100644 index 0000000000..a21ce02071 --- /dev/null +++ b/usr/src/ucblib/libcurses/llib-lcurses @@ -0,0 +1,148 @@ +/* + * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +#pragma ident "%Z%%M% %I% %E% SMI" + +/* LINTLIBRARY */ + +# include <curses.h> +# include <signal.h> +# include <varargs.h> +# include <ctype.h> + +/* addch.c */ +int waddch(win, c) register struct _win_st *win; char c; { static int x; return(x); } + +/* addstr.c */ +int waddstr(win, str) register struct _win_st *win; register char *str; { static int x; return(x); } + +/* box.c */ +int box(win, vert, hor) register struct _win_st *win; char vert; char hor; { static int x; return(x); } + +/* clear.c */ +int wclear(win) register struct _win_st *win; { static int x; return(x); } + +/* clrtobot.c */ +int wclrtobot(win) register struct _win_st *win; { static int x; return(x); } + +/* clrtoeol.c */ +int wclrtoeol(win) register struct _win_st *win; { static int x; return(x); } + +/* cr_put.c */ +int mvcur(ly, lx, y, x) int ly; int lx; int y; int x; { static int z; return(z); } +int fgoto() { static int x; return(x); } +int plodput(c) int c; { static int x; return(x); } +int plod(cnt) int cnt; { static int x; return(x); } +int tabcol(col, ts) int col; int ts; { static int x; return(x); } + +/* cr_tty.c */ +int gettmode() { static int x; return(x); } +int setterm(type) register char *type; { static int x; return(x); } +int zap() { static int x; return(x); } +char *getcap(name) char *name; { static char *x; return(x); } + +/* curses.c */ + +/* delch.c */ +int wdelch(win) register struct _win_st *win; { static int x; return(x); } + +/* deleteln.c */ +int wdeleteln(win) register struct _win_st *win; { static int x; return(x); } + +/* delwin.c */ +int delwin(win) register struct _win_st *win; { static int x; return(x); } + +/* endwin.c */ +int endwin() { static int x; return(x); } + +/* erase.c */ +int werase(win) register struct _win_st *win; { static int x; return(x); } + +/* fullname.c */ +char *fullname(bp, def) register char *bp; register char *def; { static char *x; return(x); } + +/* getch.c */ +int wgetch(win) register struct _win_st *win; { static int x; return(x); } + +/* getstr.c */ +int wgetstr(win, str) register struct _win_st *win; register char *str; { static int x; return(x); } + +/* id_subwins.c */ +int _id_subwins(orig) register struct _win_st *orig; { static int x; return(x); } + +/* idlok.c */ +int idlok(win, bf) register struct _win_st *win; char bf; { static int x; return(x); } + +/* initscr.c */ +struct _win_st *initscr() { static struct _win_st *x; return(x); } + +/* insch.c */ +int winsch(win, c) register struct _win_st *win; char c; { static int x; return(x); } + +/* insertln.c */ +int winsertln(win) register struct _win_st *win; { static int x; return(x); } + +/* longname.c */ +char *longname(bp, def) register char *bp; register char *def; { static char *x; return(x); } + +/* move.c */ +int wmove(win, y, x) register struct _win_st *win; register int y; register int x; { static int z; return(z); } + +/* mvprintw.c */ +int mvprintw(y, x, fmt, __builtin_va_alist) register int y; register int x; char *fmt; int __builtin_va_alist; { static int z; return(z); } +int mvwprintw(win, y, x, fmt, __builtin_va_alist) register struct _win_st *win; register int y; register int x; char *fmt; int __builtin_va_alist; { static int z; return(z); } + +/* mvscanw.c */ +int mvscanw(y, x, fmt, __builtin_va_alist) register int y; register int x; char *fmt; int __builtin_va_alist; { static int z; return(z); } +int mvwscanw(win, y, x, fmt, __builtin_va_alist) register struct _win_st *win; register int y; register int x; char *fmt; int __builtin_va_alist; { static int z; return(z); } + +/* mvwin.c */ +int mvwin(win, by, bx) register struct _win_st *win; register int by; register int bx; { static int x; return(x); } + +/* newwin.c */ +struct _win_st *newwin(num_lines, num_cols, begy, begx) int num_lines; int num_cols; int begy; int begx; { static struct _win_st *x; return(x); } +struct _win_st *subwin(orig, num_lines, num_cols, begy, begx) register struct _win_st *orig; int num_lines; int num_cols; int begy; int begx; { static struct _win_st *x; return(x); } +int _set_subwin_(orig, win) register struct _win_st *orig; register struct _win_st *win; { static int x; return(x); } +int _swflags_(win) register struct _win_st *win; { static int x; return(x); } + +/* overlay.c */ +int overlay(win1, win2) register struct _win_st *win1; register struct _win_st *win2; { static int x; return(x); } + +/* overwrite.c */ +int overwrite(win1, win2) register struct _win_st *win1; register struct _win_st *win2; { static int x; return(x); } + +/* printw.c */ +int printw(fmt, __builtin_va_alist) char *fmt; int __builtin_va_alist; { static int x; return(x); } +int wprintw(win, fmt, __builtin_va_alist) struct _win_st *win; char *fmt; int __builtin_va_alist; { static int x; return(x); } +int _sprintw(win, fmt, ap) struct _win_st *win; char *fmt; va_list ap; { static int x; return(x); } + +/* putchar.c */ +char _putchar(c) register char c; { static char x; return(x); } + +/* refresh.c */ +int wrefresh(win) register struct _win_st *win; { static int x; return(x); } + +/* scanw.c */ +int scanw(fmt, __builtin_va_alist) char *fmt; int __builtin_va_alist; { static int x; return(x); } +int wscanw(win, fmt, __builtin_va_alist) struct _win_st *win; char *fmt; int __builtin_va_alist; { static int x; return(x); } +int _sscans(win, fmt, ap) struct _win_st *win; char *fmt; va_list ap; { static int x; return(x); } + +/* scroll.c */ +int scroll(win) register struct _win_st *win; { static int x; return(x); } + +/* standout.c */ +char *wstandout(win) register struct _win_st *win; { static char *x; return(x); } +char *wstandend(win) register struct _win_st *win; { static char *x; return(x); } + +/* toucholap.c */ +int touchoverlap(win1, win2) register struct _win_st *win1; register struct _win_st *win2; { static int x; return(x); } + +/* touchwin.c */ +int touchwin(win) register struct _win_st *win; { static int x; return(x); } +int touchline(win, y, sx, ex) register struct _win_st *win; register int y; register int sx; register int ex; { static int x; return(x); } + +/* tstp.c */ +void tstp() {} + +/* unctrl.c */ diff --git a/usr/src/ucblib/libcurses/longname.c b/usr/src/ucblib/libcurses/longname.c new file mode 100644 index 0000000000..634f85af26 --- /dev/null +++ b/usr/src/ucblib/libcurses/longname.c @@ -0,0 +1,43 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)longname.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +/* + * This routine fills in "def" with the long name of the terminal. + */ + +char * +longname(char *bp, char *def) +{ + char *cp; + + while (*bp && *bp != ':' && *bp != '|') + bp++; + if (*bp == '|') { + bp++; + cp = def; + while (*bp && *bp != ':' && *bp != '|') + *cp++ = *bp++; + *cp = 0; + } + return (def); +} diff --git a/usr/src/ucblib/libcurses/move.c b/usr/src/ucblib/libcurses/move.c new file mode 100644 index 0000000000..acc3e3c107 --- /dev/null +++ b/usr/src/ucblib/libcurses/move.c @@ -0,0 +1,43 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)move.c 1.7 88/02/08 SMI"; /* from UCB 5.2 85/10/08 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * This routine moves the cursor to the given point + */ + +int +wmove(WINDOW *win, int y, int x) +{ +#ifdef DEBUG + fprintf(outf, "MOVE to (%d, %d)\n", y, x); +#endif + if (x < 0 || y < 0) + return (ERR); + if (x >= win->_maxx || y >= win->_maxy) + return (ERR); + win->_curx = (short)x; + win->_cury = (short)y; + return (OK); +} diff --git a/usr/src/ucblib/libcurses/mvprintw.c b/usr/src/ucblib/libcurses/mvprintw.c new file mode 100644 index 0000000000..e0875f00a2 --- /dev/null +++ b/usr/src/ucblib/libcurses/mvprintw.c @@ -0,0 +1,48 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)mvprintw.c 1.7 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include <stdarg.h> +#include "curses.ext" + +/* + * implement the mvprintw commands. Due to the variable number of + * arguments, they cannot be macros. Sigh.... + */ + +int +mvprintw(int y, int x, char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + return (move(y, x) == OK ? _sprintw(stdscr, fmt, ap) : ERR); +} + +int +mvwprintw(WINDOW *win, int y, int x, char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + return (wmove(win, y, x) == OK ? _sprintw(win, fmt, ap) : ERR); +} diff --git a/usr/src/ucblib/libcurses/mvscanw.c b/usr/src/ucblib/libcurses/mvscanw.c new file mode 100644 index 0000000000..66fedbf709 --- /dev/null +++ b/usr/src/ucblib/libcurses/mvscanw.c @@ -0,0 +1,48 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)mvscanw.c 1.8 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include <stdarg.h> +#include "curses.ext" + +/* + * implement the mvscanw commands. Due to the variable number of + * arguments, they cannot be macros. Another sigh.... + */ + +int +mvscanw(int y, int x, char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + return (move(y, x) == OK ? _sscans(stdscr, fmt, ap) : ERR); +} + +int +mvwscanw(WINDOW *win, int y, int x, char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + return (wmove(win, y, x) == OK ? _sscans(win, fmt, ap) : ERR); +} diff --git a/usr/src/ucblib/libcurses/mvwin.c b/usr/src/ucblib/libcurses/mvwin.c new file mode 100644 index 0000000000..5a97da4017 --- /dev/null +++ b/usr/src/ucblib/libcurses/mvwin.c @@ -0,0 +1,61 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)mvwin.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * relocate the starting position of a window + */ + +int +mvwin(WINDOW *win, int by, int bx) +{ + WINDOW *orig; + int dy, dx; + + if (by + win->_maxy > LINES || bx + win->_maxx > COLS) + return (ERR); + dy = by - win->_begy; + dx = bx - win->_begx; + orig = win->_orig; + if (orig == NULL) { + orig = win; + do { + win->_begy += dy; + win->_begx += dx; + _swflags_(win); + win = win->_nextp; + } while (win != orig); + } else { + if (by < orig->_begy || win->_maxy + dy > orig->_maxy) + return (ERR); + if (bx < orig->_begx || win->_maxx + dx > orig->_maxx) + return (ERR); + win->_begy = (short)by; + win->_begx = (short)bx; + _swflags_(win); + _set_subwin_(orig, win); + } + (void) touchwin(win); + return (OK); +} diff --git a/usr/src/ucblib/libcurses/newwin.c b/usr/src/ucblib/libcurses/newwin.c new file mode 100644 index 0000000000..5ee36dab03 --- /dev/null +++ b/usr/src/ucblib/libcurses/newwin.c @@ -0,0 +1,218 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)newwin.c 1.7 89/07/13 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +/* + * allocate space for and set up defaults for a new window + * + */ + +#include "curses.ext" +#include <malloc.h> + +#define SMALLOC (short *)malloc + +/* forward declaration */ +static WINDOW *makenew(int, int, int, int); + +#undef nl /* don't need it here, and it interferes */ + +WINDOW * +newwin(int num_lines, int num_cols, int begy, int begx) +{ + WINDOW *win; + char *sp; + int i, by, bx, nl, nc; + int j; + + by = begy; + bx = begx; + nl = num_lines; + nc = num_cols; + + if (nl == 0) + nl = LINES - by; + if (nc == 0) + nc = COLS - bx; + if ((win = makenew(nl, nc, by, bx)) == NULL) + return (ERR); + if ((win->_firstch = SMALLOC(nl * sizeof (win->_firstch[0]))) == NULL) { + free(win->_y); + free(win); + return (NULL); + } + if ((win->_lastch = SMALLOC(nl * sizeof (win->_lastch[0]))) == NULL) { + free(win->_y); + free(win->_firstch); + free(win); + return (NULL); + } + win->_nextp = win; + for (i = 0; i < nl; i++) { + win->_firstch[i] = _NOCHANGE; + win->_lastch[i] = _NOCHANGE; + } + for (i = 0; i < nl; i++) + if ((win->_y[i] = malloc(nc * sizeof (win->_y[0]))) == NULL) { + for (j = 0; j < i; j++) + free(win->_y[j]); + free(win->_firstch); + free(win->_lastch); + free(win->_y); + free(win); + return (ERR); + } + else + for (sp = win->_y[i]; sp < win->_y[i] + nc; ) + *sp++ = ' '; + win->_ch_off = 0; +#ifdef DEBUG + fprintf(outf, "NEWWIN: win->_ch_off = %d\n", win->_ch_off); +#endif + return (win); +} + +WINDOW * +subwin(WINDOW *orig, int num_lines, int num_cols, int begy, int begx) +{ + WINDOW *win; + int by, bx, nl, nc; + + by = begy; + bx = begx; + nl = num_lines; + nc = num_cols; + + /* + * make sure window fits inside the original one + */ +#ifdef DEBUG + fprintf(outf, "SUBWIN(%0.2o, %d, %d, %d, %d)\n", orig, nl, nc, by, bx); +#endif + if (by < orig->_begy || bx < orig->_begx || + by + nl > orig->_maxy + orig->_begy || + bx + nc > orig->_maxx + orig->_begx) + return (ERR); + if (nl == 0) + nl = orig->_maxy + orig->_begy - by; + if (nc == 0) + nc = orig->_maxx + orig->_begx - bx; + if ((win = makenew(nl, nc, by, bx)) == NULL) + return (ERR); + win->_nextp = orig->_nextp; + orig->_nextp = win; + win->_orig = orig; + _set_subwin_(orig, win); + return (win); +} + +/* + * this code is shared with mvwin() + */ + +void +_set_subwin_(WINDOW *orig, WINDOW *win) +{ + int i, j, k; + + j = win->_begy - orig->_begy; + k = win->_begx - orig->_begx; + win->_ch_off = (short)k; +#ifdef DEBUG + fprintf(outf, "_SET_SUBWIN_: win->_ch_off = %d\n", win->_ch_off); +#endif + win->_firstch = &orig->_firstch[j]; + win->_lastch = &orig->_lastch[j]; + for (i = 0; i < win->_maxy; i++, j++) + win->_y[i] = &orig->_y[j][k]; + +} + +/* + * This routine sets up a window buffer and returns a pointer to it. + */ + +static WINDOW * +makenew(int num_lines, int num_cols, int begy, int begx) +{ + WINDOW *win; + int by, bx, nl, nc; + + by = begy; + bx = begx; + nl = num_lines; + nc = num_cols; + +#ifdef DEBUG + fprintf(outf, "MAKENEW(%d, %d, %d, %d)\n", nl, nc, by, bx); +#endif + if ((win = (WINDOW *) malloc(sizeof (*win))) == NULL) + return (NULL); +#ifdef DEBUG + fprintf(outf, "MAKENEW: nl = %d\n", nl); +#endif + if ((win->_y = (char **)malloc(nl * sizeof (win->_y[0]))) == NULL) { + free(win); + return (NULL); + } +#ifdef DEBUG + fprintf(outf, "MAKENEW: nc = %d\n", nc); +#endif + win->_cury = win->_curx = 0; + win->_clear = FALSE; + win->_maxy = (short)nl; + win->_maxx = (short)nc; + win->_begy = (short)by; + win->_begx = (short)bx; + win->_flags = 0; + win->_scroll = win->_leave = FALSE; + _swflags_(win); + win->_orig = NULL; +#ifdef DEBUG + fprintf(outf, "MAKENEW: win->_clear = %d\n", win->_clear); + fprintf(outf, "MAKENEW: win->_leave = %d\n", win->_leave); + fprintf(outf, "MAKENEW: win->_scroll = %d\n", win->_scroll); + fprintf(outf, "MAKENEW: win->_flags = %0.2o\n", win->_flags); + fprintf(outf, "MAKENEW: win->_maxy = %d\n", win->_maxy); + fprintf(outf, "MAKENEW: win->_maxx = %d\n", win->_maxx); + fprintf(outf, "MAKENEW: win->_begy = %d\n", win->_begy); + fprintf(outf, "MAKENEW: win->_begx = %d\n", win->_begx); +#endif + return (win); +} + +void +_swflags_(WINDOW *win) +{ + win->_flags &= ~(_ENDLINE|_FULLLINE|_FULLWIN|_SCROLLWIN); + if (win->_begx + win->_maxx == COLS) { + win->_flags |= _ENDLINE; + if (win->_begx == 0) { + if (AL && DL) + win->_flags |= _FULLLINE; + if (win->_maxy == LINES && win->_begy == 0) + win->_flags |= _FULLWIN; + } + if (win->_begy + win->_maxy == LINES) + win->_flags |= _SCROLLWIN; + } +} diff --git a/usr/src/ucblib/libcurses/overlay.c b/usr/src/ucblib/libcurses/overlay.c new file mode 100644 index 0000000000..d4982156ba --- /dev/null +++ b/usr/src/ucblib/libcurses/overlay.c @@ -0,0 +1,66 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)overlay.c 1.9 89/07/13 SMI"; /* from UCB 5.2 86/02/12 */ +#endif /* not lint */ + +#include "curses.ext" +#include <ctype.h> + +#define min(a, b) ((a) < (b) ? (a) : (b)) +#define max(a, b) ((a) > (b) ? (a) : (b)) + +/* + * This routine writes win1 on win2 non-destructively. + */ + +int +overlay(WINDOW *win1, WINDOW *win2) +{ + char *sp, *end; + int x, y, endy, endx, starty, startx; + int y1, y2; + +#ifdef DEBUG + fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2); +#endif + starty = max(win1->_begy, win2->_begy); + startx = max(win1->_begx, win2->_begx); + endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begy); + endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); +#ifdef DEBUG + fprintf(outf, "OVERLAY:from (%d,%d) to (%d,%d)\n", + starty, startx, endy, endx); +#endif + if (starty >= endy || startx >= endx) + return (OK); + y1 = starty - win1->_begy; + y2 = starty - win2->_begy; + for (y = starty; y < endy; y++, y1++, y2++) { + end = &win1->_y[y1][endx - win1->_begx]; + x = startx - win2->_begx; + for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) { + if (!isspace(*sp)) + (void) mvwaddch(win2, y2, x, *sp); + x++; + } + } + return (OK); +} diff --git a/usr/src/ucblib/libcurses/overwrite.c b/usr/src/ucblib/libcurses/overwrite.c new file mode 100644 index 0000000000..2240eee5e6 --- /dev/null +++ b/usr/src/ucblib/libcurses/overwrite.c @@ -0,0 +1,61 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)overwrite.c 1.7 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" +#include <ctype.h> +#include <string.h> + +#define min(a, b) ((a) < (b) ? (a) : (b)) +#define max(a, b) ((a) > (b) ? (a) : (b)) + +/* + * This routine writes win1 on win2 destructively. + */ + +int +overwrite(WINDOW *win1, WINDOW *win2) +{ + int x, y, endy, endx, starty, startx; + +#ifdef DEBUG + fprintf(outf, "OVERWRITE(%0.2o, %0.2o);\n", win1, win2); +#endif + starty = max(win1->_begy, win2->_begy); + startx = max(win1->_begx, win2->_begx); + endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begy); + endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); + if (starty >= endy || startx >= endx) + return (OK); +#ifdef DEBUG + fprintf(outf, "OVERWRITE:from (%d,%d) to (%d,%d)\n", + starty, startx, endy, endx); +#endif + x = endx - startx; + for (y = starty; y < endy; y++) { + (void) memmove(&win2->_y[y - win2->_begy][startx - win2->_begx], + &win1->_y[y - win1->_begy][startx - win1->_begx], x); + (void) touchline(win2, y, startx - win2->_begx, + endx - win2->_begx); + } + return (OK); +} diff --git a/usr/src/ucblib/libcurses/printw.c b/usr/src/ucblib/libcurses/printw.c new file mode 100644 index 0000000000..74f660ec8e --- /dev/null +++ b/usr/src/ucblib/libcurses/printw.c @@ -0,0 +1,73 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)printw.c 1.8 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include <stdarg.h> + +/* + * printw and friends + * + */ + +#include "curses.ext" + +/* + * This routine implements a printf on the standard screen. + */ + +int +printw(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + return (_sprintw(stdscr, fmt, ap)); +} + +/* + * This routine implements a printf on the given window. + */ + +int +wprintw(WINDOW *win, char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + return (_sprintw(win, fmt, ap)); +} +/* + * This routine actually executes the printf and adds it to the window + * + * This code now uses the vsprintf routine, which portably digs + * into stdio. We provide a vsprintf for older systems that don't + * have one. + */ + +int +_sprintw(WINDOW *win, char *fmt, va_list ap) +{ + char buf[512]; + + (void) vsprintf(buf, fmt, ap); + return (waddstr(win, buf)); +} diff --git a/usr/src/ucblib/libcurses/putchar.c b/usr/src/ucblib/libcurses/putchar.c new file mode 100644 index 0000000000..0668214a2d --- /dev/null +++ b/usr/src/ucblib/libcurses/putchar.c @@ -0,0 +1,33 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)putchar.c 1.3 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +int +_putchar(char c) +{ +#ifdef DEBUG + fprintf(outf, "_PUTCHAR(%s)\n", unctrl(c)); +#endif + return (putchar(c)); +} diff --git a/usr/src/ucblib/libcurses/refresh.c b/usr/src/ucblib/libcurses/refresh.c new file mode 100644 index 0000000000..588dddff8c --- /dev/null +++ b/usr/src/ucblib/libcurses/refresh.c @@ -0,0 +1,329 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)refresh.c 1.8 89/08/24 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +/* + * make the current screen look like "win" over the area coverd by + * win. + */ + +#include "curses.ext" +#include <term.h> +#include <string.h> + +#ifdef DEBUG +#define DEBUGSTATIC +#else +#define DEBUGSTATIC static +#endif + +DEBUGSTATIC short ly, lx; +DEBUGSTATIC bool curwin; +WINDOW *_win = NULL; + +/* forward declarations */ +DEBUGSTATIC void domvcur(int, int, int, int); +DEBUGSTATIC int makech(WINDOW *, short); + +int +wrefresh(WINDOW *win) +{ + short wy; + int retval; + + /* + * make sure were in visual state + */ + if (_endwin) { + (void) _puts(VS); + (void) _puts(TI); + _endwin = FALSE; + } + + /* + * initialize loop parameters + */ + + ly = curscr->_cury; + lx = curscr->_curx; + _win = win; + curwin = (win == curscr); + + if (win->_clear || curscr->_clear || curwin) { + if ((win->_flags & _FULLWIN) || curscr->_clear) { + (void) _puts(CL); + ly = 0; + lx = 0; + if (!curwin) { + curscr->_clear = FALSE; + curscr->_cury = 0; + curscr->_curx = 0; + (void) werase(curscr); + } + (void) touchwin(win); + } + win->_clear = FALSE; + } + if (!CA) { + if (win->_curx != 0) + (void) _putchar('\n'); + if (!curwin) + (void) werase(curscr); + } +#ifdef DEBUG + fprintf(outf, "REFRESH(%0.2o): curwin = %d\n", win, curwin); + fprintf(outf, "REFRESH:\n\tfirstch\tlastch\n"); +#endif + for (wy = 0; wy < win->_maxy; wy++) { +#ifdef DEBUG + fprintf(outf, "%d\t%d\t%d\n", wy, win->_firstch[wy], + win->_lastch[wy]); +#endif + if (win->_firstch[wy] != _NOCHANGE) + if (makech(win, wy) == ERR) + return (ERR); + else { + if (win->_firstch[wy] >= win->_ch_off) + win->_firstch[wy] = win->_maxx + + win->_ch_off; + if (win->_lastch[wy] < win->_maxx + + win->_ch_off) + win->_lastch[wy] = win->_ch_off; + if (win->_lastch[wy] < win->_firstch[wy]) + win->_firstch[wy] = _NOCHANGE; + } +#ifdef DEBUG + fprintf(outf, "\t%d\t%d\n", win->_firstch[wy], + win->_lastch[wy]); +#endif + } + + if (win == curscr) + domvcur(ly, lx, win->_cury, win->_curx); + else { + if (win->_leave) { + curscr->_cury = ly; + curscr->_curx = lx; + ly -= win->_begy; + lx -= win->_begx; + if (ly >= 0 && ly < win->_maxy && lx >= 0 && + lx < win->_maxx) { + win->_cury = ly; + win->_curx = lx; + } + else + win->_cury = win->_curx = 0; + } else { + domvcur(ly, lx, win->_cury + win->_begy, + win->_curx + win->_begx); + curscr->_cury = win->_cury + win->_begy; + curscr->_curx = win->_curx + win->_begx; + } + } + retval = OK; + + _win = NULL; + (void) fflush(stdout); + return (retval); +} + +/* + * make a change on the screen + */ + +DEBUGSTATIC int +makech(WINDOW *win, short wy) +{ + char *nsp, *csp, *ce; + short wx, lch, y; + intptr_t nlsp, clsp; /* last space in lines */ + + wx = win->_firstch[wy] - win->_ch_off; + if (wx >= win->_maxx) + return (OK); + else if (wx < 0) + wx = 0; + lch = win->_lastch[wy] - win->_ch_off; + if (lch < 0) + return (OK); + else if (lch >= win->_maxx) + lch = win->_maxx - 1; + y = wy + win->_begy; + + if (curwin) + csp = " "; + else + csp = &curscr->_y[wy + win->_begy][wx + win->_begx]; + + nsp = &win->_y[wy][wx]; + if (CE && !curwin) { + for (ce = &win->_y[wy][win->_maxx - 1]; *ce == ' '; ce--) + if (ce <= win->_y[wy]) + break; + nlsp = ce - win->_y[wy]; + } + + if (!curwin) + ce = CE; + else + ce = NULL; + + while (wx <= lch) { + if (*nsp != *csp) { + domvcur(ly, lx, y, wx + win->_begx); +#ifdef DEBUG + fprintf(outf, "MAKECH: 1: wx = %d, lx = %d\n", wx, lx); +#endif + ly = y; + lx = wx + win->_begx; + while (wx <= lch && *nsp != *csp) { + if (ce != NULL && wx >= nlsp && *nsp == ' ') { + /* + * check for clear to end-of-line + */ + ce = &curscr->_y[ly][COLS - 1]; + while (*ce == ' ') + if (ce-- <= csp) + break; + clsp = ce - curscr->_y[ly] - win->_begx; +#ifdef DEBUG + fprintf(outf, "MAKECH: clsp = %d," + " nlsp = %d\n", clsp, nlsp); +#endif + if (clsp - nlsp >= strlen(CE) && + clsp < win->_maxx) { +#ifdef DEBUG + fprintf(outf, "MAKECH: using" + " CE\n"); +#endif + (void) _puts(CE); + lx = wx + win->_begx; + while (wx++ <= clsp) + *csp++ = ' '; + return (OK); + } + ce = NULL; + } + /* + * enter/exit standout mode as appropriate + */ + if (SO && (*nsp&_STANDOUT) != + (curscr->_flags&_STANDOUT)) { + if (*nsp & _STANDOUT) { + (void) _puts(SO); + curscr->_flags |= _STANDOUT; + } else { + (void) _puts(SE); + curscr->_flags &= ~_STANDOUT; + } + } + wx++; + if (wx >= win->_maxx && wy == win->_maxy - 1) + if (win->_scroll) { + if ((curscr->_flags&_STANDOUT) && + (win->_flags & _ENDLINE)) + if (!MS) { + (void) _puts(SE); + curscr->_flags &= + ~_STANDOUT; + } + if (!curwin) + (void) _putchar((*csp = *nsp) & + 0177); + else + (void) _putchar(*nsp & 0177); + if (win->_flags&_FULLWIN && !curwin) + (void) scroll(curscr); + if (!curwin) { + ly = wy + win->_begy; + lx = wx + win->_begx; + } else { + ly = win->_begy+win->_cury; + lx = win->_begx+win->_curx; + } + return (OK); + } else if (win->_flags&_SCROLLWIN) { + wx = wx - 1; + lx = wx; + return (ERR); + } + if (!curwin) + (void) _putchar((*csp++ = *nsp) & 0177); + else + (void) _putchar(*nsp & 0177); +#ifdef FULLDEBUG + fprintf(outf, + "MAKECH:putchar(%c)\n", *nsp & 0177); +#endif + if (UC && (*nsp & _STANDOUT)) { + (void) _putchar('\b'); + (void) _puts(UC); + } + nsp++; + } +#ifdef DEBUG + fprintf(outf, "MAKECH: 2: wx = %d, lx = %d\n", wx, lx); +#endif + if (lx == wx + win->_begx) /* if no change */ + break; + lx = wx + win->_begx; + if (lx >= COLS && AM) { + lx = 0; + ly++; + /* + * xn glitch: chomps a newline after auto-wrap. + * we just feed it now and forget about it. + */ + if (XN) { + (void) _putchar('\n'); + (void) _putchar('\r'); + } + } + } else if (wx <= lch) + while (wx <= lch && *nsp == *csp) { + nsp++; + if (!curwin) + csp++; + ++wx; + } + else + break; +#ifdef DEBUG + fprintf(outf, "MAKECH: 3: wx = %d, lx = %d\n", wx, lx); +#endif + } + return (OK); +} + +/* + * perform a mvcur, leaving standout mode if necessary + */ + +DEBUGSTATIC void +domvcur(int oy, int ox, int ny, int nx) +{ + if (curscr->_flags & _STANDOUT && !MS) { + (void) _puts(SE); + curscr->_flags &= ~_STANDOUT; + } + (void) mvcur(oy, ox, ny, nx); +} diff --git a/usr/src/ucblib/libcurses/req.flg b/usr/src/ucblib/libcurses/req.flg new file mode 100644 index 0000000000..b754760882 --- /dev/null +++ b/usr/src/ucblib/libcurses/req.flg @@ -0,0 +1,7 @@ +#!/bin/sh +#pragma ident "%Z%%M% %I% %E% SMI" + + +echo_file usr/src/lib/libc/inc/file64.h +echo_file usr/src/lib/Makefile.lib +echo_file usr/src/lib/Makefile.targ diff --git a/usr/src/ucblib/libcurses/scanw.c b/usr/src/ucblib/libcurses/scanw.c new file mode 100644 index 0000000000..9cd61cf03c --- /dev/null +++ b/usr/src/ucblib/libcurses/scanw.c @@ -0,0 +1,85 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)scanw.c 1.8 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include <stdarg.h> +#include <string.h> + +/* + * scanw and friends + */ + +#include "curses.ext" + +/* + * This routine implements a scanf on the standard screen. + */ + +int +scanw(char *fmt, ...) +{ int j; + va_list ap; + + va_start(ap, fmt); + j = _sscans(stdscr, fmt, ap); + va_end(ap); + return (j); +} + +/* + * This routine implements a scanf on the given window. + */ + +int +wscanw(WINDOW *win, char *fmt, ...) +{ + va_list ap; + int j; + + va_start(ap, fmt); + j = _sscans(win, fmt, ap); + va_end(ap); + return (j); +} +/* + * This routine actually executes the scanf from the window. + * + * This is really a modified version of "sscanf". As such, + * it assumes that sscanf interfaces with the other scanf functions + * in a certain way. If this is not how your system works, you + * will have to modify this routine to use the interface that your + * "sscanf" uses. + */ + +int +_sscans(WINDOW *win, char *fmt, va_list ap) +{ + char buf[100]; + FILE junk; + + junk._flag = _IOREAD|_IOWRT; + junk._base = junk._ptr = (unsigned char *)buf; + if (wgetstr(win, buf) == ERR) + return (ERR); + junk._cnt = (ssize_t)strlen(buf); + return (_doscan(&junk, fmt, ap)); +} diff --git a/usr/src/ucblib/libcurses/scroll.c b/usr/src/ucblib/libcurses/scroll.c new file mode 100644 index 0000000000..ef09c7aa34 --- /dev/null +++ b/usr/src/ucblib/libcurses/scroll.c @@ -0,0 +1,57 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)scroll.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * This routine scrolls the window up a line. + */ + +int +scroll(WINDOW *win) +{ + int oy, ox; + +#ifdef DEBUG + fprintf(outf, "SCROLL(%0.2o)\n", win); +#endif + + if (!win->_scroll) + return (ERR); + + getyx(win, oy, ox); + (void) wmove(win, 0, 0); + (void) wdeleteln(win); + (void) wmove(win, oy, ox); + + if (win == curscr) { + (void) _putchar('\n'); + if (!NONL) + win->_curx = 0; +#ifdef DEBUG + fprintf(outf, "SCROLL: win == curscr\n"); +#endif + } + + return (OK); +} diff --git a/usr/src/ucblib/libcurses/sparc/Makefile b/usr/src/ucblib/libcurses/sparc/Makefile new file mode 100644 index 0000000000..35bd270df4 --- /dev/null +++ b/usr/src/ucblib/libcurses/sparc/Makefile @@ -0,0 +1,38 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libcurses/sparc/Makefile + +MAPDIR= ../spec/sparc +include ../Makefile.com + +DYNFLAGS += $(DYNFLAGS32) +BUILD.SO= $(CC) -o $@ -G $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/ucblib $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/libcurses/sparcv9/Makefile b/usr/src/ucblib/libcurses/sparcv9/Makefile new file mode 100644 index 0000000000..890b579237 --- /dev/null +++ b/usr/src/ucblib/libcurses/sparcv9/Makefile @@ -0,0 +1,40 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1997-1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libcurses/sparcv9/Makefile + +MAPDIR= ../spec/sparcv9 +include ../Makefile.com +include ../../../lib/Makefile.lib.64 + +DYNFLAGS += $(DYNFLAGS64) +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) \ + -L $(ROOT)/usr/ucblib/$(MACH64) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) diff --git a/usr/src/ucblib/libcurses/spec/Makefile b/usr/src/ucblib/libcurses/spec/Makefile new file mode 100644 index 0000000000..bc7d0b29c6 --- /dev/null +++ b/usr/src/ucblib/libcurses/spec/Makefile @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libcurses/spec/Makefile + +include $(SRC)/lib/Makefile.spec.arch diff --git a/usr/src/ucblib/libcurses/spec/Makefile.override b/usr/src/ucblib/libcurses/spec/Makefile.override new file mode 100644 index 0000000000..55d9f1c59c --- /dev/null +++ b/usr/src/ucblib/libcurses/spec/Makefile.override @@ -0,0 +1,29 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# + +CPPFLAGS= -D$(MACH) -I$(ROOT)/usr/ucbinclude $(CPPFLAGS.master) diff --git a/usr/src/ucblib/libcurses/spec/Makefile.targ b/usr/src/ucblib/libcurses/spec/Makefile.targ new file mode 100644 index 0000000000..c69ad3c34a --- /dev/null +++ b/usr/src/ucblib/libcurses/spec/Makefile.targ @@ -0,0 +1,36 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libcurses/spec/Makefile.targ + +LIBRARY = libcurses.a +VERS = .1 + +OBJECTS = curses.o + +TRANSCPP = +SPECCPP = -I$(ROOT)/usr/ucbinclude diff --git a/usr/src/ucblib/libcurses/spec/amd64/Makefile b/usr/src/ucblib/libcurses/spec/amd64/Makefile new file mode 100644 index 0000000000..9207eb9774 --- /dev/null +++ b/usr/src/ucblib/libcurses/spec/amd64/Makefile @@ -0,0 +1,43 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#amd64_C_PICFLAGS = $(amd64_C_BIGPICFLAGS) + +include $(SRC)/lib/Makefile.spec +include ../Makefile.override + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/libcurses/spec/curses.spec b/usr/src/ucblib/libcurses/spec/curses.spec new file mode 100644 index 0000000000..4f1a09301e --- /dev/null +++ b/usr/src/ucblib/libcurses/spec/curses.spec @@ -0,0 +1,694 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +#pragma ident "%Z%%M% %I% %E% SMI" +# + +function initscr +include <curses.h> +declaration WINDOW *initscr(void) +version SUNW_1.1 +end + +function newwin +include <curses.h> +declaration WINDOW *newwin(int nlines, int ncols, int begin_y, int begin_x) +version SUNW_1.1 +end + +function subwin +include <curses.h> +declaration WINDOW *subwin(WINDOW *orig, int nlines, int ncols, \ + int begin_y, int begin_x) +version SUNW_1.1 +end + +function longname +include <curses.h> +declaration char *longname(char *bp, char *def) +version SUNW_1.1 +end + +function getcap +include <curses.h> +declaration char *getcap(char *name) +version SUNW_1.1 +end + +function gettmode +include <curses.h> +declaration int gettmode(void) +version SUNW_1.1 +end + +function idlok +include <curses.h> +declaration int idlok(WINDOW *win, bool bf) +version SUNW_1.1 +end + +function wstandout +include <curses.h> +declaration char *wstandout(WINDOW *win) +version SUNW_1.1 +end + +function wstandend +include <curses.h> +declaration char *wstandend(WINDOW *win) +version SUNW_1.1 +end + +function box +include <curses.h> +declaration int box(WINDOW *win, char vert, char hor) +version SUNW_1.1 +end + +function touchwin +include <curses.h> +declaration int touchwin(WINDOW *win) +version SUNW_1.1 +end + +function touchline +include <curses.h> +declaration int touchline(WINDOW *win, int y, int sx, int ex) +version SUNW_1.1 +end + +function mvcur +include <curses.h> +declaration int mvcur(int ly, int lx, int y, int x) +version SUNW_1.1 +end + +function wmove +include <curses.h> +declaration int wmove(WINDOW *win, int y, int x) +version SUNW_1.1 +end + +function scroll +include <curses.h> +declaration int scroll(WINDOW *win) +version SUNW_1.1 +end + +function werase +include <curses.h> +declaration int werase(WINDOW *win) +version SUNW_1.1 +end + +function wrefresh +include <curses.h> +declaration int wrefresh(WINDOW *win) +version SUNW_1.1 +end + +function endwin +include <curses.h> +declaration int endwin(void) +version SUNW_1.1 +end + +function mvwin +include <curses.h> +declaration int mvwin(WINDOW *win, int by, int bx) +version SUNW_1.1 +end + +function delwin +include <curses.h> +declaration int delwin(WINDOW *win) +version SUNW_1.1 +end + +function overlay +include <curses.h> +declaration int overlay(WINDOW *win1, WINDOW *win2) +version SUNW_1.1 +end + +function overwrite +include <curses.h> +declaration int overwrite(WINDOW *win1, WINDOW *win2) +version SUNW_1.1 +end + +function winsertln +include <curses.h> +declaration int winsertln(WINDOW *win) +version SUNW_1.1 +end + +function wdeleteln +include <curses.h> +declaration int wdeleteln(WINDOW *win) +version SUNW_1.1 +end + +function wgetstr +include <curses.h> +declaration int wgetstr(WINDOW *win, char *str) +version SUNW_1.1 +end + +function wgetch +include <curses.h> +declaration int wgetch(WINDOW *win) +version SUNW_1.1 +end + +function waddch +include <curses.h> +declaration int waddch(WINDOW *win, char c) +version SUNW_1.1 +end + +function waddstr +include <curses.h> +declaration int waddstr(WINDOW *win, char *str) +version SUNW_1.1 +end + +function winsch +include <curses.h> +declaration int winsch(WINDOW *win, char c) +version SUNW_1.1 +end + +function wdelch +include <curses.h> +declaration int wdelch(WINDOW *win) +version SUNW_1.1 +end + +function wclear +include <curses.h> +declaration int wclear(WINDOW *win) +version SUNW_1.1 +end + +function wclrtobot +include <curses.h> +declaration int wclrtobot(WINDOW *win) +version SUNW_1.1 +end + +function wclrtoeol +include <curses.h> +declaration int wclrtoeol(WINDOW *win) +version SUNW_1.1 +end + +function printw +include <curses.h> +declaration int printw(char *fmt, ...) +version SUNW_1.1 +end + +function wprintw +include <curses.h> +declaration int wprintw(WINDOW *win, char *fmt, ...) +version SUNW_1.1 +end + +function mvprintw +include <curses.h> +declaration int mvprintw(int y, int x, char *fmt, ...) +version SUNW_1.1 +end + +function mvwprintw +include <curses.h> +declaration int mvwprintw(WINDOW *win, int y, int x, char *fmt, ...) +version SUNW_1.1 +end + +function scanw +include <curses.h> +declaration int scanw(char *fmt, ...) +version SUNW_1.1 +end + +function wscanw +include <curses.h> +declaration int wscanw(WINDOW *win, char *fmt, ...) +version SUNW_1.1 +end + +function mvscanw +include <curses.h> +declaration int mvscanw(int y, int x, char *fmt, ...) +version SUNW_1.1 +end + +function mvwscanw +include <curses.h> +declaration int mvwscanw(WINDOW *win, int y, int x, char *fmt, ...) +version SUNW_1.1 +end + +function setterm +include <curses.h> +declaration int setterm(char *type) +version SUNW_1.1 +end + +data _unctrl +version SUNW_1.1 +end + +data My_term +version SUNW_1.1 +end + +data _echoit +version SUNW_1.1 +end + +data _rawmode +version SUNW_1.1 +end + +data _endwin +version SUNW_1.1 +end + +data LINES +version SUNW_1.1 +end + +data COLS +version SUNW_1.1 +end + +data _tty_ch +version SUNW_1.1 +end + +data _res_flg +version SUNW_1.1 +end + +data _tty +version SUNW_1.1 +end + +data stdscr +version SUNW_1.1 +end + +data curscr +version SUNW_1.1 +end + +data Def_term +version SUNW_1.1 +end + +data ttytype +version SUNW_1.1 +end + +# termcap capabilities (bool) +data AM +version SUNW_1.1 +end + +data BS +version SUNW_1.1 +end + +data CA +version SUNW_1.1 +end + +data DA +version SUNW_1.1 +end + +data DB +version SUNW_1.1 +end + +data EO +version SUNW_1.1 +end + +data HC +version SUNW_1.1 +end + +data HZ +version SUNW_1.1 +end + +data IN +version SUNW_1.1 +end + +data MI +version SUNW_1.1 +end + +data MS +version SUNW_1.1 +end + +data NC +version SUNW_1.1 +end + +data NS +version SUNW_1.1 +end + +data OS +version SUNW_1.1 +end + +data UL +version SUNW_1.1 +end + +data XB +version SUNW_1.1 +end + +data XN +version SUNW_1.1 +end + +data XT +version SUNW_1.1 +end + +data XS +version SUNW_1.1 +end + +data XX +version SUNW_1.1 +end + +# termcap capabilities (char *) +data AL +version SUNW_1.1 +end + +data BC +version SUNW_1.1 +end + +data BT +version SUNW_1.1 +end + +data CD +version SUNW_1.1 +end + +data CE +version SUNW_1.1 +end + +data CL +version SUNW_1.1 +end + +data CM +version SUNW_1.1 +end + +data CR +version SUNW_1.1 +end + +data CS +version SUNW_1.1 +end + +data DC +version SUNW_1.1 +end + +data DL +version SUNW_1.1 +end + +data DM +version SUNW_1.1 +end + +data DO +version SUNW_1.1 +end + +data ED +version SUNW_1.1 +end + +data EI +version SUNW_1.1 +end + +data K0 +version SUNW_1.1 +end + +data K1 +version SUNW_1.1 +end + +data K2 +version SUNW_1.1 +end + +data K3 +version SUNW_1.1 +end + +data K4 +version SUNW_1.1 +end + +data K5 +version SUNW_1.1 +end + +data K6 +version SUNW_1.1 +end + +data K7 +version SUNW_1.1 +end + +data K8 +version SUNW_1.1 +end + +data K9 +version SUNW_1.1 +end + +data HO +version SUNW_1.1 +end + +data IC +version SUNW_1.1 +end + +data IM +version SUNW_1.1 +end + +data IP +version SUNW_1.1 +end + +data KD +version SUNW_1.1 +end + +data KE +version SUNW_1.1 +end + +data KH +version SUNW_1.1 +end + +data KL +version SUNW_1.1 +end + +data KR +version SUNW_1.1 +end + +data KS +version SUNW_1.1 +end + +data KU +version SUNW_1.1 +end + +data LL +version SUNW_1.1 +end + +data MA +version SUNW_1.1 +end + +data ND +version SUNW_1.1 +end + +data NL +version SUNW_1.1 +end + +data RC +version SUNW_1.1 +end + +data SC +version SUNW_1.1 +end + +data SE +version SUNW_1.1 +end + +data SF +version SUNW_1.1 +end + +data SO +version SUNW_1.1 +end + +data SR +version SUNW_1.1 +end + +data TA +version SUNW_1.1 +end + +data TE +version SUNW_1.1 +end + +data TI +version SUNW_1.1 +end + +data UC +version SUNW_1.1 +end + +data UE +version SUNW_1.1 +end + +data UP +version SUNW_1.1 +end + +data US +version SUNW_1.1 +end + +data VB +version SUNW_1.1 +end + +data VS +version SUNW_1.1 +end + +data VE +version SUNW_1.1 +end + +data AL_PARM +version SUNW_1.1 +end + +data DL_PARM +version SUNW_1.1 +end + +data UP_PARM +version SUNW_1.1 +end + +data DOWN_PARM +version SUNW_1.1 +end + +data LEFT_PARM +version SUNW_1.1 +end + +data RIGHT_PARM +version SUNW_1.1 +end + +data PC +version SUNW_1.1 +end + +# for tty modes +data GT +version SUNW_1.1 +end + +data NONL +version SUNW_1.1 +end + +data UPPERCASE +version SUNW_1.1 +end + +data normtty +version SUNW_1.1 +end + +data _pfast +version SUNW_1.1 +end + +function _putchar +version SUNWprivate_1.1 +end diff --git a/usr/src/ucblib/libcurses/spec/i386/Makefile b/usr/src/ucblib/libcurses/spec/i386/Makefile new file mode 100644 index 0000000000..c9523cfe53 --- /dev/null +++ b/usr/src/ucblib/libcurses/spec/i386/Makefile @@ -0,0 +1,43 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libcurses/spec/i386/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#i386_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec +include ../Makefile.override + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/libcurses/spec/sparc/Makefile b/usr/src/ucblib/libcurses/spec/sparc/Makefile new file mode 100644 index 0000000000..289ddb4ed3 --- /dev/null +++ b/usr/src/ucblib/libcurses/spec/sparc/Makefile @@ -0,0 +1,45 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libcurses/spec/sparc/Makefile + +.KEEP_STATE: + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#sparc_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec +include ../Makefile.override + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/libcurses/spec/sparcv9/Makefile b/usr/src/ucblib/libcurses/spec/sparcv9/Makefile new file mode 100644 index 0000000000..52128c2902 --- /dev/null +++ b/usr/src/ucblib/libcurses/spec/sparcv9/Makefile @@ -0,0 +1,44 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libcurses/spec/sparcv9/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#sparcv9_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec +include ../Makefile.override + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/libcurses/spec/versions b/usr/src/ucblib/libcurses/spec/versions new file mode 100644 index 0000000000..38a2cfc77a --- /dev/null +++ b/usr/src/ucblib/libcurses/spec/versions @@ -0,0 +1,43 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# ident "%Z%%M% %I% %E% SMI" +# + +sparc { + SUNW_1.1; + SUNWprivate_1.1; +} +sparcv9 { + SUNW_1.1; + SUNWprivate_1.1; +} +i386 { + SUNW_1.1; + SUNWprivate_1.1; +} +amd64 { + SUNW_1.1; + SUNWprivate_1.1; +} diff --git a/usr/src/ucblib/libcurses/standout.c b/usr/src/ucblib/libcurses/standout.c new file mode 100644 index 0000000000..86aa50d58d --- /dev/null +++ b/usr/src/ucblib/libcurses/standout.c @@ -0,0 +1,57 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)standout.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +/* + * routines dealing with entering and exiting standout mode + * + */ + +#include "curses.ext" + +/* + * enter standout mode + */ + +char * +wstandout(WINDOW *win) +{ + if (!SO && !UC) + return (FALSE); + + win->_flags |= _STANDOUT; + return (SO ? SO : UC); +} + +/* + * exit standout mode + */ + +char * +wstandend(WINDOW *win) +{ + if (!SO && !UC) + return (FALSE); + + win->_flags &= ~_STANDOUT; + return (SE ? SE : UC); +} diff --git a/usr/src/ucblib/libcurses/toucholap.c b/usr/src/ucblib/libcurses/toucholap.c new file mode 100644 index 0000000000..165c8f7288 --- /dev/null +++ b/usr/src/ucblib/libcurses/toucholap.c @@ -0,0 +1,65 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)toucholap.c 1.4 89/08/03 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +#define min(a, b) ((a) < (b) ? (a) : (b)) +#define max(a, b) ((a) > (b) ? (a) : (b)) + +/* + * Touch, on win2, the part that overlaps with win1. + */ + +int +touchoverlap(WINDOW *win1, WINDOW *win2) +{ + int y, endy, endx, starty, startx; + +#ifdef DEBUG + fprintf(outf, "TOUCHOVERLAP(%0.2o, %0.2o);\n", win1, win2); +#endif + starty = max(win1->_begy, win2->_begy); + startx = max(win1->_begx, win2->_begx); + endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begy); + endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); +#ifdef DEBUG + fprintf(outf, "TOUCHOVERLAP:from (%d,%d) to (%d,%d)\n", + starty, startx, endy, endx); + fprintf(outf, "TOUCHOVERLAP:win1 (%d,%d) to (%d,%d)\n", + win1->_begy, win1->_begx, win1->_begy + win1->_maxy, + win1->_begx + win1->_maxx); + fprintf(outf, "TOUCHOVERLAP:win2 (%d,%d) to (%d,%d)\n", + win2->_begy, win2->_begx, win2->_begy + win2->_maxy, + win2->_begx + win2->_maxx); +#endif + if (starty >= endy || startx >= endx) + return (OK); + starty -= win2->_begy; + startx -= win2->_begx; + endy -= win2->_begy; + endx -= win2->_begx; + endx--; + for (y = starty; y < endy; y++) + (void) touchline(win2, y, startx, endx); + return (OK); +} diff --git a/usr/src/ucblib/libcurses/touchwin.c b/usr/src/ucblib/libcurses/touchwin.c new file mode 100644 index 0000000000..dd4e04944e --- /dev/null +++ b/usr/src/ucblib/libcurses/touchwin.c @@ -0,0 +1,73 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#ifndef lint +static char +sccsid[] = "@(#)touchwin.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include "curses.ext" + +/* + * make it look like the whole window has been changed. + * + */ + +int +touchwin(WINDOW *win) +{ + int y, maxy; + +#ifdef DEBUG + fprintf(outf, "TOUCHWIN(%0.2o)\n", win); +#endif + maxy = win->_maxy; + for (y = 0; y < maxy; y++) + (void) touchline(win, y, 0, win->_maxx - 1); + return (OK); +} + +/* + * touch a given line + */ + +int +touchline(WINDOW *win, int y, int sx, int ex) +{ +#ifdef DEBUG + fprintf(outf, "TOUCHLINE(%0.2o, %d, %d, %d)\n", win, y, sx, ex); + fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", + win->_firstch[y], win->_lastch[y]); +#endif + sx += win->_ch_off; + ex += win->_ch_off; + if (win->_firstch[y] == _NOCHANGE) { + win->_firstch[y] = (short)sx; + win->_lastch[y] = (short)ex; + } else { + if (win->_firstch[y] > sx) + win->_firstch[y] = (short)sx; + if (win->_lastch[y] < ex) + win->_lastch[y] = (short)ex; + } +#ifdef DEBUG + fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", + win->_firstch[y], win->_lastch[y]); +#endif + return (OK); +} diff --git a/usr/src/ucblib/libcurses/tstp.c b/usr/src/ucblib/libcurses/tstp.c new file mode 100644 index 0000000000..8d51173cea --- /dev/null +++ b/usr/src/ucblib/libcurses/tstp.c @@ -0,0 +1,57 @@ +/* + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifndef lint +static char +sccsid[] = "@(#)tstp.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +#include <sys/types.h> +#include <signal.h> +#include "curses.ext" +#include <sgtty.h> + +/* + * handle stop and start signals + * + * @(#)tstp.c 5.1 (Berkeley) 6/7/85 + */ + +void +tstp(void) +{ +#ifdef SIGTSTP + + SGTTY tty; +#ifdef DEBUG + if (outf) + (void) fflush(outf); +#endif + tty = _tty; + (void) mvcur(0, COLS - 1, LINES - 1, 0); + (void) endwin(); + (void) fflush(stdout); + /* reset signal handler so kill below stops us */ + (void) signal(SIGTSTP, SIG_DFL); + (void) sigsetmask(sigblock(0) &~ sigmask(SIGTSTP)); + (void) kill(0, SIGTSTP); + (void) sigblock(sigmask(SIGTSTP)); + (void) signal(SIGTSTP, (void(*)(int))tstp); + _tty = tty; + (void) stty(_tty_ch, &_tty); + (void) wrefresh(curscr); +#endif /* SIGTSTP */ +} diff --git a/usr/src/ucblib/libcurses/unctrl.c b/usr/src/ucblib/libcurses/unctrl.c new file mode 100644 index 0000000000..0cf4f2c33c --- /dev/null +++ b/usr/src/ucblib/libcurses/unctrl.c @@ -0,0 +1,39 @@ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifndef lint +static char +sccsid[] = "@(#)unctrl.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */ +#endif /* not lint */ + +/* + * define unctrl codes for each character + * + */ + +/* LINTLIBRARY */ +char *_unctrl[] = { /* unctrl codes for ttys */ + "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "^I", "^J", "^K", + "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W", + "^X", "^Y", "^Z", "^[", "^\\", "^]", "^~", "^_", + " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", + ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", + "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", + "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", + "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", + "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "^?" +}; diff --git a/usr/src/ucblib/libdbm/Makefile b/usr/src/ucblib/libdbm/Makefile new file mode 100644 index 0000000000..8c94a6bcb1 --- /dev/null +++ b/usr/src/ucblib/libdbm/Makefile @@ -0,0 +1,47 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 1989-1999, 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# The builds occur in isa subdirectories. +# + +include ../Makefile.ucb + +SUBDIRS = spec .WAIT $(MACH) $(BUILD64) $(MACH64) + +install := TARGET= install +clean := TARGET= clean +clobber := TARGET= clobber +lint := TARGET= lint + +.KEEP_STATE: + +all install clean clobber lint : $(SUBDIRS) + +$(MACH) $(MACH64) spec: FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: diff --git a/usr/src/ucblib/libdbm/Makefile.com b/usr/src/ucblib/libdbm/Makefile.com new file mode 100644 index 0000000000..ac659af6d6 --- /dev/null +++ b/usr/src/ucblib/libdbm/Makefile.com @@ -0,0 +1,86 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libdbm/Makefile.com +# + +LIBRARY= libdbm.a +VERS= .1 + +OBJECTS= dbm.o + +# include library definitions +include $(SRC)/lib/Makefile.lib + +ROOTLIBDIR= $(ROOT)/usr/ucblib +ROOTLIBDIR64= $(ROOT)/usr/ucblib/$(MACH64) + +MAPFILE= $(MAPDIR)/mapfile +CLOBBERFILES += $(MAPFILE) +SRCS= $(OBJECTS:%.o=../%.c) + +LIBS = $(DYNLIB) $(LINTLIB) + +LINTSRC= $(LINTLIB:%.ln=%) +ROOTLINTDIR= $(ROOTLIBDIR) +ROOTLINTDIR64= $(ROOTLIBDIR)/$(MACH64) +ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%) +ROOTLINT64= $(LINTSRC:%=$(ROOTLINTDIR64)/%) + +# install rule for lint source file target +$(ROOTLINTDIR)/%: ../% + $(INS.file) +$(ROOTLINTDIR64)/%: ../% + $(INS.file) + +$(LINTLIB):= SRCS=../llib-ldbm + +CFLAGS += $(CCVERBOSE) +DYNFLAGS += -M$(MAPFILE) +LDLIBS += -lc + +CPPFLAGS = -I$(ROOT)/usr/ucbinclude $(CPPFLAGS.master) + +.KEEP_STATE: + +all: $(LIBS) + +lint: lintcheck + +$(DYNLIB): $(MAPFILE) + +$(MAPFILE): + @cd $(MAPDIR); $(MAKE) mapfile + +# +# Include library targets +# +include $(SRC)/lib/Makefile.targ + +objs/%.o pics/%.o: ../%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) diff --git a/usr/src/ucblib/libdbm/amd64/Makefile b/usr/src/ucblib/libdbm/amd64/Makefile new file mode 100644 index 0000000000..15a2c25314 --- /dev/null +++ b/usr/src/ucblib/libdbm/amd64/Makefile @@ -0,0 +1,38 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +MAPDIR= ../spec/amd64 +include ../Makefile.com +include ../../../lib/Makefile.lib.64 + +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) \ + -L $(ROOT)/usr/ucblib/$(MACH64) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) diff --git a/usr/src/ucblib/libdbm/dbm.c b/usr/src/ucblib/libdbm/dbm.c new file mode 100644 index 0000000000..002bbd4eba --- /dev/null +++ b/usr/src/ucblib/libdbm/dbm.c @@ -0,0 +1,592 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <strings.h> +#include <malloc.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <dbm.h> +#include <errno.h> + +/* forward declarations */ +/* could be all static if not were for older *.a releases */ +void chkblk(char buf[PBLKSIZ]); +void delitem(char buf[PBLKSIZ], int n); +void dbm_access(long hash); +int getbit(void); +int setbit(void); +int additem(char buf[PBLKSIZ], datum item); +int cmpdatum(datum d1, datum d2); + +int +dbminit(char *file) +{ + struct stat64 statb; + + dbrdonly = 0; + if (strlcpy(pagbuf, file, sizeof (pagbuf)) >= sizeof (pagbuf) || + strlcat(pagbuf, ".pag", sizeof (pagbuf)) >= sizeof (pagbuf)) { + /* + * file.pag does not fit into pagbuf. + * fails with ENAMETOOLONG. + */ + errno = ENAMETOOLONG; + return (-1); + } + pagf = open(pagbuf, 2); + if (pagf < 0) { + pagf = open(pagbuf, 0); + dbrdonly = 1; + } + + /* + * We know this won't overflow so it is safe to ignore the + * return value; we use strl* to prevent false hits in + * code sweeps. + */ + (void) strlcpy(pagbuf, file, sizeof (pagbuf)); + (void) strlcat(pagbuf, ".dir", sizeof (pagbuf)); + dirf = open(pagbuf, 2); + if (dirf < 0) { + dirf = open(pagbuf, 0); + dbrdonly = 1; + } + if (pagf < 0 || dirf < 0) { + (void) printf("cannot open database %s\n", file); + return (-1); + } + /* Guards against large inodes */ + (void) fstat64(dirf, &statb); + maxbno = (off_t)statb.st_size * BYTESIZ - 1; + return (0); +} + +static long oldb1 = -1L; +static long oldb2 = -1L; + +/* Avoid using cached data for subsequent accesses. */ +int +dbmflush(void) +{ + oldb1 = -1L; + oldb2 = -1L; + return (0); +} + +/* Clean up after ourself. */ +int +dbmclose(void) +{ + (void) close(pagf); + (void) close(dirf); + bitno = 0; + maxbno = 0; + blkno = 0; + hmask = 0; + oldb1 = -1L; + oldb2 = -1L; + return (0); +} + +long +forder(datum key) +{ + long hash; + + hash = calchash(key); + for (hmask = 0; ; hmask = (hmask<<1)+1) { + blkno = hash & hmask; + bitno = blkno + hmask; + if (getbit() == 0) + break; + } + return (blkno); +} + +datum +fetch(datum key) +{ + int i; + datum item; + + dbm_access(calchash(key)); + for (i = 0; ; i += 2) { + item = makdatum(pagbuf, i); + if (item.dptr == NULL) + return (item); + if (cmpdatum(key, item) == 0) { + item = makdatum(pagbuf, i+1); + if (item.dptr == NULL) + (void) printf("items not in pairs\n"); + return (item); + } + } +} + +int +delete(datum key) +{ + int i; + datum item; + + if (dbrdonly) + return (-1); + dbm_access(calchash(key)); + for (i = 0; ; i += 2) { + item = makdatum(pagbuf, i); + if (item.dptr == NULL) + return (-1); + if (cmpdatum(key, item) == 0) { + delitem(pagbuf, i); + delitem(pagbuf, i); + break; + } + } + (void) lseek(pagf, blkno*PBLKSIZ, 0); + (void) write(pagf, pagbuf, PBLKSIZ); + return (0); +} + +int +store(datum key, datum dat) +{ + int i; + datum item; + char ovfbuf[PBLKSIZ]; + datum Sentry; + int Oneflag; + + Sentry.dsize = 0; + Sentry.dptr = NULL; + + if (dbrdonly) + return (-1); +loop: + dbm_access(calchash(key)); + for (i = 0; ; i += 2) { + item = makdatum(pagbuf, i); + if (item.dptr == NULL) + break; + if (cmpdatum(key, item) == 0) { + delitem(pagbuf, i); + delitem(pagbuf, i); + break; + } + } + i = additem(pagbuf, key); + if (i < 0) + goto split; + if (additem(pagbuf, dat) < 0) { + delitem(pagbuf, i); + goto split; + } + (void) lseek(pagf, blkno*PBLKSIZ, 0); + (void) write(pagf, pagbuf, PBLKSIZ); + return (0); +split: + if (key.dsize+dat.dsize+3*sizeof (short) >= PBLKSIZ) { + (void) printf("entry too big\n"); + return (-1); + } + bzero(ovfbuf, PBLKSIZ); + Oneflag = 0; + for (i = 0; ; ) { + item = makdatum(pagbuf, i); + Oneflag++; + if (item.dptr == NULL) { + if ((Sentry.dsize == key.dsize) && + (strncmp(Sentry.dptr, key.dptr, key.dsize) == 0)) + return (-1); + if (Oneflag == 2) { + Sentry.dsize = key.dsize; + Sentry.dptr = malloc(strlen(key.dptr)+1); + (void) strncpy(Sentry.dptr, key.dptr, + key.dsize); + } + break; + } + if (calchash(item) & (hmask+1)) { + (void) additem(ovfbuf, item); + delitem(pagbuf, i); + item = makdatum(pagbuf, i); + if (item.dptr == NULL) { + (void) printf("split not paired\n"); + break; + } + (void) additem(ovfbuf, item); + delitem(pagbuf, i); + continue; + } + i += 2; + } + (void) lseek(pagf, blkno*PBLKSIZ, 0); + if (write(pagf, pagbuf, PBLKSIZ) < 0) + return (-1); + (void) lseek(pagf, (blkno+hmask+1)*PBLKSIZ, 0); + if (write(pagf, ovfbuf, PBLKSIZ) < 0) + return (-1); + if (setbit() < 0) + return (-1); + goto loop; +} + +datum +firstkey(void) +{ + return (firsthash(0L)); +} + +datum +nextkey(datum key) +{ + int i; + datum item, bitem; + long hash; + int f; + + hash = calchash(key); + dbm_access(hash); + f = 1; + for (i = 0; ; i += 2) { + item = makdatum(pagbuf, i); + if (item.dptr == NULL) + break; + if (cmpdatum(key, item) <= 0) + continue; + if (f || cmpdatum(bitem, item) < 0) { + bitem = item; + f = 0; + } + } + if (f == 0) + return (bitem); + hash = hashinc(hash); + if (hash == 0) + return (item); + return (firsthash(hash)); +} + +datum +firsthash(long hash) +{ + int i; + datum item, bitem; + +loop: + dbm_access(hash); + bitem = makdatum(pagbuf, 0); + for (i = 2; ; i += 2) { + item = makdatum(pagbuf, i); + if (item.dptr == NULL) + break; + if (cmpdatum(bitem, item) < 0) + bitem = item; + } + if (bitem.dptr != NULL) + return (bitem); + hash = hashinc(hash); + if (hash == 0) + return (item); + goto loop; +} + +void +dbm_access(long hash) +{ + ssize_t readsize; + + for (hmask = 0; ; hmask = (hmask<<1)+1) { + blkno = hash & hmask; + bitno = blkno + hmask; + if (getbit() == 0) + break; + } + if (blkno != oldb1) { + (void) lseek(pagf, blkno*PBLKSIZ, 0); + readsize = read(pagf, pagbuf, PBLKSIZ); + if (readsize != PBLKSIZ) { + if (readsize < 0) readsize = 0; + bzero(pagbuf+readsize, PBLKSIZ-readsize); + } + chkblk(pagbuf); + oldb1 = blkno; + } +} + +int +getbit(void) +{ + long bn; + ssize_t readsize; + long b, i, n; + + if (bitno > maxbno) + return (0); + n = bitno % BYTESIZ; + bn = bitno / BYTESIZ; + i = bn % DBLKSIZ; + b = bn / DBLKSIZ; + if (b != oldb2) { + (void) lseek(dirf, (long)b*DBLKSIZ, 0); + readsize = read(dirf, dirbuf, DBLKSIZ); + if (readsize != DBLKSIZ) { + if (readsize < 0) readsize = 0; + bzero(dirbuf+readsize, DBLKSIZ-readsize); + } + oldb2 = b; + } + if (dirbuf[i] & (1<<n)) + return (1); + return (0); +} + +int +setbit(void) +{ + long bn; + long i, n, b; + + if (dbrdonly) + return (-1); + if (bitno > maxbno) { + maxbno = bitno; + (void) getbit(); + } + n = bitno % BYTESIZ; + bn = bitno / BYTESIZ; + i = bn % DBLKSIZ; + b = bn / DBLKSIZ; + dirbuf[i] |= 1<<n; + (void) lseek(dirf, (long)b*DBLKSIZ, 0); + if (write(dirf, dirbuf, DBLKSIZ) < 0) + return (-1); + return (0); +} + +datum +makdatum(char buf[PBLKSIZ], int n) +{ + short *sp; + int t; + datum item; + + sp = (short *)buf; + if (n < 0 || n >= sp[0]) + goto null; + t = PBLKSIZ; + if (n > 0) + t = sp[n+1-1]; + item.dptr = buf+sp[n+1]; + item.dsize = t - sp[n+1]; + return (item); + +null: + item.dptr = NULL; + item.dsize = 0; + return (item); +} + +int +cmpdatum(datum d1, datum d2) +{ + int n; + char *p1, *p2; + + n = d1.dsize; + if (n != d2.dsize) + return (n - d2.dsize); + if (n == 0) + return (0); + p1 = d1.dptr; + p2 = d2.dptr; + do + if (*p1++ != *p2++) + return (*--p1 - *--p2); + while (--n); + return (0); +} + +int hitab[16] +/* + * ken's + * { + * 055,043,036,054,063,014,004,005, + * 010,064,077,000,035,027,025,071, + * }; + */ + = { 61, 57, 53, 49, 45, 41, 37, 33, + 29, 25, 21, 17, 13, 9, 5, 1, + }; +long hltab[64] = { + 06100151277L, 06106161736L, 06452611562L, 05001724107L, + 02614772546L, 04120731531L, 04665262210L, 07347467531L, + 06735253126L, 06042345173L, 03072226605L, 01464164730L, + 03247435524L, 07652510057L, 01546775256L, 05714532133L, + 06173260402L, 07517101630L, 02431460343L, 01743245566L, + 00261675137L, 02433103631L, 03421772437L, 04447707466L, + 04435620103L, 03757017115L, 03641531772L, 06767633246L, + 02673230344L, 00260612216L, 04133454451L, 00615531516L, + 06137717526L, 02574116560L, 02304023373L, 07061702261L, + 05153031405L, 05322056705L, 07401116734L, 06552375715L, + 06165233473L, 05311063631L, 01212221723L, 01052267235L, + 06000615237L, 01075222665L, 06330216006L, 04402355630L, + 01451177262L, 02000133436L, 06025467062L, 07121076461L, + 03123433522L, 01010635225L, 01716177066L, 05161746527L, + 01736635071L, 06243505026L, 03637211610L, 01756474365L, + 04723077174L, 03642763134L, 05750130273L, 03655541561L, +}; + +long +hashinc(long hash) +{ + long bit; + + hash &= hmask; + bit = hmask+1; + for (;;) { + bit >>= 1; + if (bit == 0) + return (0L); + if ((hash&bit) == 0) + return (hash|bit); + hash &= ~bit; + } +} + +long +calchash(datum item) +{ + int i, j, f; + long hashl; + int hashi; + + hashl = 0; + hashi = 0; + for (i = 0; i < item.dsize; i++) { + f = item.dptr[i]; + for (j = 0; j < BYTESIZ; j += 4) { + hashi += hitab[f&017]; + hashl += hltab[hashi&63]; + f >>= 4; + } + } + return (hashl); +} + +void +delitem(char buf[PBLKSIZ], int n) +{ + short *sp; + int i1, i2, i3; + + sp = (short *)buf; + if (n < 0 || n >= sp[0]) + goto bad; + i1 = sp[n+1]; + i2 = PBLKSIZ; + if (n > 0) + i2 = sp[n+1-1]; + i3 = sp[sp[0]+1-1]; + if (i2 > i1) + while (i1 > i3) { + i1--; + i2--; + buf[i2] = buf[i1]; + buf[i1] = 0; + } + i2 -= i1; + for (i1 = n+1; i1 < sp[0]; i1++) + sp[i1+1-1] = sp[i1+1] + i2; + sp[0]--; + sp[sp[0]+1] = 0; + return; + +bad: + (void) printf("bad delitem\n"); + abort(); +} + +int +additem(char buf[PBLKSIZ], datum item) +{ + short *sp; + int i1, i2; + + sp = (short *)buf; + i1 = PBLKSIZ; + if (sp[0] > 0) + i1 = sp[sp[0]+1-1]; + i1 -= item.dsize; + i2 = (int)((sp[0]+2) * sizeof (short)); + if (i1 <= i2) + return (-1); + sp[sp[0]+1] = (short)i1; + for (i2 = 0; i2 < item.dsize; i2++) { + buf[i1] = item.dptr[i2]; + i1++; + } + sp[0]++; + return (sp[0]-1); +} + +void +chkblk(char buf[PBLKSIZ]) +{ + short *sp; + int t, i; + + sp = (short *)buf; + t = PBLKSIZ; + for (i = 0; i < sp[0]; i++) { + if (sp[i+1] > t) + goto bad; + t = sp[i+1]; + } + if (t < (sp[0]+1)*sizeof (short)) + goto bad; + return; + +bad: + (void) printf("bad block\n"); + abort(); + bzero(buf, PBLKSIZ); +} diff --git a/usr/src/ucblib/libdbm/i386/Makefile b/usr/src/ucblib/libdbm/i386/Makefile new file mode 100644 index 0000000000..cf1a8db8ea --- /dev/null +++ b/usr/src/ucblib/libdbm/i386/Makefile @@ -0,0 +1,37 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libdbm/i386/Makefile + +MAPDIR= ../spec/i386 +include ../Makefile.com + +BUILD.SO= $(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/ucblib $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/libdbm/llib-ldbm b/usr/src/ucblib/libdbm/llib-ldbm new file mode 100644 index 0000000000..1b2f5e06e8 --- /dev/null +++ b/usr/src/ucblib/libdbm/llib-ldbm @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* LINTLIBRARY */ + +#include <dbm.h> +#include <sys/stat.h> +#include <sys/types.h> + +/* dbm.c */ +int dbminit(file) char *file; { static int x; return(x); } +int dbmflush() { static int x; return(x); } +int dbmclose() { static int x; return(x); } +datum fetch(key) datum key; { static datum x; return(x); } +int delete(key) datum key; { static int x; return(x); } +int store(key, content) datum key; datum content; { static int x; return(x); } +datum firstkey() { static datum x; return(x); } +datum nextkey(key) datum key; { static datum x; return(x); } diff --git a/usr/src/ucblib/libdbm/sparc/Makefile b/usr/src/ucblib/libdbm/sparc/Makefile new file mode 100644 index 0000000000..1e40791671 --- /dev/null +++ b/usr/src/ucblib/libdbm/sparc/Makefile @@ -0,0 +1,37 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libdbm/sparc/Makefile + +MAPDIR= ../spec/sparc +include ../Makefile.com + +BUILD.SO= $(CC) -o $@ -G $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/ucblib $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/libdbm/sparcv9/Makefile b/usr/src/ucblib/libdbm/sparcv9/Makefile new file mode 100644 index 0000000000..81ff39f279 --- /dev/null +++ b/usr/src/ucblib/libdbm/sparcv9/Makefile @@ -0,0 +1,39 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1997-1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libdbm/sparcv9/Makefile + +MAPDIR= ../spec/sparcv9 +include ../Makefile.com +include ../../../lib/Makefile.lib.64 + +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) \ + -L $(ROOT)/usr/ucblib/$(MACH64) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) diff --git a/usr/src/ucblib/libdbm/spec/Makefile b/usr/src/ucblib/libdbm/spec/Makefile new file mode 100644 index 0000000000..f118e481cd --- /dev/null +++ b/usr/src/ucblib/libdbm/spec/Makefile @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1997-1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libdbm/spec/Makefile + +include $(SRC)/lib/Makefile.spec.arch diff --git a/usr/src/ucblib/libdbm/spec/Makefile.targ b/usr/src/ucblib/libdbm/spec/Makefile.targ new file mode 100644 index 0000000000..6c412cdff2 --- /dev/null +++ b/usr/src/ucblib/libdbm/spec/Makefile.targ @@ -0,0 +1,36 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1997-1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libdbm/spec/Makefile.targ + +LIBRARY = libdbm.a +VERS = .1 + +OBJECTS = dbm.o + +TRANSCPP = +SPECCPP = -I$(ROOT)/usr/ucbinclude diff --git a/usr/src/ucblib/libdbm/spec/amd64/Makefile b/usr/src/ucblib/libdbm/spec/amd64/Makefile new file mode 100644 index 0000000000..6beb38aa0f --- /dev/null +++ b/usr/src/ucblib/libdbm/spec/amd64/Makefile @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#amd64_C_PICFLAGS = $(amd64_C_BIGPICFLAGS) + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/libdbm/spec/dbm.spec b/usr/src/ucblib/libdbm/spec/dbm.spec new file mode 100644 index 0000000000..8d19c7c51a --- /dev/null +++ b/usr/src/ucblib/libdbm/spec/dbm.spec @@ -0,0 +1,128 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libdbm/spec/dbm.spec + +function delete +include <dbm.h> +declaration int delete(datum key) +version SUNW_1.1 +exception $return < 0 +end + +function firstkey +include <dbm.h> +declaration datum firstkey(void) +version SUNW_1.1 +exception $return.dptr == 0 +end + +function nextkey +include <dbm.h> +declaration datum nextkey(datum key) +version SUNW_1.1 +exception $return.dptr == 0 +end + +function dbminit +include <dbm.h> +declaration int dbminit(char *file) +version SUNW_1.1 +exception $return < 0 +end + +function dbmclose +include <dbm.h> +declaration int dbmclose(void) +version SUNW_1.1 +exception $return < 0 +end + +function fetch +include <dbm.h> +declaration datum fetch(datum key) +version SUNW_1.1 +exception $return.dptr == 0 +end + +function store +include <dbm.h> +declaration datum store(datum key, datum dat) +version SUNW_1.1 +exception $return.dptr == 0 +end + +data bitno +version SUNW_1.1 +end + +data blkno +version SUNW_1.1 +end + +function calchash +declaration long calchash(datum dat) +version SUNWprivate_1.1 +end + +data dbrdonly +version SUNW_1.1 +end + +data dirbuf +version SUNW_1.1 +end + +data dirf +version SUNW_1.1 +end + +function hashinc +declaration long hashinc(long h) +version SUNWprivate_1.1 +end + +data hmask +version SUNW_1.1 +end + +function makdatum +declaration datum makdatum(char *s, int l) +version SUNWprivate_1.1 +end + +data pagbuf +version SUNW_1.1 +end + +data pagf +version SUNW_1.1 +end + +data maxbno +version SUNW_1.1 +end + diff --git a/usr/src/ucblib/libdbm/spec/i386/Makefile b/usr/src/ucblib/libdbm/spec/i386/Makefile new file mode 100644 index 0000000000..826dad2e4b --- /dev/null +++ b/usr/src/ucblib/libdbm/spec/i386/Makefile @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1997-1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libdbm/spec/i386/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#i386_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/libdbm/spec/sparc/Makefile b/usr/src/ucblib/libdbm/spec/sparc/Makefile new file mode 100644 index 0000000000..c07b49c229 --- /dev/null +++ b/usr/src/ucblib/libdbm/spec/sparc/Makefile @@ -0,0 +1,44 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1997-1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# /ucblib/libdbm/spec/sparc/Makefile + +.KEEP_STATE: + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#sparc_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/libdbm/spec/sparcv9/Makefile b/usr/src/ucblib/libdbm/spec/sparcv9/Makefile new file mode 100644 index 0000000000..e42e96a0ab --- /dev/null +++ b/usr/src/ucblib/libdbm/spec/sparcv9/Makefile @@ -0,0 +1,43 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1997-1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libdbm/spec/sparcv9/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#sparcv9_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/libdbm/spec/versions b/usr/src/ucblib/libdbm/spec/versions new file mode 100644 index 0000000000..38a2cfc77a --- /dev/null +++ b/usr/src/ucblib/libdbm/spec/versions @@ -0,0 +1,43 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# ident "%Z%%M% %I% %E% SMI" +# + +sparc { + SUNW_1.1; + SUNWprivate_1.1; +} +sparcv9 { + SUNW_1.1; + SUNWprivate_1.1; +} +i386 { + SUNW_1.1; + SUNWprivate_1.1; +} +amd64 { + SUNW_1.1; + SUNWprivate_1.1; +} diff --git a/usr/src/ucblib/librpcsoc/Makefile b/usr/src/ucblib/librpcsoc/Makefile new file mode 100644 index 0000000000..d096da99ff --- /dev/null +++ b/usr/src/ucblib/librpcsoc/Makefile @@ -0,0 +1,59 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/librpcsoc/Makefile +# + +include $(SRC)/Makefile.master + +SUBDIRS = spec .WAIT $(MACH) $(BUILD64) $(MACH64) + +# install rule for install_h target +$(ROOTHDRDIR)/%: % + $(INS.file) + +#conditional assignments +all := TARGET=all +install := TARGET= install +clean := TARGET= clean +clobber := TARGET= clobber +lint := TARGET= lint + +.KEEP_STATE: + +all: .WAIT $(SUBDIRS) + +install: all .WAIT $(SUBDIRS) + +install_h: $(ROOTHDRS) + +clean clobber lint: $(SUBDIRS) + +$(MACH) $(MACH64) spec: FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: diff --git a/usr/src/ucblib/librpcsoc/Makefile.com b/usr/src/ucblib/librpcsoc/Makefile.com new file mode 100644 index 0000000000..574265d24a --- /dev/null +++ b/usr/src/ucblib/librpcsoc/Makefile.com @@ -0,0 +1,79 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/librpcsoc/Makefile.com +# + +LIBRARY= librpcsoc.a +VERS = .1 + +CLOBBERFILES += lint.out + + +OBJECTS= clnt_tcp.o clnt_udp.o getrpcport.o rtime.o svc_tcp.o svc_udp.o get_myaddress.o + +# include library definitions +include $(SRC)/lib/Makefile.lib + +MAPFILE= $(MAPDIR)/mapfile +CLOBBERFILES += $(MAPFILE) +SRCS= $(OBJECTS:%.o=../%.c) + +objs/%.o pics/%.o: ../%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) + +LIBS = $(DYNLIB) + +LDLIBS += -lnsl -lsocket -lc +CPPFLAGS += -DPORTMAP +DYNFLAGS += -M $(MAPFILE) + +ROOTLIBDIR= $(ROOT)/usr/ucblib +ROOTLIBDIR64= $(ROOT)/usr/ucblib/$(MACH64) + +LINTSRC= $(LINTLIB:%.ln=%) +$(LINTLIB):= SRCS=../$(LINTSRC) + +CPPFLAGS = -I$(ROOT)/usr/ucbinclude -I../../../lib/libc/inc $(CPPFLAGS.master) + +.KEEP_STATE: + +$(DYNLIB): $(MAPFILE) + +$(MAPFILE): + @cd $(MAPDIR); $(MAKE) mapfile + +lint: lintcheck + +# include library targets +include $(SRC)/lib/Makefile.targ +include ../../Makefile.ucbtarg + +# install rule for lint library target +$(ROOTLINTDIR)/%: ../% + $(INS.file) diff --git a/usr/src/ucblib/librpcsoc/amd64/Makefile b/usr/src/ucblib/librpcsoc/amd64/Makefile new file mode 100644 index 0000000000..306722bed4 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/amd64/Makefile @@ -0,0 +1,43 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +MAPDIR= ../spec/amd64 +include ../Makefile.com +include $(SRC)/lib/Makefile.lib.64 + +DYNFLAGS += $(DYNFLAGS64) +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) \ + -L $(ROOT)/usr/ucblib/$(MACH64) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) + +LIBS= $(DYNLIB) $(LINTLIB) + +.KEEP_STATE: + +all: $(LIBS) + +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/ucblib/librpcsoc/clnt_tcp.c b/usr/src/ucblib/librpcsoc/clnt_tcp.c new file mode 100644 index 0000000000..b2dccbc20a --- /dev/null +++ b/usr/src/ucblib/librpcsoc/clnt_tcp.c @@ -0,0 +1,486 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1984, 1986, 1987, 1988, 1989, 1996 AT&T + * All Rights Reserved + */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * clnt_tcp.c, Implements a TCP/IP based, client side RPC. + * + * TCP based RPC supports 'batched calls'. + * A sequence of calls may be batched-up in a send buffer. The rpc call + * return immediately to the client even though the call was not necessarily + * sent. The batching occurs if the results' xdr routine is NULL (0) AND + * the rpc timeout value is zero (see clnt.h, rpc). + * + * Clients should NOT casually batch calls that in fact return results; that is, + * the server side should be aware that a call is batched and not produce any + * return message. Batched calls that produce many result messages can + * deadlock (netlock) the client and the server.... + * + * Now go hang yourself. + */ + +#include <rpc/rpc.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <netdb.h> +#include <errno.h> +#include <rpc/pmap_clnt.h> +#include <syslog.h> +#include <malloc.h> +#include <stdio.h> + +#define MCALL_MSG_SIZE 24 + +extern int errno; + +static int readtcp(); +static int writetcp(); +extern int _socket(int, int, int); +extern pid_t getpid(); +extern int bindresvport(int, struct sockaddr_in *); +extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *); +static struct clnt_ops *clnttcp_ops(); + +struct ct_data { + int ct_sock; + bool_t ct_closeit; + struct timeval ct_wait; + bool_t ct_waitset; /* wait set by clnt_control? */ + struct sockaddr_in ct_addr; + struct rpc_err ct_error; + char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */ + u_int ct_mpos; /* pos after marshal */ + XDR ct_xdrs; +}; + +/* + * Create a client handle for a tcp/ip connection. + * If *sockp<0, *sockp is set to a newly created TCP socket and it is + * connected to raddr. If *sockp non-negative then + * raddr is ignored. The rpc/tcp package does buffering + * similar to stdio, so the client must pick send and receive buffer sizes + * 0 => use the default. + * If raddr->sin_port is 0, then a binder on the remote machine is + * consulted for the right port number. + * NB: *sockp is copied into a private area. + * NB: It is the clients responsibility to close *sockp. + * NB: The rpch->cl_auth is set null authentication. Caller may wish to + * set this something more useful. + */ +CLIENT * +clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + struct sockaddr_in *raddr; + rpcprog_t prog; + rpcvers_t vers; + register int *sockp; + u_int sendsz; + u_int recvsz; +{ + CLIENT *h; + register struct ct_data *ct; + struct timeval now; + struct rpc_msg call_msg; + int i; + + h = (CLIENT *)mem_alloc(sizeof (*h)); + if (h == NULL) { + (void) syslog(LOG_ERR, "clnttcp_create: out of memory"); + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + ct = (struct ct_data *)mem_alloc(sizeof (*ct)); + if (ct == NULL) { + (void) syslog(LOG_ERR, "clnttcp_create: out of memory"); + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + + /* + * If no port number given ask the pmap for one + */ + if (raddr->sin_port == 0) { + u_short port; + if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) + == 0) { + mem_free((caddr_t)ct, sizeof (struct ct_data)); + mem_free((caddr_t)h, sizeof (CLIENT)); + return ((CLIENT *)NULL); + } + raddr->sin_port = htons(port); + } + + /* + * If no socket given, open one + */ + if (*sockp < 0) { + *sockp = _socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + i = bindresvport(*sockp, (struct sockaddr_in *)0); + if ((*sockp < 0)|| + (connect(*sockp, (struct sockaddr *)raddr, + sizeof (*raddr)) < 0)) { + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + (void) close(*sockp); + goto fooy; + } + ct->ct_closeit = TRUE; + } else { + ct->ct_closeit = FALSE; + } + + /* + * Set up private data struct + */ + ct->ct_sock = *sockp; + ct->ct_wait.tv_usec = 0; + ct->ct_waitset = FALSE; + ct->ct_addr = *raddr; + + /* + * Initialize call message + */ + (void) gettimeofday(&now, (struct timezone *)0); + call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; + call_msg.rm_direction = CALL; + call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; + call_msg.rm_call.cb_prog = prog; + call_msg.rm_call.cb_vers = vers; + + /* + * pre-serialize the staic part of the call msg and stash it away + */ + xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, + XDR_ENCODE); + if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { + if (ct->ct_closeit) { + (void) close(*sockp); + } + goto fooy; + } + ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); + XDR_DESTROY(&(ct->ct_xdrs)); + + /* + * Create a client handle which uses xdrrec for serialization + * and authnone for authentication. + */ + xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, + (caddr_t)ct, readtcp, writetcp); + h->cl_ops = clnttcp_ops(); + h->cl_private = (caddr_t) ct; + h->cl_auth = authnone_create(); + return (h); + +fooy: + /* + * Something goofed, free stuff and barf + */ + mem_free((caddr_t)ct, sizeof (struct ct_data)); + mem_free((caddr_t)h, sizeof (CLIENT)); + return ((CLIENT *)NULL); +} + +static enum clnt_stat +clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) + register CLIENT *h; + rpcproc_t proc; + xdrproc_t xdr_args; + caddr_t args_ptr; + xdrproc_t xdr_results; + caddr_t results_ptr; + struct timeval timeout; +{ + register struct ct_data *ct = (struct ct_data *) h->cl_private; + register XDR *xdrs = &(ct->ct_xdrs); + struct rpc_msg reply_msg; + uint32_t x_id; + uint32_t *msg_x_id = (uint32_t *)(ct->ct_mcall); /* yuk */ + register bool_t shipnow; + int refreshes = 2; + + if (!ct->ct_waitset) { + ct->ct_wait = timeout; + } + + shipnow = + (xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0 && + timeout.tv_usec == 0) ? FALSE : TRUE; + +call_again: + xdrs->x_op = XDR_ENCODE; + ct->ct_error.re_status = RPC_SUCCESS; + x_id = ntohl(--(*msg_x_id)); + if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || + (! XDR_PUTINT32(xdrs, (int32_t *)&proc)) || + (! AUTH_MARSHALL(h->cl_auth, xdrs)) || + (! (*xdr_args)(xdrs, args_ptr))) { + if (ct->ct_error.re_status == RPC_SUCCESS) + ct->ct_error.re_status = RPC_CANTENCODEARGS; + (void) xdrrec_endofrecord(xdrs, TRUE); + return (ct->ct_error.re_status); + } + if (! xdrrec_endofrecord(xdrs, shipnow)) + return (ct->ct_error.re_status = RPC_CANTSEND); + if (! shipnow) + return (RPC_SUCCESS); + /* + * Hack to provide rpc-based message passing + */ + if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { + return (ct->ct_error.re_status = RPC_TIMEDOUT); + } + + + /* + * Keep receiving until we get a valid transaction id + */ + xdrs->x_op = XDR_DECODE; + while (TRUE) { + reply_msg.acpted_rply.ar_verf = _null_auth; + reply_msg.acpted_rply.ar_results.where = NULL; + reply_msg.acpted_rply.ar_results.proc = xdr_void; + if (! xdrrec_skiprecord(xdrs)) + return (ct->ct_error.re_status); + /* now decode and validate the response header */ + if (! xdr_replymsg(xdrs, &reply_msg)) { + if (ct->ct_error.re_status == RPC_SUCCESS) + continue; + return (ct->ct_error.re_status); + } + if (reply_msg.rm_xid == x_id) + break; + } + + /* + * process header + */ + __seterr_reply(&reply_msg, &(ct->ct_error)); + if (ct->ct_error.re_status == RPC_SUCCESS) { + if (! AUTH_VALIDATE(h->cl_auth, + &reply_msg.acpted_rply.ar_verf)) { + ct->ct_error.re_status = RPC_AUTHERROR; + ct->ct_error.re_why = AUTH_INVALIDRESP; + } else if (! (*xdr_results)(xdrs, results_ptr)) { + if (ct->ct_error.re_status == RPC_SUCCESS) + ct->ct_error.re_status = RPC_CANTDECODERES; + } + /* free verifier ... */ + if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { + xdrs->x_op = XDR_FREE; + (void) xdr_opaque_auth(xdrs, + &(reply_msg.acpted_rply.ar_verf)); + } + } /* end successful completion */ + else { + /* maybe our credentials need to be refreshed ... */ + if (refreshes-- && AUTH_REFRESH(h->cl_auth, &reply_msg)) + goto call_again; + } /* end of unsuccessful completion */ + return (ct->ct_error.re_status); +} + +static void +clnttcp_geterr(h, errp) + CLIENT *h; + struct rpc_err *errp; +{ + register struct ct_data *ct = + (struct ct_data *) h->cl_private; + + *errp = ct->ct_error; +} + +static bool_t +clnttcp_freeres(cl, xdr_res, res_ptr) + CLIENT *cl; + xdrproc_t xdr_res; + caddr_t res_ptr; +{ + register struct ct_data *ct = (struct ct_data *)cl->cl_private; + register XDR *xdrs = &(ct->ct_xdrs); + + xdrs->x_op = XDR_FREE; + return ((*xdr_res)(xdrs, res_ptr)); +} + +static void +clnttcp_abort() +{ +} + +static bool_t +clnttcp_control(cl, request, info) + CLIENT *cl; + int request; + char *info; +{ + register struct ct_data *ct = (struct ct_data *)cl->cl_private; + + switch (request) { + case CLSET_TIMEOUT: + ct->ct_wait = *(struct timeval *)info; + ct->ct_waitset = TRUE; + break; + case CLGET_TIMEOUT: + *(struct timeval *)info = ct->ct_wait; + break; + case CLGET_SERVER_ADDR: + *(struct sockaddr_in *)info = ct->ct_addr; + break; + case CLGET_FD: + *(int *)info = ct->ct_sock; + break; + case CLSET_FD_CLOSE: + ct->ct_closeit = TRUE; + break; + case CLSET_FD_NCLOSE: + ct->ct_closeit = FALSE; + break; + default: + return (FALSE); + } + return (TRUE); +} + + +static void +clnttcp_destroy(h) + CLIENT *h; +{ + register struct ct_data *ct = + (struct ct_data *) h->cl_private; + + if (ct->ct_closeit) { + (void) close(ct->ct_sock); + } + XDR_DESTROY(&(ct->ct_xdrs)); + mem_free((caddr_t)ct, sizeof (struct ct_data)); + mem_free((caddr_t)h, sizeof (CLIENT)); +} + +/* + * Interface between xdr serializer and tcp connection. + * Behaves like the system calls, read & write, but keeps some error state + * around for the rpc level. + */ +static int +readtcp(ct, buf, len) + register struct ct_data *ct; + caddr_t buf; + register int len; +{ + fd_set mask; + fd_set readfds; + + if (len == 0) + return (0); + FD_ZERO(&mask); + FD_SET(ct->ct_sock, &mask); + while (TRUE) { + readfds = mask; + switch (select(__rpc_dtbsize(), + &readfds, NULL, NULL, &(ct->ct_wait))) { + case 0: + ct->ct_error.re_status = RPC_TIMEDOUT; + return (-1); + + case -1: + if (errno == EINTR) + continue; + ct->ct_error.re_status = RPC_CANTRECV; + ct->ct_error.re_errno = errno; + return (-1); + } + break; + } + switch (len = read(ct->ct_sock, buf, len)) { + + case 0: + /* premature eof */ + ct->ct_error.re_errno = ECONNRESET; + ct->ct_error.re_status = RPC_CANTRECV; + len = -1; /* it's really an error */ + break; + + case -1: + ct->ct_error.re_errno = errno; + ct->ct_error.re_status = RPC_CANTRECV; + break; + } + return (len); +} + +static int +writetcp(ct, buf, len) + struct ct_data *ct; + caddr_t buf; + int len; +{ + register int i, cnt; + + for (cnt = len; cnt > 0; cnt -= i, buf += i) { + if ((i = write(ct->ct_sock, buf, cnt)) == -1) { + ct->ct_error.re_errno = errno; + ct->ct_error.re_status = RPC_CANTSEND; + return (-1); + } + } + return (len); +} + +static struct clnt_ops * +clnttcp_ops() +{ + static struct clnt_ops ops; + + if (ops.cl_call == NULL) { + ops.cl_call = clnttcp_call; + ops.cl_abort = clnttcp_abort; + ops.cl_geterr = clnttcp_geterr; + ops.cl_freeres = clnttcp_freeres; + ops.cl_destroy = clnttcp_destroy; + ops.cl_control = clnttcp_control; + } + return (&ops); +} diff --git a/usr/src/ucblib/librpcsoc/clnt_udp.c b/usr/src/ucblib/librpcsoc/clnt_udp.c new file mode 100644 index 0000000000..6712604d34 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/clnt_udp.c @@ -0,0 +1,531 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Copyright (c) 1984, 1986, 1987, 1988, 1989, 1996 AT&T + * All Rights Reserved + */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * clnt_udp.c, Implements a UDP/IP based, client side RPC. + */ + +#include <rpc/rpc.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <sys/ioctl.h> +#include <netdb.h> +#include <errno.h> +#include <rpc/pmap_clnt.h> +#include <rpc/clnt_soc.h> +#include <syslog.h> +#include <sys/filio.h> +#include <malloc.h> +#include <unistd.h> +#include <stropts.h> +#include <stdio.h> + + +extern int errno; + +extern int _socket(int, int, int); +extern pid_t getpid(); +extern int bindresvport(int, struct sockaddr_in *); +extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *); +extern int _sendto(int, const char *, int, int, + const struct sockaddr *, int); +extern int _recvfrom(int, char *, int, int, + struct sockaddr *, int *); + + +static struct clnt_ops *clntudp_ops(); + +/* + * Private data kept per client handle + */ +struct cu_data { + int cu_sock; + bool_t cu_closeit; + struct sockaddr_in cu_raddr; + int cu_rlen; + struct timeval cu_wait; + struct timeval cu_total; + struct rpc_err cu_error; + XDR cu_outxdrs; + u_int cu_xdrpos; + u_int cu_sendsz; + char *cu_outbuf; + u_int cu_recvsz; + char cu_inbuf[1]; +}; + +/* + * Create a UDP based client handle. + * If *sockp<0, *sockp is set to a newly created UPD socket. + * If raddr->sin_port is 0 a binder on the remote machine + * is consulted for the correct port number. + * NB: It is the clients responsibility to close *sockp. + * NB: The rpch->cl_auth is initialized to null authentication. + * Caller may wish to set this something more useful. + * + * wait is the amount of time used between retransmitting a call if + * no response has been heard; retransmition occurs until the actual + * rpc call times out. + * + * sendsz and recvsz are the maximum allowable packet sizes that can be + * sent and received. + */ +CLIENT * +clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + struct sockaddr_in *raddr; + rpcprog_t program; + rpcvers_t version; + struct timeval wait; + register int *sockp; + u_int sendsz; + u_int recvsz; +{ + CLIENT *cl; + register struct cu_data *cu; + struct timeval now; + struct rpc_msg call_msg; + + cl = (CLIENT *)mem_alloc(sizeof (CLIENT)); + if (cl == NULL) { + (void) syslog(LOG_ERR, "clntudp_create: out of memory"); + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + sendsz = ((sendsz + 3) / 4) * 4; + recvsz = ((recvsz + 3) / 4) * 4; + cu = (struct cu_data *)mem_alloc(sizeof (*cu) + sendsz + recvsz); + if (cu == NULL) { + (void) syslog(LOG_ERR, "clntudp_create: out of memory"); + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + cu->cu_outbuf = &cu->cu_inbuf[recvsz]; + + (void) gettimeofday(&now, (struct timezone *)0); + if (raddr->sin_port == 0) { + u_short port; + if ((port = + pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { + goto fooy; + } + raddr->sin_port = htons(port); + } + cl->cl_ops = clntudp_ops(); + cl->cl_private = (caddr_t)cu; + cu->cu_raddr = *raddr; + cu->cu_rlen = sizeof (cu->cu_raddr); + cu->cu_wait = wait; + cu->cu_total.tv_sec = -1; + cu->cu_total.tv_usec = -1; + cu->cu_sendsz = sendsz; + cu->cu_recvsz = recvsz; + call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; + call_msg.rm_direction = CALL; + call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; + call_msg.rm_call.cb_prog = program; + call_msg.rm_call.cb_vers = version; + xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, + sendsz, XDR_ENCODE); + if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) { + goto fooy; + } + cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); + if (*sockp < 0) { + int dontblock = 1; + + *sockp = _socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (*sockp < 0) { + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + /* attempt to bind to prov port */ + (void) bindresvport(*sockp, (struct sockaddr_in *)0); + /* the sockets rpc controls are non-blocking */ + (void) ioctl(*sockp, FIONBIO, (char *) &dontblock); + cu->cu_closeit = TRUE; + } else { + cu->cu_closeit = FALSE; + } + cu->cu_sock = *sockp; + cl->cl_auth = authnone_create(); + return (cl); +fooy: + if (cu) + mem_free((caddr_t)cu, sizeof (*cu) + sendsz + recvsz); + if (cl) + mem_free((caddr_t)cl, sizeof (CLIENT)); + return ((CLIENT *)NULL); +} + +CLIENT * +clntudp_create(raddr, program, version, wait, sockp) + struct sockaddr_in *raddr; + rpcprog_t program; + rpcvers_t version; + struct timeval wait; + register int *sockp; +{ + + return (clntudp_bufcreate(raddr, program, version, wait, sockp, + UDPMSGSIZE, UDPMSGSIZE)); +} + +static enum clnt_stat +clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) + register CLIENT *cl; /* client handle */ + rpcproc_t proc; /* procedure number */ + xdrproc_t xargs; /* xdr routine for args */ + caddr_t argsp; /* pointer to args */ + xdrproc_t xresults; /* xdr routine for results */ + caddr_t resultsp; /* pointer to results */ + struct timeval utimeout; /* seconds to wait before giving up */ +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + register XDR *xdrs; + register int outlen; + register int inlen; + int fromlen; + fd_set readfds; + fd_set mask; + struct sockaddr_in from; + struct rpc_msg reply_msg; + XDR reply_xdrs; + struct timeval startime, curtime; + int firsttimeout = 1; + struct timeval time_waited; + struct timeval retransmit_time; + bool_t ok; + int nrefreshes = 2; /* number of times to refresh cred */ + struct timeval timeout; + + if (cu->cu_total.tv_usec == -1) { + timeout = utimeout; /* use supplied timeout */ + } else { + timeout = cu->cu_total; /* use default timeout */ + } + + time_waited.tv_sec = 0; + time_waited.tv_usec = 0; + retransmit_time = cu->cu_wait; + +call_again: + xdrs = &(cu->cu_outxdrs); + xdrs->x_op = XDR_ENCODE; + XDR_SETPOS(xdrs, cu->cu_xdrpos); + /* + * the transaction is the first thing in the out buffer + */ + (*(u_short *)(cu->cu_outbuf))++; + if ((! XDR_PUTINT32(xdrs, (int32_t *)&proc)) || + (! AUTH_MARSHALL(cl->cl_auth, xdrs)) || + (! (*xargs)(xdrs, argsp))) + return (cu->cu_error.re_status = RPC_CANTENCODEARGS); + outlen = (int)XDR_GETPOS(xdrs); + +send_again: + if (_sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0, + (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen) + != outlen) { + cu->cu_error.re_errno = errno; + return (cu->cu_error.re_status = RPC_CANTSEND); + } + + /* + * Hack to provide rpc-based message passing + */ + if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { + return (cu->cu_error.re_status = RPC_TIMEDOUT); + } + /* + * sub-optimal code appears here because we have + * some clock time to spare while the packets are in flight. + * (We assume that this is actually only executed once.) + */ + reply_msg.acpted_rply.ar_verf = _null_auth; + reply_msg.acpted_rply.ar_results.where = resultsp; + reply_msg.acpted_rply.ar_results.proc = xresults; + FD_ZERO(&mask); + FD_SET(cu->cu_sock, &mask); + for (;;) { + readfds = mask; + switch (select(__rpc_dtbsize(), &readfds, NULL, + NULL, &(retransmit_time))) { + + case 0: + time_waited.tv_sec += retransmit_time.tv_sec; + time_waited.tv_usec += retransmit_time.tv_usec; + while (time_waited.tv_usec >= 1000000) { + time_waited.tv_sec++; + time_waited.tv_usec -= 1000000; + } + + /* update retransmit_time */ + + if (retransmit_time.tv_sec < RPC_MAX_BACKOFF) { + retransmit_time.tv_usec += retransmit_time.tv_usec; + retransmit_time.tv_sec += retransmit_time.tv_sec; + while (retransmit_time.tv_usec >= 1000000) { + retransmit_time.tv_sec++; + retransmit_time.tv_usec -= 1000000; + } + } + + if ((time_waited.tv_sec < timeout.tv_sec) || + ((time_waited.tv_sec == timeout.tv_sec) && + (time_waited.tv_usec < timeout.tv_usec))) + goto send_again; + return (cu->cu_error.re_status = RPC_TIMEDOUT); + + /* + * buggy in other cases because time_waited is not being + * updated. + */ + case -1: + if (errno != EINTR) { + cu->cu_error.re_errno = errno; + return (cu->cu_error.re_status = RPC_CANTRECV); + } + + /* interrupted by another signal, update time_waited */ + if (firsttimeout) { + /* + * Could have done gettimeofday before clnt_call + * but that means 1 more system call per each + * clnt_call, so do it after first time out + */ + if (gettimeofday(&startime, + (struct timezone *) NULL) == -1) { + errno = 0; + continue; + } + firsttimeout = 0; + errno = 0; + continue; + }; + + if (gettimeofday(&curtime, + (struct timezone *) NULL) == -1) { + errno = 0; + continue; + }; + + time_waited.tv_sec += curtime.tv_sec - startime.tv_sec; + time_waited.tv_usec += curtime.tv_usec - + startime.tv_usec; + while (time_waited.tv_usec < 0) { + time_waited.tv_sec--; + time_waited.tv_usec += 1000000; + }; + while (time_waited.tv_usec >= 1000000) { + time_waited.tv_sec++; + time_waited.tv_usec -= 1000000; + } + startime.tv_sec = curtime.tv_sec; + startime.tv_usec = curtime.tv_usec; + if ((time_waited.tv_sec > timeout.tv_sec) || + ((time_waited.tv_sec == timeout.tv_sec) && + (time_waited.tv_usec > timeout.tv_usec))) { + return (cu->cu_error.re_status = RPC_TIMEDOUT); + } + errno = 0; /* reset it */ + continue; + + } + do { + fromlen = sizeof (struct sockaddr); + inlen = _recvfrom(cu->cu_sock, cu->cu_inbuf, + (int) cu->cu_recvsz, 0, + (struct sockaddr *)&from, &fromlen); + } while (inlen < 0 && errno == EINTR); + if (inlen < 0) { + if (errno == EWOULDBLOCK) + continue; + cu->cu_error.re_errno = errno; + return (cu->cu_error.re_status = RPC_CANTRECV); + } + if (inlen < sizeof (uint32_t)) + continue; + /* see if reply transaction id matches sent id */ + if (*((uint32_t *)(cu->cu_inbuf)) != + *((uint32_t *)(cu->cu_outbuf))) + continue; + /* we now assume we have the proper reply */ + break; + } + + /* + * now decode and validate the response + */ + xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)inlen, XDR_DECODE); + ok = xdr_replymsg(&reply_xdrs, &reply_msg); + /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */ + if (ok) { + __seterr_reply(&reply_msg, &(cu->cu_error)); + if (cu->cu_error.re_status == RPC_SUCCESS) { + if (! AUTH_VALIDATE(cl->cl_auth, + &reply_msg.acpted_rply.ar_verf)) { + cu->cu_error.re_status = RPC_AUTHERROR; + cu->cu_error.re_why = AUTH_INVALIDRESP; + } + if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { + xdrs->x_op = XDR_FREE; + (void) xdr_opaque_auth(xdrs, + &(reply_msg.acpted_rply.ar_verf)); + } + } /* end successful completion */ + else { + /* maybe our credentials need to be refreshed ... */ + if (nrefreshes > 0 && + AUTH_REFRESH(cl->cl_auth, &reply_msg)) { + nrefreshes--; + goto call_again; + } + } /* end of unsuccessful completion */ + } /* end of valid reply message */ + else { + cu->cu_error.re_status = RPC_CANTDECODERES; + } + return (cu->cu_error.re_status); +} + +static void +clntudp_geterr(cl, errp) + CLIENT *cl; + struct rpc_err *errp; +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + + *errp = cu->cu_error; +} + + +static bool_t +clntudp_freeres(cl, xdr_res, res_ptr) + CLIENT *cl; + xdrproc_t xdr_res; + caddr_t res_ptr; +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + register XDR *xdrs = &(cu->cu_outxdrs); + + xdrs->x_op = XDR_FREE; + return ((*xdr_res)(xdrs, res_ptr)); +} + +static void +clntudp_abort() + /* CLIENT *h; */ +{ +} + +static bool_t +clntudp_control(cl, request, info) + CLIENT *cl; + int request; + char *info; +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + + switch (request) { + case CLSET_TIMEOUT: + cu->cu_total = *(struct timeval *)info; + break; + case CLGET_TIMEOUT: + *(struct timeval *)info = cu->cu_total; + break; + case CLSET_RETRY_TIMEOUT: + cu->cu_wait = *(struct timeval *)info; + break; + case CLGET_RETRY_TIMEOUT: + *(struct timeval *)info = cu->cu_wait; + break; + case CLGET_SERVER_ADDR: + *(struct sockaddr_in *)info = cu->cu_raddr; + break; + case CLGET_FD: + *(int *)info = cu->cu_sock; + break; + case CLSET_FD_CLOSE: + cu->cu_closeit = TRUE; + break; + case CLSET_FD_NCLOSE: + cu->cu_closeit = FALSE; + break; + default: + return (FALSE); + } + return (TRUE); +} + +static void +clntudp_destroy(cl) + CLIENT *cl; +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + + if (cu->cu_closeit) { + (void) close(cu->cu_sock); + } + XDR_DESTROY(&(cu->cu_outxdrs)); + mem_free((caddr_t)cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz)); + mem_free((caddr_t)cl, sizeof (CLIENT)); +} + +static struct clnt_ops * +clntudp_ops() +{ + static struct clnt_ops ops; + + if (ops.cl_call == NULL) { + ops.cl_call = clntudp_call; + ops.cl_abort = clntudp_abort; + ops.cl_geterr = clntudp_geterr; + ops.cl_freeres = clntudp_freeres; + ops.cl_destroy = clntudp_destroy; + ops.cl_control = clntudp_control; + } + return (&ops); +} diff --git a/usr/src/ucblib/librpcsoc/get_myaddress.c b/usr/src/ucblib/librpcsoc/get_myaddress.c new file mode 100644 index 0000000000..48be1e2102 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/get_myaddress.c @@ -0,0 +1,118 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * get_myaddress.c + * + * Get client's IP address via ioctl. This avoids using the NIS. + * Copyright (C) 1990, Sun Microsystems, Inc. + */ + +#include <rpc/types.h> +#include <rpc/pmap_prot.h> +#include <sys/socket.h> +#include <sys/sockio.h> +#include <stdio.h> +#include <net/if.h> +#include <sys/ioctl.h> +#include <arpa/inet.h> +#include <netinet/in.h> +#include <syslog.h> +#include <malloc.h> +#include <unistd.h> +#include <stropts.h> +#include <stdlib.h> +#include <errno.h> + +/* + * don't use gethostbyname, which would invoke NIS + */ +void +get_myaddress(struct sockaddr_in *addr) +{ + int s; + struct ifconf ifc; + struct ifreq ifreq, *ifr; + int len, numifs; + int ret; + + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + syslog(LOG_ERR, "get_myaddress: socket: %m"); + exit(1); + } + + do { + ret = ioctl(s, SIOCGIFNUM, (char *)&numifs); + } while (ret < 0 && (errno == EINTR || errno == EAGAIN)); + if (ret < 0) { + syslog(LOG_ERR, "get_myaddress: ioctl: %m"); + exit(1); + } + + ifc.ifc_len = numifs * sizeof (struct ifreq); + if ((ifc.ifc_buf = (caddr_t)malloc(ifc.ifc_len)) == NULL) { + syslog(LOG_ERR, "get_myaddress: malloc: %m"); + exit(1); + } + + do { + ret = ioctl(s, SIOCGIFCONF, (char *)&ifc); + } while (ret < 0 && (errno == EINTR || errno == EAGAIN)); + if (ret < 0) { + syslog(LOG_ERR, + "get_myaddress: ioctl (get interface configuration): %m"); + exit(1); + } + + /* + * set default to loopback in case nothing is found. + */ + addr->sin_family = AF_INET; + addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK); + addr->sin_port = htons(PMAPPORT); + + ifr = ifc.ifc_req; + for (len = ifc.ifc_len; len > 0; len -= sizeof (ifreq), ifr++) { + ifreq = *ifr; + do { + ret = ioctl(s, SIOCGIFFLAGS, (char *)&ifreq); + } while (ret < 0 && (errno == EINTR || errno == EAGAIN)); + if (ret < 0) { + syslog(LOG_ERR, "get_myaddress: ioctl: %m"); + exit(1); + } + if (ifr->ifr_addr.sa_family != AF_INET) + continue; + if ((ifreq.ifr_flags & IFF_UP) == 0) + continue; + if (ifreq.ifr_flags & IFF_LOOPBACK) + continue; + if ((ifreq.ifr_flags & (IFF_MULTICAST | IFF_BROADCAST)) == 0) + continue; + *addr = *((struct sockaddr_in *)&ifr->ifr_addr); + addr->sin_port = htons(PMAPPORT); + break; + } + free(ifc.ifc_buf); + (void) close(s); +} diff --git a/usr/src/ucblib/librpcsoc/getrpcport.c b/usr/src/ucblib/librpcsoc/getrpcport.c new file mode 100644 index 0000000000..1cff09bc0f --- /dev/null +++ b/usr/src/ucblib/librpcsoc/getrpcport.c @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +#ident "%Z%%M% %I% %E% SMI" + +/* + * Copyright (c) 1991 by Sun Microsystems, Inc. + */ + +#include <rpc/rpc.h> +#include <netdb.h> +#include <sys/socket.h> +#include <stdio.h> + +extern u_short pmap_getport(struct sockaddr_in *, rpcprog_t, + rpcvers_t, rpcprot_t); + +u_short +getrpcport(char *host, rpcprog_t prognum, rpcvers_t versnum, rpcprot_t proto) +{ + struct sockaddr_in addr; + struct hostent *hp; + + if ((hp = gethostbyname(host)) == NULL) + return (0); + memcpy((char *) &addr.sin_addr, hp->h_addr, hp->h_length); + addr.sin_family = AF_INET; + addr.sin_port = 0; + return (pmap_getport(&addr, prognum, versnum, proto)); +} diff --git a/usr/src/ucblib/librpcsoc/i386/Makefile b/usr/src/ucblib/librpcsoc/i386/Makefile new file mode 100644 index 0000000000..aff760668d --- /dev/null +++ b/usr/src/ucblib/librpcsoc/i386/Makefile @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/librpcsoc/i386/Makefile + +MAPDIR= ../spec/i386 +include ../Makefile.com + +DYNFLAGS += $(DYNFLAGS32) +BUILD.SO= $(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/ucblib $(LDLIBS) + +LIBS = $(DYNLIB) $(LINTLIB) + +.KEEP_STATE: + +all: $(LIBS) + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/librpcsoc/llib-lrpcsoc b/usr/src/ucblib/librpcsoc/llib-lrpcsoc new file mode 100644 index 0000000000..68a07ff75f --- /dev/null +++ b/usr/src/ucblib/librpcsoc/llib-lrpcsoc @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997 by Sun Microsystems, Inc. + * All rights reserved. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* LINTLIBRARY */ + +#include <stdio.h> +#include <rpc/rpc.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <netdb.h> +#include <errno.h> +#include <rpc/pmap_clnt.h> +#include <sys/syslog.h> +#include <sys/ioctl.h> +#include <sys/filio.h> +#include <sys/types.h> +#include <sys/errno.h> +#include <netinet/in.h> + +/* clnt_tcp.c */ +CLIENT *clnttcp_create(struct sockaddr_in *, ulong_t, ulong_t, + int *, uint_t, uint_t); + +/* clnt_udp.c */ +CLIENT *clntudp_bufcreate(struct sockaddr_in *, ulong_t, ulong_t, + struct timeval, int *, uint_t, uint_t); +CLIENT *clntudp_create(struct sockaddr_in *, ulong_t, ulong_t, + struct timeval wait, int *); + +/* get_myaddress.c */ +int get_myaddress(struct sockaddr_in *); + +/* getrpcport.c */ +int getrpcport(char *, int, int, int); + +/* rtime.c */ +int rtime(struct sockaddr_in *, struct timeval *, struct timeval *); + +/* svc_tcp.c */ +SVCXPRT *svctcp_create(int, uint_t, uint_t); +SVCXPRT *svcfd_create(int, uint_t, uint_t); + +/* svc_udp.c */ +SVCXPRT *svcudp_bufcreate(int, uint_t, uint_t); +SVCXPRT *svcudp_create(int); +int svcudp_enablecache(SVCXPRT *, ulong_t); diff --git a/usr/src/ucblib/librpcsoc/rtime.c b/usr/src/ucblib/librpcsoc/rtime.c new file mode 100644 index 0000000000..bc3ca35ad1 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/rtime.c @@ -0,0 +1,164 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * rtime - get time from remote machine + * + * gets time, obtaining value from host + * on the udp/time socket. Since timeserver returns + * with time of day in seconds since Jan 1, 1900, must + * subtract seconds before Jan 1, 1970 to get + * what unix uses. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <errno.h> +#include <netinet/in.h> +#include <malloc.h> + +#define NYEARS (1970 - 1900) +#define TOFFSET ((uint_t)60*60*24*(365*NYEARS + (NYEARS/4))) + +extern int _socket(int, int, int); +extern int _sendto(int, const char *, int, int, + const struct sockaddr *, int); +extern int _recvfrom(int, char *, int, int, + struct sockaddr *, int *); +extern int _connect(int, struct sockaddr *, int); +extern int __rpc_dtbsize(); +extern ssize_t read(int, void *, size_t); +extern int close(int); +static void do_close(); + +int +rtime(addrp, timep, timeout) + struct sockaddr_in *addrp; + struct timeval *timep; + struct timeval *timeout; +{ + int s; + fd_set readfds; + int res; + uint_t thetime; + struct sockaddr_in from; + int fromlen; + int type; + + if (timeout == NULL) { + type = SOCK_STREAM; + } else { + type = SOCK_DGRAM; + } + s = _socket(AF_INET, type, 0); + if (s < 0) { + return (-1); + } + addrp->sin_family = AF_INET; + addrp->sin_port = htons(IPPORT_TIMESERVER); + if (type == SOCK_DGRAM) { + res = _sendto(s, (char *)&thetime, sizeof (thetime), 0, + (struct sockaddr *)addrp, sizeof (*addrp)); + if (res < 0) { + do_close(s); + return (-1); + } + do { + FD_ZERO(&readfds); + FD_SET(s, &readfds); + res = select(__rpc_dtbsize(), &readfds, NULL, + NULL, timeout); + } while (res < 0 && errno == EINTR); + if (res <= 0) { + if (res == 0) { + errno = ETIMEDOUT; + } + do_close(s); + return (-1); + } + fromlen = sizeof (from); + res = _recvfrom(s, (char *)&thetime, sizeof (thetime), 0, + (struct sockaddr *)&from, &fromlen); + do_close(s); + if (res < 0) { + return (-1); + } + } else { + if (_connect(s, (struct sockaddr *)addrp, + sizeof (*addrp)) < 0) { + do_close(s); + return (-1); + } + res = read(s, (char *)&thetime, sizeof (thetime)); + do_close(s); + if (res < 0) { + return (-1); + } + } + if (res != sizeof (thetime)) { + errno = EIO; + return (-1); + } + thetime = ntohl(thetime); + + thetime = thetime - TOFFSET; +#ifdef _ILP32 + if (thetime > INT32_MAX) + thetime = INT32_MAX; +#endif + timep->tv_sec = thetime; + timep->tv_usec = 0; + return (0); +} + +static void +do_close(s) + int s; +{ + int save; + + save = errno; + (void) close(s); + errno = save; +} diff --git a/usr/src/ucblib/librpcsoc/sparc/Makefile b/usr/src/ucblib/librpcsoc/sparc/Makefile new file mode 100644 index 0000000000..26383e5faf --- /dev/null +++ b/usr/src/ucblib/librpcsoc/sparc/Makefile @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 1998-2003 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# lib/librpcsoc/sparc/Makefile + +MAPDIR= ../spec/sparc +include ../Makefile.com + +DYNFLAGS += $(DYNFLAGS32) +BUILD.SO= $(CC) -o $@ -G $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/ucblib $(LDLIBS) + +LIBS = $(DYNLIB) $(LINTLIB) + +.KEEP_STATE: + +all: $(LIBS) + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/librpcsoc/sparcv9/Makefile b/usr/src/ucblib/librpcsoc/sparcv9/Makefile new file mode 100644 index 0000000000..87a5c694c2 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/sparcv9/Makefile @@ -0,0 +1,44 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/librpcsoc/sparcv9/Makefile + +MAPDIR= ../spec/sparcv9 +include ../Makefile.com +include $(SRC)/lib/Makefile.lib.64 + +DYNFLAGS += $(DYNFLAGS64) +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) \ + -L $(ROOT)/usr/ucblib/$(MACH64) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) + +LIBS= $(DYNLIB) $(LINTLIB) + +.KEEP_STATE: + +all: $(LIBS) + +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/ucblib/librpcsoc/spec/Makefile b/usr/src/ucblib/librpcsoc/spec/Makefile new file mode 100644 index 0000000000..757104f257 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/spec/Makefile @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/librpcsoc/spec/Makefile + +include $(SRC)/lib/Makefile.spec.arch diff --git a/usr/src/ucblib/librpcsoc/spec/Makefile.targ b/usr/src/ucblib/librpcsoc/spec/Makefile.targ new file mode 100644 index 0000000000..5f49b2e642 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/spec/Makefile.targ @@ -0,0 +1,36 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/librpcsoc/spec/Makefile.targ + +LIBRARY = librpcsoc.a +VERS = .1 + +OBJECTS = rpcsoc.o + +TRANSCPP = +SPECCPP = -DPORTMAP -I$(ROOT)/usr/ucbinclude diff --git a/usr/src/ucblib/librpcsoc/spec/amd64/Makefile b/usr/src/ucblib/librpcsoc/spec/amd64/Makefile new file mode 100644 index 0000000000..6beb38aa0f --- /dev/null +++ b/usr/src/ucblib/librpcsoc/spec/amd64/Makefile @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#amd64_C_PICFLAGS = $(amd64_C_BIGPICFLAGS) + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/librpcsoc/spec/i386/Makefile b/usr/src/ucblib/librpcsoc/spec/i386/Makefile new file mode 100644 index 0000000000..9fa2f61309 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/spec/i386/Makefile @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/librpcsoc/spec/i386/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#i386_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/librpcsoc/spec/rpcsoc.spec b/usr/src/ucblib/librpcsoc/spec/rpcsoc.spec new file mode 100644 index 0000000000..e691dc6626 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/spec/rpcsoc.spec @@ -0,0 +1,117 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +#pragma ident "%Z%%M% %I% %E% SMI" +# + +function clnttcp_create +include <sys/types.h> +include <rpc/rpc.h> +declaration CLIENT *clnttcp_create(struct sockaddr_in *raddr, \ + rpcprog_t prog, rpcvers_t vers, \ + int *sockp, uint_t sendsz, uint_t recvsz) +version SUNW_0.7 +end + +function clntudp_bufcreate +include <sys/types.h> +include <rpc/rpc.h> +include <sys/time.h> +declaration CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, \ + rpcprog_t program, \ + rpcvers_t version, \ + struct timeval wait, \ + int *sockp, \ + uint_t sendsz, \ + uint_t recvsz) +version SUNW_0.7 +end + +function clntudp_create +include <sys/types.h> +include <rpc/rpc.h> +include <sys/time.h> +declaration CLIENT *clntudp_create(struct sockaddr_in *raddr, \ + rpcprog_t program, \ + rpcvers_t version, \ + struct timeval wait, \ + int *sockp) +version SUNW_0.7 +end + +function get_myaddress +include <sys/socket.h> +declaration void get_myaddress(struct sockaddr_in *addr) +version SUNW_0.7 +end + +function getrpcport +include <rpc/rpc.h> +include <sys/socket.h> +declaration ushort_t getrpcport(char *host, \ + rpcprog_t prognum, \ + rpcvers_t versnum, \ + rpcprot_t proto) +version SUNW_0.7 +end + +function rtime +include <sys/socket.h> +include <sys/time.h> +declaration int rtime(struct sockaddr_in *addrp, \ + struct timeval *timep, struct timeval *timeout) +version SUNW_0.7 +end + +function svcfd_create +include <rpc/rpc.h> +declaration SVCXPRT *svcfd_create(int fd, uint_t sendsize, uint_t recvsize) +version SUNW_0.7 +end + +function svctcp_create +include <rpc/rpc.h> +declaration SVCXPRT *svctcp_create(int sock, \ + uint_t sendsize, uint_t recvsize) +version SUNW_0.7 +end + +function svcudp_bufcreate +include <rpc/rpc.h> +declaration SVCXPRT *svcudp_bufcreate(int sock, \ + uint_t sendsz, uint_t recvsz) +version SUNW_0.7 +end + +function svcudp_create +include <rpc/rpc.h> +declaration SVCXPRT *svcudp_create(int sock) +version SUNW_0.7 +end + +function svcudp_enablecache +include <rpc/rpc.h> +declaration int svcudp_enablecache(SVCXPRT *transp, uint_t size) +version SUNW_0.7 +end diff --git a/usr/src/ucblib/librpcsoc/spec/sparc/Makefile b/usr/src/ucblib/librpcsoc/spec/sparc/Makefile new file mode 100644 index 0000000000..5f4541d4a8 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/spec/sparc/Makefile @@ -0,0 +1,44 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/librpcsoc/spec/sparc/Makefile + +.KEEP_STATE: + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#sparc_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/librpcsoc/spec/sparcv9/Makefile b/usr/src/ucblib/librpcsoc/spec/sparcv9/Makefile new file mode 100644 index 0000000000..ec392f306c --- /dev/null +++ b/usr/src/ucblib/librpcsoc/spec/sparcv9/Makefile @@ -0,0 +1,43 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/librpcsoc/spec/sparcv9/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#sparcv9_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/librpcsoc/spec/versions b/usr/src/ucblib/librpcsoc/spec/versions new file mode 100644 index 0000000000..d81db16460 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/spec/versions @@ -0,0 +1,43 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# ident "%Z%%M% %I% %E% SMI" +# + +sparc { + SUNW_1.1: {SUNW_0.7}; + SUNW_0.7; +} +sparcv9 { + SUNW_1.1: {SUNW_0.7}; + SUNW_0.7; +} +i386 { + SUNW_1.1: {SUNW_0.7}; + SUNW_0.7; +} +amd64 { + SUNW_1.1: {SUNW_0.7}; + SUNW_0.7; +} diff --git a/usr/src/ucblib/librpcsoc/svc_tcp.c b/usr/src/ucblib/librpcsoc/svc_tcp.c new file mode 100644 index 0000000000..387eb49487 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/svc_tcp.c @@ -0,0 +1,447 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * svc_tcp.c, Server side for TCP/IP based RPC. + * + * Actually implements two flavors of transporter - + * a tcp rendezvouser (a listner and connection establisher) + * and a record/tcp stream. + */ + +#include <rpc/rpc.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <errno.h> +#include <syslog.h> +#include <malloc.h> +#include <stdio.h> + +extern bool_t abort(); +extern int errno; +extern SVCXPRT *svc_xprt_alloc(); +extern void svc_xprt_free(); +extern int _socket(int, int, int); +extern int _bind(int, const struct sockaddr *, int); +extern int _getsockname(int, struct sockaddr *, int *); +extern int _listen(int, int); +extern int _accept(int, struct sockaddr *, int *); +extern int bindresvport(int, struct sockaddr_in *); + +static struct xp_ops *svctcp_ops(); +static struct xp_ops *svctcp_rendezvous_ops(); + +static int readtcp(), writetcp(); +static SVCXPRT *makefd_xprt(); + +struct tcp_rendezvous { /* kept in xprt->xp_p1 */ + u_int sendsize; + u_int recvsize; +}; + +struct tcp_conn { /* kept in xprt->xp_p1 */ + enum xprt_stat strm_stat; + uint32_t x_id; + XDR xdrs; + char verf_body[MAX_AUTH_BYTES]; +}; + +/* + * Usage: + * xprt = svctcp_create(sock, send_buf_size, recv_buf_size); + * + * Creates, registers, and returns a (rpc) tcp based transporter. + * Once *xprt is initialized, it is registered as a transporter + * see (svc.h, xprt_register). This routine returns + * a NULL if a problem occurred. + * + * If sock<0 then a socket is created, else sock is used. + * If the socket, sock is not bound to a port then svctcp_create + * binds it to an arbitrary port. The routine then starts a tcp + * listener on the socket's associated port. In any (successful) case, + * xprt->xp_sock is the registered socket number and xprt->xp_port is the + * associated port number. + * + * Since tcp streams do buffered io similar to stdio, the caller can specify + * how big the send and receive buffers are via the second and third parms; + * 0 => use the system default. + */ +SVCXPRT * +svctcp_create(sock, sendsize, recvsize) + register int sock; + u_int sendsize; + u_int recvsize; +{ + bool_t madesock = FALSE; + register SVCXPRT *xprt; + register struct tcp_rendezvous *r; + struct sockaddr_in addr; + int len = sizeof (struct sockaddr_in); + + if (sock == RPC_ANYSOCK) { + if ((sock = _socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { + (void) syslog(LOG_ERR, "svctcp_create - tcp", + " socket creation problem: %m"); + return ((SVCXPRT *)NULL); + } + madesock = TRUE; + } + memset((char *)&addr, 0, sizeof (addr)); + addr.sin_family = AF_INET; + if (bindresvport(sock, &addr)) { + addr.sin_port = 0; + (void) _bind(sock, (struct sockaddr *)&addr, len); + } + if ((_getsockname(sock, (struct sockaddr *)&addr, &len) != 0) || + (_listen(sock, 2) != 0)) { + (void) syslog(LOG_ERR, "svctcp_create - cannot", + " getsockname or listen: %m"); + if (madesock) + (void) close(sock); + return ((SVCXPRT *)NULL); + } + r = (struct tcp_rendezvous *)mem_alloc(sizeof (*r)); + if (r == NULL) { + (void) syslog(LOG_ERR, "svctcp_create: out of memory"); + if (madesock) + (void) close(sock); + return (NULL); + } + r->sendsize = sendsize; + r->recvsize = recvsize; + xprt = svc_xprt_alloc(); + if (xprt == NULL) { + (void) syslog(LOG_ERR, "svctcp_create: out of memory"); + mem_free((char *) r, sizeof (*r)); + if (madesock) + (void) close(sock); + return (NULL); + } + xprt->xp_p2 = NULL; + xprt->xp_netid = NULL; + xprt->xp_p1 = (caddr_t)r; + xprt->xp_verf = _null_auth; + xprt->xp_ops = svctcp_rendezvous_ops(); + xprt->xp_port = ntohs(addr.sin_port); + xprt->xp_sock = sock; + xprt->xp_rtaddr.buf = xprt->xp_raddr; + xprt_register(xprt); + return (xprt); +} + +/* + * Like svtcp_create(), except the routine takes any *open* UNIX file + * descriptor as its first input. + */ +SVCXPRT * +svcfd_create(fd, sendsize, recvsize) + int fd; + u_int sendsize; + u_int recvsize; +{ + + return (makefd_xprt(fd, sendsize, recvsize)); +} + +static SVCXPRT * +makefd_xprt(fd, sendsize, recvsize) + int fd; + u_int sendsize; + u_int recvsize; +{ + register SVCXPRT *xprt; + register struct tcp_conn *cd; + + xprt = svc_xprt_alloc(); + if (xprt == (SVCXPRT *)NULL) { + (void) syslog(LOG_ERR, "svc_tcp: makefd_xprt: out of memory"); + goto done; + } + cd = (struct tcp_conn *)mem_alloc(sizeof (struct tcp_conn)); + if (cd == (struct tcp_conn *)NULL) { + (void) syslog(LOG_ERR, "svc_tcp: makefd_xprt: out of memory"); + svc_xprt_free(xprt); + xprt = (SVCXPRT *)NULL; + goto done; + } + cd->strm_stat = XPRT_IDLE; + xdrrec_create(&(cd->xdrs), sendsize, recvsize, + (caddr_t)xprt, readtcp, writetcp); + xprt->xp_p2 = NULL; + xprt->xp_netid = NULL; + xprt->xp_p1 = (caddr_t)cd; + xprt->xp_verf.oa_base = cd->verf_body; + xprt->xp_addrlen = 0; + xprt->xp_ops = svctcp_ops(); /* truely deals with calls */ + xprt->xp_port = 0; /* this is a connection, not a rendezvouser */ + xprt->xp_sock = fd; + /* to handle svc_getcaller() properly */ + xprt->xp_rtaddr.buf = xprt->xp_raddr; + xprt_register(xprt); + done: + return (xprt); +} + +static bool_t +rendezvous_request(xprt, rpc_msg) + register SVCXPRT *xprt; + struct rpc_msg *rpc_msg; +{ + int sock; + struct tcp_rendezvous *r; + struct sockaddr_in addr; + int len; + + r = (struct tcp_rendezvous *)xprt->xp_p1; + again: + len = sizeof (struct sockaddr_in); + if ((sock = _accept(xprt->xp_sock, (struct sockaddr *)&addr, + &len)) < 0) { + if (errno == EINTR) + goto again; + return (FALSE); + } + /* + * make a new transporter (re-uses xprt) + */ + xprt = makefd_xprt(sock, r->sendsize, r->recvsize); + + memcpy((char *)&xprt->xp_raddr, (char *)&addr, len); + xprt->xp_addrlen = len; + return (FALSE); /* there is never an rpc msg to be processed */ +} + +static enum xprt_stat +rendezvous_stat(xprt) + SVCXPRT *xprt; +{ + + return (XPRT_IDLE); +} + +static void +svctcp_destroy(xprt) + register SVCXPRT *xprt; +{ + register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1; + + xprt_unregister(xprt); + (void) close(xprt->xp_sock); + if (xprt->xp_port != 0) { + /* a rendezvouser socket */ + xprt->xp_port = 0; + } else { + /* an actual connection socket */ + XDR_DESTROY(&(cd->xdrs)); + } + mem_free((caddr_t)cd, sizeof (struct tcp_conn)); + svc_xprt_free(xprt); +} + +/* + * All read operations timeout after 35 seconds. + * A timeout is fatal for the connection. + */ +static struct timeval wait_per_try = { 35, 0 }; + +/* + * reads data from the tcp conection. + * any error is fatal and the connection is closed. + * (And a read of zero bytes is a half closed stream => error.) + */ +static int +readtcp(xprt, buf, len) + register SVCXPRT *xprt; + caddr_t buf; + register int len; +{ + register int sock = xprt->xp_sock; + fd_set mask; + fd_set readfds; + + FD_ZERO(&mask); + FD_SET(sock, &mask); + do { + readfds = mask; + if (select(__rpc_dtbsize(), &readfds, NULL, NULL, + &wait_per_try) <= 0) { + if (errno == EINTR) { + continue; + } + goto fatal_err; + } + } while (!FD_ISSET(sock, &readfds)); + if ((len = read(sock, buf, len)) > 0) { + return (len); + } +fatal_err: + ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; + return (-1); +} + +/* + * writes data to the tcp connection. + * Any error is fatal and the connection is closed. + */ +static int +writetcp(xprt, buf, len) + register SVCXPRT *xprt; + caddr_t buf; + int len; +{ + register int i, cnt; + + for (cnt = len; cnt > 0; cnt -= i, buf += i) { + if ((i = write(xprt->xp_sock, buf, cnt)) < 0) { + ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = + XPRT_DIED; + return (-1); + } + } + return (len); +} + +static enum xprt_stat +svctcp_stat(xprt) + SVCXPRT *xprt; +{ + register struct tcp_conn *cd = + (struct tcp_conn *)(xprt->xp_p1); + + if (cd->strm_stat == XPRT_DIED) + return (XPRT_DIED); + if (! xdrrec_eof(&(cd->xdrs))) + return (XPRT_MOREREQS); + return (XPRT_IDLE); +} + +static bool_t +svctcp_recv(xprt, msg) + SVCXPRT *xprt; + register struct rpc_msg *msg; +{ + register struct tcp_conn *cd = + (struct tcp_conn *)(xprt->xp_p1); + register XDR *xdrs = &(cd->xdrs); + + xdrs->x_op = XDR_DECODE; + (void) xdrrec_skiprecord(xdrs); + if (xdr_callmsg(xdrs, msg)) { + cd->x_id = msg->rm_xid; + return (TRUE); + } + return (FALSE); +} + +static bool_t +svctcp_getargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + + return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), + args_ptr)); +} + +static bool_t +svctcp_freeargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + register XDR *xdrs = + &(((struct tcp_conn *)(xprt->xp_p1))->xdrs); + + xdrs->x_op = XDR_FREE; + return ((*xdr_args)(xdrs, args_ptr)); +} + +static bool_t +svctcp_reply(xprt, msg) + SVCXPRT *xprt; + register struct rpc_msg *msg; +{ + register struct tcp_conn *cd = + (struct tcp_conn *)(xprt->xp_p1); + register XDR *xdrs = &(cd->xdrs); + register bool_t stat; + + xdrs->x_op = XDR_ENCODE; + msg->rm_xid = cd->x_id; + stat = xdr_replymsg(xdrs, msg); + (void) xdrrec_endofrecord(xdrs, TRUE); + return (stat); +} + + +static struct xp_ops * +svctcp_ops() +{ + static struct xp_ops ops; + + if (ops.xp_recv == NULL) { + ops.xp_recv = svctcp_recv; + ops.xp_stat = svctcp_stat; + ops.xp_getargs = svctcp_getargs; + ops.xp_reply = svctcp_reply; + ops.xp_freeargs = svctcp_freeargs; + ops.xp_destroy = svctcp_destroy; + } + return (&ops); +} + + +static struct xp_ops * +svctcp_rendezvous_ops() +{ + static struct xp_ops ops; + + if (ops.xp_recv == NULL) { + ops.xp_recv = rendezvous_request; + ops.xp_stat = rendezvous_stat; + ops.xp_getargs = abort; + ops.xp_reply = abort; + ops.xp_freeargs = abort, + ops.xp_destroy = svctcp_destroy; + } + return (&ops); +} diff --git a/usr/src/ucblib/librpcsoc/svc_udp.c b/usr/src/ucblib/librpcsoc/svc_udp.c new file mode 100644 index 0000000000..bdf78fec83 --- /dev/null +++ b/usr/src/ucblib/librpcsoc/svc_udp.c @@ -0,0 +1,527 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * svc_udp.c, + * Server side for UDP/IP based RPC. (Does some caching in the hopes of + * achieving execute-at-most-once semantics.) + */ + +#include <rpc/rpc.h> +#include <rpc/clnt_soc.h> +#include <sys/socket.h> +#include <errno.h> +#include <syslog.h> +#include <malloc.h> +#include <stdio.h> + + +#define rpc_buffer(xprt) ((xprt)->xp_p1) + +static struct xp_ops *svcudp_ops(); + +extern int errno; +extern SVCXPRT *svc_xprt_alloc(); +extern void svc_xprt_free(); +extern int _socket(int, int, int); +extern int _bind(int, const struct sockaddr *, int); +extern int _getsockname(int, struct sockaddr *, int *); +extern int _listen(int, int); +extern int _accept(int, struct sockaddr *, int *); +extern int bindresvport(int, struct sockaddr_in *); +extern int _recvfrom(int, char *, int, int, + struct sockaddr *, int *); +extern int _sendto(int, const char *, int, int, + const struct sockaddr *, int); + +static int cache_get(SVCXPRT *, struct rpc_msg *, + char **, uint_t *); +static void cache_set(SVCXPRT *, uint_t); + +/* + * kept in xprt->xp_p2 + */ +struct svcudp_data { + u_int su_iosz; /* byte size of send.recv buffer */ + uint32_t su_xid; /* transaction id */ + XDR su_xdrs; /* XDR handle */ + char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */ + char * su_cache; /* cached data, NULL if no cache */ +}; +#define su_data(xprt) ((struct svcudp_data *)(xprt->xp_p2)) + +/* + * Usage: + * xprt = svcudp_create(sock); + * + * If sock<0 then a socket is created, else sock is used. + * If the socket, sock is not bound to a port then svcudp_create + * binds it to an arbitrary port. In any (successful) case, + * xprt->xp_sock is the registered socket number and xprt->xp_port is the + * associated port number. + * Once *xprt is initialized, it is registered as a transporter; + * see (svc.h, xprt_register). + * The routines returns NULL if a problem occurred. + */ +SVCXPRT * +svcudp_bufcreate(sock, sendsz, recvsz) + register int sock; + u_int sendsz, recvsz; +{ + bool_t madesock = FALSE; + register SVCXPRT *xprt; + register struct svcudp_data *su; + struct sockaddr_in addr; + int len = sizeof (struct sockaddr_in); + + if (sock == RPC_ANYSOCK) { + if ((sock = _socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + (void) syslog(LOG_ERR, "svcudp_create: socket", + " creation problem: %m"); + return ((SVCXPRT *)NULL); + } + madesock = TRUE; + } + memset((char *)&addr, 0, sizeof (addr)); + addr.sin_family = AF_INET; + if (bindresvport(sock, &addr)) { + addr.sin_port = 0; + (void) _bind(sock, (struct sockaddr *)&addr, len); + } + if (_getsockname(sock, (struct sockaddr *)&addr, &len) != 0) { + (void) syslog(LOG_ERR, "svcudp_create -", + " cannot getsockname: %m"); + if (madesock) + (void) close(sock); + return ((SVCXPRT *)NULL); + } + xprt = svc_xprt_alloc(); + if (xprt == NULL) { + (void) syslog(LOG_ERR, "svcudp_create: out of memory"); + if (madesock) + (void) close(sock); + return ((SVCXPRT *)NULL); + } + su = (struct svcudp_data *)mem_alloc(sizeof (*su)); + if (su == NULL) { + (void) syslog(LOG_ERR, "svcudp_create: out of memory"); + svc_xprt_free(xprt); + if (madesock) + (void) close(sock); + return ((SVCXPRT *)NULL); + } + su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4; + if ((rpc_buffer(xprt) = (char *)mem_alloc(su->su_iosz)) == NULL) { + (void) syslog(LOG_ERR, "svcudp_create: out of memory"); + mem_free((char *) su, sizeof (*su)); + svc_xprt_free(xprt); + if (madesock) + (void) close(sock); + return ((SVCXPRT *)NULL); + } + xdrmem_create( + &(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE); + su->su_cache = NULL; + xprt->xp_p2 = (caddr_t)su; + xprt->xp_netid = NULL; + xprt->xp_verf.oa_base = su->su_verfbody; + xprt->xp_ops = svcudp_ops(); + xprt->xp_port = ntohs(addr.sin_port); + xprt->xp_sock = sock; + xprt->xp_rtaddr.buf = &xprt->xp_raddr[0]; + xprt_register(xprt); + return (xprt); +} + +SVCXPRT * +svcudp_create(sock) + int sock; +{ + + return (svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE)); +} + +static enum xprt_stat +svcudp_stat(xprt) + SVCXPRT *xprt; +{ + + return (XPRT_IDLE); +} + +static bool_t +svcudp_recv(xprt, msg) + register SVCXPRT *xprt; + struct rpc_msg *msg; +{ + register struct svcudp_data *su = su_data(xprt); + register XDR *xdrs = &(su->su_xdrs); + register int rlen; + char *reply; + uint_t replylen; + + again: + xprt->xp_addrlen = sizeof (struct sockaddr_in); + rlen = _recvfrom(xprt->xp_sock, rpc_buffer(xprt), (int) su->su_iosz, + 0, (struct sockaddr *)&(xprt->xp_raddr), &(xprt->xp_addrlen)); + if (rlen == -1 && errno == EINTR) + goto again; + if (rlen < 4*sizeof (uint32_t)) + return (FALSE); + xdrs->x_op = XDR_DECODE; + XDR_SETPOS(xdrs, 0); + if (! xdr_callmsg(xdrs, msg)) + return (FALSE); + su->su_xid = msg->rm_xid; + if (su->su_cache != NULL) { + if (cache_get(xprt, msg, &reply, &replylen)) { + (void) _sendto(xprt->xp_sock, reply, (int) replylen, 0, + (struct sockaddr *) &xprt->xp_raddr, + xprt->xp_addrlen); + return (TRUE); + } + } + return (TRUE); +} + +static bool_t +svcudp_reply(xprt, msg) + register SVCXPRT *xprt; + struct rpc_msg *msg; +{ + register struct svcudp_data *su = su_data(xprt); + register XDR *xdrs = &(su->su_xdrs); + register int slen; + register bool_t stat = FALSE; + + xdrs->x_op = XDR_ENCODE; + XDR_SETPOS(xdrs, 0); + msg->rm_xid = su->su_xid; + if (xdr_replymsg(xdrs, msg)) { + slen = (int)XDR_GETPOS(xdrs); + if (_sendto(xprt->xp_sock, rpc_buffer(xprt), slen, 0, + (struct sockaddr *)&(xprt->xp_raddr), xprt->xp_addrlen) + == slen) { + stat = TRUE; + if (su->su_cache && slen >= 0) { + (void) cache_set(xprt, (uint_t) slen); + } + } + } + return (stat); +} + +static bool_t +svcudp_getargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + + return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr)); +} + +static bool_t +svcudp_freeargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + register XDR *xdrs = &(su_data(xprt)->su_xdrs); + + xdrs->x_op = XDR_FREE; + return ((*xdr_args)(xdrs, args_ptr)); +} + +static void +svcudp_destroy(xprt) + register SVCXPRT *xprt; +{ + register struct svcudp_data *su = su_data(xprt); + + xprt_unregister(xprt); + (void) close(xprt->xp_sock); + XDR_DESTROY(&(su->su_xdrs)); + mem_free(rpc_buffer(xprt), su->su_iosz); + mem_free((caddr_t)su, sizeof (struct svcudp_data)); + svc_xprt_free(xprt); +} + + +/* **********this could be a separate file********************* */ + +/* + * Fifo cache for udp server + * Copies pointers to reply buffers into fifo cache + * Buffers are sent again if retransmissions are detected. + */ + +#define SPARSENESS 4 /* 75% sparse */ + +#define ALLOC(type, size) \ + (type *) mem_alloc((unsigned) (sizeof (type) * (size))) + +#define BZERO(addr, type, size) \ + memset((char *) (addr), 0, sizeof (type) * (int) (size)) + +#define FREE(addr, type, size) \ + (void) mem_free((char *) (addr), (sizeof (type) * (size))) + +/* + * An entry in the cache + */ +typedef struct cache_node *cache_ptr; +struct cache_node { + /* + * Index into cache is xid, proc, vers, prog and address + */ + uint32_t cache_xid; + uint32_t cache_proc; + uint32_t cache_vers; + uint32_t cache_prog; + struct sockaddr_in cache_addr; + /* + * The cached reply and length + */ + char * cache_reply; + uint32_t cache_replylen; + /* + * Next node on the list, if there is a collision + */ + cache_ptr cache_next; +}; + + + +/* + * The entire cache + */ +struct udp_cache { + uint32_t uc_size; /* size of cache */ + cache_ptr *uc_entries; /* hash table of entries in cache */ + cache_ptr *uc_fifo; /* fifo list of entries in cache */ + uint32_t uc_nextvictim; /* points to next victim in fifo list */ + uint32_t uc_prog; /* saved program number */ + uint32_t uc_vers; /* saved version number */ + uint32_t uc_proc; /* saved procedure number */ + struct sockaddr_in uc_addr; /* saved caller's address */ +}; + + +/* + * the hashing function + */ +#define CACHE_LOC(transp, xid) \ + (xid % (SPARSENESS*((struct udp_cache *) \ + su_data(transp)->su_cache)->uc_size)) + + +/* + * Enable use of the cache. + * Note: there is no disable. + */ +int +svcudp_enablecache(transp, size) + SVCXPRT *transp; + uint_t size; +{ + struct svcudp_data *su = su_data(transp); + struct udp_cache *uc; + + if (su->su_cache != NULL) { + (void) syslog(LOG_ERR, "enablecache: cache already enabled"); + return (0); + } + uc = ALLOC(struct udp_cache, 1); + if (uc == NULL) { + (void) syslog(LOG_ERR, "enablecache: could not allocate cache"); + return (0); + } + uc->uc_size = size; + uc->uc_nextvictim = 0; + uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS); + if (uc->uc_entries == NULL) { + (void) syslog(LOG_ERR, "enablecache: could not", + " allocate cache data"); + FREE(uc, struct udp_cache, 1); + return (0); + } + BZERO(uc->uc_entries, cache_ptr, size * SPARSENESS); + uc->uc_fifo = ALLOC(cache_ptr, size); + if (uc->uc_fifo == NULL) { + (void) syslog(LOG_ERR, "enablecache: could not", + " allocate cache fifo"); + FREE((char *)uc->uc_entries, cache_ptr, size * SPARSENESS); + FREE((char *)uc, struct udp_cache, 1); + return (0); + } + BZERO(uc->uc_fifo, cache_ptr, size); + su->su_cache = (char *) uc; + return (1); +} + + +/* + * Set an entry in the cache + */ +static void +cache_set(xprt, replylen) + SVCXPRT *xprt; + uint_t replylen; +{ + register cache_ptr victim; + register cache_ptr *vicp; + register struct svcudp_data *su = su_data(xprt); + struct udp_cache *uc = (struct udp_cache *) su->su_cache; + u_int loc; + char *newbuf; + + /* + * Find space for the new entry, either by + * reusing an old entry, or by mallocing a new one + */ + victim = uc->uc_fifo[uc->uc_nextvictim]; + if (victim != NULL) { + loc = CACHE_LOC(xprt, victim->cache_xid); + for (vicp = &uc->uc_entries[loc]; + *vicp != NULL && *vicp != victim; + vicp = &(*vicp)->cache_next) + ; + if (*vicp == NULL) { + (void) syslog(LOG_ERR, "cache_set: victim not found"); + return; + } + *vicp = victim->cache_next; /* remote from cache */ + newbuf = victim->cache_reply; + } else { + victim = ALLOC(struct cache_node, 1); + if (victim == NULL) { + (void) syslog(LOG_ERR, "cache_set: victim alloc", + " failed"); + return; + } + newbuf = (char *)mem_alloc(su->su_iosz); + if (newbuf == NULL) { + (void) syslog(LOG_ERR, "cache_set: could not", + " allocate new rpc_buffer"); + FREE(victim, struct cache_node, 1); + return; + } + } + + /* + * Store it away + */ + victim->cache_replylen = replylen; + victim->cache_reply = rpc_buffer(xprt); + rpc_buffer(xprt) = newbuf; + xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), + su->su_iosz, XDR_ENCODE); + victim->cache_xid = su->su_xid; + victim->cache_proc = uc->uc_proc; + victim->cache_vers = uc->uc_vers; + victim->cache_prog = uc->uc_prog; + victim->cache_addr = uc->uc_addr; + loc = CACHE_LOC(xprt, victim->cache_xid); + victim->cache_next = uc->uc_entries[loc]; + uc->uc_entries[loc] = victim; + uc->uc_fifo[uc->uc_nextvictim++] = victim; + uc->uc_nextvictim %= uc->uc_size; +} + +/* + * Try to get an entry from the cache + * return 1 if found, 0 if not found + */ +static int +cache_get(xprt, msg, replyp, replylenp) + SVCXPRT *xprt; + struct rpc_msg *msg; + char **replyp; + uint_t *replylenp; +{ + u_int loc; + register cache_ptr ent; + register struct svcudp_data *su = su_data(xprt); + register struct udp_cache *uc = (struct udp_cache *) su->su_cache; + +#define EQADDR(a1, a2) \ + (memcmp((char *)&a1, (char *)&a2, sizeof (a1)) == 0) + + loc = CACHE_LOC(xprt, su->su_xid); + for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) { + if (ent->cache_xid == su->su_xid && + ent->cache_proc == uc->uc_proc && + ent->cache_vers == uc->uc_vers && + ent->cache_prog == uc->uc_prog && + EQADDR(ent->cache_addr, uc->uc_addr)) { + *replyp = ent->cache_reply; + *replylenp = ent->cache_replylen; + return (1); + } + } + /* + * Failed to find entry + * Remember a few things so we can do a set later + */ + uc->uc_proc = msg->rm_call.cb_proc; + uc->uc_vers = msg->rm_call.cb_vers; + uc->uc_prog = msg->rm_call.cb_prog; + memcpy((char *)&uc->uc_addr, (char *)&xprt->xp_raddr, + sizeof (struct sockaddr_in)); + return (0); +} + +static struct xp_ops * +svcudp_ops() +{ + static struct xp_ops ops; + + if (ops.xp_recv == NULL) { + ops.xp_recv = svcudp_recv; + ops.xp_stat = svcudp_stat; + ops.xp_getargs = svcudp_getargs; + ops.xp_reply = svcudp_reply; + ops.xp_freeargs = svcudp_freeargs; + ops.xp_destroy = svcudp_destroy; + } + return (&ops); +} diff --git a/usr/src/ucblib/libtermcap/Makefile b/usr/src/ucblib/libtermcap/Makefile new file mode 100644 index 0000000000..c70d123c17 --- /dev/null +++ b/usr/src/ucblib/libtermcap/Makefile @@ -0,0 +1,51 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +#ident "%Z%%M% %I% %E% SMI" +# +# Copyright 1989-1997,2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ucblib/libtermcap/Makefile +# +# The builds occur in isa subdirectories. +# + +include ../Makefile.ucb + +SUBDIRS = spec .WAIT $(MACH) $(BUILD64) $(MACH64) + +# conditional assignments +install := TARGET= install +clean := TARGET= clean +clobber := TARGET= clobber +lint := TARGET= lint + +.KEEP_STATE: + +all install clean clobber lint : $(SUBDIRS) + +$(MACH) $(MACH64) spec: FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: + diff --git a/usr/src/ucblib/libtermcap/Makefile.com b/usr/src/ucblib/libtermcap/Makefile.com new file mode 100644 index 0000000000..af6729f0f7 --- /dev/null +++ b/usr/src/ucblib/libtermcap/Makefile.com @@ -0,0 +1,91 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libtermcap/Makefile.com +# + +LIBRARY= libtermcap.a +VERS= .1 + +OBJECTS= termcap.o \ + tgoto.o \ + tputs.o + +# include library definitions +include $(SRC)/lib/Makefile.lib + +ROOTLIBDIR= $(ROOT)/usr/ucblib +ROOTLIBDIR64= $(ROOT)/usr/ucblib/$(MACH64) + +MAPFILE= $(MAPDIR)/mapfile +SRCS= $(OBJECTS:%.o=../%.c) + +LIBS = $(DYNLIB) $(LINTLIB) + +LINTSRC= $(LINTLIB:%.ln=%) +ROOTLINTDIR= $(ROOTLIBDIR) +ROOTLINTDIR64= $(ROOTLIBDIR)/$(MACH64) +ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%) +ROOTLINT64= $(LINTSRC:%=$(ROOTLINTDIR64)/%) + +# install rule for lint source file target +$(ROOTLINTDIR)/%: ../% + $(INS.file) +$(ROOTLINTDIR64)/%: ../% + $(INS.file) + +$(LINTLIB):= SRCS=../llib-ltermcap + +CFLAGS += $(CCVERBOSE) +CFLAGS64 += $(CCVERBOSE) +DYNFLAGS += +DYNFLAGS32 = -M$(MAPFILE) +DYNFLAGS64 = -M$(MAPFILE) +LDLIBS += -lc + +DEFS= -DCM_N -DCM_GT -DCM_B -DCM_D +CPPFLAGS = $(DEFS) -I$(ROOT)/usr/ucbinclude $(CPPFLAGS.master) + +.KEEP_STATE: + +all: $(LIBS) + +lint: lintcheck + +$(DYNLIB): $(MAPFILE) + +$(MAPFILE): + @cd $(MAPDIR); $(MAKE) mapfile + +# +# Include library targets +# +include $(SRC)/lib/Makefile.targ + +objs/%.o pics/%.o: ../%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) diff --git a/usr/src/ucblib/libtermcap/amd64/Makefile b/usr/src/ucblib/libtermcap/amd64/Makefile new file mode 100644 index 0000000000..5834f4af40 --- /dev/null +++ b/usr/src/ucblib/libtermcap/amd64/Makefile @@ -0,0 +1,39 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +MAPDIR= ../spec/amd64 +include ../Makefile.com +include $(SRC)/lib/Makefile.lib.64 + +DYNFLAGS += $(DYNFLAGS64) +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) \ + -L $(ROOT)/usr/ucblib/$(MACH64) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) diff --git a/usr/src/ucblib/libtermcap/i386/Makefile b/usr/src/ucblib/libtermcap/i386/Makefile new file mode 100644 index 0000000000..91f52b2d58 --- /dev/null +++ b/usr/src/ucblib/libtermcap/i386/Makefile @@ -0,0 +1,38 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libtermcap/i386/Makefile + +MAPDIR= ../spec/i386 +include ../Makefile.com + +DYNFLAGS += $(DYNFLAGS32) +BUILD.SO= $(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/ucblib $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/libtermcap/llib-ltermcap b/usr/src/ucblib/libtermcap/llib-ltermcap new file mode 100644 index 0000000000..8c3ecc759f --- /dev/null +++ b/usr/src/ucblib/libtermcap/llib-ltermcap @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* LINTLIBRARY */ + +#include <sgtty.h> +#include <ctype.h> +#include <sys/ioctl.h> + +/* termcap.c */ +int tgetent(bp, name) char *bp; char *name; { static int x; return(x); } +int tgetnum(id) char *id; { static int x; return(x); } +int tgetflag(id) char *id; { static int x; return(x); } +char *tgetstr(id, area) char *id; char **area; { static char *x; return(x); } + +/* tgoto.c */ +char *tgoto(cm, destcol, destline) char *cm; int destcol; int destline; { static char *x; return(x); } + +/* tputs.c */ +int tputs(cp, affcnt, outc) register char *cp; int affcnt; int (*outc)(); { static int x; return(x); } + diff --git a/usr/src/ucblib/libtermcap/sparc/Makefile b/usr/src/ucblib/libtermcap/sparc/Makefile new file mode 100644 index 0000000000..d53ad322f5 --- /dev/null +++ b/usr/src/ucblib/libtermcap/sparc/Makefile @@ -0,0 +1,38 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libtermcap/sparc/Makefile + +MAPDIR= ../spec/sparc +include ../Makefile.com + +DYNFLAGS += $(DYNFLAGS32) +BUILD.SO= $(CC) -o $@ -G $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/ucblib $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/libtermcap/sparcv9/Makefile b/usr/src/ucblib/libtermcap/sparcv9/Makefile new file mode 100644 index 0000000000..57a580afe2 --- /dev/null +++ b/usr/src/ucblib/libtermcap/sparcv9/Makefile @@ -0,0 +1,40 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1997-1998 by Sun Microsystems, Inc. +# All rights reserved. +# +#ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libtermcap/sparcv9/Makefile + +MAPDIR= ../spec/sparcv9 +include ../Makefile.com +include $(SRC)/lib/Makefile.lib.64 + +DYNFLAGS += $(DYNFLAGS64) +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) \ + -L $(ROOT)/usr/ucblib/$(MACH64) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) + +.KEEP_STATE: + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) diff --git a/usr/src/ucblib/libtermcap/spec/Makefile b/usr/src/ucblib/libtermcap/spec/Makefile new file mode 100644 index 0000000000..a28a1fe9fe --- /dev/null +++ b/usr/src/ucblib/libtermcap/spec/Makefile @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libtermcap/spec/Makefile + +include $(SRC)/lib/Makefile.spec.arch diff --git a/usr/src/ucblib/libtermcap/spec/Makefile.targ b/usr/src/ucblib/libtermcap/spec/Makefile.targ new file mode 100644 index 0000000000..793f5f2aed --- /dev/null +++ b/usr/src/ucblib/libtermcap/spec/Makefile.targ @@ -0,0 +1,36 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libtermcap/spec/Makefile.targ + +LIBRARY = libtermcap.a +VERS = .1 + +OBJECTS = termcap.o + +TRANSCPP = +SPECCPP = -I$(ROOT)/usr/ucbinclude diff --git a/usr/src/ucblib/libtermcap/spec/amd64/Makefile b/usr/src/ucblib/libtermcap/spec/amd64/Makefile new file mode 100644 index 0000000000..6beb38aa0f --- /dev/null +++ b/usr/src/ucblib/libtermcap/spec/amd64/Makefile @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#amd64_C_PICFLAGS = $(amd64_C_BIGPICFLAGS) + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/libtermcap/spec/i386/Makefile b/usr/src/ucblib/libtermcap/spec/i386/Makefile new file mode 100644 index 0000000000..528526ce44 --- /dev/null +++ b/usr/src/ucblib/libtermcap/spec/i386/Makefile @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libtermcap/spec/i386/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#i386_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/libtermcap/spec/sparc/Makefile b/usr/src/ucblib/libtermcap/spec/sparc/Makefile new file mode 100644 index 0000000000..7350d27138 --- /dev/null +++ b/usr/src/ucblib/libtermcap/spec/sparc/Makefile @@ -0,0 +1,44 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libtermcap/spec/sparc/Makefile + +.KEEP_STATE: + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#sparc_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/libtermcap/spec/sparcv9/Makefile b/usr/src/ucblib/libtermcap/spec/sparcv9/Makefile new file mode 100644 index 0000000000..ca7b152f8d --- /dev/null +++ b/usr/src/ucblib/libtermcap/spec/sparcv9/Makefile @@ -0,0 +1,43 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libtermcap/spec/sparcv9/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#sparcv9_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/libtermcap/spec/termcap.spec b/usr/src/ucblib/libtermcap/spec/termcap.spec new file mode 100644 index 0000000000..c95df25ef6 --- /dev/null +++ b/usr/src/ucblib/libtermcap/spec/termcap.spec @@ -0,0 +1,75 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +#pragma ident "%Z%%M% %I% %E% SMI" +# + +function tgetent +include <curses.h> +include <term.h> +declaration int tgetent(char *bp, char *name) +version SUNW_1.1 +end + +function tgetflag +declaration int tgetflag(char *id) +version SUNW_1.1 +end + +function tgetnum +declaration int tgetnum(char *id) +version SUNW_1.1 +end + +function tgetstr +declaration char *tgetstr(char *id, char **area) +version SUNW_1.1 +end + +function tgoto +declaration char *tgoto(char *CM, int destcol, int destline) +version SUNW_1.1 +end + +function tputs +declaration int tputs(char *cp, int affcnt, int (*)(char)) +version SUNW_1.1 +end + + +data PC +version SUNW_1.1 +end + +data UP +version SUNW_1.1 +end + +data BC +version SUNW_1.1 +end + +data ospeed +version SUNW_1.1 +end diff --git a/usr/src/ucblib/libtermcap/spec/versions b/usr/src/ucblib/libtermcap/spec/versions new file mode 100644 index 0000000000..f7955484e7 --- /dev/null +++ b/usr/src/ucblib/libtermcap/spec/versions @@ -0,0 +1,39 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# ident "%Z%%M% %I% %E% SMI" +# + +sparc { + SUNW_1.1; +} +sparcv9 { + SUNW_1.1; +} +i386 { + SUNW_1.1; +} +amd64 { + SUNW_1.1; +} diff --git a/usr/src/ucblib/libtermcap/termcap.c b/usr/src/ucblib/libtermcap/termcap.c new file mode 100644 index 0000000000..cdce4d5076 --- /dev/null +++ b/usr/src/ucblib/libtermcap/termcap.c @@ -0,0 +1,438 @@ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#if 0 +static char +sccsid[] = "@(#)termcap.c 1.11 88/02/08 SMI"; /* from UCB 5.1 6/5/85 */ +#endif + +#define BUFSIZ 1024 +#define MAXHOP 32 /* max number of tc= indirections */ +#define E_TERMCAP "/etc/termcap" + +#include <sys/types.h> +#include <unistd.h> +#include <stdlib.h> +#include <stddef.h> +#include <string.h> +#include <strings.h> +#include <ctype.h> + +/* + * termcap - routines for dealing with the terminal capability data base + * + * BUG: Should use a "last" pointer in tbuf, so that searching + * for capabilities alphabetically would not be a n**2/2 + * process when large numbers of capabilities are given. + * Note: If we add a last pointer now we will screw up the + * tc capability. We really should compile termcap. + * + * Essentially all the work here is scanning and decoding escapes + * in string capabilities. We don't use stdio because the editor + * doesn't, and because living w/o it is not hard. + */ + +static char *tbuf; +static int hopcount; /* detect infinite loops in termcap, init 0 */ + +/* forward declarations */ +static char *tdecode(char *, char **); +static void tngetsize(char *); +static char *tskip(char *bp); +static char *appendsmalldec(char *, int); +int tnamatch(char *); +int tnchktc(void); + +/* + * Get an entry for terminal name in buffer bp, + * from the termcap file. Parse is very rudimentary; + * we just notice escaped newlines. + */ + +int +tgetent(char *bp, char *name) +{ + char *cp; + int c; + int i = 0; + ssize_t cnt = 0; + char ibuf[BUFSIZ]; + int tf; + + tbuf = bp; + tf = -1; +#ifndef V6 + cp = getenv("TERMCAP"); + /* + * TERMCAP can have one of two things in it. It can be the + * name of a file to use instead of /etc/termcap. In this + * case it better start with a "/". Or it can be an entry to + * use so we don't have to read the file. In this case it + * has to already have the newlines crunched out. + */ + if (cp && *cp) { + if (*cp == '/') { + tf = open(cp, 0); + } else { + tbuf = cp; + c = tnamatch(name); + tbuf = bp; + if (c) { + (void) strcpy(bp, cp); + return (tnchktc()); + } + } + } + if (tf < 0) + tf = open(E_TERMCAP, 0); +#else + tf = open(E_TERMCAP, 0); +#endif + if (tf < 0) + return (-1); + for (;;) { + cp = bp; + for (;;) { + if (i == cnt) { + cnt = read(tf, ibuf, BUFSIZ); + if (cnt <= 0) { + (void) close(tf); + return (0); + } + i = 0; + } + c = ibuf[i++]; + if (c == '\n') { + if (cp > bp && cp[-1] == '\\') { + cp--; + continue; + } + break; + } + if (cp >= bp+BUFSIZ) { + (void) write(2, "Termcap entry too long\n", 23); + break; + } else + *cp++ = (char) c; + } + *cp = 0; + + /* + * The real work for the match. + */ + if (tnamatch(name)) { + (void) close(tf); + return (tnchktc()); + } + } +} + +/* + * tnchktc: check the last entry, see if it's tc=xxx. If so, + * recursively find xxx and append that entry (minus the names) + * to take the place of the tc=xxx entry. This allows termcap + * entries to say "like an HP2621 but doesn't turn on the labels". + * Note that this works because of the left to right scan. + */ + +int +tnchktc(void) +{ + char *p, *q; + char tcname[16]; /* name of similar terminal */ + char tcbuf[BUFSIZ]; + char *holdtbuf = tbuf; + ptrdiff_t l; + + p = tbuf + strlen(tbuf) - 2; /* before the last colon */ + while (*--p != ':') + if (p < tbuf) { + (void) write(2, "Bad termcap entry\n", 18); + return (0); + } + p++; + /* p now points to beginning of last field */ + if (p[0] != 't' || p[1] != 'c') { + tngetsize(tbuf); + return (1); + } + (void) strcpy(tcname, p+3); + q = tcname; + while (*q && *q != ':') + q++; + *q = 0; + if (++hopcount > MAXHOP) { + (void) write(2, "Infinite tc= loop\n", 18); + return (0); + } + if (tgetent(tcbuf, tcname) != 1) { + hopcount = 0; /* unwind recursion */ + return (0); + } + for (q = tcbuf; *q != ':'; q++) + ; + l = p - holdtbuf + strlen(q); + if (l > BUFSIZ) { + (void) write(2, "Termcap entry too long\n", 23); + q[BUFSIZ - (p-tbuf)] = 0; + } + (void) strcpy(p, q+1); + tbuf = holdtbuf; + hopcount = 0; /* unwind recursion */ + tngetsize(tbuf); + return (1); +} + +/* + * Tnamatch deals with name matching. The first field of the termcap + * entry is a sequence of names separated by |'s, so we compare + * against each such name. The normal : terminator after the last + * name (before the first field) stops us. + */ + +int +tnamatch(char *np) +{ + char *Np, *Bp; + + Bp = tbuf; + if (*Bp == '#') + return (0); + for (;;) { + for (Np = np; *Np && *Bp == *Np; Bp++, Np++) + continue; + if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0)) + return (1); + while (*Bp && *Bp != ':' && *Bp != '|') + Bp++; + if (*Bp == 0 || *Bp == ':') + return (0); + Bp++; + } +} + +/* + * Skip to the next field. Notice that this is very dumb, not + * knowing about \: escapes or any such. If necessary, :'s can be put + * into the termcap file in octal. + */ + +static char * +tskip(char *bp) +{ + + while (*bp && *bp != ':') + bp++; + if (*bp == ':') { + do { + bp++; + while (isspace(*bp)) + bp++; + } while (*bp == ':'); + } + return (bp); +} + +/* + * Return the (numeric) option id. + * Numeric options look like + * li#80 + * i.e. the option string is separated from the numeric value by + * a # character. If the option is not found we return -1. + * Note that we handle octal numbers beginning with 0. + */ + +int +tgetnum(char *id) +{ + int i, base; + char *bp = tbuf; + + for (;;) { + bp = tskip(bp); + if (*bp == 0) + return (-1); + if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) + continue; + if (*bp == '@') + return (-1); + if (*bp != '#') + continue; + bp++; + base = 10; + if (*bp == '0') + base = 8; + i = 0; + while (isdigit(*bp)) + i *= base, i += *bp++ - '0'; + return (i); + } +} + +/* + * Handle a flag option. + * Flag options are given "naked", i.e. followed by a : or the end + * of the buffer. Return 1 if we find the option, or 0 if it is + * not given. + */ + +int +tgetflag(char *id) +{ + char *bp = tbuf; + + for (;;) { + bp = tskip(bp); + if (!*bp) + return (0); + if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) { + if (!*bp || *bp == ':') + return (1); + else if (*bp == '@') + return (0); + } + } +} + +/* + * Get a string valued option. + * These are given as + * cl=^Z + * Much decoding is done on the strings, and the strings are + * placed in area, which is a ref parameter which is updated. + * No checking on area overflow. + */ + +char * +tgetstr(char *id, char **area) +{ + char *bp = tbuf; + + for (;;) { + bp = tskip(bp); + if (!*bp) + return (0); + if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) + continue; + if (*bp == '@') + return (0); + if (*bp != '=') + continue; + bp++; + return (tdecode(bp, area)); + } +} + +/* + * Tdecode does the grung work to decode the + * string capability escapes. + */ + +static char * +tdecode(char *str, char **area) +{ + char *cp; + int c; + char *dp; + int i; + + cp = *area; + while (((c = *str++) != 0) && c != ':') { + switch (c) { + + case '^': + c = *str++ & 037; + break; + + case '\\': + dp = "E\033^^\\\\::n\nr\rt\tb\bf\f"; + c = *str++; +nextc: + if (*dp++ == c) { + c = *dp++; + break; + } + dp++; + if (*dp) + goto nextc; + if (isdigit(c)) { + c -= '0', i = 2; + do + c <<= 3, c |= *str++ - '0'; + while (--i && isdigit(*str)); + } + break; + } + *cp++ = (char) c; + } + *cp++ = 0; + str = *area; + *area = cp; + return (str); +} + +#include <sys/ioctl.h> + +static void +tngetsize(char *bp) +{ + struct winsize ws; + char *np, *cp; + + if (ioctl(1, TIOCGWINSZ, (char *)&ws) < 0) + return; + if (ws.ws_row == 0 || ws.ws_col == 0 || + ws.ws_row > 999 || ws.ws_col > 999) + return; + cp = index(bp, ':'); /* find start of description */ + bp = rindex(bp, 0); /* find end of description */ + np = bp + 15; /* allow enough room for stuff below */ + while (bp >= cp) /* move description right 15 chars */ + *np-- = *bp--; + bp++; /* bp now points to where ':' used to be */ + *bp++ = ':'; + *bp++ = 'l'; + *bp++ = 'i'; + *bp++ = '#'; + bp = appendsmalldec(bp, ws.ws_row); + *bp++ = ':'; + *bp++ = 'c'; + *bp++ = 'o'; + *bp++ = '#'; + bp = appendsmalldec(bp, ws.ws_col); + *bp++ = ':'; + while (bp <= np) /* space fill to start of orig description */ + *bp++ = ' '; +} + +static char * +appendsmalldec(char *bp, int val) +{ + int i; + + if ((i = val / 100) != 0) { + *bp++ = '0' + i; + val %= 100; + if (0 == val / 10) + *bp++ = '0'; /* place holder because next test fails */ + } + if ((i = val / 10) != 0) + *bp++ = '0' + i; + *bp++ = '0' + val % 10; + return (bp); +} diff --git a/usr/src/ucblib/libtermcap/tgoto.c b/usr/src/ucblib/libtermcap/tgoto.c new file mode 100644 index 0000000000..69880447ca --- /dev/null +++ b/usr/src/ucblib/libtermcap/tgoto.c @@ -0,0 +1,212 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* Copyright (c) 1979 Regents of the University of California */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <string.h> +#include <sys/ttychars.h> + +#if 0 +static char +sccsid[] = "@(#)tgoto.c 1.5 88/02/08 SMI"; /* from UCB 4.1 6/27/83 */ +#endif + +#define MAXRETURNSIZE 64 + +char *UP; +char *BC; + +/* + * Routine to perform cursor addressing. + * CM is a string containing printf type escapes to allow + * cursor addressing. We start out ready to print the destination + * line, and switch each time we print row or column. + * The following escapes are defined for substituting row/column: + * + * %d as in printf + * %2 like %2d + * %3 like %3d + * %. gives %c hacking special case characters + * %+x like %c but adding x first + * + * The codes below affect the state but don't use up a value. + * + * %>xy if value > x add y + * %r reverses row/column + * %i increments row/column (for one origin indexing) + * %% gives % + * %B BCD (2 decimal digits encoded in one byte) + * %D Delta Data (backwards bcd) + * + * all other characters are ``self-inserting''. + */ + +char * +tgoto(char *CM, int destcol, int destline) +{ + static char result[MAXRETURNSIZE]; + static char added[10]; + char *cp = CM; + char *dp = result; + int c; + int oncol = 0; + int which = destline; + + if (cp == 0) { +toohard: + /* + * ``We don't do that under BOZO's big top'' + */ + return ("OOPS"); + } + added[0] = 0; + while ((c = *cp++) != 0) { + if (c != '%') { + *dp++ = (char) c; + continue; + } + switch (c = *cp++) { + +#ifdef CM_N + case 'n': + destcol ^= 0140; + destline ^= 0140; + goto setwhich; +#endif + + case 'd': + if (which < 10) + goto one; + if (which < 100) + goto two; + /*FALLTHRU*/ + + case '3': + *dp++ = (which / 100) | '0'; + which %= 100; + /*FALLTHRU*/ + + case '2': +two: + *dp++ = which / 10 | '0'; +one: + *dp++ = which % 10 | '0'; +swap: + oncol = 1 - oncol; +setwhich: + which = oncol ? destcol : destline; + continue; + +#ifdef CM_GT + case '>': + if (which > *cp++) + which += *cp++; + else + cp++; + continue; +#endif + + case '+': + which += *cp++; + /*FALLTHRU*/ + + case '.': + /* + * This code is worth scratching your head at for a + * while. The idea is that various weird things can + * happen to nulls, EOT's, tabs, and newlines by the + * tty driver, arpanet, and so on, so we don't send + * them if we can help it. + * + * Tab is taken out to get Ann Arbors to work, otherwise + * when they go to column 9 we increment which is wrong + * because bcd isn't continuous. We should take out + * the rest too, or run the thing through more than + * once until it doesn't make any of these, but that + * would make termlib (and hence pdp-11 ex) bigger, + * and also somewhat slower. This requires all + * programs which use termlib to stty tabs so they + * don't get expanded. They should do this anyway + * because some terminals use ^I for other things, + * like nondestructive space. + */ + if (which == 0 || which == CTRL('d') || which == '\n') { + if (oncol || UP) + /* Assumption: backspace works */ + /* + * Loop needed because newline happens + * to be the successor of tab. + */ + do { + (void) strcat(added, oncol ? + (BC ? BC : "\b") : UP); + which++; + } while (which == '\n'); + } + *dp++ = (char) which; + goto swap; + + case 'r': + oncol = 1; + goto setwhich; + + case 'i': + destcol++; + destline++; + which++; + continue; + + case '%': + *dp++ = (char) c; + continue; + +#ifdef CM_B + case 'B': + which = (which/10 << 4) + which%10; + continue; +#endif + +#ifdef CM_D + case 'D': + which = which - 2 * (which%16); + continue; +#endif + + default: + goto toohard; + } + } + (void) strcpy(dp, added); + return (result); +} diff --git a/usr/src/ucblib/libtermcap/tputs.c b/usr/src/ucblib/libtermcap/tputs.c new file mode 100644 index 0000000000..cc15ee7614 --- /dev/null +++ b/usr/src/ucblib/libtermcap/tputs.c @@ -0,0 +1,131 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* Copyright (c) 1979 Regents of the University of California */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#if 0 +static char +sccsid[] = "@(#)tputs.c 1.5 88/02/08 SMI"; /* from UCB 4.1 6/27/83 */ +#endif + +#include <sys/types.h> +#include <sgtty.h> +#include <ctype.h> + +/* + * The following array gives the number of tens of milliseconds per + * character for each speed as returned by gtty. Thus since 300 + * baud returns a 7, there are 33.3 milliseconds per char at 300 baud. + */ +static +short tmspc10[] = { + 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5 +}; + +short ospeed; +char PC; + +/* + * Put the character string cp out, with padding. + * The number of affected lines is affcnt, and the routine + * used to output one character is outc. + * + * Note: + * Return value is provided only because prototype is defined as such; + * no real meaning. + */ + +int +tputs(char *cp, int affcnt, int (*outc)(char)) +{ + int i = 0; + int mspc10; + + if (cp == 0) + return (0); + + /* + * Convert the number representing the delay. + */ + if (isdigit(*cp)) { + do + i = i * 10 + *cp++ - '0'; + while (isdigit(*cp)); + } + i *= 10; + if (*cp == '.') { + cp++; + if (isdigit(*cp)) + i += *cp - '0'; + /* + * Only one digit to the right of the decimal point. + */ + while (isdigit(*cp)) + cp++; + } + + /* + * If the delay is followed by a `*', then + * multiply by the affected lines count. + */ + if (*cp == '*') + cp++, i *= affcnt; + + /* + * The guts of the string. + */ + while (*cp) + (*outc)(*cp++); + + /* + * If no delay needed, or output speed is + * not comprehensible, then don't try to delay. + */ + if (i == 0) + return (0); + if (ospeed <= 0 || ospeed >= (sizeof (tmspc10) / sizeof (tmspc10[0]))) + return (0); + + /* + * Round up by a half a character frame, + * and then do the delay. + * Too bad there are no user program accessible programmed delays. + * Transmitting pad characters slows many + * terminals down and also loads the system. + */ + mspc10 = tmspc10[ospeed]; + i += mspc10 / 2; + for (i /= mspc10; i > 0; i--) + (*outc)(PC); + return (0); +} diff --git a/usr/src/ucblib/libucb/Makefile b/usr/src/ucblib/libucb/Makefile new file mode 100644 index 0000000000..60ae097c14 --- /dev/null +++ b/usr/src/ucblib/libucb/Makefile @@ -0,0 +1,50 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +#ident "%Z%%M% %I% %E% SMI" +# +# Copyright 1989-1999,2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ucblib/libucb/Makefile +# +# The builds occur in isa subdirectories. +# + +include ../Makefile.ucb + +SUBDIRS = spec .WAIT $(MACH) $(BUILD64) $(MACH64) + +# conditional assignments +install := TARGET= install +clean := TARGET= clean +clobber := TARGET= clobber +lint := TARGET= lint + +.KEEP_STATE: + +all install clean clobber lint : $(SUBDIRS) + +$(MACH) $(MACH64) spec: FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: diff --git a/usr/src/ucblib/libucb/Makefile.com b/usr/src/ucblib/libucb/Makefile.com new file mode 100644 index 0000000000..5075d43068 --- /dev/null +++ b/usr/src/ucblib/libucb/Makefile.com @@ -0,0 +1,160 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libucb/Makefile.com +# common part for i386/amd64/sparc/sparcv9 +# + +LIBRARY= libucb.a +VERS= .1 + +PORTSYSOBJS= \ + flock.o \ + getdtblsize.o \ + gethostid.o \ + gethostname.o \ + getpagesize.o \ + gettimeofday.o \ + killpg.o \ + mctl.o \ + reboot.o \ + setpgrp.o \ + wait3.o \ + wait4.o + +PORTSTDIOOBJS= \ + doprnt.o \ + fopen.o \ + fprintf.o \ + printf.o \ + sprintf.o \ + vfprintf.o \ + vprintf.o \ + vsprintf.o + +PORTGENOBJS= \ + _psignal.o \ + bcmp.o \ + bcopy.o \ + bzero.o \ + ftime.o \ + getwd.o \ + index.o \ + nice.o \ + nlist.o \ + psignal.o \ + rand.o \ + readdir.o \ + regex.o \ + rindex.o \ + scandir.o \ + setbuffer.o \ + siglist.o \ + statfs.o \ + times.o + +OBJECTS= $(SYSOBJS) $(PORTGENOBJS) $(PORTSYSOBJS) $(PORTSTDIOOBJS) + +# include library definitions +include $(SRC)/lib/Makefile.lib + +ROOTLIBDIR= $(ROOT)/usr/ucblib +ROOTLIBDIR64= $(ROOT)/usr/ucblib/$(MACH64) + +MAPFILE= $(MAPDIR)/mapfile +MAPOPTS= $(MAPFILE:%=-M%) + +SRCS= $(PORTGENOBJS:%.o=../port/gen/%.c) \ + $(PORTSTDIOOBJS:%.o=../port/stdio/%.c) \ + $(PORTSYSOBJS:%.o=../port/sys/%.c) + +LIBS = $(DYNLIB) $(LINTLIB) + +LINTSRC= $(LINTLIB:%.ln=%) +ROOTLINTDIR= $(ROOTLIBDIR) +ROOTLINTDIR64= $(ROOTLIBDIR)/$(MACH64) +ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%) +ROOTLINT64= $(LINTSRC:%=$(ROOTLINTDIR64)/%) + +# install rule for lint source file target +$(ROOTLINTDIR)/%: ../port/% + $(INS.file) +$(ROOTLINTDIR64)/%: ../% + $(INS.file) + +$(LINTLIB):= SRCS=../port/llib-lucb + +CFLAGS += $(CCVERBOSE) +CFLAGS64 += $(CCVERBOSE) +DYNFLAGS += $(MAPOPTS) +LDLIBS += -lelf -lc + +CPPFLAGS = -D$(MACH) -I$(ROOT)/usr/ucbinclude -I../inc \ + -I../../../lib/libc/inc $(CPPFLAGS.master) + +ASFLAGS= -P -D__STDC__ -DLOCORE -D_SYS_SYS_S -D_ASM $(CPPFLAGS) + +pics/%.o:= ASFLAGS += $(AS_PICFLAGS) + +# libc method of building an archive, using AT&T ordering +BUILD.AR= $(RM) $@ ; \ + $(AR) q $@ `$(LORDER) $(OBJECTS:%=$(DIR)/%)| $(TSORT)` + +.KEEP_STATE: + +all: $(LIBS) + +lint: lintcheck + +$(DYNLIB): $(MAPFILE) + +$(MAPFILE): + @cd $(MAPDIR); $(MAKE) mapfile + +objs/%.o pics/%.o: ../port/gen/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) +objs/%.o pics/%.o: ../port/stdio/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) +objs/%.o pics/%.o: ../port/sys/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) + +# shared (sparc/sparcv9/i386/amd64) platform-specific rule +objs/%.o pics/%.o: sys/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) + +objs/%.o pics/%.o: ../$(MACH)/sys/%.s + $(BUILD.s) + $(POST_PROCESS_O) + +# +# Include library targets +# +include $(SRC)/lib/Makefile.targ diff --git a/usr/src/ucblib/libucb/amd64/Makefile b/usr/src/ucblib/libucb/amd64/Makefile new file mode 100644 index 0000000000..a6b20549c9 --- /dev/null +++ b/usr/src/ucblib/libucb/amd64/Makefile @@ -0,0 +1,46 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +SYSOBJS= signal.o + +MAPDIR= ../spec/amd64 + +include ../Makefile.com +include $(SRC)/lib/Makefile.lib.64 + +DYNFLAGS += $(DYNFLAGS64) +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) + +# amd64-specific rule +objs/%.o pics/%.o: ../$(MACH)/sys/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) + +.KEEP_STATE: + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) diff --git a/usr/src/ucblib/libucb/amd64/llib-lucb b/usr/src/ucblib/libucb/amd64/llib-lucb new file mode 100644 index 0000000000..4e91e5210a --- /dev/null +++ b/usr/src/ucblib/libucb/amd64/llib-lucb @@ -0,0 +1,256 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* LINTLIBRARY */ +/* PROTOLIB1 */ + +#include <sys/time.h> +#include <varargs.h> +#include <stdio.h> +#include <sys/types.h> +#include <errno.h> +#include <sys/syscall.h> +#include <sys/siginfo.h> +#include <sys/ucontext.h> +#include <signal.h> +#include <ucontext.h> +#include <setjmp.h> +#include <sys/resource.h> +#include <sys/utsname.h> +#include <sys/systeminfo.h> +#include <sys/errno.h> +#include <sys/unistd.h> +#include <sys/mman.h> +#include <sys/uadmin.h> +#include <sys/times.h> +#include <wait.h> +#include <sys/procset.h> +#include <sys/param.h> +#include <values.h> +#include <ctype.h> +#include <nan.h> +#include <memory.h> +#include <string.h> +#include <locale.h> +#include <fcntl.h> +#include <nlist.h> +#include <sys/dir.h> +#include <sys/stat.h> +#include <sys/priocntl.h> +#include <sys/file.h> +#include <sys/fcntl.h> +#include <sys/statvfs.h> +#include <sys/vfs.h> + +#include <sys/timeb.h> + +/* port/sys/gettimeofday.c */ +int gettimeofday(struct timeval *tp, void *tzp); +int settimeofday(struct timeval *tp, void *tzp); + +/* port/sys/signal.c */ +int _sigvechandler(int sig, siginfo_t *sip, ucontext_t *ucp); +int _sigsetmask(int mask); +int ucbsigsetmask(int mask); +int _sigblock(int mask); +int ucbsigblock(int mask); +int usigpause(int mask); +int ucbsigpause(int mask); +int _sigvec(int sig, struct sigvec *nvec, struct sigvec *ovec); +int ucbsigvec(int sig, struct sigvec *nvec, struct sigvec *ovec); +int _sigstack(struct sigstack *nss, struct sigstack *oss); +void ucbsignal(int s, void (*a)()); +void usignal(int s, void (*a)()); +int _siginterrupt(int sig, int flag); +int ucbsiginterrupt(int sig, int flag); + +/* port/sys/setjmp.c */ +int setjmp(jmp_buf env); +int _setjmp(jmp_buf env); +void _longjmp(jmp_buf env, int val); +void longjmp(jmp_buf env, int val); + +/* port/sys/getdtblsize.c */ +int getdtablesize(void); + +/* port/sys/gethostid.c */ +long gethostid(void); + +/* port/sys/gethostname.c */ +int gethostname(char *name, int namelen); +int sethostname(char *name, int namelen); + +/* port/sys/getpagesize.c */ +int getpagesize(void); + +/* port/sys/killpg.c */ +int killpg(int pgrp, int sig); + +/* port/sys/mctl.c */ +int mctl(caddr_t addr, size_t len, int function, int arg); + +/* port/sys/reboot.c */ +int reboot(int howto, char *bootargs); + +/* port/sys/setreid.c */ +int setreuid(int ruid, int euid); +int setregid(int rgid, int egid); + +/* port/sys/wait3.c */ +int wait3(int *status, int options, struct rusage *rp); +int wstat(int code, int status); + +/* port/sys/wait4.c */ +pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage); + +/* port/sys/getrusage.c */ +int getrusage(int who, struct rusage *rusage); + +/* port/sys/setpgrp.c */ +int setpgrp(pid_t pid1, pid_t pid2); + +/* port/stdio/sprintf.c */ +char *sprintf(const char *string, const char *format, ...); + +/* port/stdio/doprnt.c */ +int _doprnt(char *format, va_list in_args, FILE *iop); +/* + * void _mkarglst(fmt, args, arglst) char *fmt; stva_list args; + * stva_list arglst[]; {} + * void _getarg(fmt, pargs, argno) char *fmt; stva_list *pargs; int argno; {} + */ + +/* port/stdio/fopen.c */ +FILE *fopen(const char *file, const char *mode); +FILE *freopen(const char *file, const char *mode, FILE *iop); + +/* port/stdio/fprintf.c */ +int fprintf(FILE *iop, const char *format, ...); + +/* port/stdio/printf.c */ +/* VARARGS1 */ +int printf(const char *format, ...); + +/* port/stdio/vfprintf.c */ +/* VARARGS 2 */ +int vfprintf(FILE *iop, const char *format, va_list); + +/* port/stdio/vprintf.c */ +/* VARARGS 1 */ +int vprintf(const char *format, va_list); + +/* port/stdio/vsprintf.c */ +/* VARARGS 2 */ +char *vsprintf(char *string, char *format, va_list); + +/* port/gen/nlist.c */ +int nlist(const char *name, struct nlist *list); + +/* port/gen/readdir.c */ +struct direct *readdir(DIR *dirp); + +/* port/gen/scandir.c */ +int scandir(char *dirname, struct direct *(*namelist[]), int (*select)(), + int (*dcomp)()); +int alphasort(struct direct **d1, struct direct **d2); + +/* port/gen/setpriority.c */ +int getpriority(int which, int who); +int setpriority(int which, int who, int prio); + +/* port/gen/siglist.c */ + +/* port/gen/_psignal.c */ +void _psignal(unsigned sig, char *s); + +/* port/gen/bcmp.c */ +int bcmp(char *s1, char *s2, int len); + +/* port/gen/bcopy.c */ +void bcopy(char *s1, char *s2, int len); + +/* port/gen/bzero.c */ +void bzero(char *sp, int len); + +/* port/gen/ftime.c */ +int ftime(struct timeb *tp); + +/* port/gen/getusershell.c */ +char *getusershell(void); +int endusershell(void); +int setusershell(void); + +/* port/gen/getwd.c */ +char *getwd(char *pathname); + +/* port/gen/index.c */ +char *index(char *sp, char c); + +/* port/gen/mkstemp.c */ +int mkstemp(char *as); + +/* port/gen/nice.c */ +int nice(int incr); + +/* port/gen/psignal.c */ +void psignal(unsigned sig, char *s); + +/* port/gen/rand.c */ +int srand(unsigned x); +int rand(void); + +/* port/gen/random.c */ +int srandom(unsigned x); +char *initstate(unsigned seed, char *arg_state, int n); +char *setstate(char *arg_state); +long random(void); + +/* port/gen/regex.c */ +char *re_comp(char *sp); +int re_exec(char *p1); + +/* port/gen/rindex.c */ +char *rindex(char *sp, char c); + +/* port/gen/setbuffer.c */ +void setbuffer(FILE *iop, char *abuf, int asize); +int setlinebuf(FILE *iop); + +/* port/gen/statfs.c */ +int statfs(char *path, struct statfs *buf); +int fstatfs(int fd, struct statfs *buf); +int cnvtvfs(struct statfs *buf, struct statvfs *vbuf); + +/* port/gen/times.c */ +clock_t times(struct tms *tmsp); + +/* port/gen/ualarm.c */ +unsigned ualarm(unsigned usecs, unsigned reload); + +/* port/gen/usleep.c */ +int usleep(unsigned n); diff --git a/usr/src/ucblib/libucb/i386/Makefile b/usr/src/ucblib/libucb/i386/Makefile new file mode 100644 index 0000000000..53067fd898 --- /dev/null +++ b/usr/src/ucblib/libucb/i386/Makefile @@ -0,0 +1,43 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libucb/i386/Makefile + +SYSOBJS= \ + signal.o + +NOCTFOBJS= + +MAPDIR= ../spec/i386 + +include ../Makefile.com + +DYNFLAGS += $(DYNFLAGS32) + +.KEEP_STATE: + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/libucb/i386/sys/signal.c b/usr/src/ucblib/libucb/i386/sys/signal.c new file mode 100644 index 0000000000..2afb74cd34 --- /dev/null +++ b/usr/src/ucblib/libucb/i386/sys/signal.c @@ -0,0 +1,415 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +/* + * 4.3BSD signal compatibility functions + * + * the implementation interprets signal masks equal to -1 as "all of the + * signals in the signal set", thereby allowing signals with numbers + * above 32 to be blocked when referenced in code such as: + * + * for (i = 0; i < NSIG; i++) + * mask |= sigmask(i) + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/types.h> +#include <ucontext.h> +#include <signal.h> +#include <errno.h> + +#undef BUS_OBJERR /* namespace conflict */ +#include <sys/siginfo.h> +#include "libc.h" + +#pragma weak sigvechandler = _sigvechandler +#pragma weak sigsetmask = _sigsetmask +#pragma weak sigblock = _sigblock +#pragma weak sigpause = usigpause +#pragma weak sigvec = _sigvec +#pragma weak sigstack = _sigstack +#pragma weak signal = usignal +#pragma weak siginterrupt = _siginterrupt + +#define set2mask(setp) ((setp)->__sigbits[0]) +#define mask2set(mask, setp) \ + ((mask) == -1 ? sigfillset(setp) : \ + (sigemptyset(setp), (((setp)->__sigbits[0]) = (int)(mask)))) + +void (*_siguhandler[NSIG])() = { 0 }; + +/* forward declarations */ +int ucbsigsetmask(int); +int ucbsigblock(int); +int ucbsigvec(int, struct sigvec *, struct sigvec *); +int ucbsigpause(int); +int ucbsiginterrupt(int, int); + +/* + * sigvechandler is the real signal handler installed for all + * signals handled in the 4.3BSD compatibility interface - it translates + * SVR4 signal hander arguments into 4.3BSD signal handler arguments + * and then calls the real handler + */ + +void +_sigvechandler(int sig, siginfo_t *sip, ucontext_t *ucp) +{ + static void ucbsigvechandler(); + + ucbsigvechandler(sig, sip, ucp); +} + +static void +ucbsigvechandler(int sig, siginfo_t *sip, ucontext_t *ucp) +{ + struct sigcontext sc; + int code; + char *addr; + int i, j; + int gwinswitch = 0; + + sc.sc_onstack = ((ucp->uc_stack.ss_flags & SS_ONSTACK) != 0); + sc.sc_mask = set2mask(&ucp->uc_sigmask); + +#if defined(__amd64) + sc.sc_sp = (long)ucp->uc_mcontext.gregs[REG_RSP]; + sc.sc_pc = (long)ucp->uc_mcontext.gregs[REG_RIP]; + sc.sc_ps = (long)ucp->uc_mcontext.gregs[REG_RFL]; + sc.sc_r0 = (long)ucp->uc_mcontext.gregs[REG_RAX]; + sc.sc_r1 = (long)ucp->uc_mcontext.gregs[REG_RDX]; +#else + sc.sc_sp = (int)ucp->uc_mcontext.gregs[UESP]; + sc.sc_pc = (int)ucp->uc_mcontext.gregs[EIP]; + sc.sc_ps = (int)ucp->uc_mcontext.gregs[EFL]; + sc.sc_r0 = (int)ucp->uc_mcontext.gregs[EAX]; + sc.sc_r1 = (int)ucp->uc_mcontext.gregs[EDX]; +#endif + + /* + * Translate signal codes from new to old. + * /usr/include/sys/siginfo.h contains new codes. + * /usr/ucbinclude/sys/signal.h contains old codes. + */ + code = 0; + addr = SIG_NOADDR; + if (sip != NULL && SI_FROMKERNEL(sip)) { + addr = sip->si_addr; + + switch (sig) { + case SIGILL: + case SIGFPE: + code = ILL_ILLINSTR_FAULT; + break; + + case SIGBUS: + switch (sip->si_code) { + case BUS_ADRALN: + code = BUS_ALIGN; + break; + case BUS_ADRERR: + code = BUS_HWERR; + break; + default: /* BUS_OBJERR */ + code = FC_MAKE_ERR(sip->si_errno); + break; + } + break; + + case SIGSEGV: + switch (sip->si_code) { + case SEGV_MAPERR: + code = SEGV_NOMAP; + break; + case SEGV_ACCERR: + code = SEGV_PROT; + break; + default: + code = FC_MAKE_ERR(sip->si_errno); + break; + } + break; + + default: + addr = SIG_NOADDR; + break; + } + } + + (*_siguhandler[sig])(sig, code, &sc, addr); + + if (sc.sc_onstack) + ucp->uc_stack.ss_flags |= SS_ONSTACK; + else + ucp->uc_stack.ss_flags &= ~SS_ONSTACK; + mask2set(sc.sc_mask, &ucp->uc_sigmask); + +#if defined(__amd64) + ucp->uc_mcontext.gregs[REG_RSP] = (long)sc.sc_sp; + ucp->uc_mcontext.gregs[REG_RIP] = (long)sc.sc_pc; + ucp->uc_mcontext.gregs[REG_RFL] = (long)sc.sc_ps; + ucp->uc_mcontext.gregs[REG_RAX] = (long)sc.sc_r0; + ucp->uc_mcontext.gregs[REG_RDX] = (long)sc.sc_r1; +#else + ucp->uc_mcontext.gregs[UESP] = (int)sc.sc_sp; + ucp->uc_mcontext.gregs[EIP] = (int)sc.sc_pc; + ucp->uc_mcontext.gregs[EFL] = (int)sc.sc_ps; + ucp->uc_mcontext.gregs[EAX] = (int)sc.sc_r0; + ucp->uc_mcontext.gregs[EDX] = (int)sc.sc_r1; +#endif + + setcontext(ucp); +} + +int +_sigsetmask(int mask) +{ + return (ucbsigsetmask(mask)); +} + +int +ucbsigsetmask(int mask) +{ + sigset_t oset; + sigset_t nset; + + (void) sigprocmask(0, (sigset_t *)0, &nset); + mask2set(mask, &nset); + (void) sigprocmask(SIG_SETMASK, &nset, &oset); + return (set2mask(&oset)); +} + +int +_sigblock(int mask) +{ + return (ucbsigblock(mask)); +} + +int +ucbsigblock(int mask) +{ + sigset_t oset; + sigset_t nset; + + (void) sigprocmask(0, (sigset_t *)0, &nset); + mask2set(mask, &nset); + (void) sigprocmask(SIG_BLOCK, &nset, &oset); + return (set2mask(&oset)); +} + +int +usigpause(int mask) +{ + return (ucbsigpause(mask)); +} + +int +ucbsigpause(int mask) +{ + sigset_t set, oset; + int ret; + + (void) sigprocmask(0, (sigset_t *)0, &set); + oset = set; + mask2set(mask, &set); + ret = sigsuspend(&set); + (void) sigprocmask(SIG_SETMASK, &oset, (sigset_t *)0); + return (ret); +} + +int +_sigvec(int sig, struct sigvec *nvec, struct sigvec *ovec) +{ + return (ucbsigvec(sig, nvec, ovec)); +} + +int +ucbsigvec(int sig, struct sigvec *nvec, struct sigvec *ovec) +{ + struct sigaction nact; + struct sigaction oact; + struct sigaction *nactp; + void (*ohandler)(), (*nhandler)(); + + if (sig <= 0 || sig >= NSIG) { + errno = EINVAL; + return (-1); + } + + if ((intptr_t)ovec == -1 || (intptr_t)nvec == -1) { + errno = EFAULT; + return (-1); + } + + ohandler = _siguhandler[sig]; + + if (nvec) { + _sigaction(sig, (struct sigaction *)0, &nact); + nhandler = nvec->sv_handler; + /* + * To be compatible with the behavior of SunOS 4.x: + * If the new signal handler is SIG_IGN or SIG_DFL, + * do not change the signal's entry in the handler array. + * This allows a child of vfork(2) to set signal handlers + * to SIG_IGN or SIG_DFL without affecting the parent. + */ + if (nhandler != SIG_DFL && nhandler != SIG_IGN) { + _siguhandler[sig] = nhandler; + nact.sa_handler = (void (*)())ucbsigvechandler; + } else { + nact.sa_handler = nhandler; + } + mask2set(nvec->sv_mask, &nact.sa_mask); + if (sig == SIGKILL || sig == SIGSTOP) + nact.sa_handler = SIG_DFL; + nact.sa_flags = SA_SIGINFO; + if (!(nvec->sv_flags & SV_INTERRUPT)) + nact.sa_flags |= SA_RESTART; + if (nvec->sv_flags & SV_RESETHAND) + nact.sa_flags |= SA_RESETHAND; + if (nvec->sv_flags & SV_ONSTACK) + nact.sa_flags |= SA_ONSTACK; + nactp = &nact; + } else + nactp = (struct sigaction *)0; + + if (_sigaction(sig, nactp, &oact) < 0) { + _siguhandler[sig] = ohandler; + return (-1); + } + + if (ovec) { + if (oact.sa_handler == SIG_DFL || oact.sa_handler == SIG_IGN) + ovec->sv_handler = oact.sa_handler; + else + ovec->sv_handler = ohandler; + ovec->sv_mask = set2mask(&oact.sa_mask); + ovec->sv_flags = 0; + if (oact.sa_flags & SA_ONSTACK) + ovec->sv_flags |= SV_ONSTACK; + if (oact.sa_flags & SA_RESETHAND) + ovec->sv_flags |= SV_RESETHAND; + if (!(oact.sa_flags & SA_RESTART)) + ovec->sv_flags |= SV_INTERRUPT; + } + + return (0); +} + +int +_sigstack(struct sigstack *nss, struct sigstack *oss) +{ + struct sigaltstack nalt; + struct sigaltstack oalt; + struct sigaltstack *naltp; + + if (nss) { + /* + * assumes stack growth is down (like sparc and x86) + */ + nalt.ss_sp = nss->ss_sp - SIGSTKSZ; + nalt.ss_size = SIGSTKSZ; + nalt.ss_flags = 0; + naltp = &nalt; + } else + naltp = (struct sigaltstack *)0; + + if (sigaltstack(naltp, &oalt) < 0) + return (-1); + + if (oss) { + /* + * assumes stack growth is down (like sparc and x86) + */ + oss->ss_sp = oalt.ss_sp + oalt.ss_size; + oss->ss_onstack = ((oalt.ss_flags & SS_ONSTACK) != 0); + } + + return (0); +} + +void (* +ucbsignal(int s, void (*a)()))() +{ + struct sigvec osv; + struct sigvec nsv; + static int mask[NSIG]; + static int flags[NSIG]; + + nsv.sv_handler = a; + nsv.sv_mask = mask[s]; + nsv.sv_flags = flags[s]; + if (ucbsigvec(s, &nsv, &osv) < 0) + return (SIG_ERR); + if (nsv.sv_mask != osv.sv_mask || nsv.sv_flags != osv.sv_flags) { + mask[s] = nsv.sv_mask = osv.sv_mask; + flags[s] = nsv.sv_flags = + osv.sv_flags & ~(SV_RESETHAND|SV_INTERRUPT); + if (ucbsigvec(s, &nsv, (struct sigvec *)0) < 0) + return (SIG_ERR); + } + return (osv.sv_handler); +} + +void (* +usignal(int s, void (*a)()))() +{ + return (ucbsignal(s, a)); +} + +/* + * Set signal state to prevent restart of system calls + * after an instance of the indicated signal. + */ +int +_siginterrupt(int sig, int flag) +{ + return (ucbsiginterrupt(sig, flag)); +} + +int +ucbsiginterrupt(int sig, int flag) +{ + struct sigvec sv; + int ret; + + if ((ret = ucbsigvec(sig, 0, &sv)) < 0) + return (ret); + if (flag) + sv.sv_flags |= SV_INTERRUPT; + else + sv.sv_flags &= ~SV_INTERRUPT; + return (ucbsigvec(sig, &sv, 0)); +} diff --git a/usr/src/ucblib/libucb/inc/libc.h b/usr/src/ucblib/libucb/inc/libc.h new file mode 100644 index 0000000000..c2a7f14f4c --- /dev/null +++ b/usr/src/ucblib/libucb/inc/libc.h @@ -0,0 +1,94 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * This is where all the interfaces that are internal to libucb + * which do not have a better home live + */ + +#ifndef _LIBC_H +#define _LIBC_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <stdio.h> +#include <stdarg.h> +#include <sys/time.h> +#include <sys/regset.h> +#include <sys/times.h> +#include <sys/ucontext.h> +#include <sys/dirent.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * getdents64 transitional interface is intentionally internal to libc + */ +extern int getdents64(int, struct dirent64 *, size_t); + +/* + * defined in port/stdio/doprnt.c + */ +extern int _doprnt(char *format, va_list in_args, FILE *iop); + +/* + * defined in port/gen/_psignal.c + */ +extern void _psignal(unsigned int sig, char *s); + +/* + * defined in _getsp.s + */ +extern greg_t _getsp(void); + +/* + * defined in ucontext.s + */ +extern int __getcontext(ucontext_t *); + +/* + * defined in libc + */ +extern int _sigaction(int, const struct sigaction *, struct sigaction *); + +/* + * External Variables + */ +extern void (*_siguhandler[])(int, int, struct sigcontext *, char *); + /* for BSD */ + +/* + * defined in port/gen/siglist.c + */ +extern char *sys_siglist[]; + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBC_H */ diff --git a/usr/src/ucblib/libucb/inc/stdiom.h b/usr/src/ucblib/libucb/inc/stdiom.h new file mode 100644 index 0000000000..0ec6e4940b --- /dev/null +++ b/usr/src/ucblib/libucb/inc/stdiom.h @@ -0,0 +1,117 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * stdiom.h - shared guts of stdio therefore it doesn't need + * a surrounding #ifndef + */ + +#ifndef _STDIOM_H +#define _STDIOM_H + +typedef unsigned char Uchar; + +#define MAXVAL (MAXINT - (MAXINT % BUFSIZ)) + +/* + * The number of actual pushback characters is the value + * of PUSHBACK plus the first byte of the buffer. The FILE buffer must, + * for performance reasons, start on a word aligned boundry so the value + * of PUSHBACK should be a multiple of word. + * At least 4 bytes of PUSHBACK are needed. If sizeof(int) = 1 this breaks. + */ + +#define PUSHBACK ((int)(((3 + sizeof (int) - 1) / sizeof (int)) * sizeof (int))) + +/* minimum buffer size must be at least 8 or shared library will break */ +#define _SMBFSZ (((PUSHBACK + 4) < 8) ? 8 : (PUSHBACK + 4)) + +extern Uchar *_bufendtab[]; + +#if BUFSIZ == 1024 +#define MULTIBFSZ(SZ) ((SZ) & ~0x3ff) +#elif BUFSIZ == 512 +#define MULTIBFSZ(SZ) ((SZ) & ~0x1ff) +#else +#define MULTIBFSZ(SZ) ((SZ) - (SZ % BUFSIZ)) +#endif + +#define _bufend(iop) _realbufend(iop) +#define setbufend(iop, end) _setbufend(iop, end) + + /* + * Internal routines from _iob.c + */ +extern void _cleanup(void); +extern void _flushlbf(void); +extern FILE *_findiop(void); +extern Uchar *_realbufend(FILE *iop); +extern void _setbufend(FILE *iop, Uchar *end); +extern int _wrtchk(FILE *iop); + + /* + * Internal routines from flush.c + */ +extern void _bufsync(FILE *iop, Uchar *bufend); +extern int _xflsbuf(FILE *iop); + + /* + * Internal routines from _findbuf.c + */ +extern Uchar *_findbuf(FILE *iop); + +/* + * The following macros improve performance of the stdio by reducing the + * number of calls to _bufsync and _wrtchk. _needsync checks whether + * or not _bufsync needs to be called. _WRTCHK has the same effect as + * _wrtchk, but often these functions have no effect, and in those cases + * the macros avoid the expense of calling the functions. + */ + +#define _needsync(p, bufend) ((bufend - (p)->_ptr) < \ + ((p)->_cnt < 0 ? 0 : (p)->_cnt)) + +#define _WRTCHK(iop) ((((iop->_flag & (_IOWRT | _IOEOF)) != _IOWRT) || \ + (iop->_base == 0) || \ + (iop->_ptr == iop->_base && iop->_cnt == 0 && \ + !(iop->_flag & (_IONBF | _IOLBF)))) \ + ? _wrtchk(iop) : 0) +#endif /* _STDIOM_H */ diff --git a/usr/src/ucblib/libucb/port/gen/_psignal.c b/usr/src/ucblib/libucb/port/gen/_psignal.c new file mode 100644 index 0000000000..67b3212349 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/_psignal.c @@ -0,0 +1,70 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +/* + * Print the name of the signal indicated + * along with the supplied message. + */ +#include <sys/types.h> +#include <unistd.h> +#include <signal.h> +#include <string.h> +#include "libc.h" + +void +_psignal(unsigned int sig, char *s) +{ + char *c; + size_t n; + + c = "Unknown signal"; + if (sig < NSIG) + c = sys_siglist[sig]; + n = strlen(s); + if (n) { + (void) write(2, s, n); + (void) write(2, ": ", (size_t)2); + } + (void) write(2, c, strlen(c)); + (void) write(2, "\n", (size_t)1); +} diff --git a/usr/src/ucblib/libucb/port/gen/bcmp.c b/usr/src/ucblib/libucb/port/gen/bcmp.c new file mode 100644 index 0000000000..86ca3c78ad --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/bcmp.c @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <string.h> + +extern int _memcmp(const void *, const void *, size_t); + + +/*LINTLIBRARY*/ + +int +bcmp(char *s1, char *s2, int len) +{ + if (_memcmp(s1, s2, (size_t)len) == 0) + return (0); + else + return (1); +} diff --git a/usr/src/ucblib/libucb/port/gen/bcopy.c b/usr/src/ucblib/libucb/port/gen/bcopy.c new file mode 100644 index 0000000000..4dec9208bc --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/bcopy.c @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <string.h> + +extern void *_memmove(void *, const void *, size_t); + +/* + * Copy s1 to s2, always copy n bytes. + * For overlapped copies it does the right thing. + */ +void +bcopy(char *s1, char *s2, int len) +{ + if (len > 0) + (void) _memmove(s2, s1, (size_t)len); +} diff --git a/usr/src/ucblib/libucb/port/gen/bzero.c b/usr/src/ucblib/libucb/port/gen/bzero.c new file mode 100644 index 0000000000..3cb3b82c40 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/bzero.c @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <string.h> + +extern void *_memset(void *, int, size_t); + +/* + * Set an array of n chars starting at sp to zero. + */ + +void +bzero(char *sp, int len) +{ + if (len > 0) + (void) _memset(sp, 0, (size_t)len); +} diff --git a/usr/src/ucblib/libucb/port/gen/ftime.c b/usr/src/ucblib/libucb/port/gen/ftime.c new file mode 100644 index 0000000000..61158bacc1 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/ftime.c @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <sys/timeb.h> + +/* + * Backwards compatible ftime. + */ + +int +ftime(struct timeb *tp) +{ + struct timeval t; + struct timezone tz; + + if (gettimeofday(&t, &tz) < 0) + return (-1); + tp->time = t.tv_sec; + tp->millitm = t.tv_usec / 1000; + tp->timezone = (short)tz.tz_minuteswest; + tp->dstflag = (short)tz.tz_dsttime; + + return (0); /* no useful value, keep the prototype unchanged */ +} diff --git a/usr/src/ucblib/libucb/port/gen/getwd.c b/usr/src/ucblib/libucb/port/gen/getwd.c new file mode 100644 index 0000000000..e9cd76bd62 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/getwd.c @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995-1997, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <sys/param.h> +#include <errno.h> +#include <unistd.h> +#include <string.h> +#include <stdlib.h> + +char * +getwd(char *pathname) +{ + char *c; + long val; + + if ((val = pathconf(".", _PC_PATH_MAX)) == -1L) + val = MAXPATHLEN + 1; + + if ((c = getcwd(pathname, val)) == NULL) { + if (errno == EACCES) + (void) strcpy(pathname, + "getwd: a parent directory cannot be read"); + else if (errno == ERANGE) + (void) strcpy(pathname, "getwd: buffer too small"); + else + (void) strcpy(pathname, "getwd: failure occurred"); + return (0); + } + + return (c); +} diff --git a/usr/src/ucblib/libucb/port/gen/index.c b/usr/src/ucblib/libucb/port/gen/index.c new file mode 100644 index 0000000000..d4186f2f8a --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/index.c @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +/* + * Return the ptr in sp at which the character c appears; + * NULL if not found + */ + +#include <sys/types.h> +#include <strings.h> +#include <stddef.h> + +char * +index(char *sp, char c) +{ + + do { + if (*sp == c) + return (sp); + } while (*sp++); + return (NULL); +} diff --git a/usr/src/ucblib/libucb/port/gen/nice.c b/usr/src/ucblib/libucb/port/gen/nice.c new file mode 100644 index 0000000000..9fb37b796d --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/nice.c @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <errno.h> + +/* + * Backwards compatible nice. + */ +int +nice(int incr) +{ + int prio; + int serrno; + + serrno = errno; + errno = 0; + prio = getpriority(PRIO_PROCESS, 0); + if (prio == -1 && errno) + return (-1); + if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) + return (-1); + errno = serrno; + return (0); +} diff --git a/usr/src/ucblib/libucb/port/gen/nlist.c b/usr/src/ucblib/libucb/port/gen/nlist.c new file mode 100644 index 0000000000..02ef8371e0 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/nlist.c @@ -0,0 +1,532 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include "libelf.h" +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <nlist.h> +#include <sys/file.h> +#include <string.h> + +#if COFF_NLIST_SUPPORTED +#include "aouthdr.h" +#include "filehdr.h" +#include "scnhdr.h" +#include "reloc.h" +#endif /* COFF_NLIST_SUPPORTED */ + +#include "linenum.h" +#include "syms.h" + +#undef BADMAG +#define BADMAG(x) (!ISCOFF(x)) + +#ifndef FLEXNAMES +#define FLEXNAMES 1 +#endif +#undef n_name /* this patch causes problems here */ + +#define SPACE 100 /* number of symbols read at a time */ +#define ISELF (strncmp(magic_buf, ELFMAG, SELFMAG) == 0) + +#if COFF_NLIST_SUPPORTED +static char sym_buf[SPACE * SYMESZ]; +static int num_in_buf = 0; +static char *next_entry = (char *)0; +#endif /* COFF_NLIST_SUPPORTED */ + +static unsigned encode; /* data encoding if an ELF file */ +static unsigned fvers; /* object file version if an ELF file */ + +/* forward declarations */ +static int _elf_nlist(int, struct nlist *); +static int end_elf_job(int); +static Elf_Data *elf_read(int, long, size_t, size_t, Elf_Type); + +#if COFF_NLIST_SUPPORTED +static int _coff_nlist(int, struct nlist *); +static void sym_close(int); +static int sym_read(int, struct syment *, int); +static int fill_sym_buf(int, int); +#endif /* COFF_NLIST_SUPPORTED */ + +int +nlist(const char *name, struct nlist *list) +{ + struct nlist *p; + char magic_buf[EI_NIDENT+1]; + int fd; + + for (p = list; p->n_name && p->n_name[0]; p++) { /* n_name can be ptr */ + p->n_type = 0; + p->n_value = 0L; + p->n_scnum = 0; + p->n_sclass = 0; + p->n_numaux = 0; + } + + if ((fd = open(name, 0)) < 0) + return (-1); + if (read(fd, magic_buf, (size_t)EI_NIDENT) == -1) { + (void) close(fd); + return (-1); + } + magic_buf[EI_NIDENT] = '\0'; + if (lseek(fd, 0L, 0) == -1L) { /* rewind to beginning of object file */ + (void) close(fd); + return (-1); + } + + if (ISELF) { + /* + * right now can only handle 32-bit architectures + * XX64 work to come? ELFCLASS64? + */ + if (magic_buf[EI_CLASS] != ELFCLASS32) { + (void) close(fd); + return (-1); + } + encode = (unsigned)magic_buf[EI_DATA]; + fvers = (unsigned)magic_buf[EI_VERSION]; + return (_elf_nlist(fd, list)); + } + else +#if COFF_NLIST_SUPPORTED + return (_coff_nlist(fd, list)); +#else /* COFF_NLIST_SUPPORTED */ + return (-1); +#endif /* COFF_NLIST_SUPPORTED */ +} + +static int +_elf_nlist(int fd, struct nlist *list) +{ + Elf_Data *symdata; /* buffer points to symbol table */ + Elf_Data *strdata; /* buffer points to string table */ + Elf_Data *secdata; /* buffer points to section table */ + Elf32_Shdr *symhdr; /* section table entry for symtab */ + Elf32_Shdr *strhdr; /* section table entry for strtab */ + Elf32_Sym *sym; /* buffer storing one symbol information */ + Elf32_Sym *sym_end; /* end of symbol table */ + Elf32_Ehdr *ehdr; /* file header */ + Elf_Data *edata; /* data buffer for ehdr */ + int i; + int nreq; + struct nlist *inl; + + if (elf_version(EV_CURRENT) == EV_NONE) + return (end_elf_job(fd)); + + /* count the number of symbols requested */ + for (inl = list, nreq = 0; inl->n_name && inl->n_name[0]; ++inl, nreq++) + ; + + /* read file header and section header table */ + if ((edata = elf_read(fd, 0L, elf32_fsize(ELF_T_EHDR, 1, fvers), + sizeof (Elf32_Ehdr), ELF_T_EHDR)) == 0) + return (end_elf_job(fd)); + + ehdr = (Elf32_Ehdr *)edata->d_buf; + + if (ehdr->e_shoff == 0) { + free(edata->d_buf); + free(edata); + return (end_elf_job(fd)); + } + + if ((secdata = elf_read(fd, (long)ehdr->e_shoff, + (size_t)(ehdr->e_shentsize * ehdr->e_shnum), + (size_t)(ehdr->e_shnum * sizeof (Elf32_Ehdr)), + ELF_T_SHDR)) == 0) { + free(edata->d_buf); + free(edata); + return (end_elf_job(fd)); + } + + /* find symbol table section */ + symhdr = (Elf32_Shdr *)secdata->d_buf; + for (i = 0; i < (Elf32_Word)ehdr->e_shnum; i++, symhdr++) + if (symhdr->sh_type == SHT_SYMTAB) + break; + + if ((symhdr->sh_type != SHT_SYMTAB) || + (symhdr->sh_link >= ehdr->e_shnum)) { + free(secdata->d_buf); + free(secdata); + free(edata->d_buf); + free(edata); + return (end_elf_job(fd)); + } + + if ((symdata = elf_read(fd, (long)symhdr->sh_offset, + (size_t)symhdr->sh_size, + (size_t)((symhdr->sh_size / symhdr->sh_entsize) * + sizeof (Elf32_Sym)), ELF_T_SYM)) == 0) { + free(secdata->d_buf); + free(secdata); + free(edata->d_buf); + free(edata); + return (end_elf_job(fd)); + } + + /* read string table */ + strhdr = (Elf32_Shdr *)secdata->d_buf; + strhdr = strhdr + symhdr->sh_link; + + if (strhdr->sh_type != SHT_STRTAB) { + free(symdata->d_buf); + free(symdata); + free(secdata->d_buf); + free(secdata); + free(edata->d_buf); + free(edata); + return (end_elf_job(fd)); + } + + if ((strdata = elf_read(fd, strhdr->sh_offset, strhdr->sh_size, + strhdr->sh_size, ELF_T_BYTE)) == 0) { + free(symdata->d_buf); + free(symdata); + free(secdata->d_buf); + free(secdata); + free(edata->d_buf); + free(edata); + return (end_elf_job(fd)); + } + + ((char *)strdata->d_buf)[0] = '\0'; + ((char *)strdata->d_buf)[strhdr->sh_size-1] = '\0'; + + sym = (Elf32_Sym *) (symdata->d_buf); + sym_end = sym + symdata->d_size / sizeof (Elf32_Sym); + for (; sym < sym_end; ++sym) { + struct nlist *p; + char *name; + if (sym->st_name > strhdr->sh_size) { + free(strdata->d_buf); + free(strdata); + free(symdata->d_buf); + free(symdata); + free(secdata->d_buf); + free(secdata); + free(edata->d_buf); + free(edata); + return (end_elf_job(fd)); + } + name = (char *)strdata->d_buf + sym->st_name; + if (name == 0) + continue; + for (p = list; p->n_name && p->n_name[0]; ++p) { + if (strcmp(p->n_name, name)) { + continue; + } + p->n_value = sym->st_value; + p->n_type = ELF32_ST_TYPE(sym->st_info); + p->n_scnum = sym->st_shndx; + nreq--; + break; + } + } + /* + * Currently there is only one symbol table section + * in an object file, but this restriction may be + * relaxed in the future. + */ + (void) close(fd); + free(secdata->d_buf); + free(strdata->d_buf); + free(symdata->d_buf); + free(edata->d_buf); + free(secdata); + free(strdata); + free(symdata); + free(edata); + return (nreq); +} + +/* + * allocate memory of size memsize and read size bytes + * starting at offset from fd - the file data are + * translated in place using the low-level libelf + * translation routines + */ + +static Elf_Data * +elf_read(int fd, long offset, size_t size, size_t memsize, Elf_Type dtype) +{ + Elf_Data *dsrc, *ddst; + Elf_Data srcdata; + size_t maxsize; + char *p; + + dsrc = &srcdata; + + if (size == 0) + return (0); + + if ((maxsize = memsize) < size) + maxsize = size; + + + if ((ddst = (Elf_Data *)malloc(sizeof (Elf_Data))) == 0) + return (0); + + if ((p = malloc(maxsize)) == 0) { + free(ddst); + return (0); + } + + if (lseek(fd, offset, 0L) == -1) { + free(ddst); + free(p); + return (0); + } + + if (read(fd, p, size) != size) { + free(ddst); + free(p); + return (0); + } + + dsrc->d_buf = p; + dsrc->d_type = dtype; + dsrc->d_size = size; + dsrc->d_version = fvers; + ddst->d_buf = p; + ddst->d_size = memsize; + ddst->d_version = EV_CURRENT; + + if (elf32_xlatetom(ddst, dsrc, encode) != ddst) { + free(ddst); + free(p); + return (0); + } + + return (ddst); +} + +static int +end_elf_job(int fd) +{ + (void) close(fd); + return (-1); +} + +#if COFF_NLIST_SUPPORTED +static int +_coff_nlist(int fd, struct nlist *list) +{ + struct filehdr buf; + struct syment sym; + long n; + int bufsiz = FILHSZ; +#if FLEXNAMES + char *strtab = (char *)0; + long strtablen; +#endif + struct nlist *p, *inl; + struct syment *q; + long sa; + int nreq; + + if (read(fd, (char *)&buf, bufsiz) == -1) { + (void) close(fd); + return (-1); + } + + if (BADMAG(buf.f_magic)) { + (void) close(fd); + return (-1); + } + sa = buf.f_symptr; /* direct pointer to sym tab */ + if (lseek(fd, (long)sa, 0) == -1L) { + (void) close(fd); + return (-1); + } + q = &sym; + n = buf.f_nsyms; /* num. of sym tab entries */ + + /* count the number of symbols requested */ + for (inl = list, nreq = 0; inl->n_name && inl->n_name[0]; ++inl, nreq++) + ; + + while (n) { + if (sym_read(fd, &sym, SYMESZ) == -1) { + sym_close(fd); + return (-1); + } + n -= (q->n_numaux + 1L); + for (p = list; p->n_name && p->n_name[0]; ++p) { + if (p->n_value != 0L && p->n_sclass == C_EXT) + continue; + /* + * For 6.0, the name in an object file is + * either stored in the eight long character + * array, or in a string table at the end + * of the object file. If the name is in the + * string table, the eight characters are + * thought of as a pair of longs, (n_zeroes + * and n_offset) the first of which is zero + * and the second is the offset of the name + * in the string table. + */ +#if FLEXNAMES + if (q->n_zeroes == 0L) /* in string table */ + { + if (strtab == (char *)0) /* need it */ + { + long home = lseek(fd, 0L, 1); + if (home == -1L) { + sym_close(fd); + return (-1); + } + if (lseek(fd, buf.f_symptr + + buf.f_nsyms * SYMESZ, 0) == -1 || + read(fd, (char *)&strtablen, + sizeof (long)) != sizeof (long) || + (strtab = (char *)malloc( + (unsigned)strtablen)) == + (char *)0 || + read(fd, strtab + sizeof (long), + strtablen - sizeof (long)) != + strtablen - sizeof (long) || + strtab[strtablen - 1] != '\0' || + lseek(fd, home, 0) == -1) { + (void) lseek(fd, home, 0); + sym_close(fd); + if (strtab != (char *)0) + free(strtab); + return (-1); + } + } + if (q->n_offset < sizeof (long) || + q->n_offset >= strtablen) { + sym_close(fd); + if (strtab != (char *)0) + free(strtab); + return (-1); + } + if (strcmp(&strtab[q->n_offset], + p->n_name)) { + continue; + } + } + else +#endif /* FLEXNAMES */ + { + if (strncmp(q->_n._n_name, + p->n_name, SYMNMLEN)) { + continue; + } + } + + p->n_value = q->n_value; + p->n_type = q->n_type; + p->n_scnum = q->n_scnum; + p->n_sclass = q->n_sclass; + nreq--; + break; + } + } +#if FLEXNAMES + sym_close(fd); + if (strtab != (char *)0) + free(strtab); +#endif + return (nreq); +} + +static void +sym_close(int fd) +{ + num_in_buf = 0; + next_entry = (char *)0; + + (void) close(fd); +} + +/* buffered read of symbol table */ +static int +sym_read(int fd, struct syment *sym, int size) +{ + long where = 0L; + + if ((where = lseek(fd, 0L, 1)) == -1L) { + sym_close(fd); + return (-1); + } + + if (!num_in_buf) { + if (fill_sym_buf(fd, size) == -1) + return (-1); + } + (void) memcpy((char *)sym, next_entry, size); + num_in_buf--; + + if (sym->n_numaux && !num_in_buf) { + if (fill_sym_buf(fd, size) == -1) + return (-1); + } + if ((lseek(fd, where + SYMESZ + (AUXESZ * sym->n_numaux), 0)) == -1L) { + sym_close(fd); + return (-1); + } + size += AUXESZ * sym->n_numaux; + num_in_buf--; + + next_entry += size; + return (0); +} + +static int +fill_sym_buf(int fd, int size) +{ + if ((num_in_buf = read(fd, sym_buf, size * SPACE)) == -1) + return (-1); + num_in_buf /= size; + next_entry = &(sym_buf[0]); + return (0); +} +#endif /* COFF_NLIST_SUPPORTED */ diff --git a/usr/src/ucblib/libucb/port/gen/psignal.c b/usr/src/ucblib/libucb/port/gen/psignal.c new file mode 100644 index 0000000000..d39c37b24e --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/psignal.c @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +/* + * Print the name of the signal indicated + * along with the supplied message. + */ + +#include <sys/types.h> +#include <stdio.h> +#include "libc.h" + +void +psignal(unsigned int sig, char *s) +{ + (void) fflush(stderr); + _psignal(sig, s); +} diff --git a/usr/src/ucblib/libucb/port/gen/rand.c b/usr/src/ucblib/libucb/port/gen/rand.c new file mode 100644 index 0000000000..b525f6ef67 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/rand.c @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <stdlib.h> + +static int randx = 1; + +void +srand(unsigned int x) +{ + randx = x; +} + +int +rand(void) +{ + return ((randx = randx * 1103515245 + 12345) & 0x7fffffff); +} diff --git a/usr/src/ucblib/libucb/port/gen/readdir.c b/usr/src/ucblib/libucb/port/gen/readdir.c new file mode 100644 index 0000000000..cf20c06f91 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/readdir.c @@ -0,0 +1,123 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +/* + * readdir -- C library extension routine + */ + +#include <sys/types.h> +#include <sys/dir.h> +#include <sys/dirent.h> +#include <limits.h> +#include <string.h> +#include <errno.h> +#include "libc.h" + +static struct direct dc; +static struct direct64 dc64; + +static struct direct64 * +internal_readdir(DIR *dirp) +{ + struct dirent64 *dp; /* -> directory data */ + int saveloc = 0; + + if (dirp->dd_size != 0) { + dp = (struct dirent64 *)&dirp->dd_buf[dirp->dd_loc]; + saveloc = dirp->dd_loc; /* save for possible EOF */ + dirp->dd_loc += dp->d_reclen; + } + if (dirp->dd_loc >= dirp->dd_size) + dirp->dd_loc = dirp->dd_size = 0; + + if (dirp->dd_size == 0 && /* refill buffer */ + (dirp->dd_size = getdents64(dirp->dd_fd, + (struct dirent64 *)dirp->dd_buf, DIRBUF)) <= 0) { + if (dirp->dd_size == 0) /* This means EOF */ + dirp->dd_loc = saveloc; /* EOF so save for telldir */ + return (NULL); /* error or EOF */ + } + + dp = (struct dirent64 *)&dirp->dd_buf[dirp->dd_loc]; + + /* Copy dirent into direct */ + dc64.d_ino = dp->d_ino; + dc64.d_reclen = dp->d_reclen; + dc64.d_namlen = (ushort_t)strlen(dp->d_name); + if (dc64.d_namlen > MAXNAMLEN) { + errno = ENAMETOOLONG; + return (NULL); + } + (void) strcpy(dc64.d_name, dp->d_name); + + return (&dc64); +} + +struct direct * +readdir(DIR *dirp) +{ + if (internal_readdir(dirp) == NULL) + return (NULL); + + /* Check for overflows */ + if (dc64.d_ino > SIZE_MAX) { + errno = EOVERFLOW; + return (NULL); + } + + /* Copy dirent into direct */ + dc.d_ino = dc64.d_ino; + dc.d_reclen = dc64.d_reclen - 4; + dc.d_namlen = dc64.d_namlen; + (void) strcpy(dc.d_name, dc64.d_name); + + return (&dc); +} + +#if !defined(_LP64) +struct direct64 * +readdir64(DIR *dirp) +{ + return (internal_readdir(dirp)); +} +#endif diff --git a/usr/src/ucblib/libucb/port/gen/regex.c b/usr/src/ucblib/libucb/port/gen/regex.c new file mode 100644 index 0000000000..bd00f45281 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/regex.c @@ -0,0 +1,454 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997, by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* Portions Copyright(c) 1988, Sun Microsystems Inc. */ +/* All Rights Reserved */ + +#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ + +/*LINTLIBRARY*/ + +/* + * routines to do regular expression matching + * + * Entry points: + * + * re_comp(s) + * char *s; + * ... returns 0 if the string s was compiled successfully, + * a pointer to an error message otherwise. + * If passed 0 or a null string returns without changing + * the currently compiled re (see note 11 below). + * + * re_exec(s) + * char *s; + * ... returns 1 if the string s matches the last compiled regular + * expression, + * 0 if the string s failed to match the last compiled + * regular expression, and + * -1 if the compiled regular expression was invalid + * (indicating an internal error). + * + * The strings passed to both re_comp and re_exec may have trailing or + * embedded newline characters; they are terminated by nulls. + * + * The identity of the author of these routines is lost in antiquity; + * this is essentially the same as the re code in the original V6 ed. + * + * The regular expressions recognized are described below. This description + * is essentially the same as that for ed. + * + * A regular expression specifies a set of strings of characters. + * A member of this set of strings is said to be matched by + * the regular expression. In the following specification for + * regular expressions the word `character' means any character but NUL. + * + * 1. Any character except a special character matches itself. + * Special characters are the regular expression delimiter plus + * \ [ . and sometimes ^ * $. + * 2. A . matches any character. + * 3. A \ followed by any character except a digit or ( ) + * matches that character. + * 4. A nonempty string s bracketed [s] (or [^s]) matches any + * character in (or not in) s. In s, \ has no special meaning, + * and ] may only appear as the first letter. A substring + * a-b, with a and b in ascending ASCII order, stands for + * the inclusive range of ASCII characters. + * 5. A regular expression of form 1-4 followed by * matches a + * sequence of 0 or more matches of the regular expression. + * 6. A regular expression, x, of form 1-8, bracketed \(x\) + * matches what x matches. + * 7. A \ followed by a digit n matches a copy of the string that the + * bracketed regular expression beginning with the nth \( matched. + * 8. A regular expression of form 1-8, x, followed by a regular + * expression of form 1-7, y matches a match for x followed by + * a match for y, with the x match being as long as possible + * while still permitting a y match. + * 9. A regular expression of form 1-8 preceded by ^ (or followed + * by $), is constrained to matches that begin at the left + * (or end at the right) end of a line. + * 10. A regular expression of form 1-9 picks out the longest among + * the leftmost matches in a line. + * 11. An empty regular expression stands for a copy of the last + * regular expression encountered. + */ + +#include <sys/types.h> +#include <stdlib.h> +#include <stddef.h> + +/* + * constants for re's + */ +#define CBRA 1 +#define CCHR 2 +#define CDOT 4 +#define CCL 6 +#define NCCL 8 +#define CDOL 10 +#define CEOF 11 +#define CKET 12 +#define CBACK 18 + +#define CSTAR 01 + +#define ESIZE 512 +#define NBRA 9 + +static struct re_globals { + char _expbuf[ESIZE]; + char *_braslist[NBRA], *_braelist[NBRA]; + char _circf; +} *re_globals; +#define expbuf (_re->_expbuf) +#define braslist (_re->_braslist) +#define braelist (_re->_braelist) +#define circf (_re->_circf) + +/* + * forward declarations + */ +static int backref(int, char *); +static int advance(char *, char *); +static int cclass(char *, char, int); + +/* + * compile the regular expression argument into a dfa + */ +char * +re_comp(char *sp) +{ + char c; + struct re_globals *_re = re_globals; + char *ep; + int cclcnt, numbra = 0; + char *lastep = 0; + char bracket[NBRA]; + char *bracketp = &bracket[0]; + char *retoolong = "Regular expression too long"; + + if (_re == 0) { + _re = (struct re_globals *)calloc(1, sizeof (*_re)); + if (_re == 0) + return ("Out of memory"); + re_globals = _re; + } + ep = expbuf; + +#define comerr(msg) {expbuf[0] = 0; return (msg); } + + if (sp == 0 || *sp == '\0') { + if (*ep == 0) + return ("No previous regular expression"); + return (0); + } + if (*sp == '^') { + circf = 1; + sp++; + } + else + circf = 0; + for (;;) { + if (ep >= &expbuf[ESIZE]) + comerr(retoolong); + if ((c = *sp++) == '\0') { + if (bracketp != bracket) + comerr("unmatched \\("); + *ep++ = CEOF; + *ep++ = 0; + return (0); + } + if (c != '*') + lastep = ep; + switch (c) { + + case '.': + *ep++ = CDOT; + continue; + + case '*': + if (lastep == 0 || *lastep == CBRA || *lastep == CKET) + goto defchar; + *lastep |= CSTAR; + continue; + + case '$': + if (*sp != '\0') + goto defchar; + *ep++ = CDOL; + continue; + + case '[': + *ep++ = CCL; + *ep++ = 0; + cclcnt = 1; + if ((c = *sp++) == '^') { + c = *sp++; + ep[-2] = NCCL; + } + do { + if (c == '\0') + comerr("missing ]"); + if (c == '-' && ep [-1] != 0) { + if ((c = *sp++) == ']') { + *ep++ = '-'; + cclcnt++; + break; + } + while (ep[-1] < c) { + *ep = ep[-1] + 1; + ep++; + cclcnt++; + if (ep >= &expbuf[ESIZE]) + comerr(retoolong); + } + } + *ep++ = c; + cclcnt++; + if (ep >= &expbuf[ESIZE]) + comerr(retoolong); + } while ((c = *sp++) != ']'); + lastep[1] = (char)cclcnt; + continue; + + case '\\': + if ((c = *sp++) == '(') { + if (numbra >= NBRA) + comerr("too many \\(\\) pairs"); + *bracketp++ = (char)numbra; + *ep++ = CBRA; + *ep++ = numbra++; + continue; + } + if (c == ')') { + if (bracketp <= bracket) + comerr("unmatched \\)"); + *ep++ = CKET; + *ep++ = *--bracketp; + continue; + } + if (c >= '1' && c < ('1' + NBRA)) { + *ep++ = CBACK; + *ep++ = c - '1'; + continue; + } + *ep++ = CCHR; + *ep++ = c; + continue; + + defchar: + default: + *ep++ = CCHR; + *ep++ = c; + } + } +} + +/* + * match the argument string against the compiled re + */ +int +re_exec(char *p1) +{ + struct re_globals *_re = re_globals; + char *p2; + int c; + int rv; + + if (_re == 0) + return (0); + p2 = expbuf; + for (c = 0; c < NBRA; c++) { + braslist[c] = 0; + braelist[c] = 0; + } + if (circf) + return ((advance(p1, p2))); + /* + * fast check for first character + */ + if (*p2 == CCHR) { + c = p2[1]; + do { + if (*p1 != c) + continue; + if (rv = advance(p1, p2)) + return (rv); + } while (*p1++); + return (0); + } + /* + * regular algorithm + */ + do + if (rv = advance(p1, p2)) + return (rv); + while (*p1++); + return (0); +} + +/* + * try to match the next thing in the dfa + */ +static int +advance(char *lp, char *ep) +{ + char *curlp; + int i; + ptrdiff_t ct; + int rv; + struct re_globals *_re = re_globals; + + for (;;) + switch (*ep++) { + + case CCHR: + if (*ep++ == *lp++) + continue; + return (0); + + case CDOT: + if (*lp++) + continue; + return (0); + + case CDOL: + if (*lp == '\0') + continue; + return (0); + + case CEOF: + return (1); + + case CCL: + if (cclass(ep, *lp++, 1)) { + ep += *ep; + continue; + } + return (0); + + case NCCL: + if (cclass(ep, *lp++, 0)) { + ep += *ep; + continue; + } + return (0); + + case CBRA: + braslist[*ep++] = lp; + continue; + + case CKET: + braelist[*ep++] = lp; + continue; + + case CBACK: + if (braelist[i = *ep++] == 0) + return (-1); + if (backref(i, lp)) { + lp += braelist[i] - braslist[i]; + continue; + } + return (0); + + case CBACK|CSTAR: + if (braelist[i = *ep++] == 0) + return (-1); + curlp = lp; + ct = braelist[i] - braslist[i]; + while (backref(i, lp)) + lp += ct; + while (lp >= curlp) { + if (rv = advance(lp, ep)) + return (rv); + lp -= ct; + } + continue; + + case CDOT|CSTAR: + curlp = lp; + while (*lp++) + ; + goto star; + + case CCHR|CSTAR: + curlp = lp; + while (*lp++ == *ep) + ; + ep++; + goto star; + + case CCL|CSTAR: + case NCCL|CSTAR: + curlp = lp; + while (cclass(ep, *lp++, ep[-1] == (CCL|CSTAR))) + ; + ep += *ep; + goto star; + + star: + do { + lp--; + if (rv = advance(lp, ep)) + return (rv); + } while (lp > curlp); + return (0); + + default: + return (-1); + } +} + +static int +backref(int i, char *lp) +{ + char *bp; + struct re_globals *_re = re_globals; + + bp = braslist[i]; + while (*bp++ == *lp++) + if (bp >= braelist[i]) + return (1); + return (0); +} + +static int +cclass(char *set, char c, int af) +{ + int n; + + if (c == 0) + return (0); + n = *set++; + while (--n) + if (*set++ == c) + return (af); + return (! af); +} diff --git a/usr/src/ucblib/libucb/port/gen/rindex.c b/usr/src/ucblib/libucb/port/gen/rindex.c new file mode 100644 index 0000000000..7a130563e7 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/rindex.c @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <strings.h> + +/* + * Return the ptr in sp at which the character c last + * appears; NULL if not found + */ + +char * +rindex(char *sp, char c) +{ + char *r; + + r = NULL; + do { + if (*sp == c) + r = sp; + } while (*sp++); + return (r); +} diff --git a/usr/src/ucblib/libucb/port/gen/scandir.c b/usr/src/ucblib/libucb/port/gen/scandir.c new file mode 100644 index 0000000000..1d36f5bad6 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/scandir.c @@ -0,0 +1,221 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +/* + * Scan the directory dirname calling select to make a list of selected + * directory entries then sort using qsort and compare routine dcomp. + * Returns the number of entries and a pointer to a list of pointers to + * struct direct (through namelist). Returns -1 if there were any errors. + */ + +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/dir.h> +#include <errno.h> +#include <limits.h> +#include <stdlib.h> +#include <string.h> + +/* + * The macro DIRSIZ(dp) gives an amount of space required to represent + * a directory entry. For any directory entry dp->d_reclen >= DIRSIZ(dp). + * Specific filesystem types may use this use this macro to construct the value + * for d_reclen. + */ +#undef DIRSIZ +#define DIRSIZ(dp) \ + ((sizeof (struct direct) - sizeof ((dp)->d_name) + \ + (strlen((dp)->d_name)+1) + 3) & ~3) + +#if !defined(_LP64) +int +scandir64(char *dirname, struct direct64 *(*namelist[]), + int (*select)(struct direct64 *), + int (*dcomp)(struct direct64 **, struct direct64 **)) +{ + struct direct64 *d, *p, **names; + int nitems; + char *cp1, *cp2; + struct stat64 stb; + long arraysz; + DIR *dirp; + + if ((dirp = opendir(dirname)) == NULL) + return (-1); + if (fstat64(dirp->dd_fd, &stb) < 0) + return (-1); + + /* + * estimate the array size by taking the size of the directory file + * and dividing it by a multiple of the minimum size entry. + */ + arraysz = (stb.st_size / 24); + names = (struct direct64 **)malloc(arraysz * + sizeof (struct direct64 *)); + if (names == NULL) + return (-1); + + nitems = 0; + while ((d = readdir64(dirp)) != NULL) { + if (select != NULL && !(*select)(d)) + continue; /* just selected names */ + /* + * Make a minimum size copy of the data + */ + p = (struct direct64 *)malloc(DIRSIZ64(d)); + if (p == NULL) + return (-1); + p->d_ino = d->d_ino; + p->d_reclen = d->d_reclen; + p->d_namlen = d->d_namlen; + for (cp1 = p->d_name, cp2 = d->d_name; *cp1++ = *cp2++; ) + ; + /* + * Check to make sure the array has space left and + * realloc the maximum size. + */ + if (++nitems >= arraysz) { + if (fstat64(dirp->dd_fd, &stb) < 0) + return (-1); /* just might have grown */ + arraysz = stb.st_size / 12; + names = (struct direct64 **)realloc((char *)names, + arraysz * sizeof (struct direct64 *)); + if (names == NULL) + return (-1); + } + names[nitems-1] = p; + } + (void) closedir(dirp); + if (nitems && dcomp != NULL) + qsort(names, nitems, sizeof (struct direct64 *), + (int(*)(const void *, const void *)) dcomp); + *namelist = names; + return (nitems); +} +#endif + + +int +scandir(char *dirname, struct direct *(*namelist[]), + int (*select)(struct direct *), + int (*dcomp)(struct direct **, struct direct **)) +{ + struct direct *d, *p, **names; + int nitems; + char *cp1, *cp2; + struct stat64 stb; + long arraysz; + DIR *dirp; + + if ((dirp = opendir(dirname)) == NULL) + return (-1); + if (fstat64(dirp->dd_fd, &stb) < 0) + return (-1); + /* + * estimate the array size by taking the size of the directory file + * and dividing it by a multiple of the minimum size entry. + */ + if (stb.st_size > SSIZE_MAX) { + errno = EOVERFLOW; + return (-1); + } + arraysz = (stb.st_size / 24); + + names = (struct direct **)malloc(arraysz * sizeof (struct direct *)); + if (names == NULL) + return (-1); + + nitems = 0; + while ((d = readdir(dirp)) != NULL) { + if (select != NULL && !(*select)(d)) + continue; /* just selected names */ + /* + * Make a minimum size copy of the data + */ + p = (struct direct *)malloc(DIRSIZ(d)); + if (p == NULL) + return (-1); + p->d_ino = d->d_ino; + p->d_reclen = d->d_reclen; + p->d_namlen = d->d_namlen; + for (cp1 = p->d_name, cp2 = d->d_name; *cp1++ = *cp2++; ) + ; + /* + * Check to make sure the array has space left and + * realloc the maximum size. + */ + if (++nitems >= arraysz) { + if (fstat64(dirp->dd_fd, &stb) < 0) + return (-1); /* just might have grown */ + arraysz = stb.st_size / 12; + names = (struct direct **)realloc((char *)names, + arraysz * sizeof (struct direct *)); + if (names == NULL) + return (-1); + } + names[nitems-1] = p; + } + (void) closedir(dirp); + if (nitems && dcomp != NULL) + qsort(names, nitems, sizeof (struct direct *), + (int(*)(const void *, const void *)) dcomp); + *namelist = names; + return (nitems); +} + +/* + * Alphabetic order comparison routine for those who want it. + */ +int +alphasort(struct direct **d1, struct direct **d2) +{ + return (strcmp((*d1)->d_name, (*d2)->d_name)); +} + +#if !defined(_LP64) +int +alphasort64(struct direct64 **d1, struct direct64 **d2) +{ + return (strcmp((*d1)->d_name, (*d2)->d_name)); +} +#endif diff --git a/usr/src/ucblib/libucb/port/gen/setbuffer.c b/usr/src/ucblib/libucb/port/gen/setbuffer.c new file mode 100644 index 0000000000..65983dca4b --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/setbuffer.c @@ -0,0 +1,110 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include "file64.h" +#include <stdio.h> +#include "stdiom.h" +#include <stdlib.h> + +extern Uchar _smbuf[][_NFILE]; + +void +setbuffer(FILE *iop, char *abuf, int asize) +{ + Uchar *buf = (Uchar *)abuf; + int fno = iop->_file; /* file number */ + int size = asize - _SMBFSZ; + Uchar *temp; + + if (iop->_base != 0 && iop->_flag & _IOMYBUF) + free((char *)iop->_base - PUSHBACK); + iop->_flag &= ~(_IOMYBUF | _IONBF | _IOLBF); + if (buf == 0) { + iop->_flag |= _IONBF; +#ifndef _STDIO_ALLOCATE + if (fno < 2) { + /* use special buffer for std{in,out} */ + buf = (fno == 0) ? _sibuf : _sobuf; + size = BUFSIZ - _SMBFSZ; + } else /* needed for ifdef */ +#endif + if (fno < _NFILE) { + buf = _smbuf[fno]; + size = _SMBFSZ - PUSHBACK; + } else if ((buf = (Uchar *)malloc(_SMBFSZ * sizeof (Uchar))) != + 0) { + iop->_flag |= _IOMYBUF; + size = _SMBFSZ - PUSHBACK; + } + } else /* regular buffered I/O, specified buffer size */ { + if (size <= 0) + return; + } + if (buf == 0) + return; /* malloc() failed */ + temp = buf + PUSHBACK; + iop->_base = temp; + _setbufend(iop, temp + size); + iop->_ptr = temp; + iop->_cnt = 0; +} + +/* + * set line buffering + */ + +int +setlinebuf(FILE *iop) +{ + char *buf; + + (void) fflush(iop); + setbuffer(iop, (char *)NULL, 0); + buf = (char *)malloc(128); + if (buf != NULL) { + setbuffer(iop, buf, 128); + iop->_flag |= _IOLBF|_IOMYBUF; + } + return (0); /* returns no useful value, keep the same prototype */ +} diff --git a/usr/src/ucblib/libucb/port/gen/siglist.c b/usr/src/ucblib/libucb/port/gen/siglist.c new file mode 100644 index 0000000000..69b2d88fa8 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/siglist.c @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <signal.h> +#include "libc.h" + +#ifndef NSIG +#define NSIG 32 +#endif + +char *sys_siglist[NSIG] = { + "Signal 0", + "Hangup", /* SIGHUP */ + "Interrupt", /* SIGINT */ + "Quit", /* SIGQUIT */ + "Illegal instruction", /* SIGILL */ + "Trace/BPT trap", /* SIGTRAP */ + "Abort", /* SIGABRT */ + "Emulator trap", /* SIGEMT */ + "Arithmetic exception", /* SIGFPE */ + "Killed", /* SIGKILL */ + "Bus error", /* SIGBUS */ + "Segmentation fault", /* SIGSEGV */ + "Bad system call", /* SIGSYS */ + "Broken pipe", /* SIGPIPE */ + "Alarm clock", /* SIGALRM */ + "Terminated", /* SIGTERM */ + "User defined signal 1", /* SIGUSR1 */ + "User defined signal 2", /* SIGUSR2 */ + "Child status change", /* SIGCLD */ + "Power-fail restart", /* SIGPWR */ + "Window changed", /* SIGWINCH */ + "Handset, line status change", /* SIGURG */ + "Pollable event occurred", /* SIGPOLL */ + "Stopped (signal)", /* SIGSTOP */ + "Stopped", /* SIGTSTP */ + "Continued", /* SIGCONT */ + "Stopped (tty input)", /* SIGTTIN */ + "Stopped (tty output)", /* SIGTTOU */ + "Virtual timer expired", /* SIGVTALRM */ + "Profiling timer expired", /* SIGPROF */ + "Cputime limit exceeded", /* SIGXCPU */ + "Filesize limit exceeded", /* SIGXFSZ */ + "No runnable lwp", /* SIGWAITING */ + "Inter-lwp signal", /* SIGLWP */ +}; diff --git a/usr/src/ucblib/libucb/port/gen/statfs.c b/usr/src/ucblib/libucb/port/gen/statfs.c new file mode 100644 index 0000000000..a53e34e275 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/statfs.c @@ -0,0 +1,108 @@ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * Copyright (c) 1988-1997, by Sun Microsystems, Inc. + * All Rights reserved. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <errno.h> +#include <sys/statvfs.h> +#include <sys/vfs.h> + +#if !defined(_LP64) +static void +cnvtvfs64(struct statfs64 *buf, struct statvfs64 *vbuf) +{ + buf->f_type = 0; + buf->f_bsize = vbuf->f_frsize; + buf->f_blocks = vbuf->f_blocks; + buf->f_bfree = vbuf->f_bfree; + buf->f_bavail = vbuf->f_bavail; + buf->f_files = vbuf->f_files; + buf->f_ffree = vbuf->f_ffree; + buf->f_fsid.val[0] = vbuf->f_fsid; + buf->f_fsid.val[1] = 0; +} + +int +statfs64(char *path, struct statfs64 *buf) +{ + int ret; + struct statvfs64 vbuf; + + if ((long)buf == -1L) { + errno = EFAULT; + return (-1); + } + + if ((ret = statvfs64(path, &vbuf)) != -1) + cnvtvfs64(buf, &vbuf); + return (ret); +} + +int +fstatfs64(int fd, struct statfs64 *buf) +{ + int ret; + struct statvfs64 vbuf; + + if ((ret = fstatvfs64(fd, &vbuf)) != -1) + cnvtvfs64(buf, &vbuf); + return (ret); +} +#endif + +static void +cnvtvfs(struct statfs *buf, struct statvfs *vbuf) +{ + buf->f_type = 0; + buf->f_bsize = vbuf->f_frsize; + buf->f_blocks = vbuf->f_blocks; + buf->f_bfree = vbuf->f_bfree; + buf->f_bavail = vbuf->f_bavail; + buf->f_files = vbuf->f_files; + buf->f_ffree = vbuf->f_ffree; + buf->f_fsid.val[0] = vbuf->f_fsid; + buf->f_fsid.val[1] = 0; +} + +int +statfs(char *path, struct statfs *buf) +{ + int ret; + struct statvfs vbuf; + + if ((long)buf == -1L) { + errno = EFAULT; + return (-1); + } + + if ((ret = statvfs(path, &vbuf)) != -1) + cnvtvfs(buf, &vbuf); + return (ret); +} + + +int +fstatfs(int fd, struct statfs *buf) +{ + int ret; + struct statvfs vbuf; + + if ((ret = fstatvfs(fd, &vbuf)) != -1) + cnvtvfs(buf, &vbuf); + return (ret); +} diff --git a/usr/src/ucblib/libucb/port/gen/synonyms.h b/usr/src/ucblib/libucb/port/gen/synonyms.h new file mode 100644 index 0000000000..4b1c33503b --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/synonyms.h @@ -0,0 +1,444 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#ifndef _UCBLIB_SYNONYMS_H +#define _UCBLIB_SYNONYMS_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__STDC__) + +/* external data */ +#define altzone _altzone +#define daylight _daylight +#define lone _lone +#define lten _lten +#define lzero _lzero +#define timezone _timezone +#define tzname _tzname + +/* functions */ +#define Msgdb _Msgdb +#define a64l _a64l +#define access _access +#define acct _acct +#define addseverity _addseverity +#define adjtime _adjtime +#define alarm _alarm +#define ascftime _ascftime +#define brk _brk +#define brkbase _brkbase +#define catclose _catclose +#define catgets _catgets +#define catopen _catopen +#define cfgetispeed _cfgetispeed +#define cfgetospeed _cfgetospeed +#define cfree _cfree +#define cfsetispeed _cfsetispeed +#define cfsetospeed _cfsetospeed +#define cftime _cftime +#define chdir _chdir +#define chmod _chmod +#define chown _chown +#define chroot _chroot +#define close _close +#define closedir _closedir +#define closelog _closelog +#define countbase _countbase +#define creat _creat +#define crypt _crypt +#define ctermid _ctermid +#define cuserid _cuserid +#define dial _dial +#define drand48 _drand48 +#define dup _dup +#define dup2 _dup2 +#define ecvt _ecvt +#define edata _edata +#define encrypt _encrypt +#define end _end +#define endgrent _endgrent +#define endpwent _endpwent +#define endspent _endspent +#define endutent _endutent +#define endutxent _endutxent +#define environ _environ +#define erand48 _erand48 +#define etext _etext +#define execl _execl +#define execle _execle +#define execlp _execlp +#define execv _execv +#define execve _execve +#define execvp _execvp +#define exportfs _exportfs +#define fattach _fattach +#define fchdir _fchdir +#define fchmod _fchmod +#define fchown _fchown +#define fcntl _fcntl +#define fcvt _fcvt +#define fdetach _fdetach +#define fdopen _fdopen +#define ffs _ffs +#define fgetgrent _fgetgrent +#define fgetpwent _fgetpwent +#define fgetspent _fgetspent +#define finite _finite +#define fmount _fmount +#define fmtmsg _fmtmsg +#define fork _fork +#define fpathconf _fpathconf +#define fpclass _fpclass +#define fpgetmask _fpgetmask +#define fpgetround _fpgetround +#define fpgetsticky _fpgetsticky +#define fpsetmask _fpsetmask +#define fpsetround _fpsetround +#define fpsetsticky _fpsetsticky +#define fptrap _fptrap +#define fstat _fstat +#define fstatvfs _fstatvfs +#define fsync _fsync +#define ftok _ftok +#define ftruncate _ftruncate +#define ftw _ftw +#define funmount _funmount +#define gcvt _gcvt +#define getcontext _getcontext +#define getcwd _getcwd +#define getdate _getdate +#define getdate_err _getdate_err +#define getdents _getdents +#define getegid _getegid +#define geteuid _geteuid +#define getgid _getgid +#define getgrent _getgrent +#define getgrgid _getgrgid +#define getgrnam _getgrnam +#define getgroups _getgroups +#define gethz _gethz +#define getitimer _getitimer +#define getlogin _getlogin +#define getmntany _getmntany +#define getmntent _getmntent +#define getmsg _getmsg +#define getopt _getopt +#define getpass _getpass +#define getpgid _getpgid +#define getpgrp _getpgrp +#define getpid _getpid +#define getpmsg _getpmsg +#define getppid _getppid +#define getpw _getpw +#define getpwent _getpwent +#define getpwnam _getpwnam +#define getpwuid _getpwuid +#define getrlimit _getrlimit +#define getsid _getsid +#define getspent _getspent +#define getspnam _getspnam +#define getsubopt _getsubopt +#define gettimeofday _gettimeofday +#define gettxt _gettxt +#define getuid _getuid +#define getutent _getutent +#define getutid _getutid +#define getutline _getutline +#define getutmp _getutmp +#define getutmpx _getutmpx +#define getutxent _getutxent +#define getutxid _getutxid +#define getutxline _getutxline +#define getvfsany _getvfsany +#define getvfsent _getvfsent +#define getvfsfile _getvfsfile +#define getvfsspec _getvfsspec +#define getw _getw +#define grantpt _grantpt +#define gsignal _gsignal +#define gtty _gtty +#define hcreate _hcreate +#define hdestroy _hdestroy +#define hsearch _hsearch +#define id2str _id2str +#define initgroups _initgroups +#define insque _insque +#define ioctl _ioctl +#define isastream _isastream +#define isatty _isatty +#define jrand48 _jrand48 +#define kill _kill +#define l3tol _l3tol +#define l64a _l64a +#define ladd _ladd +#define lchown _lchown +#define lckpwdf _lckpwdf +#define lcong48 _lcong48 +#define ldivide _ldivide +#define lexp10 _lexp10 +#define lfind _lfind +#define link _link +#define llog10 _llog10 +#define lmul _lmul +#define lockf _lockf +#define lrand48 _lrand48 +#define lsearch _lsearch +#define lseek _lseek +#define lshiftl _lshiftl +#define lsign _lsign +#define lstat _lstat +#define lsub _lsub +#define ltol3 _ltol3 +#define makecontext _makecontext +#define makeut _makeut +#define makeutx _makeutx +#define memalign _memalign +#define memccpy _memccpy +#define memcntl _memcntl +#define mincore _mincore +#define mkdir _mkdir +#define mkfifo _mkfifo +#define mktemp _mktemp +#define mlock _mlock +#define mlockall _mlockall +#define mmap _mmap +#define modut _modut +#define modutx _modutx +#define monitor _monitor +#define mount _mount +#define mprotect _mprotect +#define mrand48 _mrand48 +#define msgctl _msgctl +#define msgget _msgget +#define msgrcv _msgrcv +#define msgsnd _msgsnd +#define msync _msync +#define munlock _munlock +#define munlockall _munlockall +#define munmap _munmap +#define nfs_getfh _nfs_getfh +#define nfssvc _nfssvc +#define nftw _nftw +#define nice _nice +#define nl_langinfo _nl_langinfo +#define nrand48 _nrand48 +#define nuname _nuname +#define open _open +#define opendir _opendir +#define openlog _openlog +#define pathconf _pathconf +#define pause _pause +#define pclose _pclose +#define pipe _pipe +#define plock _plock +#define poll _poll +#define popen _popen +#define profil _profil +#define psiginfo _psiginfo +#define psignal _psignal +#define ptrace _ptrace +#define ptsname _ptsname +#define putenv _putenv +#define putmsg _putmsg +#define putpmsg _putpmsg +#define putpwent _putpwent +#define putspent _putspent +#define pututline _pututline +#define pututxline _pututxline +#define putw _putw +#define read _read +#define readdir _readdir +#define readlink _readlink +#define readv _readv +#define realpath _realpath +#define remque _remque +#define rmdir _rmdir +#define sbrk _sbrk +#define seed48 _seed48 +#define seekdir _seekdir +#define select _select +#define semctl _semctl +#define semget _semget +#define semop _semop +#define setchrclass _setchrclass +#define setcontext _setcontext +#define setegid _setegid +#define seteuid _seteuid +#define setgid _setgid +#define setgrent _setgrent +#define setgroups _setgroups +#define setitimer _setitimer +#define setkey _setkey +#define setlogmask _setlogmask +#define setpgid _setpgid +#define setpgrp _setpgrp +#define setpwent _setpwent +#define setrlimit _setrlimit +#define setsid _setsid +#define setspent _setspent +#define settimeofday _settimeofday +#define setuid _setuid +#define setutent _setutent +#define setutxent _setutxent +#define shmat _shmat +#define shmctl _shmctl +#define shmdt _shmdt +#define shmget _shmget +#define sig2str _sig2str +#define sigaction _sigaction +#define sigaddset _sigaddset +#define sigaltstack _sigaltstack +#define sigdelset _sigdelset +#define sigemptyset _sigemptyset +#define sigfillset _sigfillset +#define sigflag _sigflag +#define sighold _sighold +#define sigignore _sigignore +#define sigismember _sigismember +#define siglongjmp _siglongjmp +#define sigpause _sigpause +#define sigpending _sigpending +#define sigprocmask _sigprocmask +#define sigrelse _sigrelse +#define sigsend _sigsend +#define sigsendset _sigsendset +#define sigset _sigset +#define sigsetjmp _sigsetjmp +#define sigsuspend _sigsuspend +#define sleep _sleep +#define srand48 _srand48 +#define ssignal _ssignal +#define stat _stat +#define statfs _statfs +#define statvfs _statvfs +#define stime _stime +#define str2id _str2id +#define str2sig _str2sig +#define strdup _strdup +#define stty _stty +#define swab _swab +#define swapcontext _swapcontext +#define swapctl _swapctl +#define symlink _symlink +#define sync _sync +#define synchutmp _synchutmp +#define sys3b _sys3b +#define sysi86 _sysi86 +#define sys_errlist _sys_errlist +#define sys_nerr _sys_nerr +#define sysconf _sysconf +#define sysfs _sysfs +#define sysinfo _sysinfo +#define syslog _syslog +#define tcdrain _tcdrain +#define tcflow _tcflow +#define tcflush _tcflush +#define tcgetattr _tcgetattr +#define tcgetpgrp _tcgetpgrp +#define tcgetsid _tcgetsid +#define tcsendbreak _tcsendbreak +#define tcsetattr _tcsetattr +#define tcsetpgrp _tcsetpgrp +#define tdelete _tdelete +#define tell _tell +#define telldir _telldir +#define tempnam _tempnam +#define tfind _tfind +#define truncate _truncate +#define tsearch _tsearch +#define ttyname _ttyname +#define ttyslot _ttyslot +#define twalk _twalk +#define tzname _tzname +#define tzset _tzset +#define uadmin _uadmin +#define ulckpwdf _ulckpwdf +#define ulimit _ulimit +#define umask _umask +#define umount _umount +#define uname _uname +#define undial _undial +#define unlink _unlink +#define unlockpt _unlockpt +#define unordered _unordered +#define updutfile _updutfile +#define updutxfile _updutxfile +#define updutmp _updutmp +#define updutmpx _updutmpx +#define updwtmp _updwtmp +#define updwtmpx _updwtmpx +#define utime _utime +#define utmpname _utmpname +#define utmpxname _utmpxname +#define utssys _utssys +#define valloc _valloc +#define vfork _vfork +#define vsyslog _vsyslog +#define wait _wait +#define waitid _waitid +#define waitpid _waitpid +#define write _write +#define writev _writev +#define _assert __assert +#define _ctype __ctype +#define _filbuf __filbuf +#define _flsbuf __flsbuf +#define _iob __iob + +#else /* not __STDC__ */ + +#define const + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _UCBLIB_SYNONYMS_H */ diff --git a/usr/src/ucblib/libucb/port/gen/times.c b/usr/src/ucblib/libucb/port/gen/times.c new file mode 100644 index 0000000000..2459428e48 --- /dev/null +++ b/usr/src/ucblib/libucb/port/gen/times.c @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/times.h> +#include "libc.h" + +/* + * Backwards compatible times. + * BSD times() returns 0 if successful, vs sys5's times() + * whih returns the elapsed real times in ticks. + */ + +/* + * This is defined in sys/_times.s + * This extern cannot be in libc.h due to name conflict with synonyms.h + */ +extern int _times(struct tms *); + +clock_t +times(struct tms *tmsp) +{ + int error; + + errno = 0; + if (!tmsp) { + errno = EFAULT; + return (-1); + } + + error = _times(tmsp); + return (error == -1 ? error : 0); +} diff --git a/usr/src/ucblib/libucb/port/llib-lucb b/usr/src/ucblib/libucb/port/llib-lucb new file mode 100644 index 0000000000..d1f187baab --- /dev/null +++ b/usr/src/ucblib/libucb/port/llib-lucb @@ -0,0 +1,250 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* LINTLIBRARY */ +/* PROTOLIB1 */ + +#include <sys/time.h> +#include <varargs.h> +#include <stdio.h> +#include <sys/types.h> +#include <errno.h> +#include <sys/syscall.h> +#include <sys/siginfo.h> +#include <sys/ucontext.h> +#include <signal.h> +#include <ucontext.h> +#include <setjmp.h> +#include <sys/resource.h> +#include <sys/utsname.h> +#include <sys/systeminfo.h> +#include <sys/errno.h> +#include <unistd.h> +#include <sys/mman.h> +#include <sys/uadmin.h> +#include <sys/times.h> +#include <wait.h> +#include <sys/procset.h> +#include <sys/param.h> +#include <values.h> +#include <ctype.h> +#include <nan.h> +#include <memory.h> +#include <string.h> +#include <locale.h> +#include <fcntl.h> +#include <nlist.h> +#include <sys/dir.h> +#include <sys/stat.h> +#include <sys/priocntl.h> +#include <sys/file.h> +#include <sys/fcntl.h> +#include <sys/statvfs.h> +#include <sys/vfs.h> + +#include <sys/timeb.h> + +/* port/sys/gettimeofday.c */ +int gettimeofday(struct timeval *, void *); +int settimeofday(struct timeval *, void *); + +/* port/sys/signal.c */ +int _sigvechandler(int, siginfo_t *, ucontext_t *); +int _sigsetmask(int); +int ucbsigsetmask(int); +int _sigblock(int); +int ucbsigblock(int); +int usigpause(int); +int ucbsigpause(int); +int _sigvec(int, struct sigvec *, struct sigvec *); +int ucbsigvec(int, struct sigvec *, struct sigvec *); +int _sigstack(struct sigstack *, struct sigstack *); +void ucbsignal(int, void (*)()); +void usignal(int, void (*)()); +int _siginterrupt(int, int); +int ucbsiginterrupt(int, int); +#ifdef sparc +void __sigcleanup(struct sigcontext *); +#endif + +/* port/sys/flock.c */ +int flock(int, int); + +/* port/sys/getdtblsize.c */ +int getdtablesize(void); + +/* port/sys/gethostid.c */ +long gethostid(void); + +/* port/sys/gethostname.c */ +int gethostname(char *, int); +int sethostname(char *, int); + +/* port/sys/getpagesize.c */ +int getpagesize(void); + +/* port/sys/killpg.c */ +int killpg(int, int); + +/* port/sys/mctl.c */ +int mctl(caddr_t, size_t, int, int); + +/* port/sys/reboot.c */ +int reboot(int, char *); + +/* port/sys/setreid.c */ +int setreuid(int, int); +int setregid(int, int); + +/* port/sys/wait3.c */ +int wait3(int *, int, struct rusage *); +int wstat(int, int); + +/* port/sys/wait4.c */ +int wait4(pid_t, int *, int, struct rusage *); + +/* port/sys/getrusage.c */ +int getrusage(int, struct rusage *); + +/* port/sys/setpgrp.c */ +int setpgrp(pid_t, pid_t); + +/* port/stdio/sprintf.c */ +char *sprintf(const char *, const char *, ...); + +/* port/stdio/doprnt.c */ +int _doprnt(char *, va_list, FILE *); +/* void _mkarglst(char *, stva_list args, stva_list arglst[]); */ +/* void _getarg(char *, stva_list *, int); */ + + + + +/* port/stdio/fopen.c */ +FILE *fopen(const char *, const char *); +FILE *fopen64(const char *, const char *); +FILE *freopen(const char *, const char *, FILE *); +FILE *freopen64(const char *, const char *, FILE *); + +/* port/stdio/fprintf.c */ +int fprintf(FILE *, const char *, ...); + +/* port/stdio/printf.c */ +/* VARARGS1 */ +int printf(const char *, ...); + +/* port/stdio/vfprintf.c */ +/* VARARGS2 */ +int vfprintf(FILE *, const char *, va_list); + +/* port/stdio/vprintf.c */ +/* VARARGS1 */ +int vprintf(const char *, va_list); + +/* port/stdio/vsprintf.c */ +/* VARARGS2 */ +char *vsprintf(char *, char *, va_list); + +/* port/gen/nlist.c */ +int nlist(const char *, struct nlist *); + +/* port/gen/setpriority.c */ +int getpriority(int, int); +int setpriority(int, int, int); + +/* port/gen/siglist.c */ + +/* port/gen/_psignal.c */ +void _psignal(unsigned, char *); + +/* port/gen/bcmp.c */ +int bcmp(char *, char *, int); + +/* port/gen/bcopy.c */ +void bcopy(char *, char *, int); + +/* port/gen/bzero.c */ +void bzero(char *, int); + +/* port/gen/ftime.c */ +int ftime(struct timeb *); + +/* port/gen/getusershell.c */ +char *getusershell(void); +int endusershell(void); +int setusershell(void); + +/* port/gen/getwd.c */ +char *getwd(char *); + +/* port/gen/index.c */ +char *index(char *, char); + +/* port/gen/mkstemp.c */ +int mkstemp(char *); + +/* port/gen/nice.c */ +int nice(int); + +/* port/gen/psignal.c */ +void psignal(unsigned, char *); + +/* port/gen/rand.c */ +int srand(unsigned); +int rand(void); + +/* port/gen/random.c */ +int srandom(unsigned); +char *initstate(unsigned, char *, int); +char *setstate(char *); +long random(void); + +/* port/gen/regex.c */ +char *re_comp(char *); +int re_exec(char *); + +/* port/gen/rindex.c */ +char *rindex(char *, char); + +/* port/gen/setbuffer.c */ +void setbuffer(FILE *, char *, int); +int setlinebuf(FILE *); + +/* port/gen/statfs.c */ +int statfs(char *, struct statfs *); +int fstatfs(int, struct statfs *); +int cnvtvfs(struct statfs *, struct statvfs *); + +/* port/gen/times.c */ +clock_t times(struct tms *); + +/* port/gen/ualarm.c */ +unsigned ualarm(unsigned, unsigned); + +/* port/gen/usleep.c */ +int usleep(unsigned); diff --git a/usr/src/ucblib/libucb/port/stdio/_locale.h b/usr/src/ucblib/libucb/port/stdio/_locale.h new file mode 100644 index 0000000000..ecf18a7e93 --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/_locale.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997, by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ + +#define LC_NAMELEN 15 /* maximum part name length (inc. \0) */ +#define SZ_CTYPE (257 + 257) /* is* and to{upp,low}er tables */ +#define SZ_CODESET 7 /* bytes for codeset information */ +#define SZ_NUMERIC 2 /* bytes for numeric editing */ +#define SZ_TOTAL (SZ_CTYPE + SZ_CODESET) +#define NM_UNITS 0 /* index of decimal point character */ +#define NM_THOUS 1 /* index of thousand's sep. character */ + +extern char _cur_locale[LC_ALL][LC_NAMELEN]; +extern unsigned char __ctype[SZ_TOTAL]; +extern unsigned char _numeric[SZ_NUMERIC]; + +char *_nativeloc(int); /* trunc. name for category's "" locale */ +char *_fullocale(const char *, const char *); /* complete path */ +int _set_tab(const char *, int); /* fill __ctype[] or _numeric[] */ diff --git a/usr/src/ucblib/libucb/port/stdio/doprnt.c b/usr/src/ucblib/libucb/port/stdio/doprnt.c new file mode 100644 index 0000000000..0f95dca946 --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/doprnt.c @@ -0,0 +1,1305 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +/* + * _doprnt: common code for printf, fprintf, sprintf + */ + +#include "../gen/synonyms.h" +#include <sys/types.h> +#include "file64.h" +#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> +#include <stdarg.h> +#include <values.h> +#include <nan.h> +#include <memory.h> +#include <string.h> +#include "print.h" /* parameters & macros for doprnt */ +#include "stdiom.h" +#include <locale.h> +#include <stddef.h> +#include "_locale.h" +#include "libc.h" + +#define PUT(p, n) { unsigned char *newbufptr; \ + if ((newbufptr = bufptr + (n)) > bufferend) { \ + _dowrite((p), (n), iop, &bufptr); \ + } else { \ + (void) memcpy(bufptr, (p), (n)); \ + bufptr = newbufptr; \ + } \ + } +#define PAD(s, n) { int nn; \ + for (nn = (n); nn > 20; nn -= 20) \ + _dowrite((s), 20, iop, &bufptr); \ + PUT((s), nn); \ + } + +#define SNLEN 5 /* Length of string used when printing a NaN */ + +/* bit positions for flags used in doprnt */ + +#define LENGTH 1 /* l */ +#define FPLUS 2 /* + */ +#define FMINUS 4 /* - */ +#define FBLANK 8 /* blank */ +#define FSHARP 16 /* # */ +#define PADZERO 32 /* padding zeroes requested via '0' */ +#define DOTSEEN 64 /* dot appeared in format specification */ +#define SUFFIX 128 /* a suffix is to appear in the output */ +#define RZERO 256 /* there will be trailing zeros in output */ +#define LZERO 512 /* there will be leading zeroes in output */ +#define SHORT 1024 /* h */ + +/* + * Positional Parameter information + */ +#define MAXARGS 30 /* max. number of args for fast positional paramters */ + +/* + * stva_list is used to subvert C's restriction that a variable with an + * array type can not appear on the left hand side of an assignment operator. + * By putting the array inside a structure, the functionality of assigning to + * the whole array through a simple assignment is achieved.. + */ +typedef struct stva_list { + va_list ap; +} stva_list; + +static char _blanks[] = " "; +static char _zeroes[] = "00000000000000000000"; +static char uc_digs[] = "0123456789ABCDEF"; +static char lc_digs[] = "0123456789abcdef"; +static char lc_nan[] = "nan0x"; +static char uc_nan[] = "NAN0X"; +static char lc_inf[] = "inf"; +static char uc_inf[] = "INF"; + +/* + * forward declarations + */ +void _mkarglst(char *, stva_list, stva_list []); +void _getarg(char *, stva_list *, int); +static int _lowdigit(long *); +static void _dowrite(char *, ssize_t, FILE *, unsigned char **); + +static int +_lowdigit(long *valptr) +{ /* This function computes the decimal low-order digit of the number */ + /* pointed to by valptr, and returns this digit after dividing */ + /* *valptr by ten. This function is called ONLY to compute the */ + /* low-order digit of a long whose high-order bit is set. */ + + int lowbit = (int)(*valptr & 1); + long value = (*valptr >> 1) & ~HIBITL; + + *valptr = value / 5; + return ((int)(value % 5 * 2 + lowbit + '0')); +} + +/* The function _dowrite carries out buffer pointer bookkeeping surrounding */ +/* a call to fwrite. It is called only when the end of the file output */ +/* buffer is approached or in other unusual situations. */ +static void +_dowrite(char *p, ssize_t n, FILE *iop, unsigned char **ptrptr) +{ + if (!(iop->_flag & _IOREAD)) { + iop->_cnt -= (*ptrptr - iop->_ptr); + iop->_ptr = *ptrptr; + _bufsync(iop, _bufend(iop)); + (void) fwrite(p, 1, n, iop); + *ptrptr = iop->_ptr; + } else + *ptrptr = (unsigned char *) memcpy(*ptrptr, p, n) + n; +} + +int +_doprnt(char *format, va_list in_args, FILE *iop) +{ + + /* bufptr is used inside of doprnt instead of iop->_ptr; */ + /* bufferend is a copy of _bufend(iop), if it exists. For */ + /* dummy file descriptors (iop->_flag & _IOREAD), bufferend */ + /* may be meaningless. Dummy file descriptors are used so that */ + /* sprintf and vsprintf may share the _doprnt routine with the */ + /* rest of the printf family. */ + + unsigned char *bufptr; + unsigned char *bufferend; + + /* This variable counts output characters. */ + int count = 0; + + /* Starting and ending points for value to be printed */ + char *bp; + char *p; + + /* Field width and precision */ + int width, prec; + + /* Format code */ + int fcode; + + /* Number of padding zeroes required on the left and right */ + int lzero, rzero; + + /* Flags - bit positions defined by LENGTH, FPLUS, FMINUS, FBLANK, */ + /* and FSHARP are set if corresponding character is in format */ + /* Bit position defined by PADZERO means extra space in the field */ + /* should be padded with leading zeroes rather than with blanks */ + int flagword; + + /* Values are developed in this buffer */ + char buf[max(MAXDIGS, 1+max(MAXFCVT+MAXEXP, MAXECVT))]; + + /* Pointer to sign, "0x", "0X", or empty */ + char *prefix; + + /* Exponent or empty */ + char *suffix; + + /* Buffer to create exponent */ + char expbuf[MAXESIZ + 1]; + + /* Length of prefix and of suffix */ + int prefixlength, suffixlength; + + /* Combined length of leading zeroes, trailing zeroes, and suffix */ + int otherlength; + + /* The value being converted, if integer */ + long val; + + /* The value being converted, if real */ + double dval; + + /* Output values from fcvt and ecvt */ + int decpt, sign; + + /* Pointer to a translate table for digits of whatever radix */ + char *tab; + + /* Work variables */ + int k, lradix, mradix; + + /* Variables used to flag an infinities and nans, resp. */ + /* Nan_flg is used with two purposes: to flag a NaN and */ + /* as the length of the string ``NAN0X'' (``nan0x'') */ + int inf_nan = 0, NaN_flg = 0; + + /* Pointer to string "NAN0X" or "nan0x" */ + char *SNAN; + + /* Flag for negative infinity or NaN */ + int neg_in = 0; + + /* variables for positional parameters */ + char *sformat = format; /* save the beginning of the format */ + int fpos = 1; /* 1 if first positional parameter */ + stva_list args; /* used to step through the argument list */ + stva_list sargs; + /* used to save the start of the argument list */ + stva_list bargs; + /* used to restore args if positional width or precision */ + stva_list arglst[MAXARGS]; + /* + * array giving the appropriate values for va_arg() to + * retrieve the corresponding argument: + * arglst[0] is the first argument, + * arglst[1] is the second argument, etc. + */ + int starflg = 0; /* set to 1 if * format specifier seen */ + /* + * Initialize args and sargs to the start of the argument list. + * Note that ANSI guarantees that the address of the first member of + * a structure will be the same as the address of the structure. + * See equivalent code in libc doprnt.c + */ + +#if !(defined(__amd64) && defined(__GNUC__)) /* XX64 - fix me */ + va_copy(args.ap, in_args); +#endif + sargs = args; + + /* if first I/O to the stream get a buffer */ + /* Note that iop->_base should not equal 0 for sprintf and vsprintf */ + if (iop->_base == 0 && _findbuf(iop) == 0) + return (EOF); + + /* initialize buffer pointer and buffer end pointer */ + bufptr = iop->_ptr; + bufferend = (iop->_flag & _IOREAD) ? + (unsigned char *)((long)bufptr | (-1L & ~HIBITL)) + : _bufend(iop); + + /* + * The main loop -- this loop goes through one iteration + * for each string of ordinary characters or format specification. + */ + for (;;) { + ptrdiff_t pdiff; + + if ((fcode = *format) != '\0' && fcode != '%') { + bp = format; + do { + format++; + } while ((fcode = *format) != '\0' && fcode != '%'); + + pdiff = format - bp; + /* pdiff = no. of non-% chars */ + count += pdiff; + PUT(bp, pdiff); + } + if (fcode == '\0') { /* end of format; return */ + ptrdiff_t d = bufptr - iop->_ptr; + iop->_cnt -= d; + iop->_ptr = bufptr; + if (bufptr + iop->_cnt > bufferend && + !(iop->_flag & _IOREAD)) + _bufsync(iop, bufferend); + /* + * in case of interrupt during last + * several lines + */ + if (iop->_flag & (_IONBF | _IOLBF) && + (iop->_flag & _IONBF || + memchr((char *)(bufptr-count), '\n', count) != + NULL)) + (void) _xflsbuf(iop); + return (ferror(iop) ? EOF : count); + } + + /* + * % has been found. + * The following switch is used to parse the format + * specification and to perform the operation specified + * by the format letter. The program repeatedly goes + * back to this switch until the format letter is + * encountered. + */ + width = prefixlength = otherlength = flagword = + suffixlength = 0; + format++; + + charswitch: + + switch (fcode = *format++) { + + case '+': + flagword |= FPLUS; + goto charswitch; + case '-': + flagword |= FMINUS; + flagword &= ~PADZERO; /* ignore 0 flag */ + goto charswitch; + case ' ': + flagword |= FBLANK; + goto charswitch; + case '#': + flagword |= FSHARP; + goto charswitch; + + /* Scan the field width and precision */ + case '.': + flagword |= DOTSEEN; + prec = 0; + goto charswitch; + + case '*': + if (isdigit(*format)) { + starflg = 1; + bargs = args; + goto charswitch; + } + if (!(flagword & DOTSEEN)) { + width = va_arg(args.ap, int); + if (width < 0) { + width = -width; + flagword ^= FMINUS; + } + } else { + prec = va_arg(args.ap, int); + if (prec < 0) + prec = 0; + } + goto charswitch; + + case '$': + { + int position; + stva_list targs; + if (fpos) { + _mkarglst(sformat, sargs, arglst); + fpos = 0; + } + if (flagword & DOTSEEN) { + position = prec; + prec = 0; + } else { + position = width; + width = 0; + } + if (position <= 0) { + /* illegal position */ + format--; + continue; + } + if (position <= MAXARGS) { + targs = arglst[position - 1]; + } else { + targs = arglst[MAXARGS - 1]; + _getarg(sformat, &targs, position); + } + if (!starflg) + args = targs; + else { + starflg = 0; + args = bargs; + if (flagword & DOTSEEN) + prec = va_arg(targs.ap, int); + else + width = va_arg(targs.ap, int); + } + goto charswitch; + } + + case '0': /* obsolescent spec: leading zero in width */ + /* means pad with leading zeros */ + if (!(flagword & (DOTSEEN | FMINUS))) + flagword |= PADZERO; + /* FALLTHROUGH */ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { int num = fcode - '0'; + while (isdigit(fcode = *format)) { + num = num * 10 + fcode - '0'; + format++; + } + if (flagword & DOTSEEN) + prec = num; + else + width = num; + goto charswitch; + } + + /* Scan the length modifier */ + case 'l': + flagword |= LENGTH; + goto charswitch; + case 'h': + flagword |= SHORT; + goto charswitch; + case 'L': + goto charswitch; + + /* + * The character addressed by format must be + * the format letter -- there is nothing + * left for it to be. + * + * The status of the +, -, #, and blank + * flags are reflected in the variable + * "flagword". "width" and "prec" contain + * numbers corresponding to the digit + * strings before and after the decimal + * point, respectively. If there was no + * decimal point, then flagword & DOTSEEN + * is false and the value of prec is meaningless. + * + * The following switch cases set things up + * for printing. What ultimately gets + * printed will be padding blanks, a + * prefix, left padding zeroes, a value, + * right padding zeroes, a suffix, and + * more padding blanks. Padding blanks + * will not appear simultaneously on both + * the left and the right. Each case in + * this switch will compute the value, and + * leave in several variables the informa- + * tion necessary to construct what is to + * be printed. + * + * The prefix is a sign, a blank, "0x", + * "0X", or null, and is addressed by + * "prefix". + * + * The suffix is either null or an + * exponent, and is addressed by "suffix". + * If there is a suffix, the flagword bit + * SUFFIX will be set. + * + * The value to be printed starts at "bp" + * and continues up to and not including + * "p". + * + * "lzero" and "rzero" will contain the + * number of padding zeroes required on + * the left and right, respectively. + * The flagword bits LZERO and RZERO tell + * whether padding zeros are required. + * + * The number of padding blanks, and + * whether they go on the left or the + * right, will be computed on exit from + * the switch. + */ + + + + + /* + * decimal fixed point representations + * + * HIBITL is 100...000 + * binary, and is equal to the maximum + * negative number. + * We assume a 2's complement machine + */ + + case 'i': + case 'd': + /* Fetch the argument to be printed */ + if (flagword & LENGTH) + val = va_arg(args.ap, long); + else + val = va_arg(args.ap, int); + + if (flagword & SHORT) + val = (short)val; + + /* Set buffer pointer to last digit */ + p = bp = buf + MAXDIGS; + + /* If signed conversion, make sign */ + if (val < 0) { + prefix = "-"; + prefixlength = 1; + /* + * Negate, checking in + * advance for possible + * overflow. + */ + if (val != HIBITL) + val = -val; + else /* number is -HIBITL; convert last */ + /* digit now and get positive number */ + *--bp = _lowdigit(&val); + } else if (flagword & FPLUS) { + prefix = "+"; + prefixlength = 1; + } else if (flagword & FBLANK) { + prefix = " "; + prefixlength = 1; + } + + decimal: + { long qval = val; + long saveq; + + if (qval <= 9) { + if (qval != 0 || !(flagword & DOTSEEN)) + *--bp = (char)(qval + '0'); + } else { + do { + saveq = qval; + qval /= 10; + *--bp = (char)(saveq - + qval * 10 + '0'); + } while (qval > 9); + *--bp = (char)(qval + '0'); + pdiff = (ptrdiff_t)saveq; + } + } + + /* Calculate minimum padding zero requirement */ + if (flagword & DOTSEEN) { + int leadzeroes = prec - (int)(p - bp); + if (leadzeroes > 0) { + otherlength = lzero = leadzeroes; + flagword |= LZERO; + } + } + + break; + + case 'u': + /* Fetch the argument to be printed */ + if (flagword & LENGTH) + val = va_arg(args.ap, long); + else + val = va_arg(args.ap, unsigned); + + if (flagword & SHORT) + val = (unsigned short)val; + + p = bp = buf + MAXDIGS; + + if (val & HIBITL) + *--bp = _lowdigit(&val); + + goto decimal; + + /* + * non-decimal fixed point representations + * for radix equal to a power of two + * + * "mradix" is one less than the radix for the conversion. + * "lradix" is one less than the base 2 log + * of the radix for the conversion. Conversion is unsigned. + * HIBITL is 100...000 + * binary, and is equal to the maximum + * negative number. + * We assume a 2's complement machine + */ + + case 'o': + mradix = 7; + lradix = 2; + goto fixed; + + case 'X': + case 'x': + case 'p': + mradix = 15; + lradix = 3; + + fixed: + /* Fetch the argument to be printed */ + if (flagword & LENGTH) + val = va_arg(args.ap, long); + else + val = va_arg(args.ap, unsigned); + + if (flagword & SHORT) + val = (unsigned short)val; + + /* Set translate table for digits */ + tab = (fcode == 'X') ? uc_digs : lc_digs; + + /* Entry point when printing a double which is a NaN */ + put_pc: + /* Develop the digits of the value */ + p = bp = buf + MAXDIGS; + { long qval = val; + if (qval == 0) { + if (!(flagword & DOTSEEN)) { + otherlength = lzero = 1; + flagword |= LZERO; + } + } else + do { + *--bp = tab[qval & mradix]; + qval = ((qval >> 1) & ~HIBITL) + >> lradix; + } while (qval != 0); + } + + /* Calculate minimum padding zero requirement */ + if (flagword & DOTSEEN) { + int leadzeroes = prec - (int)(p - bp); + if (leadzeroes > 0) { + otherlength = lzero = leadzeroes; + flagword |= LZERO; + } + } + + /* Handle the # flag */ + if (flagword & FSHARP && val != 0) + switch (fcode) { + case 'o': + if (!(flagword & LZERO)) { + otherlength = lzero = 1; + flagword |= LZERO; + } + break; + case 'x': + prefix = "0x"; + prefixlength = 2; + break; + case 'X': + prefix = "0X"; + prefixlength = 2; + break; + } + + break; + + case 'E': + case 'e': + /* + * E-format. The general strategy + * here is fairly easy: we take + * what ecvt gives us and re-format it. + */ + + /* Establish default precision */ + if (!(flagword & DOTSEEN)) + prec = 6; + + /* Fetch the value */ + dval = va_arg(args.ap, double); + + /* Check for NaNs and Infinities */ + if (IsNANorINF(dval)) { + if (IsINF(dval)) { + if (IsNegNAN(dval)) + neg_in = 1; + inf_nan = 1; + bp = (fcode == 'E')? uc_inf: lc_inf; + p = bp + 3; + break; + } else { + if (IsNegNAN(dval)) + neg_in = 1; + inf_nan = 1; + val = GETNaNPC(dval); + NaN_flg = SNLEN; + mradix = 15; + lradix = 3; + if (fcode == 'E') { + SNAN = uc_nan; + tab = uc_digs; + } else { + SNAN = lc_nan; + tab = lc_digs; + } + goto put_pc; + } + } + /* Develop the mantissa */ + bp = ecvt(dval, min(prec + 1, MAXECVT), &decpt, &sign); + + /* Determine the prefix */ + e_merge: + if (sign) { + prefix = "-"; + prefixlength = 1; + } else if (flagword & FPLUS) { + prefix = "+"; + prefixlength = 1; + } else if (flagword & FBLANK) { + prefix = " "; + prefixlength = 1; + } + + /* Place the first digit in the buffer */ + p = &buf[0]; + *p++ = (*bp != '\0') ? *bp++ : '0'; + + /* Put in a decimal point if needed */ + if (prec != 0 || (flagword & FSHARP)) + *p++ = _numeric[0]; + + /* Create the rest of the mantissa */ + { int rz = prec; + for (; rz > 0 && *bp != '\0'; --rz) + *p++ = *bp++; + if (rz > 0) { + otherlength = rzero = rz; + flagword |= RZERO; + } + } + + bp = &buf[0]; + + /* Create the exponent */ + *(suffix = &expbuf[MAXESIZ]) = '\0'; + if (dval != 0) { + int nn = decpt - 1; + if (nn < 0) + nn = -nn; + for (; nn > 9; nn /= 10) + *--suffix = todigit(nn % 10); + *--suffix = todigit(nn); + } + + /* Prepend leading zeroes to the exponent */ + while (suffix > &expbuf[MAXESIZ - 2]) + *--suffix = '0'; + + /* Put in the exponent sign */ + *--suffix = (decpt > 0 || dval == 0) ? '+' : '-'; + + /* Put in the e */ + *--suffix = isupper(fcode) ? 'E' : 'e'; + + /* compute size of suffix */ + otherlength += (suffixlength = + (int)(&expbuf[MAXESIZ] - suffix)); + flagword |= SUFFIX; + + break; + + case 'f': + /* + * F-format floating point. This is a + * good deal less simple than E-format. + * The overall strategy will be to call + * fcvt, reformat its result into buf, + * and calculate how many trailing + * zeroes will be required. There will + * never be any leading zeroes needed. + */ + + /* Establish default precision */ + if (!(flagword & DOTSEEN)) + prec = 6; + + /* Fetch the value */ + dval = va_arg(args.ap, double); + + /* Check for NaNs and Infinities */ + if (IsNANorINF(dval)) { + if (IsINF(dval)) { + if (IsNegNAN(dval)) + neg_in = 1; + inf_nan = 1; + bp = lc_inf; + p = bp + 3; + break; + } else { + if (IsNegNAN(dval)) + neg_in = 1; + inf_nan = 1; + val = GETNaNPC(dval); + NaN_flg = SNLEN; + mradix = 15; + lradix = 3; + tab = lc_digs; + SNAN = lc_nan; + goto put_pc; + } + } + /* Do the conversion */ + bp = fcvt(dval, min(prec, MAXFCVT), &decpt, &sign); + + /* Determine the prefix */ + f_merge: + if (sign) { + prefix = "-"; + prefixlength = 1; + } else if (flagword & FPLUS) { + prefix = "+"; + prefixlength = 1; + } else if (flagword & FBLANK) { + prefix = " "; + prefixlength = 1; + } + + /* Initialize buffer pointer */ + p = &buf[0]; + + { int nn = decpt; + + /* Emit the digits before the decimal point */ + k = 0; + do { + *p++ = (nn <= 0 || *bp == '\0' || + k >= MAXFSIG) ? + '0' : (k++, *bp++); + } while (--nn > 0); + + /* Decide whether we need a decimal point */ + if ((flagword & FSHARP) || prec > 0) + *p++ = _numeric[0]; + + /* Digits (if any) after the decimal point */ + nn = min(prec, MAXFCVT); + if (prec > nn) { + flagword |= RZERO; + otherlength = rzero = prec - nn; + } + while (--nn >= 0) + *p++ = (++decpt <= 0 || *bp == '\0' || + k >= MAXFSIG) ? + '0' : (k++, *bp++); + } + + bp = &buf[0]; + + break; + + case 'G': + case 'g': + /* + * g-format. We play around a bit + * and then jump into e or f, as needed. + */ + + /* Establish default precision */ + if (!(flagword & DOTSEEN)) + prec = 6; + else if (prec == 0) + prec = 1; + + /* Fetch the value */ + dval = va_arg(args.ap, double); + + /* Check for NaN and Infinities */ + if (IsNANorINF(dval)) { + if (IsINF(dval)) { + if (IsNegNAN(dval)) + neg_in = 1; + bp = (fcode == 'G') ? uc_inf : lc_inf; + p = bp + 3; + inf_nan = 1; + break; + } else { + if (IsNegNAN(dval)) + neg_in = 1; + inf_nan = 1; + val = GETNaNPC(dval); + NaN_flg = SNLEN; + mradix = 15; + lradix = 3; + if (fcode == 'G') { + SNAN = uc_nan; + tab = uc_digs; + } else { + SNAN = lc_nan; + tab = lc_digs; + } + goto put_pc; + } + } + + /* Do the conversion */ + bp = ecvt(dval, min(prec, MAXECVT), &decpt, &sign); + if (dval == 0) + decpt = 1; + + { int kk = prec; + size_t sz; + + if (!(flagword & FSHARP)) { + sz = strlen(bp); + if (sz < kk) + kk = (int)sz; + while (kk >= 1 && bp[kk-1] == '0') + --kk; + } + + if (decpt < -3 || decpt > prec) { + prec = kk - 1; + goto e_merge; + } + prec = kk - decpt; + goto f_merge; + } + + case '%': + buf[0] = (char)fcode; + goto c_merge; + + case 'c': + buf[0] = va_arg(args.ap, int); + c_merge: + p = (bp = &buf[0]) + 1; + break; + + case 's': + bp = va_arg(args.ap, char *); + if (!(flagword & DOTSEEN)) + p = bp + strlen(bp); + else { /* a strnlen function would be useful here! */ + char *qp = bp; + while (*qp++ != '\0' && --prec >= 0) + ; + p = qp - 1; + } + break; + + case 'n': + { + if (flagword & LENGTH) { + long *svcount; + svcount = va_arg(args.ap, long *); + *svcount = count; + } else if (flagword & SHORT) { + short *svcount; + svcount = va_arg(args.ap, short *); + *svcount = (short)count; + } else { + int *svcount; + svcount = va_arg(args.ap, int *); + *svcount = count; + } + continue; + } + + default: /* this is technically an error; what we do is to */ + /* back up the format pointer to the offending char */ + /* and continue with the format scan */ + format--; + continue; + + } + + if (inf_nan) { + if (neg_in) { + prefix = "-"; + prefixlength = 1; + neg_in = 0; + } else if (flagword & FPLUS) { + prefix = "+"; + prefixlength = 1; + } else if (flagword & FBLANK) { + prefix = " "; + prefixlength = 1; + } + inf_nan = 0; + } + + /* Calculate number of padding blanks */ + k = (int)(pdiff = p - bp) + prefixlength + otherlength + + NaN_flg; + if (width <= k) + count += k; + else { + count += width; + + /* Set up for padding zeroes if requested */ + /* Otherwise emit padding blanks unless output is */ + /* to be left-justified. */ + + if (flagword & PADZERO) { + if (!(flagword & LZERO)) { + flagword |= LZERO; + lzero = width - k; + } + else + lzero += width - k; + k = width; /* cancel padding blanks */ + } else + /* Blanks on left if required */ + if (!(flagword & FMINUS)) + PAD(_blanks, width - k); + } + + /* Prefix, if any */ + if (prefixlength != 0) + PUT(prefix, prefixlength); + + /* If value is NaN, put string NaN */ + if (NaN_flg) { + PUT(SNAN, SNLEN); + NaN_flg = 0; + } + + /* Zeroes on the left */ + if (flagword & LZERO) + PAD(_zeroes, lzero); + + /* The value itself */ + if (pdiff > 0) + PUT(bp, pdiff); + + if (flagword & (RZERO | SUFFIX | FMINUS)) { + /* Zeroes on the right */ + if (flagword & RZERO) + PAD(_zeroes, rzero); + + /* The suffix */ + if (flagword & SUFFIX) + PUT(suffix, suffixlength); + + /* Blanks on the right if required */ + if (flagword & FMINUS && width > k) + PAD(_blanks, width - k); + } + } +} + +/* + * This function initializes arglst, to contain the appropriate va_list values + * for the first MAXARGS arguments. + */ +void +_mkarglst(char *fmt, stva_list args, stva_list arglst[]) +{ + static char digits[] = "01234567890", skips[] = "# +-.0123456789hL$"; + + enum types {INT = 1, LONG, CHAR_PTR, DOUBLE, LONG_DOUBLE, VOID_PTR, + LONG_PTR, INT_PTR}; + enum types typelst[MAXARGS], curtype; + int maxnum, n, curargno, flags; + + /* + * Algorithm 1. set all argument types to zero. + * 2. walk through fmt putting arg types in typelst[]. + * 3. walk through args using va_arg(args.ap, typelst[n]) + * and set arglst[] to the appropriate values. + * Assumptions: Cannot use %*$... to specify variable position. + */ + + (void) memset((void *)typelst, 0, sizeof (typelst)); + maxnum = -1; + curargno = 0; + while ((fmt = strchr(fmt, '%')) != 0) { + size_t sz; + + fmt++; /* skip % */ + if (fmt[sz = strspn(fmt, digits)] == '$') { + curargno = atoi(fmt) - 1; + /* convert to zero base */ + if (curargno < 0) + continue; + fmt += sz + 1; + } + flags = 0; + again:; + fmt += strspn(fmt, skips); + switch (*fmt++) { + case '%': /* there is no argument! */ + continue; + case 'l': + flags |= 0x1; + goto again; + case '*': /* int argument used for value */ + /* check if there is a positional parameter */ + if (isdigit(*fmt)) { + int targno; + targno = atoi(fmt) - 1; + fmt += strspn(fmt, digits); + if (*fmt == '$') + fmt++; /* skip '$' */ + if (targno >= 0 && targno < MAXARGS) { + typelst[targno] = INT; + if (maxnum < targno) + maxnum = targno; + } + goto again; + } + flags |= 0x2; + curtype = INT; + break; + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + curtype = DOUBLE; + break; + case 's': + curtype = CHAR_PTR; + break; + case 'p': + curtype = VOID_PTR; + break; + case 'n': + if (flags & 0x1) + curtype = LONG_PTR; + else + curtype = INT_PTR; + break; + default: + if (flags & 0x1) + curtype = LONG; + else + curtype = INT; + break; + } + if (curargno >= 0 && curargno < MAXARGS) { + typelst[curargno] = curtype; + if (maxnum < curargno) + maxnum = curargno; + } + curargno++; /* default to next in list */ + if (flags & 0x2) /* took care of *, keep going */ + { + flags ^= 0x2; + goto again; + } + } + for (n = 0; n <= maxnum; n++) { + arglst[n] = args; + if (typelst[n] == 0) + typelst[n] = INT; + + switch (typelst[n]) { + case INT: + (void) va_arg(args.ap, int); + break; + case LONG: + (void) va_arg(args.ap, long); + break; + case CHAR_PTR: + (void) va_arg(args.ap, char *); + break; + case DOUBLE: + (void) va_arg(args.ap, double); + break; + case LONG_DOUBLE: + (void) va_arg(args.ap, double); + break; + case VOID_PTR: + (void) va_arg(args.ap, void *); + break; + case LONG_PTR: + (void) va_arg(args.ap, long *); + break; + case INT_PTR: + (void) va_arg(args.ap, int *); + break; + } + } +} + +/* + * This function is used to find the va_list value for arguments whose + * position is greater than MAXARGS. This function is slow, so hopefully + * MAXARGS will be big enough so that this function need only be called in + * unusual circumstances. + * pargs is assumed to contain the value of arglst[MAXARGS - 1]. + */ +void +_getarg(char *fmt, stva_list *pargs, int argno) +{ + static char digits[] = "01234567890", skips[] = "# +-.0123456789h$"; + int i, curargno, flags; + size_t n; + char *sfmt = fmt; + int found = 1; + + i = MAXARGS; + curargno = 1; + while (found) { + fmt = sfmt; + found = 0; + while ((i != argno) && (fmt = strchr(fmt, '%')) != 0) { + fmt++; /* skip % */ + if (fmt[n = strspn(fmt, digits)] == '$') { + curargno = atoi(fmt); + if (curargno <= 0) + continue; + fmt += n + 1; + } + + /* find conversion specifier for next argument */ + if (i != curargno) { + curargno++; + continue; + } else + found = 1; + flags = 0; + again:; + fmt += strspn(fmt, skips); + switch (*fmt++) { + case '%': /* there is no argument! */ + continue; + case 'l': + flags |= 0x1; + goto again; + case '*': /* int argument used for value */ + /* + * check if there is a positional parameter; + * if so, just skip it; its size will be + * correctly determined by default + */ + if (isdigit(*fmt)) { + fmt += strspn(fmt, digits); + if (*fmt == '$') + fmt++; /* skip '$' */ + goto again; + } + flags |= 0x2; + (void) va_arg((*pargs).ap, int); + break; + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + if (flags & 0x1) + (void) va_arg((*pargs).ap, double); + else + (void) va_arg((*pargs).ap, double); + break; + case 's': + (void) va_arg((*pargs).ap, char *); + break; + case 'p': + (void) va_arg((*pargs).ap, void *); + break; + case 'n': + if (flags & 0x1) + (void) va_arg((*pargs).ap, long *); + else + (void) va_arg((*pargs).ap, int *); + break; + default: + if (flags & 0x1) + (void) va_arg((*pargs).ap, long int); + else + (void) va_arg((*pargs).ap, int); + break; + } + i++; + curargno++; /* default to next in list */ + if (flags & 0x2) /* took care of *, keep going */ + { + flags ^= 0x2; + goto again; + } + } + + /* + * missing specifier for parameter, assume parameter is an int + */ + if (!found && i != argno) { + (void) va_arg((*pargs).ap, int); + i++; + curargno = i; + found = 1; + } + } +} diff --git a/usr/src/ucblib/libucb/port/stdio/fopen.c b/usr/src/ucblib/libucb/port/stdio/fopen.c new file mode 100644 index 0000000000..edfa76228e --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/fopen.c @@ -0,0 +1,149 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include "file64.h" +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/file.h> +#include "stdiom.h" + +/* Final argument to _endopen depends on build environment */ +#define ALWAYS_LARGE_OPEN 1 +#define LARGE_OPEN (_FILE_OFFSET_BITS == 64) + +static FILE * +_endopen(const char *file, const char *mode, FILE *iop, int largefile) +{ + int plus, oflag, fd; + + if (iop == NULL || file == NULL || file[0] == '\0') + return (NULL); + plus = (mode[1] == '+'); + switch (mode[0]) { + case 'w': + oflag = (plus ? O_RDWR : O_WRONLY) | O_TRUNC | O_CREAT; + break; + case 'a': + oflag = (plus ? O_RDWR : O_WRONLY) | O_CREAT; + break; + case 'r': + oflag = plus ? O_RDWR : O_RDONLY; + break; + default: + return (NULL); + } + if (largefile) { + fd = open64(file, oflag, 0666); /* mapped to open() for V9 */ + } else { + fd = open(file, oflag, 0666); + } + if (fd < 0) + return (NULL); + iop->_cnt = 0; + iop->_file = (unsigned char) fd; + iop->_flag = plus ? _IORW : (mode[0] == 'r') ? _IOREAD : _IOWRT; + if (mode[0] == 'a') { + if ((lseek64(fd, 0L, SEEK_END)) < 0) { + (void) close(fd); + return (NULL); + } + } + iop->_base = iop->_ptr = NULL; + /* + * Sys5 does not support _bufsiz + * + * iop->_bufsiz = 0; + */ + return (iop); +} + +FILE * +fopen(const char *file, const char *mode) +{ + FILE *iop; + FILE *rc; + + iop = _findiop(); + rc = _endopen(file, mode, iop, LARGE_OPEN); + if (rc == NULL && iop != NULL) + iop->_flag = 0; /* release iop */ + return (rc); +} + +/* + * For _LP64, all fopen() calls are 64-bit calls, i.e., open64() system call. + * There should not be fopen64() calls. + * Similar for freopen64(). + */ +#if !defined(_LP64) +FILE * +fopen64(const char *file, const char *mode) +{ + FILE *iop; + FILE *rc; + + iop = _findiop(); + rc = _endopen(file, mode, iop, ALWAYS_LARGE_OPEN); + if (rc == NULL && iop != NULL) + iop->_flag = 0; /* release iop */ + return (rc); +} +#endif + +FILE * +freopen(const char *file, const char *mode, FILE *iop) +{ + (void) fclose(iop); /* doesn't matter if this fails */ + return (_endopen(file, mode, iop, LARGE_OPEN)); +} + +#if !defined(_LP64) +FILE * +freopen64(const char *file, const char *mode, FILE *iop) +{ + (void) fclose(iop); /* doesn't matter if this fails */ + return (_endopen(file, mode, iop, ALWAYS_LARGE_OPEN)); +} +#endif diff --git a/usr/src/ucblib/libucb/port/stdio/fprintf.c b/usr/src/ucblib/libucb/port/stdio/fprintf.c new file mode 100644 index 0000000000..4abbbc26ca --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/fprintf.c @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include "file64.h" +#include <stdio.h> +#include <stdarg.h> +#include "libc.h" + +int +fprintf(FILE *iop, const char *format, ...) +{ + int count; + va_list ap; + + va_start(ap, format); + + if (!(iop->_flag & _IOWRT)) { + /* if no write flag */ + if (iop->_flag & _IORW) { + /* if ok, cause read-write */ + iop->_flag |= _IOWRT; + } else { + /* else error */ + return (EOF); + } + } + count = _doprnt((char *) format, ap, iop); + va_end(ap); + return (count); +} diff --git a/usr/src/ucblib/libucb/port/stdio/print.h b/usr/src/ucblib/libucb/port/stdio/print.h new file mode 100644 index 0000000000..c02e5394fb --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/print.h @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997, by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + + +#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ + +/* Maximum number of digits in any integer representation */ +#define MAXDIGS 11 + +/* Maximum total number of digits in E format */ +#if u3b || M32 +#define MAXECVT 17 +#else +#define MAXECVT 18 +#endif + +/* Maximum number of digits after decimal point in F format */ +#define MAXFCVT 60 + +/* Maximum significant figures in a floating-point number */ +#define MAXFSIG MAXECVT + +/* Maximum number of characters in an exponent */ +#if u3b || M32 +#define MAXESIZ 5 +#else +#define MAXESIZ 4 +#endif + +/* Maximum (positive) exponent */ +#if u3b || M32 +#define MAXEXP 310 +#else +#define MAXEXP 40 +#endif + +/* Data type for flags */ +typedef char bool; + +/* Convert a digit character to the corresponding number */ +#define tonumber(x) ((x)-'0') + +/* Convert a number between 0 and 9 to the corresponding digit */ +#define todigit(x) ((x)+'0') + +/* Max and Min macros */ +#define max(a, b) ((a) > (b)? (a): (b)) +#define min(a, b) ((a) < (b)? (a): (b)) diff --git a/usr/src/ucblib/libucb/port/stdio/printf.c b/usr/src/ucblib/libucb/port/stdio/printf.c new file mode 100644 index 0000000000..ed7708f8e7 --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/printf.c @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include "file64.h" +#include <stdio.h> +#include <stdarg.h> +#include "libc.h" + +int +printf(const char *format, ...) +{ + int count; + va_list ap; + + va_start(ap, format); + if (!(stdout->_flag & _IOWRT)) { + /* if no write flag */ + if (stdout->_flag & _IORW) { + /* if ok, cause read-write */ + stdout->_flag |= _IOWRT; + } else { + /* else error */ + return (EOF); + } + } + count = _doprnt((char *) format, ap, stdout); + va_end(ap); + return (count); +} diff --git a/usr/src/ucblib/libucb/port/stdio/sprintf.c b/usr/src/ucblib/libucb/port/stdio/sprintf.c new file mode 100644 index 0000000000..258e1d0a8c --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/sprintf.c @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include "file64.h" +#include <stdio.h> +#include <stdarg.h> +#include <values.h> +#include "libc.h" + +char * +sprintf(const char *string, const char *format, ...) +{ + FILE siop; + va_list ap; + + siop._cnt = MAXINT; + siop._base = siop._ptr = (unsigned char *)string; + siop._flag = _IOREAD; + va_start(ap, format); + (void) _doprnt((char *) format, ap, &siop); + va_end(ap); + *siop._ptr = '\0'; /* plant terminating null character */ + return ((char *)string); +} diff --git a/usr/src/ucblib/libucb/port/stdio/vfprintf.c b/usr/src/ucblib/libucb/port/stdio/vfprintf.c new file mode 100644 index 0000000000..70d6032c3a --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/vfprintf.c @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include "file64.h" +#include <stdio.h> +#include <stdarg.h> +#include "libc.h" + +int +vfprintf(FILE *iop, const char *format, va_list ap) +{ + int count; + + if (!(iop->_flag & _IOWRT)) { + /* if no write flag */ + if (iop->_flag & _IORW) { + /* if ok, cause read-write */ + iop->_flag |= _IOWRT; + } else { + /* else error */ + return (EOF); + } + } + count = _doprnt((char *) format, ap, iop); + return (count); +} diff --git a/usr/src/ucblib/libucb/port/stdio/vprintf.c b/usr/src/ucblib/libucb/port/stdio/vprintf.c new file mode 100644 index 0000000000..2b50fd6f45 --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/vprintf.c @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include "file64.h" +#include <stdio.h> +#include <stdarg.h> +#include "libc.h" + +int +vprintf(const char *format, va_list ap) +{ + if (!(stdout->_flag & _IOWRT)) { + /* if no write flag */ + if (stdout->_flag & _IORW) { + /* if ok, cause read-write */ + stdout->_flag |= _IOWRT; + } else { + /* else error */ + return (EOF); + } + } + return (_doprnt((char *) format, ap, stdout)); +} diff --git a/usr/src/ucblib/libucb/port/stdio/vsprintf.c b/usr/src/ucblib/libucb/port/stdio/vsprintf.c new file mode 100644 index 0000000000..d8ff862fcd --- /dev/null +++ b/usr/src/ucblib/libucb/port/stdio/vsprintf.c @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1998 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include "file64.h" +#include <stdio.h> +#include <stdarg.h> +#include <values.h> +#include "libc.h" + +char * +vsprintf(char *string, char *format, va_list ap) +{ + FILE siop; + + siop._cnt = MAXINT; + siop._base = siop._ptr = (unsigned char *)string; + siop._flag = _IOREAD; + (void) _doprnt(format, ap, &siop); + *siop._ptr = '\0'; /* plant terminating null character */ + return (string); +} diff --git a/usr/src/ucblib/libucb/port/sys/flock.c b/usr/src/ucblib/libucb/port/sys/flock.c new file mode 100644 index 0000000000..7bc8d034cb --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/flock.c @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <sys/file.h> +#include <fcntl.h> +#include <errno.h> + +int +flock(int fd, int operation) +{ + struct flock fl; + int cmd; + int ret; + + /* initialize the flock struct to set lock on entire file */ + fl.l_whence = 0; + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = 0; + + /* In non-blocking lock, use F_SETLK for cmd, F_SETLKW otherwise */ + if (operation & LOCK_NB) { + cmd = F_SETLK; + operation &= ~LOCK_NB; /* turn off this bit */ + } else + cmd = F_SETLKW; + + switch (operation) { + case LOCK_UN: + fl.l_type |= F_UNLCK; + break; + case LOCK_SH: + fl.l_type |= F_RDLCK; + break; + case LOCK_EX: + fl.l_type |= F_WRLCK; + break; + default: + errno = EINVAL; + return (-1); + } + + ret = fcntl(fd, cmd, &fl); + + if (ret == -1 && errno == EACCES) + errno = EWOULDBLOCK; + + return (ret); +} diff --git a/usr/src/ucblib/libucb/port/sys/getdtblsize.c b/usr/src/ucblib/libucb/port/sys/getdtblsize.c new file mode 100644 index 0000000000..d54f5df91c --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/getdtblsize.c @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2000 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <limits.h> + +/* + * getdtablesize is implemented on top of getrlimit's + * RLIMIT_NOFILE feature. The current (Soft) limit is returned. + */ +int +getdtablesize(void) +{ + struct rlimit rip; + + if (getrlimit(RLIMIT_NOFILE, &rip) == -1) + return (-1); /* can't happen */ + if (rip.rlim_cur == RLIM_INFINITY) + return (INT_MAX); + return ((int)rip.rlim_cur); +} diff --git a/usr/src/ucblib/libucb/port/sys/gethostid.c b/usr/src/ucblib/libucb/port/sys/gethostid.c new file mode 100644 index 0000000000..24b48d8877 --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/gethostid.c @@ -0,0 +1,74 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <sys/utsname.h> +#include <sys/systeminfo.h> +#include <unistd.h> +#include <stdlib.h> + +#define HOSTIDLEN 40 + +long +gethostid(void) +{ + char name[HOSTIDLEN], *end; + unsigned long hostid; + int error; + + error = sysinfo(SI_HW_SERIAL, name, HOSTIDLEN); + /* + * error > 0 ==> number of bytes to hold name + * and is discarded since gethostid only + * cares if it succeeded or failed + */ + if (error == -1) + return (-1); + else { + hostid = strtoul(name, &end, 10); + if (hostid == 0 && end == name) { + return (-1); + } + return ((long) hostid); + } +} diff --git a/usr/src/ucblib/libucb/port/sys/gethostname.c b/usr/src/ucblib/libucb/port/sys/gethostname.c new file mode 100644 index 0000000000..4967f6e859 --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/gethostname.c @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <sys/utsname.h> +#include <sys/systeminfo.h> +#include <unistd.h> +#include <errno.h> + +int +gethostname(char *name, int namelen) +{ + int error; + + error = sysinfo(SI_HOSTNAME, name, namelen); + /* + * error > 0 ==> number of bytes to hold name + * and is discarded since gethostname only + * cares if it succeeded or failed + */ + return (error == -1 ? -1 : 0); +} + +int +sethostname(char *name, int namelen) +{ + int error; + + /* + * Check if superuser + */ + if (getuid()) { + errno = EPERM; + return (-1); + } + error = sysinfo(SI_SET_HOSTNAME, name, namelen); + return (error == -1 ? -1 : 0); +} diff --git a/usr/src/ucblib/libucb/port/sys/getpagesize.c b/usr/src/ucblib/libucb/port/sys/getpagesize.c new file mode 100644 index 0000000000..f7ab007c20 --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/getpagesize.c @@ -0,0 +1,55 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +/* + * getpagesize(3C) - returns logical pagesize + */ + +#include <sys/types.h> +#include <unistd.h> + +int +getpagesize(void) +{ + return ((int) sysconf(_SC_PAGESIZE)); +} diff --git a/usr/src/ucblib/libucb/port/sys/gettimeofday.c b/usr/src/ucblib/libucb/port/sys/gettimeofday.c new file mode 100644 index 0000000000..09df1d5688 --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/gettimeofday.c @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <sys/time.h> +#include <stdio.h> +#include <unistd.h> +#include <errno.h> +#include <sys/syscall.h> +#include "libc.h" + +/* + * Get the time of day information. + * BSD compatibility on top of SVr4 facilities: + * u_sec always zero, and don't do anything with timezone pointer. + */ + +/* + * This is defined in sys/gettimeofday.s + * This extern cannot be in libc.h due to name conflict with port/gen/synonyms.h + */ +extern int _gettimeofday(struct timeval *); + +/*ARGSUSED*/ +int +gettimeofday(struct timeval *tp, void *tzp) +{ + if (tp == NULL) + return (0); + + return (_gettimeofday(tp)); +} + +/* + * Set the time. + * Don't do anything with the timezone information. + */ + +/*ARGSUSED*/ +int +settimeofday(struct timeval *tp, void *tzp) +{ + time_t t; /* time in seconds */ + + if (tp == NULL) + return (0); + + t = (time_t) tp->tv_sec; + if (tp->tv_usec >= 500000) + /* round up */ + t++; + + return (stime(&t)); +} diff --git a/usr/src/ucblib/libucb/port/sys/killpg.c b/usr/src/ucblib/libucb/port/sys/killpg.c new file mode 100644 index 0000000000..54cc02e147 --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/killpg.c @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <signal.h> +#include <errno.h> + +int +killpg(int pgrp, int sig) +{ + /* + * errno is set by kill() + */ + if (pgrp < 0) { + errno = ESRCH; + return (-1); + } + return (kill(-pgrp, sig)); +} diff --git a/usr/src/ucblib/libucb/port/sys/mctl.c b/usr/src/ucblib/libucb/port/sys/mctl.c new file mode 100644 index 0000000000..e77eb9c14c --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/mctl.c @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <errno.h> +#include <sys/mman.h> + +/* + * Memory control function. + */ + +int +mctl(caddr_t addr, size_t len, int function, int arg) +{ + if ((long)len < 0L) { + errno = EINVAL; + return (-1); + } + return (memcntl(addr, len, function, (caddr_t)(uintptr_t)arg, 0, 0)); +} diff --git a/usr/src/ucblib/libucb/port/sys/reboot.c b/usr/src/ucblib/libucb/port/sys/reboot.c new file mode 100644 index 0000000000..4d1aa40da0 --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/reboot.c @@ -0,0 +1,91 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997, by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* Portions Copyright(c) 1988, Sun Microsystems Inc. */ +/* All Rights Reserved */ + +#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <sys/uadmin.h> +#include <unistd.h> +#include <errno.h> + +/* + * Not all BSD's semantics are supported + * including RB_SINGLE, RB_RB_DUMP, RB_STRING + */ + +/* + * BSD reboot.h + */ +#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */ + +#define RB_ASKNAME 0x001 /* ask for file name to reboot from */ +#define RB_SINGLE 0x002 /* reboot to single user only */ +#define RB_NOSYNC 0x004 /* dont sync before reboot */ +#define RB_HALT 0x008 /* don't reboot, just halt */ +#define RB_INITNAME 0x010 /* name given for /etc/init */ +#define RB_NOBOOTRC 0x020 /* don't run /etc/rc.boot */ +#define RB_DEBUG 0x040 /* being run under debugger */ +#define RB_DUMP 0x080 /* dump system core */ +#define RB_WRITABLE 0x100 /* mount root read/write */ +#define RB_STRING 0x200 /* pass boot args to prom monitor */ + +/*ARGSUSED*/ +int +reboot(int howto, char *bootargs) +{ + int cmd; + int fcn; + int mdep = 0; + + if (getuid() != 0) { + errno = EPERM; + return (-1); + } + + if (howto & RB_HALT) { + cmd = A_SHUTDOWN; + fcn = AD_HALT; + } else if (howto & RB_ASKNAME) { + cmd = A_SHUTDOWN; + fcn = AD_IBOOT; + } else { /* assume RB_AUTOBOOT */ + cmd = A_SHUTDOWN; + fcn = AD_BOOT; + } + + /* return something to be consistent with the original prototype */ + return (uadmin(cmd, fcn, mdep)); + /* most cases, we are gone and code does not reach here */ +} diff --git a/usr/src/ucblib/libucb/port/sys/setpgrp.c b/usr/src/ucblib/libucb/port/sys/setpgrp.c new file mode 100644 index 0000000000..6d8518d8ed --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/setpgrp.c @@ -0,0 +1,38 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1997, by Sun Microsystems, Inc. + * All rights reserved. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ + +/*LINTLIBRARY*/ + +#include <sys/types.h> +#include <unistd.h> + +int +setpgrp(pid_t pid1, pid_t pid2) +{ + return (setpgid(pid1, pid2)); +} diff --git a/usr/src/ucblib/libucb/port/sys/wait3.c b/usr/src/ucblib/libucb/port/sys/wait3.c new file mode 100644 index 0000000000..bca1c25cda --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/wait3.c @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 1997 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +/* + * Compatibility lib for BSD's wait3() - falls through to wait4(). + */ +#include <sys/types.h> +#include <sys/time.h> +#include <sys/times.h> +#include <sys/wait.h> +#include <sys/resource.h> + +pid_t +wait3(int *status, int options, struct rusage *rp) +{ + return (wait4(0, status, options, rp)); +} diff --git a/usr/src/ucblib/libucb/port/sys/wait4.c b/usr/src/ucblib/libucb/port/sys/wait4.c new file mode 100644 index 0000000000..425431af1d --- /dev/null +++ b/usr/src/ucblib/libucb/port/sys/wait4.c @@ -0,0 +1,166 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995-1997, by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* Portions Copyright(c) 1988, Sun Microsystems Inc. */ +/* All Rights Reserved */ + +#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ + +/*LINTLIBRARY*/ + +/* + * Compatibility lib for SunOS's wait4(). + */ + +#include <sys/types.h> +#include <sys/time.h> +#include <sys/times.h> +#include <sys/wait.h> +#include <sys/siginfo.h> +#include <sys/procset.h> +#include <sys/param.h> +#include <sys/resource.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> + +/* + * Since sysV does not support rusage as in BSD, an approximate approach + * is: + * ... + * call times + * call waitid + * if ( a child is found ) + * call times again + * rusage ~= diff in the 2 times call + * ... + */ + +/* + * forward declaration + */ +static int wstat(int, int); + +pid_t +wait4(pid_t pid, int *status, int options, struct rusage *rp) +{ + struct tms before_tms; + struct tms after_tms; + siginfo_t info; + int error; + int noptions; + idtype_t idtype; + + if ((long)status == -1L || (long)rp == -1L) { + errno = EFAULT; + return (-1); + } + + if (rp) + (void) memset(rp, 0, sizeof (struct rusage)); + (void) memset(&info, 0, sizeof (siginfo_t)); + if (times(&before_tms) < 0) + return (-1); /* errno is set by times() */ + + /* + * SunOS's wait4() only supports WNOHANG & WUNTRACED + */ + if (options & ~(WNOHANG|WUNTRACED)) + return (EINVAL); /* used to be done by the kernel */ + noptions = options | WEXITED | WTRAPPED; + + /* + * Emulate undocumented 4.x semantics for 1186845 + */ + if (pid < 0) { + pid = -pid; + idtype = P_PGID; + } else if (pid == 0) + idtype = P_ALL; + else + idtype = P_PID; + + error = waitid(idtype, pid, &info, noptions); + if (error == 0) { + clock_t diffu; /* difference in usertime (ticks) */ + clock_t diffs; /* difference in systemtime (ticks) */ + + if ((options & WNOHANG) && (info.si_pid == 0)) + return (0); /* no child found */ + + if (rp) { + if (times(&after_tms) < 0) + return (-1); /* errno set by times() */ + /* + * The system/user time is an approximation only !!! + */ + diffu = after_tms.tms_cutime - before_tms.tms_cutime; + diffs = after_tms.tms_cstime - before_tms.tms_cstime; + rp->ru_utime.tv_sec = diffu / HZ; + rp->ru_utime.tv_usec = (diffu % HZ) * (1000000 / HZ); + rp->ru_stime.tv_sec = diffs/ HZ; + rp->ru_stime.tv_usec = (diffs % HZ) * (1000000 / HZ); + } + if (status) + *status = wstat(info.si_code, info.si_status); + return (info.si_pid); + } else { + return (-1); /* error number is set by waitid() */ + } +} + +/* + * Convert the status code to old style wait status + */ +static int +wstat(int code, int status) +{ + int stat = (status & 0377); + + switch (code) { + case CLD_EXITED: + stat <<= 8; + break; + case CLD_DUMPED: + stat |= WCOREFLG; + break; + case CLD_KILLED: + break; + case CLD_TRAPPED: + case CLD_STOPPED: + stat <<= 8; + stat |= WSTOPFLG; + break; + case CLD_CONTINUED: + stat = WCONTFLG; + break; + } + return (stat); +} diff --git a/usr/src/ucblib/libucb/req.flg b/usr/src/ucblib/libucb/req.flg new file mode 100644 index 0000000000..b6c42650d7 --- /dev/null +++ b/usr/src/ucblib/libucb/req.flg @@ -0,0 +1,28 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +#pragma ident "%Z%%M% %I% %E% SMI" + + +echo_file usr/src/lib/libc/inc/file64.h +echo_file usr/src/lib/Makefile.lib +echo_file usr/src/lib/Makefile.targ diff --git a/usr/src/ucblib/libucb/sparc/Makefile b/usr/src/ucblib/libucb/sparc/Makefile new file mode 100644 index 0000000000..4150e7b8b6 --- /dev/null +++ b/usr/src/ucblib/libucb/sparc/Makefile @@ -0,0 +1,47 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libucb/sparc/Makefile + +SYSOBJS= \ + setjmp.o \ + signal.o + +MAPDIR= ../spec/sparc +include ../Makefile.com + +DYNFLAGS += $(DYNFLAGS32) +BUILD.s= $(AS) $(ASFLAGS) $< -o $@ + +# sparc-specific rule +objs/%.o pics/%.o: sys/%.s + $(BUILD.s) + $(POST_PROCESS_O) + +.KEEP_STATE: + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/ucblib/libucb/sparc/sys/setjmp.s b/usr/src/ucblib/libucb/sparc/sys/setjmp.s new file mode 100644 index 0000000000..86b83b2a5d --- /dev/null +++ b/usr/src/ucblib/libucb/sparc/sys/setjmp.s @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * The UCB setjmp(env) is the same as SYSV's sigsetjmp(env, 1) + * while _setjmp(env) is the same as SYSV's sigsetjmp(env, 0) + * Both longjmp(env, val) and _longjmp(env, val) are the same + * as SYSV's siglongjmp(env, val). + * + * These are #defined as such in /usr/ucbinclude/setjmp.h + * but setjmp/longjmp and _setjmp/_longjmp have historically + * been entry points in libucb, so for binary compatibility + * we implement them as tail calls into libc in order to make + * them appear as direct calls to sigsetjmp/siglongjmp, which + * is essential for the correct operation of sigsetjmp. + */ + + .file "%M%" + +#include <sys/asm_linkage.h> + + ANSI_PRAGMA_WEAK(longjmp,function) + + ENTRY_NP(setjmp) + mov %o7, %g1 + mov 1, %o1 + call _sigsetjmp + mov %g1, %o7 + SET_SIZE(setjmp) + + ENTRY_NP(_setjmp) + mov %o7, %g1 + clr %o1 + call _sigsetjmp + mov %g1, %o7 + SET_SIZE(_setjmp) + + ENTRY_NP(_longjmp) + mov %o7, %g1 + call _siglongjmp + mov %g1, %o7 + SET_SIZE(_longjmp) diff --git a/usr/src/ucblib/libucb/sparc/sys/signal.c b/usr/src/ucblib/libucb/sparc/sys/signal.c new file mode 100644 index 0000000000..4ade237db6 --- /dev/null +++ b/usr/src/ucblib/libucb/sparc/sys/signal.c @@ -0,0 +1,614 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/*LINTLIBRARY*/ + +/* + * 4.3BSD signal compatibility functions + * + * the implementation interprets signal masks equal to -1 as "all of the + * signals in the signal set", thereby allowing signals with numbers + * above 32 to be blocked when referenced in code such as: + * + * for (i = 0; i < NSIG; i++) + * mask |= sigmask(i) + */ + +#include <sys/types.h> +#include <ucontext.h> +#include <signal.h> +#include <errno.h> + +#undef BUS_OBJERR /* namespace conflict */ +#include <sys/siginfo.h> +#include "libc.h" + +#pragma weak sigvechandler = _sigvechandler +#pragma weak sigsetmask = _sigsetmask +#pragma weak sigblock = _sigblock +#pragma weak sigpause = usigpause +#pragma weak sigvec = _sigvec +#pragma weak sigstack = _sigstack +#pragma weak signal = usignal +#pragma weak siginterrupt = _siginterrupt + +/* + * DO NOT remove the _ from these 3 functions or the subsequent + * calls to them below. The non _ versions of these functions + * are the wrong functions to call. This is BCP. Extra + * care should be taken when modifying this code. + */ +extern int _sigfillset(sigset_t *); +extern int _sigemptyset(sigset_t *); +extern int _sigprocmask(int, const sigset_t *, sigset_t *); + +#define set2mask(setp) ((setp)->__sigbits[0]) +#define mask2set(mask, setp) \ + ((mask) == -1 ? _sigfillset(setp) : \ + ((void) _sigemptyset(setp), (((setp)->__sigbits[0]) = (int)(mask)))) + +void (*_siguhandler[NSIG])() = { 0 }; + +/* + * forward declarations + */ +int ucbsiginterrupt(int, int); +int ucbsigvec(int, struct sigvec *, struct sigvec *); +int ucbsigpause(int); +int ucbsigblock(int); +int ucbsigsetmask(int); +static void ucbsigvechandler(int, siginfo_t *, ucontext_t *); + +/* + * sigvechandler is the real signal handler installed for all + * signals handled in the 4.3BSD compatibility interface - it translates + * SVR4 signal hander arguments into 4.3BSD signal handler arguments + * and then calls the real handler + */ + +int +_sigvechandler(int sig, siginfo_t *sip, ucontext_t *ucp) +{ + ucbsigvechandler(sig, sip, ucp); + return (0); /* keep the same as the original prototype */ +} + +static void +ucbsigvechandler(int sig, siginfo_t *sip, ucontext_t *ucp) +{ + struct sigcontext sc; + int code; + char *addr; +#ifdef NEVER + int gwinswitch = 0; +#endif + + sc.sc_onstack = ((ucp->uc_stack.ss_flags & SS_ONSTACK) != 0); + sc.sc_mask = set2mask(&ucp->uc_sigmask); + +#if defined(__sparc) + if (sig == SIGFPE && sip != NULL && SI_FROMKERNEL(sip) && + (sip->si_code == FPE_INTDIV || sip->si_code == FPE_INTOVF)) { + /* + * Hack to emulate the 4.x kernel behavior of incrementing + * the PC on integer divide by zero and integer overflow + * on sparc machines. (5.x does not increment the PC.) + */ + ucp->uc_mcontext.gregs[REG_PC] = + ucp->uc_mcontext.gregs[REG_nPC]; + ucp->uc_mcontext.gregs[REG_nPC] += 4; + } + sc.sc_sp = ucp->uc_mcontext.gregs[REG_SP]; + sc.sc_pc = ucp->uc_mcontext.gregs[REG_PC]; + sc.sc_npc = ucp->uc_mcontext.gregs[REG_nPC]; + + /* XX64 There is no REG_PSR for sparcv9, we map in REG_CCR for now */ +#if defined(__sparcv9) + sc.sc_psr = ucp->uc_mcontext.gregs[REG_CCR]; +#else + sc.sc_psr = ucp->uc_mcontext.gregs[REG_PSR]; +#endif + + sc.sc_g1 = ucp->uc_mcontext.gregs[REG_G1]; + sc.sc_o0 = ucp->uc_mcontext.gregs[REG_O0]; + + /* + * XXX - What a kludge! + * Store a pointer to the original ucontext_t in the sigcontext + * so that it's available to the sigcleanup call that needs to + * return from the signal handler. Otherwise, vital information + * (e.g., the "out" registers) that's only saved in the + * ucontext_t isn't available to sigcleanup. + */ + sc.sc_wbcnt = (int)(sizeof (*ucp)); + sc.sc_spbuf[0] = (char *)sig; + sc.sc_spbuf[1] = (char *)ucp; +#ifdef NEVER + /* + * XXX - Sorry, we can never pass the saved register windows + * on in the sigcontext because we use that space to save the + * ucontext_t. + */ + if (ucp->uc_mcontext.gwins != (gwindows_t *)0) { + int i, j; + + gwinswitch = 1; + sc.sc_wbcnt = ucp->uc_mcontext.gwins->wbcnt; + /* XXX - should use bcopy to move this in bulk */ + for (i = 0; i < ucp->uc_mcontext.gwins; i++) { + sc.sc_spbuf[i] = ucp->uc_mcontext.gwins->spbuf[i]; + for (j = 0; j < 8; j++) + sc.sc_wbuf[i][j] = + ucp->uc_mcontext.gwins->wbuf[i].rw_local[j]; + for (j = 0; j < 8; j++) + sc.sc_wbuf[i][j+8] = + ucp->uc_mcontext.gwins->wbuf[i].rw_in[j]; + } + } +#endif +#endif + + /* + * Translate signal codes from new to old. + * /usr/include/sys/siginfo.h contains new codes. + * /usr/ucbinclude/sys/signal.h contains old codes. + */ + code = 0; + addr = SIG_NOADDR; + if (sip != NULL && SI_FROMKERNEL(sip)) { + addr = sip->si_addr; + + switch (sig) { + case SIGILL: + switch (sip->si_code) { + case ILL_PRVOPC: + code = ILL_PRIVINSTR_FAULT; + break; + case ILL_BADSTK: + code = ILL_STACK; + break; + case ILL_ILLTRP: + code = ILL_TRAP_FAULT(sip->si_trapno); + break; + default: + code = ILL_ILLINSTR_FAULT; + break; + } + break; + + case SIGEMT: + code = EMT_TAG; + break; + + case SIGFPE: + switch (sip->si_code) { + case FPE_INTDIV: + code = FPE_INTDIV_TRAP; + break; + case FPE_INTOVF: + code = FPE_INTOVF_TRAP; + break; + case FPE_FLTDIV: + code = FPE_FLTDIV_TRAP; + break; + case FPE_FLTOVF: + code = FPE_FLTOVF_TRAP; + break; + case FPE_FLTUND: + code = FPE_FLTUND_TRAP; + break; + case FPE_FLTRES: + code = FPE_FLTINEX_TRAP; + break; + default: + code = FPE_FLTOPERR_TRAP; + break; + } + break; + + case SIGBUS: + switch (sip->si_code) { + case BUS_ADRALN: + code = BUS_ALIGN; + break; + case BUS_ADRERR: + code = BUS_HWERR; + break; + default: /* BUS_OBJERR */ + code = FC_MAKE_ERR(sip->si_errno); + break; + } + break; + + case SIGSEGV: + switch (sip->si_code) { + case SEGV_MAPERR: + code = SEGV_NOMAP; + break; + case SEGV_ACCERR: + code = SEGV_PROT; + break; + default: + code = FC_MAKE_ERR(sip->si_errno); + break; + } + break; + + default: + addr = SIG_NOADDR; + break; + } + } + + (*_siguhandler[sig])(sig, code, &sc, addr); + + if (sc.sc_onstack) + ucp->uc_stack.ss_flags |= SS_ONSTACK; + else + ucp->uc_stack.ss_flags &= ~SS_ONSTACK; + mask2set(sc.sc_mask, &ucp->uc_sigmask); + +#if defined(__sparc) + ucp->uc_mcontext.gregs[REG_SP] = sc.sc_sp; + ucp->uc_mcontext.gregs[REG_PC] = sc.sc_pc; + ucp->uc_mcontext.gregs[REG_nPC] = sc.sc_npc; +#if defined(__sparcv9) + ucp->uc_mcontext.gregs[REG_CCR] = sc.sc_psr; +#else + ucp->uc_mcontext.gregs[REG_PSR] = sc.sc_psr; +#endif + ucp->uc_mcontext.gregs[REG_G1] = sc.sc_g1; + ucp->uc_mcontext.gregs[REG_O0] = sc.sc_o0; +#ifdef NEVER + if (gwinswitch == 1) { + int i, j; + + ucp->uc_mcontext.gwins->wbcnt = sc.sc_wbcnt; + /* XXX - should use bcopy to move this in bulk */ + for (i = 0; i < sc.sc_wbcnt; i++) { + ucp->uc_mcontext.gwins->spbuf[i] = sc.sc_spbuf[i]; + for (j = 0; j < 8; j++) + ucp->uc_mcontext.gwins->wbuf[i].rw_local[j] = + sc.sc_wbuf[i][j]; + for (j = 0; j < 8; j++) + ucp->uc_mcontext.gwins->wbuf[i].rw_in[j] = + sc.sc_wbuf[i][j+8]; + } + } +#endif + + if (sig == SIGFPE) { + if (ucp->uc_mcontext.fpregs.fpu_qcnt > 0) { + ucp->uc_mcontext.fpregs.fpu_qcnt--; + ucp->uc_mcontext.fpregs.fpu_q++; + } + } +#endif + + (void) setcontext(ucp); +} + +#if defined(__sparc) +/* + * Emulate the special sigcleanup trap. + * This is only used by statically linked 4.x applications + * and thus is only called by the static BCP support. + * It lives here because of its close relationship with + * the ucbsigvechandler code above. + * + * It's used by 4.x applications to: + * 1. return from a signal handler (in __sigtramp) + * 2. [sig]longjmp + * 3. context switch, in the old 4.x liblwp + */ + +void +__sigcleanup(struct sigcontext *scp) +{ + ucontext_t uc, *ucp; + int sig; + + /* + * If there's a pointer to a ucontext_t hiding in the sigcontext, + * we *must* use that to return, since it contains important data + * such as the original "out" registers when the signal occurred. + */ + if (scp->sc_wbcnt == sizeof (*ucp)) { + sig = (int)scp->sc_spbuf[0]; + ucp = (ucontext_t *)scp->sc_spbuf[1]; + } else { + /* + * Otherwise, use a local ucontext_t and + * initialize it with getcontext. + */ + sig = 0; + ucp = &uc; + (void) getcontext(ucp); + } + + if (scp->sc_onstack) { + ucp->uc_stack.ss_flags |= SS_ONSTACK; + } else + ucp->uc_stack.ss_flags &= ~SS_ONSTACK; + mask2set(scp->sc_mask, &ucp->uc_sigmask); + + ucp->uc_mcontext.gregs[REG_SP] = scp->sc_sp; + ucp->uc_mcontext.gregs[REG_PC] = scp->sc_pc; + ucp->uc_mcontext.gregs[REG_nPC] = scp->sc_npc; +#if defined(__sparcv9) + ucp->uc_mcontext.gregs[REG_CCR] = scp->sc_psr; +#else + ucp->uc_mcontext.gregs[REG_PSR] = scp->sc_psr; +#endif + ucp->uc_mcontext.gregs[REG_G1] = scp->sc_g1; + ucp->uc_mcontext.gregs[REG_O0] = scp->sc_o0; + + if (sig == SIGFPE) { + if (ucp->uc_mcontext.fpregs.fpu_qcnt > 0) { + ucp->uc_mcontext.fpregs.fpu_qcnt--; + ucp->uc_mcontext.fpregs.fpu_q++; + } + } + (void) setcontext(ucp); + /* NOTREACHED */ +} +#endif + +int +_sigsetmask(int mask) +{ + return (ucbsigsetmask(mask)); +} + +int +ucbsigsetmask(int mask) +{ + sigset_t oset; + sigset_t nset; + + (void) _sigprocmask(0, (sigset_t *)0, &nset); + mask2set(mask, &nset); + (void) _sigprocmask(SIG_SETMASK, &nset, &oset); + return (set2mask(&oset)); +} + +int +_sigblock(int mask) +{ + return (ucbsigblock(mask)); +} + +int +ucbsigblock(int mask) +{ + sigset_t oset; + sigset_t nset; + + (void) _sigprocmask(0, (sigset_t *)0, &nset); + mask2set(mask, &nset); + (void) _sigprocmask(SIG_BLOCK, &nset, &oset); + return (set2mask(&oset)); +} + +int +usigpause(int mask) +{ + return (ucbsigpause(mask)); +} + +int +ucbsigpause(int mask) +{ + sigset_t set, oset; + int ret; + + (void) _sigprocmask(0, (sigset_t *)0, &set); + oset = set; + mask2set(mask, &set); + ret = sigsuspend(&set); + (void) _sigprocmask(SIG_SETMASK, &oset, (sigset_t *)0); + return (ret); +} + +int +_sigvec(int sig, struct sigvec *nvec, struct sigvec *ovec) +{ + return (ucbsigvec(sig, nvec, ovec)); +} + +int +ucbsigvec(int sig, struct sigvec *nvec, struct sigvec *ovec) +{ + struct sigaction nact; + struct sigaction oact; + struct sigaction *nactp; + void (*ohandler)(int, int, struct sigcontext *, char *); + void (*nhandler)(int, int, struct sigcontext *, char *); + + if (sig <= 0 || sig >= NSIG) { + errno = EINVAL; + return (-1); + } + + if ((long)ovec == -1L || (long)nvec == -1L) { + errno = EFAULT; + return (-1); + } + + ohandler = _siguhandler[sig]; + + if (nvec) { + (void) _sigaction(sig, (struct sigaction *)0, &nact); + nhandler = nvec->sv_handler; + /* + * To be compatible with the behavior of SunOS 4.x: + * If the new signal handler is SIG_IGN or SIG_DFL, + * do not change the signal's entry in the handler array. + * This allows a child of vfork(2) to set signal handlers + * to SIG_IGN or SIG_DFL without affecting the parent. + */ + if ((void (*)(int))nhandler != SIG_DFL && + (void (*)(int))nhandler != SIG_IGN) { + _siguhandler[sig] = nhandler; + nact.sa_handler = (void (*)(int))ucbsigvechandler; + } else { + nact.sa_handler = (void (*)(int))nhandler; + } + mask2set(nvec->sv_mask, &nact.sa_mask); + if (sig == SIGKILL || sig == SIGSTOP) + nact.sa_handler = SIG_DFL; + nact.sa_flags = SA_SIGINFO; + if (!(nvec->sv_flags & SV_INTERRUPT)) + nact.sa_flags |= SA_RESTART; + if (nvec->sv_flags & SV_RESETHAND) + nact.sa_flags |= SA_RESETHAND; + if (nvec->sv_flags & SV_ONSTACK) + nact.sa_flags |= SA_ONSTACK; + nactp = &nact; + } else + nactp = (struct sigaction *)0; + + if (_sigaction(sig, nactp, &oact) < 0) { + _siguhandler[sig] = ohandler; + return (-1); + } + + if (ovec) { + if (oact.sa_handler == SIG_DFL || oact.sa_handler == SIG_IGN) + ovec->sv_handler = + (void (*) (int, int, struct sigcontext *, char *)) + oact.sa_handler; + else + ovec->sv_handler = ohandler; + ovec->sv_mask = set2mask(&oact.sa_mask); + ovec->sv_flags = 0; + if (oact.sa_flags & SA_ONSTACK) + ovec->sv_flags |= SV_ONSTACK; + if (oact.sa_flags & SA_RESETHAND) + ovec->sv_flags |= SV_RESETHAND; + if (!(oact.sa_flags & SA_RESTART)) + ovec->sv_flags |= SV_INTERRUPT; + } + + return (0); +} + +int +_sigstack(struct sigstack *nss, struct sigstack *oss) +{ + struct sigaltstack nalt; + struct sigaltstack oalt; + struct sigaltstack *naltp; + + if (nss) { + /* + * XXX: assumes stack growth is down (like sparc) + */ + nalt.ss_sp = nss->ss_sp - SIGSTKSZ; + nalt.ss_size = SIGSTKSZ; + nalt.ss_flags = 0; + naltp = &nalt; + } else + naltp = (struct sigaltstack *)0; + + if (sigaltstack(naltp, &oalt) < 0) + return (-1); + + if (oss) { + /* + * XXX: assumes stack growth is down (like sparc) + */ + oss->ss_sp = oalt.ss_sp + oalt.ss_size; + oss->ss_onstack = ((oalt.ss_flags & SS_ONSTACK) != 0); + } + + return (0); +} + +void (* +ucbsignal(int s, void (*a)(int)))(int) +{ + struct sigvec osv; + struct sigvec nsv; + static int mask[NSIG]; + static int flags[NSIG]; + + nsv.sv_handler = (void (*) (int, int, struct sigcontext *, char *)) a; + nsv.sv_mask = mask[s]; + nsv.sv_flags = flags[s]; + if (ucbsigvec(s, &nsv, &osv) < 0) + return (SIG_ERR); + if (nsv.sv_mask != osv.sv_mask || nsv.sv_flags != osv.sv_flags) { + mask[s] = nsv.sv_mask = osv.sv_mask; + flags[s] = nsv.sv_flags = + osv.sv_flags & ~(SV_RESETHAND|SV_INTERRUPT); + if (ucbsigvec(s, &nsv, (struct sigvec *)0) < 0) + return (SIG_ERR); + } + return ((void (*) (int)) osv.sv_handler); +} + +void (* +usignal(int s, void (*a) (int)))(int) +{ + return (ucbsignal(s, a)); +} + +/* + * Set signal state to prevent restart of system calls + * after an instance of the indicated signal. + */ + +int +_siginterrupt(int sig, int flag) +{ + return (ucbsiginterrupt(sig, flag)); +} + +int +ucbsiginterrupt(int sig, int flag) +{ + struct sigvec sv; + int ret; + + if ((ret = ucbsigvec(sig, 0, &sv)) < 0) + return (ret); + if (flag) + sv.sv_flags |= SV_INTERRUPT; + else + sv.sv_flags &= ~SV_INTERRUPT; + return (ucbsigvec(sig, &sv, 0)); +} diff --git a/usr/src/ucblib/libucb/sparcv9/Makefile b/usr/src/ucblib/libucb/sparcv9/Makefile new file mode 100644 index 0000000000..a708a444bc --- /dev/null +++ b/usr/src/ucblib/libucb/sparcv9/Makefile @@ -0,0 +1,54 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1997-1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libucb/sparcv9/Makefile + +SYSOBJS= \ + setjmp.o \ + signal.o + +MAPDIR= ../spec/sparcv9 + +include ../Makefile.com +include $(SRC)/lib/Makefile.lib.64 + +DYNFLAGS += $(DYNFLAGS64) +BUILD.SO= $(CC) $(CFLAGS) -o $@ -G $(DYNFLAGS) $(PICS) -L $(ROOT)/usr/lib/$(MACH64) $(LDLIBS) +BUILD.s= $(AS) $(ASFLAGS) -xarch=v9 -D__sparcv9 $< -o $@ + +# sparcv9-specific rule +objs/%.o pics/%.o: ../sparc/sys/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) + +objs/%.o pics/%.o: sys/%.s + $(BUILD.s) + $(POST_PROCESS_O) + +.KEEP_STATE: + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) diff --git a/usr/src/ucblib/libucb/sparcv9/llib-lucb b/usr/src/ucblib/libucb/sparcv9/llib-lucb new file mode 100644 index 0000000000..ef235b901e --- /dev/null +++ b/usr/src/ucblib/libucb/sparcv9/llib-lucb @@ -0,0 +1,256 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 1995-1997, by Sun Microsystems, Inc. + * All Rights Reserved + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* LINTLIBRARY */ +/* PROTOLIB1 */ + +#include <sys/time.h> +#include <varargs.h> +#include <stdio.h> +#include <sys/types.h> +#include <errno.h> +#include <sys/syscall.h> +#include <sys/siginfo.h> +#include <sys/ucontext.h> +#include <signal.h> +#include <ucontext.h> +#include <setjmp.h> +#include <sys/resource.h> +#include <sys/utsname.h> +#include <sys/systeminfo.h> +#include <sys/errno.h> +#include <sys/unistd.h> +#include <sys/mman.h> +#include <sys/uadmin.h> +#include <sys/times.h> +#include <wait.h> +#include <sys/procset.h> +#include <sys/param.h> +#include <values.h> +#include <ctype.h> +#include <nan.h> +#include <memory.h> +#include <string.h> +#include <locale.h> +#include <fcntl.h> +#include <nlist.h> +#include <sys/dir.h> +#include <sys/stat.h> +#include <sys/priocntl.h> +#include <sys/file.h> +#include <sys/fcntl.h> +#include <sys/statvfs.h> +#include <sys/vfs.h> + +#include <sys/timeb.h> + +/* port/sys/gettimeofday.c */ +int gettimeofday(struct timeval *tp, void *tzp); +int settimeofday(struct timeval *tp, void *tzp); + +/* port/sys/signal.c */ +int _sigvechandler(int sig, siginfo_t *sip, ucontext_t *ucp); +int _sigsetmask(int mask); +int ucbsigsetmask(int mask); +int _sigblock(int mask); +int ucbsigblock(int mask); +int usigpause(int mask); +int ucbsigpause(int mask); +int _sigvec(int sig, struct sigvec *nvec, struct sigvec *ovec); +int ucbsigvec(int sig, struct sigvec *nvec, struct sigvec *ovec); +int _sigstack(struct sigstack *nss, struct sigstack *oss); +void ucbsignal(int s, void (*a)()); +void usignal(int s, void (*a)()); +int _siginterrupt(int sig, int flag); +int ucbsiginterrupt(int sig, int flag); + +/* port/sys/setjmp.c */ +int setjmp(jmp_buf env); +int _setjmp(jmp_buf env); +void _longjmp(jmp_buf env, int val); +void longjmp(jmp_buf env, int val); + +/* port/sys/getdtblsize.c */ +int getdtablesize(void); + +/* port/sys/gethostid.c */ +long gethostid(void); + +/* port/sys/gethostname.c */ +int gethostname(char *name, int namelen); +int sethostname(char *name, int namelen); + +/* port/sys/getpagesize.c */ +int getpagesize(void); + +/* port/sys/killpg.c */ +int killpg(int pgrp, int sig); + +/* port/sys/mctl.c */ +int mctl(caddr_t addr, size_t len, int function, int arg); + +/* port/sys/reboot.c */ +int reboot(int howto, char *bootargs); + +/* port/sys/setreid.c */ +int setreuid(int ruid, int euid); +int setregid(int rgid, int egid); + +/* port/sys/wait3.c */ +int wait3(int *status, int options, struct rusage *rp); +int wstat(int code, int status); + +/* port/sys/wait4.c */ +pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage); + +/* port/sys/getrusage.c */ +int getrusage(int who, struct rusage *rusage); + +/* port/sys/setpgrp.c */ +int setpgrp(pid_t pid1, pid_t pid2); + +/* port/stdio/sprintf.c */ +char *sprintf(const char *string, const char *format, ...); + +/* port/stdio/doprnt.c */ +int _doprnt(char *format, va_list in_args, FILE *iop); +/* + * void _mkarglst(fmt, args, arglst) char *fmt; stva_list args; + * stva_list arglst[]; {} + * void _getarg(fmt, pargs, argno) char *fmt; stva_list *pargs; int argno; {} + */ + +/* port/stdio/fopen.c */ +FILE *fopen(const char *file, const char *mode); +FILE *freopen(const char *file, const char *mode, FILE *iop); + +/* port/stdio/fprintf.c */ +int fprintf(FILE *iop, const char *format, ...); + +/* port/stdio/printf.c */ +/* VARARGS1 */ +int printf(const char *format, ...); + +/* port/stdio/vfprintf.c */ +/* VARARGS 2 */ +int vfprintf(FILE *iop, const char *format, va_list); + +/* port/stdio/vprintf.c */ +/* VARARGS 1 */ +int vprintf(const char *format, va_list); + +/* port/stdio/vsprintf.c */ +/* VARARGS 2 */ +char *vsprintf(char *string, char *format, va_list); + +/* port/gen/nlist.c */ +int nlist(const char *name, struct nlist *list); + +/* port/gen/readdir.c */ +struct direct *readdir(DIR *dirp); + +/* port/gen/scandir.c */ +int scandir(char *dirname, struct direct *(*namelist[]), int (*select)(), + int (*dcomp)()); +int alphasort(struct direct **d1, struct direct **d2); + +/* port/gen/setpriority.c */ +int getpriority(int which, int who); +int setpriority(int which, int who, int prio); + +/* port/gen/siglist.c */ + +/* port/gen/_psignal.c */ +void _psignal(unsigned sig, char *s); + +/* port/gen/bcmp.c */ +int bcmp(char *s1, char *s2, int len); + +/* port/gen/bcopy.c */ +void bcopy(char *s1, char *s2, int len); + +/* port/gen/bzero.c */ +void bzero(char *sp, int len); + +/* port/gen/ftime.c */ +int ftime(struct timeb *tp); + +/* port/gen/getusershell.c */ +char *getusershell(void); +int endusershell(void); +int setusershell(void); + +/* port/gen/getwd.c */ +char *getwd(char *pathname); + +/* port/gen/index.c */ +char *index(char *sp, char c); + +/* port/gen/mkstemp.c */ +int mkstemp(char *as); + +/* port/gen/nice.c */ +int nice(int incr); + +/* port/gen/psignal.c */ +void psignal(unsigned sig, char *s); + +/* port/gen/rand.c */ +int srand(unsigned x); +int rand(void); + +/* port/gen/random.c */ +int srandom(unsigned x); +char *initstate(unsigned seed, char *arg_state, int n); +char *setstate(char *arg_state); +long random(void); + +/* port/gen/regex.c */ +char *re_comp(char *sp); +int re_exec(char *p1); + +/* port/gen/rindex.c */ +char *rindex(char *sp, char c); + +/* port/gen/setbuffer.c */ +void setbuffer(FILE *iop, char *abuf, int asize); +int setlinebuf(FILE *iop); + +/* port/gen/statfs.c */ +int statfs(char *path, struct statfs *buf); +int fstatfs(int fd, struct statfs *buf); +int cnvtvfs(struct statfs *buf, struct statvfs *vbuf); + +/* port/gen/times.c */ +clock_t times(struct tms *tmsp); + +/* port/gen/ualarm.c */ +unsigned ualarm(unsigned usecs, unsigned reload); + +/* port/gen/usleep.c */ +int usleep(unsigned n); diff --git a/usr/src/ucblib/libucb/spec/Makefile b/usr/src/ucblib/libucb/spec/Makefile new file mode 100644 index 0000000000..810d58ffb7 --- /dev/null +++ b/usr/src/ucblib/libucb/spec/Makefile @@ -0,0 +1,30 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libucb/spec/Makefile + +include $(SRC)/lib/Makefile.spec.arch diff --git a/usr/src/ucblib/libucb/spec/Makefile.override b/usr/src/ucblib/libucb/spec/Makefile.override new file mode 100644 index 0000000000..55d9f1c59c --- /dev/null +++ b/usr/src/ucblib/libucb/spec/Makefile.override @@ -0,0 +1,29 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# + +CPPFLAGS= -D$(MACH) -I$(ROOT)/usr/ucbinclude $(CPPFLAGS.master) diff --git a/usr/src/ucblib/libucb/spec/Makefile.targ b/usr/src/ucblib/libucb/spec/Makefile.targ new file mode 100644 index 0000000000..f3ccd86859 --- /dev/null +++ b/usr/src/ucblib/libucb/spec/Makefile.targ @@ -0,0 +1,36 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libucb/spec/Makefile.targ + +LIBRARY = libucb.a +VERS = .1 + +OBJECTS = ucb.o + +TRANSCPP = +SPECCPP = -I$(ROOT)/usr/ucbinclude diff --git a/usr/src/ucblib/libucb/spec/amd64/Makefile b/usr/src/ucblib/libucb/spec/amd64/Makefile new file mode 100644 index 0000000000..9207eb9774 --- /dev/null +++ b/usr/src/ucblib/libucb/spec/amd64/Makefile @@ -0,0 +1,43 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#amd64_C_PICFLAGS = $(amd64_C_BIGPICFLAGS) + +include $(SRC)/lib/Makefile.spec +include ../Makefile.override + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/libucb/spec/i386/Makefile b/usr/src/ucblib/libucb/spec/i386/Makefile new file mode 100644 index 0000000000..cfea9bbb75 --- /dev/null +++ b/usr/src/ucblib/libucb/spec/i386/Makefile @@ -0,0 +1,43 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libucb/spec/i386/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#i386_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec +include ../Makefile.override + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/libucb/spec/sparc/Makefile b/usr/src/ucblib/libucb/spec/sparc/Makefile new file mode 100644 index 0000000000..35c6dab469 --- /dev/null +++ b/usr/src/ucblib/libucb/spec/sparc/Makefile @@ -0,0 +1,45 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libucb/spec/sparc/Makefile + +.KEEP_STATE: + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib + +# Uncomment the following if the linker complains +#sparc_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec +include ../Makefile.override + +install: $(UCBLIB_ABILIB) diff --git a/usr/src/ucblib/libucb/spec/sparcv9/Makefile b/usr/src/ucblib/libucb/spec/sparcv9/Makefile new file mode 100644 index 0000000000..7ea9199c8e --- /dev/null +++ b/usr/src/ucblib/libucb/spec/sparcv9/Makefile @@ -0,0 +1,44 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 1999 by Sun Microsystems, Inc. +# All rights reserved. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# ucblib/libucb/spec/sparcv9/Makefile + +include ../Makefile.targ + +# Add arch specific objects here +OBJECTS += + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.lib.64 + +# Uncomment the following if the linker complains +#sparcv9_C_PICFLAGS = -K PIC + +include $(SRC)/lib/Makefile.spec +include ../Makefile.override + +install: $(UCBLIB_ABILIB64) diff --git a/usr/src/ucblib/libucb/spec/ucb.spec b/usr/src/ucblib/libucb/spec/ucb.spec new file mode 100644 index 0000000000..aead21f06c --- /dev/null +++ b/usr/src/ucblib/libucb/spec/ucb.spec @@ -0,0 +1,565 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# ident "%Z%%M% %I% %E% SMI" +# + +function alphasort64 +include <sys/types.h> +include <sys/dir.h> +declaration int alphasort64(struct direct64 **d1, struct direct64 **d2) +arch sparc i386 +version SUNW_1.1 +end + +function fopen64 +include <stdio.h> +declaration FILE *fopen64(const char *file, const char *mode) +arch sparc i386 +version SUNW_1.1 +end + +function freopen64 +include <stdio.h> +declaration FILE *freopen64(const char *file, const char *mode, FILE *iop) +arch sparc i386 +version SUNW_1.1 +end + +function readdir64 +include <sys/types.h> +include <sys/dir.h> +declaration struct direct64 *readdir64(DIR *dirp) +arch sparc i386 +version SUNW_1.1 +end + +function scandir64 +include <sys/types.h> +include <sys/dir.h> +declaration int scandir64(char *dirname, struct direct64 *(*namelist[]), \ + int (*select)(struct direct64 *), \ + int (*dcomp)(struct direct64 **, struct direct64 **)) +arch sparc i386 +version SUNW_1.1 +end + +function alphasort +include <sys/types.h> +include <sys/dir.h> +declaration int alphasort(struct direct **d1, struct direct **d2) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function bcmp +include <sys/types.h> +include <strings.h> +declaration int bcmp(const void *s1, const void *s2, size_t len) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function bcopy +include <sys/types.h> +include <strings.h> +declaration void bcopy(const void *s1, void *s2, size_t len) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function bzero +include <sys/types.h> +include <strings.h> +declaration void bzero(void *sp, size_t len) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function flock +include <sys/types.h> +include <sys/file.h> +include <fcntl.h> +declaration int flock(int fd, int operation) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function fopen +include <stdio.h> +declaration FILE *fopen(const char *file, const char *mode) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function fprintf +include <stdio.h> +declaration int fprintf(FILE *iop, const char *format, ...) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function freopen +include <stdio.h> +declaration FILE *freopen(const char *file, const char *mode, FILE *iop) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function fstatfs +include <sys/types.h> +include <sys/vfs.h> +declaration int fstatfs(int fd, struct statfs *buf) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function ftime +include <sys/types.h> +include <sys/timeb.h> +declaration int ftime(struct timeb *tp) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function getdtablesize +include <sys/types.h> +include <sys/time.h> +include <sys/resource.h> +declaration int getdtablesize(void) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function gethostid +include <sys/types.h> +include <sys/systeminfo.h> +declaration long gethostid(void) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function gethostname +include <sys/types.h> +include <sys/utsname.h> +declaration int gethostname(char *name, int namelen) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function getpagesize +include <unistd.h> +declaration int getpagesize(void) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function getrusage extends libc/spec/gen.spec +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +filter libc.so.1 +end + +function gettimeofday +include <sys/types.h> +include <sys/time.h> +declaration int gettimeofday(struct timeval *tp, void *tzp) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function getwd +include <stdlib.h> +declaration char *getwd(char *pathname) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function index +include <strings.h> +declaration char *index(char *sp, char c) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function killpg +include <sys/types.h> +include <signal.h> +declaration int killpg(int pgrp, int sig) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function longjmp +arch sparc sparcv9 +version sparc=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function longjmp +arch i386 +version i386=SUNW_0.7 +filter libc.so.1 +end + +function mctl +include <sys/types.h> +include <sys/mman.h> +declaration int mctl(caddr_t addr, size_t len, int function, int arg) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function nice +include <sys/resource.h> +declaration int nice(int incr) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function nlist +include <sys/types.h> +include <nlist.h> +declaration int nlist(const char *name, struct nlist *list) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function printf +include <stdio.h> +declaration int printf(const char *format, ...) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function psignal +include <sys/types.h> +declaration void psignal(unsigned int sig, char *s) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function rand +include <stdlib.h> +declaration int rand(void) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function re_comp +include <sys/types.h> +include <stdlib.h> +declaration char *re_comp(char *sp) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function re_exec +include <sys/types.h> +include <stdlib.h> +declaration int re_exec(char *p1) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function readdir +include <sys/types.h> +include <sys/dir.h> +declaration struct direct *readdir(DIR *dirp) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function reboot +include <sys/types.h> +declaration int reboot(int howto, char *bootargs) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function rindex +include <strings.h> +declaration char *rindex(char *sp, char c) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function scandir +include <sys/dir.h> +declaration int scandir(char *dirname, struct direct *(*namelist[]), \ + int (*)(struct direct *), \ + int (*)(struct direct **, struct direct **)) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function setbuffer +declaration void setbuffer(FILE *iop, char *abuf, int asize) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function sethostname +declaration int sethostname(char *name, int namelen) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function setjmp +arch sparc sparcv9 +version sparc=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function setjmp +arch i386 +version i386=SUNW_0.7 +filter libc.so.1 +end + +function setlinebuf +include <stdio.h> +declaration int setlinebuf(FILE *iop) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function setpgrp +include <sys/types.h> +include <unistd.h> +declaration int setpgrp(pid_t pid1, pid_t pid2) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function settimeofday +declaration int settimeofday(struct timeval *tp, void *tzp) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function sigblock +declaration int sigblock(int mask) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function siginterrupt +declaration int siginterrupt(int sig, int flag) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function signal +declaration void (*signal(int s, void (*a)(int)))(int) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function sigpause +declaration int sigpause(int mask) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function sigsetmask +declaration int sigsetmask(int mask) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function sigstack +declaration int sigstack(struct sigstack *nss, struct sigstack *oss) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function sigvec +declaration int sigvec(int sig, struct sigvec *nvec, struct sigvec *ovec) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function sigvechandler +include <sys/types.h> +include <signal.h> +include <sys/siginfo.h> +include <sys/ucontext.h> +declaration int sigvechandler(int sig, siginfo_t *sip, ucontext_t *ucp) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function sleep +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +filter libc.so.1 +end + +function sprintf +include <stdio.h> +declaration char *sprintf(const char *string, const char *format, ...) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function srand +include <stdlib.h> +declaration void srand(unsigned int x) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function statfs +include <sys/vfs.h> +declaration int statfs(char *path, struct statfs *buf) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +data sys_siglist +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +data _siguhandler +version SUNW_1.3 +end + +function times +include <sys/time.h> +include <sys/times.h> +declaration clock_t times(struct tms *tmsp) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function ualarm +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +filter libc.so.1 +end + +function usignal +include <signal.h> +declaration void (*usignal(int s, void (*a)(int)))(int) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function usigpause +include <signal.h> +declaration int usigpause(int mask) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function usleep +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +filter libc.so.1 +end + +function vfprintf +include <stdarg.h> +include <stdio.h> +declaration int vfprintf(FILE *iop, const char *format, va_list ap) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function vprintf +include <stdio.h> +include <stdarg.h> +declaration int vprintf(const char *format, va_list ap) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function vsprintf +include <stdio.h> +include <stdarg.h> +declaration char *vsprintf(char *string, char *format, va_list ap) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function wait3 +include <sys/types.h> +include <sys/resource.h> +include <sys/wait.h> +declaration pid_t wait3(int *status, int options, struct rusage *rp) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function wait4 +include <sys/types.h> +include <sys/wait.h> +include <sys/resource.h> +declaration pid_t wait4(pid_t pid, int *status, int options, \ + struct rusage *rp) +version sparc=SUNW_0.7 i386=SUNW_0.7 amd64=SUNW_0.7 sparcv9=SUNW_1.1 +end + +function _doprnt +version SUNWprivate_1.1 +end + +function _getarg +version SUNWprivate_1.1 +end + +function _longjmp +arch sparc sparcv9 +version SUNWprivate_1.1 +end + +function _longjmp +arch i386 +version SUNWprivate_1.1 +filter libc.so.1 +end + +function _mkarglst +version SUNWprivate_1.1 +end + +function _setjmp +arch sparc sparcv9 +version SUNWprivate_1.1 +end + +function _setjmp +arch i386 +version SUNWprivate_1.1 +filter libc.so.1 +end + +function _sigblock +version SUNWprivate_1.1 +end + +function _siginterrupt +version SUNWprivate_1.1 +end + +function _sigsetmask +version SUNWprivate_1.1 +end + +function _sigstack +version SUNWprivate_1.1 +end + +function _sigvec +version SUNWprivate_1.1 +end + +function _sigvechandler +version SUNWprivate_1.1 +end + +function ucbsigblock +version SUNWprivate_1.1 +end + +function ucbsiginterrupt +version SUNWprivate_1.1 +end + +function ucbsigpause +version SUNWprivate_1.1 +end + +function ucbsigsetmask +version SUNWprivate_1.1 +end + +function ucbsigvec +version SUNWprivate_1.1 +end + +function __sigcleanup +arch sparc sparcv9 +version SUNWprivate_1.1 +end + +function syscall +arch sparc +version SUNWprivate_1.1 +filter libc.so.1 +end + +function _syscall +arch i386 +version SUNWprivate_1.1 +filter libc.so.1 +end + +function _times +arch i386 +version SUNWprivate_1.1 +filter libc.so.1 +end diff --git a/usr/src/ucblib/libucb/spec/versions b/usr/src/ucblib/libucb/spec/versions new file mode 100644 index 0000000000..68c9b98bdc --- /dev/null +++ b/usr/src/ucblib/libucb/spec/versions @@ -0,0 +1,60 @@ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# ident "%Z%%M% %I% %E% SMI" +# +# Note: Even though the SUNW_1.2 version now contains no symbols +# beyond what was present at Solaris 2.6, the SUNW_1.2 version MUST be +# present. This is because applications built on 2.6 Beta +# (when it did contain symbols explicitly) may depend on it. +# + +sparc { + SUNW_1.3: {SUNW_1.2}; # Solaris 10 + SUNW_1.2: {SUNW_1.1}; # see note above + SUNW_1.1: {SUNW_0.7}; # Solaris ABI as of Solaris 2.6 + SUNW_0.7; # Solaris ABI as of Solaris 2.3 + SUNWprivate_1.1; +} +sparcv9 { + SUNW_1.3: {SUNW_1.2}; + SUNW_1.2: {SUNW_1.1}; + SUNW_1.1: {SUNW_0.7}; + SUNW_0.7; + SUNWprivate_1.1; +} +i386 { + SUNW_1.3: {SUNW_1.2}; + SUNW_1.2: {SUNW_1.1}; + SUNW_1.1: {SUNW_0.7}; + SUNW_0.7; + SUNWprivate_1.1; +} +amd64 { + SUNW_1.3: {SUNW_1.2}; + SUNW_1.2: {SUNW_1.1}; + SUNW_1.1: {SUNW_0.7}; + SUNW_0.7; + SUNWprivate_1.1; +} diff --git a/usr/src/ucblib/req.flg b/usr/src/ucblib/req.flg new file mode 100644 index 0000000000..23416a94b2 --- /dev/null +++ b/usr/src/ucblib/req.flg @@ -0,0 +1,26 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +#pragma ident "%Z%%M% %I% %E% SMI" + + +echo_file usr/src/ucblib/Makefile.ucbtarg |