Before moving to git, checked in a bunch of apparent work-in-progress

files that have been sitting idle for a few years.  Unfortunately
I can't gaurantee at the moment that these even compile let alone build.
Caveat Emptor
This commit is contained in:
gdr 2012-08-26 02:55:00 +00:00
parent e55fb1c59f
commit 0df1477cf9
19 changed files with 294 additions and 408 deletions

View File

@ -2,7 +2,43 @@
# This file is intended for use with dmake. There are constructs in
# here that (as yet) make it unsuitable to be used on the GS.
#
# $Id: Makefile,v 1.5 1997/12/22 01:11:08 gdr Exp $
# $Id: Makefile,v 1.6 2012/08/26 02:54:57 gdr Exp $
#
.INCLUDE: /src/gno/paths.mk
INSTALL *= /usr/bin/install
CHTYP *= /bin/chtyp
headerInstall .USESHELL:
$(CHTYP) -lasm $(SRC_DIR)/gno/ainclude/m*
$(CHTYP) -lrez $(SRC_DIR)/gno/rinclude/*.rez
$(CHTYP) -lcc $(SRC_DIR)/gno/include/*.h
$(CHTYP) -lcc $(SRC_DIR)/gno/include/arpa/*.h
$(CHTYP) -lcc $(SRC_DIR)/gno/include/gno/*.h
$(CHTYP) -lcc $(SRC_DIR)/gno/include/machine/*.h
$(CHTYP) -lcc $(SRC_DIR)/gno/include/net/*.h
$(CHTYP) -lcc $(SRC_DIR)/gno/include/netinet/*.h
$(CHTYP) -lcc $(SRC_DIR)/gno/include/protocols/*.h
$(CHTYP) -lcc $(SRC_DIR)/gno/include/rpc/*.h
$(CHTYP) -lcc $(SRC_DIR)/gno/include/sys/*.h
$(CHTYP) -lcc $(SRC_DIR)/gno/orcacdefs/*.h
$(INSTALL) $(SRC_DIR)/gno/ainclude/m* /usr/ainclude
$(INSTALL) $(SRC_DIR)/gno/rinclude/*.rez /usr/rinclude
$(INSTALL) $(SRC_DIR)/gno/include/*.h /usr/include
$(INSTALL) $(SRC_DIR)/gno/include/arpa/*.h /usr/include/arpa
$(INSTALL) $(SRC_DIR)/gno/include/gno/*.h /usr/include/gno
$(INSTALL) $(SRC_DIR)/gno/include/machine/*.h /usr/include/machine
$(INSTALL) $(SRC_DIR)/gno/include/net/*.h /usr/include/net
$(INSTALL) $(SRC_DIR)/gno/include/netinet/*.h /usr/include/netinet
$(INSTALL) $(SRC_DIR)/gno/include/protocols/*.h /usr/include/protocols
$(INSTALL) $(SRC_DIR)/gno/include/rpc/*.h /usr/include/rpc
$(INSTALL) $(SRC_DIR)/gno/include/sys/*.h /usr/include/sys
$(INSTALL) $(SRC_DIR)/gno/orcacdefs/*.h /lib/orcacdefs
#
# The remaining macros, targets, and recipies were used before trenco
# was fully serving the GNO stuff.
#
XFER = xfer
TMP = /tmp/gnobuild

View File

@ -11,7 +11,7 @@
* *
* Devin Reade, 10 April 1998. *
* *
* $Id: status.bin,v 1.21 1999/04/29 15:48:51 gdr-ftp Exp $ *
* $Id: status.bin,v 1.22 2012/08/26 02:54:58 gdr Exp $ *
* *
*************************************************************************
@ -95,7 +95,7 @@ Program 204 Req Owner Source Man Compile Test Target Target [Note] Comments
/bin/conv Y # should be replaced by /usr/bin/udl
/bin/cp Y Y
/bin/csh
/bin/date Y Y tl Y
/bin/date Y Y mober Y # uploaded to mail distrib on trenco
/bin/dd
/bin/df N Y evan Y T Y Y Y RI
/bin/domainname
@ -128,7 +128,7 @@ Program 204 Req Owner Source Man Compile Test Target Target [Note] Comments
/bin/purge Y Y . Y . . . Y
/bin/pwd N Y dave Y T Y Y Y RI
/bin/rcp N Y dt Y T Y . Y RI
/bin/rm Y Y tribby
/bin/rm Y Y tribby Y T Y Y Y RI
/bin/rmail N N
/bin/rmdir N Y gdr Y T Y Y Y RI
/bin/sh N Y gdr

View File

@ -1,4 +1,4 @@
$Id: status.lib,v 1.8 1999/01/09 21:28:35 gdr-ftp Exp $
$Id: status.lib,v 1.9 2012/08/26 02:54:58 gdr Exp $
Key for Code Status column:
R == reviewed
@ -352,6 +352,7 @@ strncasecmp libc/str/case.c C 3 string.h
strsep libc/string/str.c C 3 string.h
stty libc/gen/compat.c C 3 sgtty.h
suboptarg [var] libc/stdlib/getsubopt.c C 3 stdlib.h
swab libc/string/swab.c C 3 string.h
swait libc/sys/trap.asm T 2 gno/gno.h
sys_errlist [var] libc/stdio/perror.c T 3 stdio.h
sys_nerr [var] libc/stdio/perror.c T 3 stdio.h
@ -399,7 +400,7 @@ writev libc/sys/syscall.c T 2 sys/uio.h
zopen libc/stdio/ stdio.h
Notes:
[var] symbol is a variable, not a fuction
[var] symbol is a variable, not a function
[A] function needs to be modified before use
[B] these sets of routines rely on a modified utmp/wtmp file
structure. Therefore a large list of routines and programs
@ -538,6 +539,7 @@ BANK MODEL COMPLETE
78 0 0 Y N libc/string/case.c
78 0 0 Y N libc/string/str.c
78 0 0 Y Y libc/string/strerror.c
78 0 0 Y N libc/string/swab.c
78 0 0 Y libc/sys/exec.c
78 0 0 Y libc/sys/syscall.c

View File

@ -1,93 +0,0 @@
***********************************************************************
*
* MKDIR.ASM - Version 1.0
* Written by Tim Meekins
* Copyright (C) 1991 by Procyon, Inc.
* This program is hereby donated to the public domain.
*
* This program creates a new directory in the current (or specified)
* directory.
*
* TODO:
* o Add -p option.
* o Should I support creating multiple directories like Unix?
*
* HISTORY:
* 1.0 11/29/91 First version.
*
**************************************************************************
keep mkdir
mcopy mkdir.mac
mkdir START
jml ~GNO_COMMAND
END
main START
arg equ 0
retval equ arg+4
space equ retval+2
subroutine (2:argc,4:argv),space
stz retval
lda argc
dec a
bne part2
ErrWriteCString #usage
jmp error
part2 dec a
beq part3
ErrWriteCString #oneerr
jmp error
part3 ldy #4
lda [argv],y
sta arg
iny2
lda [argv],y
sta arg+2
ldy #0
short a
loop lda [arg],y
beq part4
sta pathname+2,y
iny
bra loop
part4 long a
sty pathname
Create createparm
bcc done
sta errval
ErrWriteCString #errleadin
Error errval
error inc retval
done return 2:retval
createparm dc i2'5'
createpath dc i4'pathname'
dc i2'$C3'
dc i2'$0F'
dc i4'$0000'
dc i2'$0D'
errval dc i2'0'
usage dc c'Usage: mkdir directory.',h'0d0a00'
oneerr dc c'mkdir: too many arguments.',h'0d0a00'
errleadin dc c'mkdir: ',h'00'
pathname dc i2'0'
ds 256 ;I dread any person entering a pathname
; ;this long!
END

View File

@ -1,247 +0,0 @@
macro
&lab subroutine &parms,&work
&lab anop
aif c:&work,.a
lclc &work
&work setc 0
.a
gbla &totallen
gbla &worklen
&worklen seta &work
&totallen seta 0
aif c:&parms=0,.e
lclc &len
lclc &p
lcla &i
&i seta c:&parms
.b
&p setc &parms(&i)
&len amid &p,2,1
aif "&len"=":",.c
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .d
.c
&len amid &p,1,1
&p amid &p,3,l:&p-2
.d
&p equ &totallen+3+&work
&totallen seta &totallen+&len
&i seta &i-1
aif &i,^b
.e
tsc
sec
sbc #&work
tcs
inc a
phd
tcd
phb
phk
plb
mend
macro
&lab return &r
&lab anop
lclc &len
aif c:&r,.a
lclc &r
&r setc 0
&len setc 0
ago .h
.a
&len amid &r,2,1
aif "&len"=":",.b
&len amid &r,1,2
&r amid &r,4,l:&r-3
ago .c
.b
&len amid &r,1,1
&r amid &r,3,l:&r-2
.c
aif &len<>2,.d
ldy &r
ago .h
.d
aif &len<>4,.e
ldx &r+2
ldy &r
ago .h
.e
aif &len<>10,.g
ldy #&r
ldx #^&r
ago .h
.g
mnote 'Not a valid return length',16
mexit
.h
aif &totallen=0,.i
lda &worklen+1
sta &worklen+&totallen+1
lda &worklen
sta &worklen+&totallen
.i
plb
pld
tsc
clc
adc #&worklen+&totallen
tcs
aif &len=0,.j
tya
.j
rtl
mend
macro
&lab ErrWriteCString &a1
&lab ph4 &a1
Tool $210c
mend
macro
&lab ERROR &a1
&lab p16 $105,&a1
mend
macro
&lab Create &a1
&lab gsos $2001,&a1
mend
macro
&lab tool &a1
&lab ldx #&a1
jsl $e10000
mend
macro
&lab p16 &a1,&a2
&lab jsl $E100A8
dc i2'&a1'
dc i4'&a2'
mend
macro
&lab gsos &a1,&a2
&lab jsl $E100A8
dc i2'&a1'
dc i4'&a2'
mend
macro
&lab ph4 &parm
lclc &char
lclc &char1
lclc &char2
&lab anop
&char amid &parm,1,1
aif "&char"="#",.immediate
aif "&char"="@",.at
aif s:longa=1,.chk1
rep #%00100000
.chk1
aif "&char"<>"{",.chk2
&char amid &parm,l:&parm,1
aif "&char"<>"}",.error
&parm amid &parm,2,l:&parm-2
ldy #2
lda (&parm),y
pha
lda (&parm)
pha
ago .shorten
.chk2
aif "&char"<>"[",.absolute
ldy #2
lda &parm,y
pha
lda &parm
pha
ago .shorten
.absolute
lda &parm+2
pha
lda &parm
pha
ago .shorten
.at
&char1 amid &parm,2,1
&char2 setc &char1
ph&char1
aif l:&parm<3,.chk2a
&char2 amid &parm,3,1
.chk2a
ph&char2
ago .shorten
.immediate
&parm amid &parm,2,l:&parm-1
pea +(&parm)|-16
pea &parm
ago .done
.shorten
aif s:longa=1,.done
sep #%00100000
.done
mexit
.error
mnote "Missing closing '}'",16
mend
macro
&lab long &stat
&lab anop
lcla &t
lcla &len
lclc &ch
&t seta 0
&len seta l:&stat
.a
aif &len=0,.b
&ch amid &stat,&len,1
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
aif ("&ch"="a").or.("&ch"="m"),.m
.c
&len seta &len-1
ago ^a
.i
longi on
&t seta &t+16
ago ^c
.m
longa on
&t seta &t+32
ago ^c
.b
aif &t=0,.d
rep #&t
.d
mend
macro
&lab short &stat
&lab anop
lcla &t
lcla &len
lclc &ch
&t seta 0
&len seta l:&stat
.a
aif &len=0,.b
&ch amid &stat,&len,1
aif ("&ch"="x").or.("&ch"="y").or.("&ch"="i"),.i
aif ("&ch"="a").or.("&ch"="m"),.m
.c
&len seta &len-1
ago ^a
.i
longi off
&t seta &t+16
ago ^c
.m
longa off
&t seta &t+32
ago ^c
.b
aif &t=0,.d
sep #&t
.d
mend
macro
&lab iny2
&lab iny
iny
mend

View File

@ -85,7 +85,7 @@ __OFLAG = -a0
AR := makelib #ar # archiver
ARFLAGS+= #ruv
RM := /bin/cp -p rm # remove a file command
RM := /bin/rm # remove a file command
RMFLAGS +=
CP := /bin/cp # copy files command

View File

@ -6,7 +6,7 @@
#
# Devin Reade, September 1997.
#
# $Id: fudgeinstall,v 1.9 1999/02/15 21:39:11 gdr-ftp Exp $
# $Id: fudgeinstall,v 1.10 2012/08/26 02:54:59 gdr Exp $
# What is our release directory? (The second one must be HFS, and
# may be the same as the first.)
@ -93,7 +93,7 @@ install -dV $RELDIR/var/run
install -dV $RELDIR/var/spool
echo "installing files in /"
install -V $ROOT/kern.971027 $RELDIR/kern
# kern done
install -V $SRC/gno/verbatim/initrc $RELDIR
echo "installing files in /HFSinclude"
@ -120,7 +120,7 @@ echo "installing files in /bin"
# aroff done
# binprint done
# cat done
install -V /bin/center $RELDIR/bin
# center done
install -V /usr/orca/bin/chmod $RELDIR/bin
# chtyp done
# cmp done
@ -170,10 +170,10 @@ install -V /bin/vi $RELDIR/bin
# wc done
# yes done
echo "installing files in /dev"
install -V /dev/modem $RELDIR/dev
install -V /dev/printer $RELDIR/dev
install -V /dev/null $RELDIR/dev
# echo "installing files in /dev"
# /dev/modem done
# /dev/null done
# /dev/printer done
echo "installing files in /etc"
# don't need cronlog, crontab yet

View File

@ -59,6 +59,6 @@ typedef _BSD_WCHAR_T_ wchar_t;
#define NULL 0
#endif
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
#define offsetof(type,member) ((size_t) (&(((type *)0L)->member)))
#endif /* _STDDEF_H_ */

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)signal.h 8.2 (Berkeley) 1/21/94
* $Id: signal.h,v 1.3 1997/07/28 02:55:56 gdr Exp $
* $Id: signal.h,v 1.4 2012/08/26 02:54:59 gdr Exp $
*/
#ifndef _SYS_SIGNAL_H_
@ -48,6 +48,20 @@
#include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
#endif
#ifdef KERNEL
/*
* The kernel doesn't currently use these macros, but if they ever get
* into the kernel sources, they'd really cause havoc; the numbers differ
* between GNO and ORCA/C
*/
#undef SIGABRT
#undef SIGFPE
#undef SIGILL
#undef SIGINT
#undef SIGSEGV
#undef SIGTERM
#endif
#define SIGHUP 1 /* hangup */
#define SIGINT 2 /* interrupt */
#define SIGQUIT 3 /* quit */

View File

@ -35,7 +35,7 @@
* This is an old implementation and needs to be replaced; just not quite
* yet -- gdr
*
* $Id: getpwent.c,v 1.2 1997/09/21 06:05:00 gdr Exp $
* $Id: getpwent.c,v 1.3 2012/08/26 02:54:59 gdr Exp $
*
* This file is formatted with tab stops every 8 characters.
*/
@ -44,8 +44,6 @@
segment "libc_gen__";
#endif
#define _PATH_PASSWD "/etc/passwd"
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getpwent.c 5.21 (Berkeley) 3/14/91";
#endif /* LIBC_SCCS and not lint */
@ -59,7 +57,6 @@ static char sccsid[] = "@(#)getpwent.c 5.21 (Berkeley) 3/14/91";
#include <err.h>
#define LENGTH 128
#define _PATH_PASSWD "/etc/passwd"
static struct passwd _pw_passwd; /* password structure */
static char pwline[LENGTH]; /* line in /etc/passwd */

View File

@ -1,21 +1,25 @@
#
# Makefile for libc/stdtime.
#
# $Id: Makefile,v 1.3 1998/02/09 08:45:04 taubert Exp $
# $Id: Makefile,v 1.4 2012/08/26 02:54:59 gdr Exp $
#
LIB= c
LIBPFX= $(OBJ_DIR)../
OBJS= asctime.o difftime.o localtime.o strftime.o
LIB = c
LIBPFX = $(OBJ_DIR)../
NO_REZ = true
# SRCS = asctime.c difftime.c localtime.c strftime.c
SRCS = localtime.c strftime.c
DEBUG = 25
OPTIMIZE= 0
CFLAGS += -v
default:
@echo do not use this directory yet
#default:
# @echo do not use this directory yet
.INCLUDE: /src/gno/lib/lib.mk
asctime.o:: private.h
difftime.o:: private.h
localtime.o:: private.h
strftime.o:: private.h
asctime.o: private.h
difftime.o: private.h
localtime.o: private.h
strftime.o: private.h

View File

@ -1,5 +1,5 @@
/*
* $Id: localtime.c,v 1.1 1997/09/21 06:22:10 gdr Exp $
* $Id: localtime.c,v 1.2 2012/08/26 02:54:59 gdr Exp $
*
* This file is formatted for tab stops every 8 columns.
*/
@ -1278,6 +1278,8 @@ register struct tm * const tmp;
#endif /* defined TM_GMTOFF */
}
#ifndef __ORCAC__
char *
#ifdef USE_PROTOS
ctime(const time_t * const timep)
@ -1294,6 +1296,7 @@ const time_t * const timep;
*/
return asctime(localtime(timep));
}
#endif /* __ORCAC__ */
/*
** Adapted from code provided by Robert Elz, who writes:

View File

@ -14,7 +14,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: strftime.c,v 1.1 1997/09/21 06:22:10 gdr Exp $
* $Id: strftime.c,v 1.2 2012/08/26 02:54:59 gdr Exp $
*
* This file is formatted for tab stops every 8 columns.
*/
@ -22,11 +22,14 @@
#ifdef __ORCAC__
segment "libc_stdtm";
#define NOID
#define CONST
#else
#define CONST const
#endif
#ifdef LIBC_RCS
static const char rcsid[] =
"$Id: strftime.c,v 1.1 1997/09/21 06:22:10 gdr Exp $";
"$Id: strftime.c,v 1.2 2012/08/26 02:54:59 gdr Exp $";
#endif
#ifndef lint
@ -52,7 +55,9 @@ static const char sccsid[] = "@(#)strftime.c 5.4 (Berkeley) 3/14/89";
#include <locale.h>
#include <rune.h> /* for _PATH_LOCALE */
#include <sys/stat.h>
#ifdef __ORCAC__
#include <string.h> /* for memcpy() */
#endif
#define LOCALE_HOME _PATH_LOCALE
struct lc_time_T {
@ -69,12 +74,16 @@ struct lc_time_T {
};
static struct lc_time_T localebuf;
#ifdef __ORCAC__
#define Locale (&C_time_locale)
#else
static struct lc_time_T * _loc P((void));
static int using_locale;
#define Locale (using_locale ? &localebuf : &C_time_locale)
#endif
static const struct lc_time_T C_time_locale = {
static CONST struct lc_time_T C_time_locale = {
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
@ -121,7 +130,7 @@ static const struct lc_time_T C_time_locale = {
static char * _add P((const char *, char *, const char *));
static char * _conv P((int, const char *, char *, const char *));
static char * _fmt P((const char *, const struct tm *, char *, const char *));
static char * _fmt P((const char *, CONST struct tm *, char *, CONST char *));
static char * _secs P((const struct tm *, char *, const char *));
size_t strftime P((char *, size_t, const char *, const struct tm *));
@ -152,8 +161,8 @@ strftime(s, maxsize, format, t)
static char *
#ifdef USE_PROTOS
_fmt(const char *format, const struct tm *const t, char *pt,
const char *const ptlim)
_fmt(const char *format, CONST struct tm *CONST t, char *pt,
CONST char *CONST ptlim)
#else
_fmt(format, t, pt, ptlim)
const char *format;
@ -415,9 +424,12 @@ label:
pt, ptlim);
continue;
case 'Z':
#ifndef __ORCAC__
/* we don't currently have the tm_zone field */
if (t->tm_zone != NULL)
pt = _add(t->tm_zone, pt, ptlim);
else
#endif
if (t->tm_isdst == 0 || t->tm_isdst == 1) {
pt = _add(tzname[t->tm_isdst],
pt, ptlim);
@ -476,7 +488,15 @@ _secs(t, pt, ptlim)
struct tm tmp;
/* Make a copy, mktime(3) modifies the tm struct. */
#ifdef __ORCAC__
/*
* ORCA/C pukes with an "illegal operand for the indirection
* operator" message
*/
memcpy(&tmp, t, sizeof(struct tm));
#else
tmp = *t;
#endif
s = mktime(&tmp);
(void) sprintf(buf, "%ld", s);
return _add(buf, pt, ptlim);
@ -497,6 +517,8 @@ _add(str, pt, ptlim)
return pt;
}
#if 0 /* we don't seem to need this yet, so don't build it; it's untested */
extern char *_PathLocale;
int
@ -607,6 +629,12 @@ no_locale:
* setlocale() assumes that we left the old locale alone.
*/
locale_buf = locale_buf_C;
#ifdef __ORCAC__
memcpy(&localebuf, &C_time_locale, sizeof(struct lc_time_T));
#else
localebuf = C_time_locale;
#endif
return -1;
}
#endif /* 0 */

View File

@ -7,7 +7,7 @@
#
# Devin Reade, 1997
#
# $Id: paths.mk,v 1.11 1999/03/19 05:53:31 gdr-ftp Exp $
# $Id: paths.mk,v 1.12 2012/08/26 02:54:58 gdr Exp $
#
# This one isn't really a path, but it affects the creation of path
@ -33,7 +33,7 @@ PRODOS_OBJS = true
#
# To turn this off, completely comment it out; don't just change the value.
# APPLESHARE_CASE_SENSITIVE = true
APPLESHARE_CASE_SENSITIVE = true
# SRC_DIR is the top-level GNO source distribution directory (containing
# $(SRC_DIR)/gno, $(SRC_DIR)/gno/lib, and so forth). It also corresponds

View File

@ -1,7 +1,7 @@
/*
* newuser - add a new user to the system -- James Brookes
*
* $Id: newuser.c,v 1.3 1999/02/15 00:22:11 gdr-ftp Exp $
* $Id: newuser.c,v 1.4 2012/08/26 02:54:59 gdr Exp $
*
* Changes for version 1.2 (Modifications by Devin Reade)
* - account home directories are now made in /home rather than /user
@ -503,7 +503,7 @@ main (int argc, char **argv)
acct_name, pass1, uid, gid, name, HOME, acct_name, DEFAULT_SHELL);
fclose(FOutPtr);
syslog(LOG_INFO, "created account %s pending validation", acct_name);
printf("\nYour account will be available after the system administrator");
printf("\nYour account will be available after the system administrator ");
printf("has had a\nchance to review it.\n");
}
closelog();

View File

@ -1,12 +1,12 @@
#
# $Id: Makefile,v 1.2 1998/10/31 19:02:47 gdr-ftp Exp $
# $Id: Makefile,v 1.3 2012/08/26 02:54:59 gdr Exp $
#
PROG = syslogd
MAIN = syslogd2
SRCS = syslogd2.c
CFLAGS += -D__STACK_CHECK__
CFLAGS += -D__STACK_CHECK__ -v
STACK = 4096
BINDIR = /usr/sbin
CHAPTER = 8

View File

@ -131,7 +131,8 @@ If a received message matches the specified
.IR facility
and is of the specified
.IR level
.IR (or "a higher level) ,"
.BI ( or
a higher level),
and the first word in the message after the date matches the
.IR program ,
the action specified in the

View File

@ -1,5 +1,5 @@
/*
* $Id: syslogd.rez,v 1.2 1998/12/22 16:05:46 gdr-ftp Exp $
* $Id: syslogd.rez,v 1.3 2012/08/26 02:55:00 gdr Exp $
*/
#include "Types.Rez"
@ -9,7 +9,7 @@ resource rVersion (0x1, purgeable3, nocrossbank) {
{ 2, 0, 0, /* version */
alpha, /* development|alpha|beta|final|release */
1 /* non-final release number */
2 /* non-final release number */
},
verUS,
"syslogd",

View File

@ -4,7 +4,7 @@
* have sufficient bits for the facility/priority values, and at the time
* his sources weren't available for modification.
*
* $Id: syslogd2.c,v 1.1 1998/10/31 19:02:47 gdr-ftp Exp $
* $Id: syslogd2.c,v 1.2 2012/08/26 02:55:00 gdr Exp $
*/
/*
@ -27,6 +27,9 @@
* set up so that we can't get interrupted by SIGHUP or SIGTERM
* while we're in the SIGALRM handler.
* - should logInternal be using the internal "none" priority?
* - logMessage should be modified to ensure that there is a trailing
* newline. Internal messages (at least) via logInternal are currently
* missing newlines.
*/
/*
@ -71,10 +74,14 @@
#include <stdarg.h>
#include <string.h>
#include <fcntl.h>
#include <memory.h>
#include <misctool.h>
#ifdef __STACK_CHECK__
#include <err.h>
#endif
#include <assert.h>
#include <ctype.h> /* debugging only */
#include "syslogd.h"
#ifndef EOF
#define EOF (-1)
@ -85,8 +92,7 @@
#if 0
static void die (const char *message);
#endif
static int logMessage (long facpri, char *msg, int len);
static void logInternal (const char *message, ...);
static int logMessage (int facpri, char *msg, int len);
static int writeConsole (const char *buf, size_t size);
#if 0
static void handle_HUP (int sig, int code);
@ -99,17 +105,25 @@ char MessageBuffer[_SYSLOG_BUFFERLEN];
int MessageBufferLen = 0; /* number of used chars in MessageBuffer */
int bytesToCopy;
long FacPri; /* facility/priorty */
int FacPri; /* facility/priorty */
time_t Now;
char * LogFile = NULL; /* temporary kludge */
int LogConsole = 0; /* temporary kludge */
static void handleVersionZero (SyslogDataBuffer0_t *dataptr0);
int
main(int argc, char **argv) {
int fd, ch;
SyslogDataBuffer_t *dataptr;
int fd, ch, isVersionZero;
union {
SyslogDataBuffer0_t *v0;
SyslogDataBuffer_t *vN;
} datap;
char *p, *q;
Handle datahandle;
Word oldID, myID;
#ifdef DEBUG
int loopcount = 0;
#endif
@ -120,9 +134,12 @@ main(int argc, char **argv) {
* to have to call atexit() since we may be in a signal handler
* when we have to die.
*/
_beginStackCheck();
_beginStackCheck();
#endif
/* We'll be needing our mem mgr ID later ... */
myID = _getUserID();
while ((ch = getopt(argc, argv, "cF:")) != EOF) {
switch(ch) {
case 'c':
@ -142,6 +159,7 @@ main(int argc, char **argv) {
char *myname;
myname = __prognameGS();
writeConsole(argv[0], strlen(argv[0]));
writeConsole("/", 1);
writeConsole(myname, strlen(myname));
}
#endif
@ -180,10 +198,27 @@ main(int argc, char **argv) {
logInternal("couldn't create port: %s", strerror(errno));
exit(1);
}
logInternal("DEBUG: got port %d", Port);
#undef __SYSLOG_PORT_NAME
#define __SYSLOG_PORT_NAME "syslogd_test"
if (pbind (Port, __SYSLOG_PORT_NAME) == -1) {
#if 0
logInternal("DEBUG: Bound port first time");
/* KLUDGE KLUDGE KLUDGE
* Kill off the old v1 syslogd
*/
kill(3, SIGTERM);
sleep(1);
if (pbind(Port, __SYSLOG_PORT_NAME) == -1) {
#endif
logInternal("couldn't bind port: %s", strerror(errno));
exit(1);
#if 0
}
#endif
}
logInternal("DEBUG: bound to port");
/* now loop forever waiting for messages */
for (;;) {
@ -198,14 +233,87 @@ main(int argc, char **argv) {
}
#endif
logInternal("Entering loop");
/* block until a message comes in */
dataptr = (SyslogDataBuffer_t *) preceive(Port);
datahandle = (Handle) preceive(Port);
/* paranoia */
if (datahandle == NULL) {
logInternal("Received NULL pointer. Discarded.");
continue;
}
CheckHandle(datahandle);
if (_toolErr) {
if (_toolErr == handleErr) {
logInternal("invalid handle 0x%lx: message dropped",
(unsigned long) datahandle);
} else {
logInternal("CheckHandle on 0x%lx failed with code %d",
(unsigned long) datahandle,
_toolErr);
}
continue;
}
/* Change the memory block to be owned by our ID */
oldID = SetHandleID(myID, datahandle);
/* lock the handle */
HLock(datahandle);
if (_toolErr) {
logInternal("HLock on 0x%lx failed with code %d",
(unsigned long) datahandle, _toolErr);
}
/* , and
* free up the old ID
*/
{
int *iptr, j;
char *cptr, c;
iptr = (int *) *datahandle;
cptr = (char *) &iptr[5];
logInternal("buffer: %d %d %d %d %d:\r",
iptr[0], iptr[1], iptr[2], iptr[3], iptr[4]);
for (j=0; j<iptr[4]; j++) {
c = cptr[j];
logInternal("GSString[%d] = 0x%x '%c'",
j, (int) c, isprint(c) ? c : '?');
}
continue;
}
#ifdef BORK
/* dereference the handle */
datap.vN = (SyslogDataBuffer_t *) *datahandle;
/* determine if it's an old version zero message */
isVersionZero = (datap.v0->sdb0_version == 0);
if (isVersionZero) {
handleVersionZero(datap.v0);
HUnlock(datahandle); /* ignore errors */
continue;
} else {
DeleteID (oldID);
logInternal("not version zero");
HUnlock(datahandle); /* ignore errors */
continue;
}
if (isVersionZero) {
FacPri = datap.v0->sdb0_prio;
} else {
/* verify that this isn't a garbage pointer */
if (dataptr->sdb_magic != _SYSLOG_MAGIC) {
if (datap.vN->sdb_magic != _SYSLOG_MAGIC) {
logInternal("Bad magic number 0x%X; message "
"discarded. Caller may hang.",
dataptr->sdb_magic);
datap.vN->sdb_magic);
HUnlock(datahandle); /* ignore errors */
continue;
}
@ -213,11 +321,12 @@ main(int argc, char **argv) {
* Do the library and daemon agree on the format of the
* SyslogDataBuffer_t structure?
*/
if (dataptr->sdb_version != _SYSLOG_STRUCT_VERSION) {
if (datap.vN->sdb_version != _SYSLOG_STRUCT_VERSION) {
logInternal("Message version mismatch. Expected %d "
"got %d. Message discarded. Caller may hang.",
_SYSLOG_STRUCT_VERSION,
dataptr->sdb_version);
datap.vN->sdb_version);
HUnlock(datahandle); /* ignore errors */
continue;
}
@ -230,8 +339,8 @@ main(int argc, char **argv) {
* This should be changed so that we immediately copy the
* buffer and any other required info, then release the caller.
*/
p = dataptr->sdb_buffer;
bytesToCopy = dataptr->sdb_msglen;
p = datap.vN->sdb_buffer;
bytesToCopy = datap.vN->sdb_msglen;
if (*p == '<') {
p++;
FacPri = strtol(p, &q, 10);
@ -243,10 +352,12 @@ main(int argc, char **argv) {
} else {
p = q;
}
bytesToCopy -= (p - dataptr->sdb_buffer);
bytesToCopy -= (p - datap.vN->sdb_buffer);
} else {
FacPri = LOG_MAKEPRI(LOG_USER, LOG_NOTICE);
}
}
/*
* At this point, p points the point in the caller's buffer
* where we should start copying bytes. bytesToCopy
@ -256,7 +367,7 @@ main(int argc, char **argv) {
* If the 'needtime' flag is set, we now copy a time stamp
* into our own buffer (the user's buffer is untouched).
*/
if (dataptr->sdb_needtime) {
if (datap.vN->sdb_needtime) {
time(&Now);
q = ctime(&Now) + 4;
q[16] = '\0';
@ -303,16 +414,40 @@ main(int argc, char **argv) {
* See the comments in the syslog(3) code as to why we do
* it with a busy-wait.
*/
dataptr->sdb_busywait = 0;
datap.vN->sdb_busywait = 0;
/* print the message */
logMessage(FacPri, MessageBuffer, MessageBufferLen);
#endif /* BORK */
}
/*NOTREACHED*/
return 0;
}
static void
handleVersionZero (SyslogDataBuffer0_t *dataptr0)
{
int *offset; /* offset from dataptr0 of current string */
int *length;
char *string;
if (dataptr0->sdb0_numstrings == 0) {
logInternal("[zero length message]");
return;
}
offset = (int *) ((char *) dataptr0 + sizeof(SyslogDataBuffer0_t));
length = (int *) ((char *) dataptr0 + *offset);
string = ((char *) length) + sizeof(int);
logMessage(dataptr0->sdb0_prio, string, *length);
if (dataptr0->sdb0_numstrings > 1) {
logInternal("Cannot handle multiple strings. Last %d ignored",
dataptr0->sdb0_numstrings -1);
}
return;
}
/*
* Print the message <msg> of length <len> to the relevent files based on
* the facility/priority value <facpri>.
@ -325,7 +460,7 @@ main(int argc, char **argv) {
* LogFile (temporary kludge)
*/
static int
logMessage (long facpri, const char *msg, int len) {
logMessage (int facpri, const char *msg, int len) {
int result = 0;
if (LogConsole) {
@ -427,7 +562,7 @@ writeConsole (const char *buf, size_t size) {
#pragma optimize 78
#pragma debug 0
static void
void
logInternal (const char *message, ...) {
#define BUFFER_SIZE 256
static char buffer[BUFFER_SIZE];
@ -444,11 +579,17 @@ logInternal (const char *message, ...) {
p = ctime(&now) + 4;
p[16] = '\0';
p = sprintmt(buffer, BUFFER_SIZE, "%s syslogd[%d]: ", p, getpid());
#if 1
p = vsprintmt(p, BUFFER_SIZE - (p - buffer), message, ap);
#else
p = vsprintmt(p, p - buffer, message, ap);
logMessage(LOG_MAKEPRI(LOG_DAEMON, LOG_CRIT), buffer, p - buffer);
#endif
#if 0
/* this is the one we *should* be using */
logMessage(LOG_MAKEPRI(LOG_DAEMON, LOG_CRIT), buffer, p - buffer);
#else
/* for debugging only */
if ((p - buffer) < BUFFER_SIZE) {
*p++ = '\r';
*p = '\0';