summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:33 +0100
committerKarel Zak2006-12-07 00:25:33 +0100
commit726f69e29ca9d4842f3acb20fffd2466fda62c09 (patch)
treeabbc1b6e9bfb0dfe32e81a83648e261ccb2d5a5f /misc-utils
parentImported from util-linux-2.2 tarball. (diff)
downloadkernel-qcow2-util-linux-726f69e29ca9d4842f3acb20fffd2466fda62c09.tar.gz
kernel-qcow2-util-linux-726f69e29ca9d4842f3acb20fffd2466fda62c09.tar.xz
kernel-qcow2-util-linux-726f69e29ca9d4842f3acb20fffd2466fda62c09.zip
Imported from util-linux-2.5 tarball.
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/Makefile40
-rw-r--r--misc-utils/cal.c62
-rw-r--r--misc-utils/chkdupexe.138
-rw-r--r--misc-utils/chkdupexe.pl56
-rw-r--r--misc-utils/clear.16
-rw-r--r--misc-utils/ddate.1101
-rw-r--r--misc-utils/ddate.c313
-rw-r--r--misc-utils/domainname.133
-rw-r--r--misc-utils/dsplit.c2
-rw-r--r--misc-utils/hostname.c.orig187
-rw-r--r--misc-utils/mcookie.136
-rw-r--r--misc-utils/mcookie.c110
-rw-r--r--misc-utils/namei.c2
-rw-r--r--misc-utils/procs.c6
-rw-r--r--misc-utils/reset.18
-rw-r--r--misc-utils/write.1115
-rw-r--r--misc-utils/write.c20
17 files changed, 979 insertions, 156 deletions
diff --git a/misc-utils/Makefile b/misc-utils/Makefile
index e8e517fea..f69f0c1ef 100644
--- a/misc-utils/Makefile
+++ b/misc-utils/Makefile
@@ -1,45 +1,56 @@
# Makefile -- Makefile for util-linux Linux utilities
# Created: Sat Dec 26 20:09:40 1992
-# Revised: Thu Feb 16 10:00:24 1995 by faith@cs.unc.edu
+# Revised: Fri Oct 6 20:27:07 1995 by r.faith@ieee.org
# Copyright 1992, 1993, 1994, 1995 Rickard E. Faith (faith@cs.unc.edu)
+# May be distirbuted under the GPL
#
include ../MCONFIG
# Where to put man pages?
-MAN1= cal.1 clear.1 dnsdomainname.1 domainname.1 dsplit.1 \
- hostid.1 hostname.1 kill.1 logger.1 look.1 mcookie.1 \
- md5sum.1 namei.1 reset.1 script.1 setterm.1 tsort.1 \
+MAN1= cal.1 chkdupexe.1 ddate.1 dnsdomainname.1 domainname.1 \
+ dsplit.1 hostid.1 hostname.1 kill.1 logger.1 look.1 mcookie.1 \
+ namei.1 reset.1 script.1 setterm.1 tsort.1 \
whereis.1 write.1
+ifeq "$(HAVE_CLEAR)" "no"
+MAN1:=$(MAN1) clear.1
+endif
+
# Where to put binaries?
# See the "install" rule for the links. . .
BIN= domainname hostname kill
-USRBIN= cal clear dsplit hostid logger look mcookie md5sum namei \
- reset script setterm tsort whereis write
+USRBIN= cal chkdupexe ddate dsplit hostid logger look mcookie \
+ namei reset script setterm tsort whereis write
+
+ifeq "$(HAVE_CLEAR)" "no"
+USRBIN:=$(USRBIN) clear
+endif
# Programs requiring special compilation
NEEDS_TERMCAP= setterm
-SCRIPTS= clear reset
all: $(BIN) $(USRBIN) $(USRBIN.NONSHADOW) $(USRGAMES) getoptprog
-%.o: %.c
- $(CC) -c $(CFLAGS) $< -o $@
-
$(NEEDS_TERMCAP):
$(CC) $(LDFLAGS) $^ -o $@ -ltermcap
-$(SCRIPTS):
+%: %.sh
cp $@.sh $@
+ chmod 755 $@
+
+%: %.pl
+ cp $@.pl $@
+ chmod 755 $@
# Rules for everything else
cal: cal.o $(BSD)/getopt.o $(BSD)/err.o
+chkdupexe: chkdupexe.pl
clear: clear.sh
domainname: domainname.o
dsplit: dsplit.o
@@ -48,7 +59,8 @@ hostid: hostid.o
hostname: hostname.o
kill: kill.o procs.o
logger: logger.o $(BSD)/getopt.o
-md5sum: md5.o
+mcookie: mcookie.o md5.o
+md5sum: md5sum.o md5.o
md5.o: md5.h
namei: namei.o
reset: reset.sh
@@ -65,6 +77,10 @@ install: all
$(INSTALLDIR) $(MAN1DIR) $(MAN8DIR)
$(INSTALLMAN) $(MAN1) $(MAN1DIR)
$(INSTALLMAN) getoptprog.1 $(MAN1DIR)/getopt.1
+ifeq "$(USE_TTY_GROUP)" "yes"
+ chgrp tty $(USRBINDIR)/write
+ chmod g+s $(USRBINDIR)/write
+endif
.PHONY: clean
clean:
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 8004016d6..87ab71df6 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -54,7 +54,12 @@ static char sccsid[] = "@(#)cal.c 8.4 (Berkeley) 4/2/94";
#include <time.h>
#include <unistd.h>
#include <locale.h>
-#include <localeinfo.h>
+
+#if defined(__linux__) && _LINUX_C_LIB_VERSION_MAJOR > 4
+# include <langinfo.h>
+#else
+# include <localeinfo.h>
+#endif
#define THURSDAY 4 /* for reformation */
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
@@ -93,13 +98,14 @@ int sep1752[MAXDAYS] = {
SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE,
};
-char *day_headings = " S M Tu W Th F S ";
-char *j_day_headings = " S M Tu W Th F S ";
+char day_headings[] = " S M Tu W Th F S ";
+char j_day_headings[] = " S M Tu W Th F S ";
+const char *full_month[12];
/* leap year -- account for gregorian reformation in 1752 */
#define leap_year(yr) \
((yr) <= 1752 ? !((yr) % 4) : \
- !((yr) % 4) && ((yr) % 100) || !((yr) % 400))
+ (!((yr) % 4) && ((yr) % 100)) || !((yr) % 400))
/* number of centuries since 1700, not inclusive */
#define centuries_since_1700(yr) \
@@ -116,7 +122,7 @@ char *j_day_headings = " S M Tu W Th F S ";
int julian;
void ascii_day __P((char *, int));
-void center __P((char *, int, int));
+void center __P((const char *, int, int));
void day_array __P((int, int, int *));
int day_in_week __P((int, int, int));
int day_in_year __P((int, int, int));
@@ -201,17 +207,27 @@ void headers_init(void)
int i;
strcpy(day_headings,"");
- for(i = 0 ; i < 7 ; i++ )
- {
- strncat(day_headings,_time_info->abbrev_wkday[i],2);
- strcat(day_headings," ");
- }
strcpy(j_day_headings,"");
- for(i = 0 ; i < 7 ; i++ )
- {
- strcat(j_day_headings,_time_info->abbrev_wkday[i]);
- strcat(j_day_headings," ");
- }
+
+ for(i = 0 ; i < 7 ; i++ ) {
+#if defined(__linux__) && _LINUX_C_LIB_VERSION_MAJOR > 4
+ strncat(day_headings,nl_langinfo(ABDAY_1+i),2);
+ strcat(j_day_headings,nl_langinfo(ABDAY_1+i));
+#else
+ strncat(day_headings,_time_info->abbrev_wkday[i],2);
+ strcat(j_day_headings,_time_info->abbrev_wkday[i]);
+#endif
+ strcat(day_headings," ");
+ strcat(j_day_headings," ");
+ }
+
+ for (i = 0; i < 12; i++) {
+#if defined(__linux__) && _LINUX_C_LIB_VERSION_MAJOR > 4
+ full_month[i] = nl_langinfo(MON_1+i);
+#else
+ full_month[i] = _time_info->full_month[i];
+#endif
+ }
}
void
@@ -222,7 +238,7 @@ monthly(month, year)
char *p, lineout[30];
day_array(month, year, days);
- len = sprintf(lineout, "%s %d", _time_info->full_month[month - 1], year);
+ len = sprintf(lineout, "%s %d", full_month[month - 1], year);
(void)printf("%*s%s\n%s\n",
((julian ? J_WEEK_LEN : WEEK_LEN) - len) / 2, "",
lineout, julian ? j_day_headings : day_headings);
@@ -252,8 +268,8 @@ j_yearly(year)
(void)memset(lineout, ' ', sizeof(lineout) - 1);
lineout[sizeof(lineout) - 1] = '\0';
for (month = 0; month < 12; month += 2) {
- center(_time_info->full_month[month], J_WEEK_LEN, J_HEAD_SEP);
- center(_time_info->full_month[month + 1], J_WEEK_LEN, 0);
+ center(full_month[month], J_WEEK_LEN, J_HEAD_SEP);
+ center(full_month[month + 1], J_WEEK_LEN, 0);
(void)printf("\n%s%*s%s\n", j_day_headings, J_HEAD_SEP, "",
j_day_headings);
for (row = 0; row < 6; row++) {
@@ -287,9 +303,9 @@ yearly(year)
(void)memset(lineout, ' ', sizeof(lineout) - 1);
lineout[sizeof(lineout) - 1] = '\0';
for (month = 0; month < 12; month += 3) {
- center(_time_info->full_month[month], WEEK_LEN, HEAD_SEP);
- center(_time_info->full_month[month + 1], WEEK_LEN, HEAD_SEP);
- center(_time_info->full_month[month + 2], WEEK_LEN, 0);
+ center(full_month[month], WEEK_LEN, HEAD_SEP);
+ center(full_month[month + 1], WEEK_LEN, HEAD_SEP);
+ center(full_month[month + 2], WEEK_LEN, 0);
(void)printf("\n%s%*s%s%*s%s\n", day_headings, HEAD_SEP,
"", day_headings, HEAD_SEP, "", day_headings);
for (row = 0; row < 6; row++) {
@@ -392,7 +408,7 @@ ascii_day(p, day)
return;
}
if (julian) {
- if (val = day / 100) {
+ if ((val = day / 100)) {
day %= 100;
*p++ = val + '0';
display = 1;
@@ -430,7 +446,7 @@ trim_trailing_spaces(s)
void
center(str, len, separate)
- char *str;
+ const char *str;
int len;
int separate;
{
diff --git a/misc-utils/chkdupexe.1 b/misc-utils/chkdupexe.1
new file mode 100644
index 000000000..279562e59
--- /dev/null
+++ b/misc-utils/chkdupexe.1
@@ -0,0 +1,38 @@
+.\" chkdupexe.1 --
+.\" Created: Sat Mar 11 18:19:44 1995 by faith@cs.unc.edu
+.\" Revised: Sat Mar 11 19:07:05 1995 by faith@cs.unc.edu
+.\" Revised: Wed Jul 5 01:56:26 1995 by shields@tembel.org
+.\" Copyright 1995 Rickard E. Faith (faith@cs.unc.edu)
+.\"
+.\" Permission is granted to make and distribute verbatim copies of this
+.\" manual provided the copyright notice and this permission notice are
+.\" preserved on all copies.
+.\"
+.\" Permission is granted to copy and distribute modified versions of this
+.\" manual under the conditions for verbatim copying, provided that the
+.\" entire resulting derived work is distributed under the terms of a
+.\" permission notice identical to this one
+.\"
+.\" Since the Linux kernel and libraries are constantly changing, this
+.\" manual page may be incorrect or out-of-date. The author(s) assume no
+.\" responsibility for errors or omissions, or for damages resulting from
+.\" the use of the information contained herein. The author(s) may not
+.\" have taken the same level of care in the production of this manual,
+.\" which is licensed free of charge, as they might when working
+.\" professionally.
+.\"
+.\" Formatted or processed versions of this manual, if unaccompanied by
+.\" the source, must acknowledge the copyright and authors of this work.
+.\"
+.TH CHKDUPEXE 1 "11 Mar 1995" "" "Linux Programmer's Manual"
+.SH NAME
+chkdupexe \- find duplicate executables
+.SH SYNOPSIS
+.B chkdupexe
+.SH DESCRIPTION
+.B chkdupexe
+will scan the union of $PATH and a hardcoded list of common locations
+for binaries. It will report dangling symlinks and duplicately-named
+binaries.
+.SH AUTHOR
+Nicolai Langfeldt, Michael Shields.
diff --git a/misc-utils/chkdupexe.pl b/misc-utils/chkdupexe.pl
new file mode 100644
index 000000000..117d20fa5
--- /dev/null
+++ b/misc-utils/chkdupexe.pl
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+#
+# chkdupexe version 2.0
+#
+# Simple script to look for and list duplicate executables and dangling
+# symlinks in the system executable directories.
+#
+# Copyright 1993 Nicolai Langfeldt. Distribute under gnu copyleft
+# (included in perl package)
+#
+# Modified 1995-07-04 Michael Shields <shields@tembel.org>
+# Don't depend on GNU ls.
+# Cleanups.
+# Merge together $ENV{'PATH'} and $execdirs.
+# Don't break if there are duplicates in $PATH.
+#
+
+$execdirs='/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/local/bin:/local/sbin:/usr/X11/bin:/usr/bin/X11:/usr/local/X11/bin:/local/X11/bin:/usr/TeX/bin:/usr/tex/bin:/usr/local/graph/bin:/usr/games:/usr/local/games:/usr/intervies/bin/LINUX';
+
+DIRECTORY:
+foreach $dir (split(/:/, "$execdirs:$ENV{'PATH'}")) {
+
+ # Follow symlinks and make sure we haven't scanned this directory already.
+ while (-l $dir) {
+ $newdir = readlink($dir);
+ print "Dangling symlink: $dir\n" unless $newdir;
+ $dir = $newdir;
+ next DIRECTORY if $seendir{$dir}++;
+ }
+
+ opendir(DIR,$dir) || (warn "Couldn't opendir($dir): $!\n", next);
+ foreach $_ (readdir(DIR)) {
+ lstat("$dir/$_");
+ if (-l _) {
+ ($dum)=stat("$dir/$_");
+ # Might as well report these since we discover them anyway
+ print "Dangling symlink: $dir/$_\n" unless $dum;
+ next;
+ }
+ next unless -f _ && -x _; # Only handle regular executable files
+ if ($count{$_}) {
+ $progs{$_}.=" $dir/$_";
+ $count{$_}++;
+ } else {
+ $progs{$_}="$dir/$_";
+ $count{$_}=1;
+ }
+ }
+ closedir(DIR);
+}
+
+open(LS,"| xargs ls -ldU");
+while (($prog,$paths)=each %progs) {
+ print LS "$paths\n" if ($count{$prog}>1);
+}
+close(LS);
diff --git a/misc-utils/clear.1 b/misc-utils/clear.1
index 1d4a5df79..9d2082304 100644
--- a/misc-utils/clear.1
+++ b/misc-utils/clear.1
@@ -15,6 +15,12 @@ argument. This causes
.B tput
to attempt to clear the screen checking the data in
.I /etc/termcap
+(for the GNU or BSD
+.BR tput )
+or in the terminfo database
+(for the
+.B ncurses
+.BR tput )
and sending the appropriate sequence to the terminal. This command can be
redirected to clear the screen of some other terminal.
.SH "SEE ALSO"
diff --git a/misc-utils/ddate.1 b/misc-utils/ddate.1
new file mode 100644
index 000000000..1ccc201f6
--- /dev/null
+++ b/misc-utils/ddate.1
@@ -0,0 +1,101 @@
+.\" All Rites Reversed. This file is in the PUBLIC DOMAIN.
+.\" Kallisti.
+.TH DDATE 1 "59 Bureaucracy 3161" "" "Emperor Norton Utilities"
+.SH NAME
+ddate \- converts Gregorian dates to Discordian dates
+.SH SYNOPSIS
+.B ddate [+format] [date]
+.SH DESCRIPTION
+.B ddate
+prints the date in Discordian date format.
+.PP
+If called with no arguments,
+.B ddate
+will get the current system date, convert this to the Discordian
+date format and print this on the standard output. Alternatively, a
+Gregorian date may be specified on the command line, in the form of a numerical
+day, month and year.
+.PP
+If a format string is specified, the Discordian date will be printed in
+a format specified by the string. This mechanism works similarly to the
+format string mechanism of
+.B date(1),
+only almost completely differently. The fields are:
+.IP %A
+Full name of the day of the week (i.e., Sweetmorn)
+.IP %a
+Abbreviated name of the day of the week (i.e., SM)
+.IP %B
+Full name of the season (i.e., Chaos)
+.IP %b
+Abbreviated name of the season (i.e., Chs)
+.IP %d
+Ordinal number of day in season (i.e., 23)
+.IP %e
+Cardinal number of day in season (i.e., 23rd)
+.IP %H
+Name of current Holyday, if any
+.IP %N
+Magic code to prevent rest of format from being printed unless today is
+a Holyday.
+.IP %n
+Newline
+.IP %t
+Tab
+.IP %X
+Number of days remaining until X-Day. (Not valid if the SubGenius options are not
+compiled in.)
+.IP %{
+.IP %}
+Used to enclose the part of the string which is to be replaced with the
+words "St. Tib's Day" if the current day is St. Tib's Day.
+.IP %\.
+Try it and see.
+.bp
+.SH EXAMPLES
+.nf
+% ddate
+.br
+Sweetmorn, Bureaucracy 42, 3161 YOLD
+.PP
+% ddate +'Today is %{%A, the %e of %B%}, %Y. %N%nCelebrate %H'
+.br
+Today is Sweetmorn, the 42nd of Bureaucracy, 3161.
+.PP
+% ddate +"It's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 26 9 1995
+.br
+It's Prickle-Prickle, the 50th of Bureaucracy, 3161.
+.br
+Celebrate Bureflux
+.PP
+% ddate +'Today's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H' 29 2 1996
+.br
+Today's St. Tib's Day, 3162.
+.br
+
+.SH BUGS
+
+.B ddate(1)
+will produce undefined behaviour if asked to produce the date for St. Tib's
+day and its format string does not contain the St. Tib's Day delimiters
+%{ and %}.
+
+.SH AUTHOR
+.nh
+Original program by Druel the Chaotic aka Jeremy Johnson (mpython@gnu.ai.mit.edu)
+.br
+Major rewrite by Lee H:. O:. Smith, KYTP, aka Andrew Bulhak (acb@dev.null.org)
+.br
+Five tons of flax.
+
+.SH DISTRIBUTION POLICY
+
+Public domain. All rites reversed.
+
+.SH SEE ALSO
+
+date(1),
+.br
+Malaclypse the Younger,
+.I "Principia Discordia, Or How I Found Goddess And What I Did To Her When I Found Her"
+
diff --git a/misc-utils/ddate.c b/misc-utils/ddate.c
new file mode 100644
index 000000000..96421d021
--- /dev/null
+++ b/misc-utils/ddate.c
@@ -0,0 +1,313 @@
+/* $ DVCS ID: $jer|,523/lhos,KYTP!41023161\b"?" <<= DO NOT DELETE! */
+
+/* ddate.c .. converts boring normal dates to fun Discordian Date -><-
+ written the 65th day of The Aftermath in the Year of Our Lady of
+ Discord 3157 by Druel the Chaotic aka Jeremy Johnson aka
+ mpython@gnu.ai.mit.edu
+ 28 Sever St Apt #3
+ Worcester MA 01609
+
+ and I'm not responsible if this program messes anything up (except your
+ mind, I'm responsible for that)
+
+ (k) YOLD 3161 and all time before and after.
+ Reprint, reuse, and recycle what you wish.
+ This program is in the public domain. Distribute freely. Or not.
+
+ Majorly hacked, extended and bogotified/debogotified on
+ Sweetmorn, Bureaucracy 42, 3161 YOLD, by Lee H:. O:. Smith, KYTP,
+ aka Andrew Bulhak, aka acb@dev.null.org
+
+ and I'm not responsible if this program messes anything up (except your
+ mind, I'm responsible for that) (and that goes for me as well --lhos)
+
+ Version history:
+ Bureflux 3161: First release of enhanced ddate with format strings
+ 59 Bcy, 3161: PRAISE_BOB and KILL_BOB options split, other minor
+ changes.
+
+*/
+
+
+/* configuration options VVVVV READ THIS!!! */
+
+/* If you wish ddate(1) to print the date in the same format as Druel's
+ * original ddate when called in immediate mode, define OLD_IMMEDIATE_FMT
+ */
+
+#define OLD_IMMEDIATE_FMT
+
+/* If you wish to use the US format for aneristic dates (m-d-y), as opposed to
+ * the Commonwealth format, define US_FORMAT.
+ */
+
+/* #define US_FORMAT */
+
+/* If you are ideologically, theologically or otherwise opposed to the
+ * Church of the SubGenius and do not wish your copy of ddate(1) to contain
+ * code for counting down to X-Day, undefine KILL_BOB */
+
+#define KILL_BOB 13013
+
+/* If you wish ddate(1) to contain SubGenius slogans, define PRAISE_BOB */
+
+/*#define PRAISE_BOB 13013*/
+
+#include <time.h>
+#include <string.h>
+#include <stdio.h>
+
+#ifndef __GNUC__
+#define inline /* foo */
+#endif
+
+/* string constants */
+
+char *day_long[5] = {
+ "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"
+};
+
+char *day_short[5] = {"SM","BT","PD","PP","SO"};
+
+char *season_long[5] = {
+ "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"
+};
+
+char *season_short[5] = {"Chs", "Dsc", "Cfn", "Bcy", "Afm"};
+
+char *holyday[5][2] = {
+ "Mungday", "Chaoflux",
+ "Mojoday", "Discoflux",
+ "Syaday", "Confuflux",
+ "Zaraday", "Bureflux",
+ "Maladay", "Afflux"
+};
+
+struct disc_time {
+ int season; /* 0-4 */
+ int day; /* 0-72 */
+ int yday; /* 0-365 */
+ int year; /* 3066- */
+};
+
+char *excl[] = {
+ "Hail Eris!", "All Hail Discordia!", "Kallisti!", "Fnord.", "Or not.",
+ "Wibble.", "Pzat!", "P'tang!", "Frink!",
+#ifdef PRAISE_BOB
+ "Slack!", "Praise \"Bob\"!", "Or kill me.",
+#endif /* PRAISE_BOB */
+ /* randomness, from the Net and other places. Feel free to add (after
+ checking with the relevant authorities, of course). */
+ "Grudnuk demand sustenance!", "Keep the Lasagna flying!",
+ "Umlaut Zebra über alles!", "You are what you see.",
+ "Or is it?", "This statement is false.",
+#if defined(linux) || defined (__linux__) || defined (__linux)
+ "Hail Eris, Hack Linux!",
+#endif
+ ""
+};
+
+char default_fmt[] = "%{%A, %B %d%}, %Y YOLD";
+char *default_immediate_fmt=
+#ifdef OLD_IMMEDIATE_FMT
+"Today is %{%A, the %e day of %B%} in the YOLD %Y%N%nCelebrate %H"
+#else
+default_fmt
+#endif
+;
+
+#define DY(y) (y+1166)
+
+inline char *ending(int i) { return (i%10==1)?"st":(i%10==2?"nd":(i%10==3?"rd":"th"));};
+inline int leapp(int i) { return (!(DY(i)%4))&&((DY(i)%100)||(!(DY(i)%400)));};
+
+void print(struct disc_time,char **); /* old */
+void format(char *buf, const char* fmt, struct disc_time dt);
+/* select a random string */
+inline char *sel(char **strings, int num) {return(strings[random()%num]); };
+/* read a fortune file */
+int load_fortunes(char *fn, char *delim, char** result);
+
+struct disc_time convert(int,int);
+struct disc_time makeday(int,int,int);
+
+main (int argc, char *argv[])
+{
+ long t;
+ struct tm *eris;
+ int bob,raw;
+ struct disc_time hastur;
+ char schwa[23*17], *fnord=0;
+ int pi;
+
+ srandom(time(NULL));
+ /* do args here */
+ for(pi=1; pi<argc; pi++) {
+ switch(argv[pi][0]) {
+ case '+': fnord=argv[pi]+1; break;
+ case '-':
+ switch(argv[pi][1]) {
+ default: goto usage;
+ }
+ default: goto thud;
+ }
+ }
+
+ thud:
+ if (argc-pi==3){
+ int moe=atoi(argv[pi]), larry=atoi(argv[pi+1]), curly=atoi(argv[pi+2]);
+ hastur=makeday(
+#ifdef US_FORMAT
+ moe,larry,
+#else
+ larry,moe,
+#endif
+ curly);
+ fnord=fnord?fnord:default_fmt;
+ } else if (argc!=pi) {
+ usage:
+ fprintf(stderr,"usage: %s [+format] [day month year]\n", argv[0]);
+ exit(1);
+ } else {
+ t= time(NULL);
+ eris=localtime(&t);
+ bob=eris->tm_yday; /* days since Jan 1. */
+ raw=eris->tm_year; /* years since 1980 */
+ hastur=convert(bob,raw);
+ fnord=fnord?fnord:default_immediate_fmt;
+ }
+ format(schwa, fnord, hastur);
+ printf("%s\n", schwa);
+ return 0;
+}
+
+void format(char *buf, const char* fmt, struct disc_time dt)
+{
+ int tib_start=-1, tib_end=0;
+ int i, fmtlen=strlen(fmt);
+ char *bufptr=buf;
+
+/* fprintf(stderr, "format(%p, \"%s\", dt)\n", buf, fmt);*/
+
+ /* first, find extents of St. Tib's Day area, if defined */
+ for(i=0; i<fmtlen; i++) {
+ if(fmt[i]=='%') {
+ switch(fmt[i+1]) {
+ case 'A':
+ case 'a':
+ case 'd':
+ case 'e':
+ if(tib_start>0) tib_end=i+1;
+ else tib_start=i;
+ break;
+ case '{': tib_start=i; break;
+ case '}': tib_end=i+1; break;
+ }
+ }
+ }
+
+ /* now do the formatting */
+ buf[0]=0;
+
+ for(i=0; i<fmtlen; i++) {
+ if((i==tib_start) && (dt.day==-1)) {
+ /* handle St. Tib's Day */
+ strcpy(bufptr, "St. Tib's Day"); bufptr += 13;
+ i=tib_end;
+ } else {
+ if(fmt[i]=='%') {
+ char *wibble=0, snarf[23];
+ switch(fmt[++i]) {
+ case 'A': wibble=day_long[dt.yday%5]; break;
+ case 'a': wibble=day_short[dt.yday%5]; break;
+ case 'B': wibble=season_long[dt.season]; break;
+ case 'b': wibble=season_short[dt.season]; break;
+ case 'd': sprintf(snarf, "%d", dt.day+1); wibble=snarf; break;
+ case 'e': sprintf(snarf, "%d%s", dt.day+1, ending(dt.day+1));
+ wibble=snarf; break;
+ case 'H': if(dt.day==4||dt.day==49)
+ wibble=holyday[dt.season][dt.day==49]; break;
+ case 'N': if(dt.day!=4&&dt.day!=49) goto eschaton; break;
+ case 'n': *(bufptr++)='\n'; break;
+ case 't': *(bufptr++)='\t'; break;
+
+ case 'Y': sprintf(snarf, "%d", dt.year); wibble=snarf; break;
+ case '.': wibble=sel(excl, sizeof(excl)/sizeof(excl[0]));
+ break;
+#ifdef KILL_BOB
+ case 'X': sprintf(snarf, "%d",
+ xday_countdown(dt.yday, dt.year));
+ wibble = snarf; break;
+#endif /* KILL_BOB */
+ }
+ if(wibble) {
+/* fprintf(stderr, "wibble = (%s)\n", wibble);*/
+ strcpy(bufptr, wibble); bufptr+=strlen(wibble);
+ }
+ } else {
+ *(bufptr++) = fmt[i];
+ }
+ }
+ }
+ eschaton:
+ *(bufptr)=0;
+}
+
+struct disc_time makeday(int imonth,int iday,int iyear) /*i for input */
+{
+ struct disc_time funkychickens;
+
+ int cal[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
+ int dayspast=0;
+
+ imonth--;
+ funkychickens.year= iyear+1166;
+ while(imonth>0) { dayspast+=cal[--imonth]; }
+ funkychickens.day=dayspast+iday-1;
+ funkychickens.season=0;
+ if((funkychickens.year%4)==2) {
+ if (funkychickens.day==59) funkychickens.day=-1;
+ }
+ funkychickens.yday=funkychickens.day;
+/* note: EQUAL SIGN...hopefully that fixes it */
+ while(funkychickens.day>=73) {
+ funkychickens.season++;
+ funkychickens.day-=73;
+ }
+ return funkychickens;
+}
+
+struct disc_time convert(int nday, int nyear)
+{ struct disc_time funkychickens;
+
+ funkychickens.year = nyear+3066;
+ funkychickens.day=nday;
+ funkychickens.season=0;
+ if ((funkychickens.year%4)==2)
+ {if (funkychickens.day==59)
+ funkychickens.day=-1;
+ else if (funkychickens.day >59)
+ funkychickens.day-=1;
+ }
+ funkychickens.yday=funkychickens.day;
+ while (funkychickens.day>=73)
+ { funkychickens.season++;
+ funkychickens.day-=73;
+ }
+ return funkychickens;
+
+ }
+
+
+#ifdef KILL_BOB
+
+/* Code for counting down to X-Day, X-Day being Cfn 40, 3164 */
+
+int xday_countdown(int yday, int year) {
+ int r=(185-yday)+(((yday<59)&&(leapp(year)))?1:0);
+ while(year<3164) r+=(leapp(++year)?366:365);
+ while(year>3164) r-=(leapp(year--)?366:365);
+ return r;
+}
+
+#endif
diff --git a/misc-utils/domainname.1 b/misc-utils/domainname.1
index 447c71266..0a305ad1e 100644
--- a/misc-utils/domainname.1
+++ b/misc-utils/domainname.1
@@ -1,43 +1,28 @@
-.\" Copyright 1992, 1995 Rickard E. Faith (faith@cs.unc.edu)
+.\" Copyright 1992 Rickard E. Faith (faith@cs.unc.edu)
.\" May be distributed under the GNU General Public License
-.TH DOMAINNAME 1 "16 February 1995" "Linux 1.0" "Linux Programmer's Manual"
+.TH DOMAINNAME 1 "26 December 1992" "Linux 0.98" "Linux Programmer's Manual"
.SH NAME
-domainname \- set or print NIS domain of current host
+domainname \- set or print domain of current host
.SH SYNOPSIS
.BR "domainname [ " name " ]"
.SH DESCRIPTION
.B domainname
-prints the NIS domainname of the current host, from the
+prints the domainname of the current host, from the
.BR getdomainname (3)
library call. If an argument is present and the effective UID is 0,
.B domainname
-changes the NIS domainname of the host, with the
+changes the name of the host, with the
.BR setdomainname (2)
system call. This is usually done at boot time in the
.I /etc/rc.local
script.
-.PP
-.B Note:
-This command sets the NIS (Network Information Services) domain,
-.I not
-the DNS (Domain Name System) domain. Unless you are running NIS
-(formerly known as Sun Yellow Pages (YP)), you should
-.I not
-use the
-.B domainname
-command to set your domain. You probably want to set the DNS domain, which
-is used to map human-readable machine names into IP addresses on the
-InterNet. See
-.BR dnsdomainname (1)
-for more information.
.SH FILES
.I /etc/rc.local
.SH "SEE ALSO"
-.BR hostname (1),
-.BR dnsdomainname (1),
-.BR named (8),
-.BR sendmail (8),
-.bR ypinit (8)
+.BR getdomainname (3),
+.BR setdomainname (2),
+.BR uname (1),
+.BR uname (2)
.SH AUTHOR
Lars Wirzenius by substituting in hostname.c
diff --git a/misc-utils/dsplit.c b/misc-utils/dsplit.c
index 14d8ffff1..c3c22a305 100644
--- a/misc-utils/dsplit.c
+++ b/misc-utils/dsplit.c
@@ -1,5 +1,5 @@
#ifdef lint
- static char RCSid[] = "dsplit.c,v 1.1.1.1 1995/02/22 19:09:14";
+ static char RCSid[] = "$RCSfile: dsplit.c,v $ $Revision: 1.9 $ $Date: 1995/03/12 01:31:03 $";
#endif
/*
Program dsplit: Splits a large file into pieces.
diff --git a/misc-utils/hostname.c.orig b/misc-utils/hostname.c.orig
new file mode 100644
index 000000000..b7e61d1f7
--- /dev/null
+++ b/misc-utils/hostname.c.orig
@@ -0,0 +1,187 @@
+/* hostname -- set the host name or show the host/domain name
+
+ Copyright (C) 1994 Peter Tobias
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <string.h>
+#include <netdb.h>
+#include <errno.h>
+#include <sys/param.h>
+
+#define NO_OPT -1
+
+static char *program_name;
+static const char *version_string = "hostname 1.5";
+
+static void sethname(char *);
+static void showhname(char *, int);
+static void usage(void);
+
+static void sethname(char *hname)
+{
+ if(sethostname(hname, strlen(hname))) {
+ switch(errno) {
+ case EPERM:
+ fprintf(stderr,"%s: you must be root to change the host name\n", program_name);
+ break;
+ case EINVAL:
+ fprintf(stderr,"%s: name too long\n", program_name);
+ break;
+ default:
+ }
+ exit(1);
+ };
+}
+
+static void showhname(char *hname, int c)
+{
+ struct hostent *hp;
+ register char *p;
+
+ if (!(hp = gethostbyname(hname))) {
+ herror(program_name);
+ exit(1);
+ }
+
+ if (!(p = strchr(hp->h_name, '.'))) {
+ fprintf(stderr,"%s: can't find a FQDN for the host name `%s'\n", program_name, hname);
+ exit(1);
+ }
+
+ switch(c) {
+ case 'd':
+ printf("%s\n", ++p);
+ break;
+ case 'f':
+ printf("%s\n", hp->h_name);
+ break;
+ case 's':
+ *p = '\0';
+ printf("%s\n", hp->h_name);
+ break;
+ default:
+ }
+}
+
+static void usage(void)
+{
+ printf("Usage: %s [OPTION]... [hostname]\n\n\
+ -d, --domain display the DNS domain name\n\
+ -F, --file filename read the host name from file\n\
+ -f, --fqdn, --long display the long host name (FQDN)\n\
+ -s, --short display the short host name\n\
+ -h, --help display this help and exit\n\
+ -v, --version output version information and exit\n\
+\n\
+ When the program is called without any arguments, it displays the\n\
+ current host name as set by the hostname command. If an argument\n\
+ is given, the program will set the value of the host name to the\n\
+ value specified.\n\
+ Unless you are using bind or NIS for host lookups you can change the\n\
+ FQDN (Fully Qualified Domain Name) and the DNS domain name (which is\n\
+ part of the FQDN) in the /etc/hosts file.\n", program_name);
+}
+
+int main(int argc, char **argv)
+{
+ int c;
+ int option_index = 0;
+
+ char myname[MAXHOSTNAMELEN+1];
+
+ static const struct option long_options[] =
+ {
+ {"domain", no_argument, 0, 'd'},
+ {"file", required_argument, 0, 'F'},
+ {"fqdn", no_argument, 0, 'f'},
+ {"help", no_argument, 0, 'h'},
+ {"long", no_argument, 0, 'f'},
+ {"short", no_argument, 0, 's'},
+ {"version", no_argument, 0, 'v'},
+ {0, 0, 0, 0}
+ };
+
+ program_name = (rindex(argv[0], '/')) ? rindex(argv[0], '/') + 1 : argv[0];
+
+ if (strcmp(program_name, "dnsdomainname") == 0) {
+ if (argc > 1) {
+ fprintf(stderr,"%s: You can't change the DNS domainname with this command\n", program_name);
+ fprintf(stderr,"\nUnless you are using bind or NIS for host lookups you can change the DNS\n");
+ fprintf(stderr,"domain name (which is part of the FQDN) in the /etc/hosts file.\n");
+ exit(1);
+ }
+ c = 'd';
+ } else
+ c = getopt_long(argc, argv, "dfF:hsv", long_options, &option_index);
+
+ gethostname(myname, sizeof(myname));
+
+ switch(c)
+ {
+ case 'd':
+ case 'f':
+ case 's':
+ showhname(myname, c);
+ break;
+ case 'F':
+ {
+ register FILE *fd;
+ register char *p;
+ char fline[MAXHOSTNAMELEN];
+
+ if ((fd = fopen(optarg, "r")) != NULL) {
+ while (fgets(fline, sizeof(fline), fd) != NULL)
+ if ((p = index(fline, '\n')) != NULL) {
+ *p = '\0';
+ if (fline[0] == '#')
+ continue;
+ sethname(fline);
+ }
+ (void) fclose(fd);
+ } else {
+ fprintf(stderr,"%s: can't open `%s'\n",
+ program_name, optarg);
+ exit(1);
+ }
+ }
+ break;
+ case 'h':
+ usage();
+ break;
+ case 'v':
+ printf("%s\n", version_string);
+ break;
+ case '?':
+ fprintf(stderr,"Try `%s --help' for more information.\n", program_name);
+ exit(1);
+ break;
+ case NO_OPT:
+ if (optind < argc) {
+ sethname(argv[optind]);
+ exit(0);
+ }
+ default:
+ printf("%s\n", myname);
+
+ };
+ exit(0);
+}
diff --git a/misc-utils/mcookie.1 b/misc-utils/mcookie.1
index 395082548..6d3a11c30 100644
--- a/misc-utils/mcookie.1
+++ b/misc-utils/mcookie.1
@@ -1,10 +1,10 @@
.\" mcookie.1 --
.\" Public Domain 1995 Rickard E. Faith (faith@cs.unc.edu)
-.TH MCOOKIE 1 "12 Feb 1995" "" "Linux Programmer's Manual"
+.TH MCOOKIE 1 "25 September 1995" "" "Linux Programmer's Manual"
.SH NAME
mcookie \- generate magic cookies for xauth
.SH SYNOPSIS
-.B mcookie
+.BI "mcookie [\-v] [\-f " filename " ]"
.SH DESCRIPTION
.B mcookie
generates a 128-bit random hexadecimal number for use with the X authority
@@ -12,6 +12,36 @@ system. Typical usage:
.RS
xauth add :0 . `mcookie`
.RE
+.PP
+The "random" number generated is actually the output of the MD5 message
+digest fed with various piece of random information: the current time, the
+process id, the parent process id, the contents of an input file (if
+.B \-f
+is specified), and several bytes of information from the first of the
+following devices which is present:
+.IR /dev/urandom ", " /dev/random ", " /dev/audio .
+Other files in
+.I /proc
+may be used as a last resort.
+.SH BUGS
+The entropy in the generated 128-bit is probably quite small (and,
+therefore, vulnerable to attack) unless a non-pseudorandom number generator
+is used (e.g.,
+.I /dev/random
+under Linux).
+.PP
+It is assumed that none of the devices opened will block.
+.SH FILES
+.I /dev/random
+.br
+.I /dev/urandom
+.br
+.I /dev/audio
+.br
+.I /proc/stat
+.br
+.I /proc/loadavg
.SH "SEE ALSO"
.BR X (1),
-.BR xauth (1)
+.BR xauth (1),
+.BR md5sum (1)
diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c
index d0730edde..a4c896075 100644
--- a/misc-utils/mcookie.c
+++ b/misc-utils/mcookie.c
@@ -1,43 +1,119 @@
/* mcookie.c -- Generates random numbers for xauth
* Created: Fri Feb 3 10:42:48 1995 by faith@cs.unc.edu
- * Revised: Sun Feb 12 20:29:58 1995 by faith@cs.unc.edu
+ * Revised: Mon Sep 25 23:44:43 1995 by r.faith@ieee.org
* Public Domain 1995 Rickard E. Faith (faith@cs.unc.edu)
* This program comes with ABSOLUTELY NO WARRANTY.
*
- * mcookie.c,v 1.1.1.1 1995/02/22 19:09:16 faith Exp
+ * $Id: mcookie.c,v 1.2 1995/10/07 01:32:00 faith Exp $
+ *
+ * This program gathers some random bits of data and used the MD5
+ * message-digest algorithm to generate a 128-bit hexadecimal number for
+ * use with xauth(1).
+ *
+ * NOTE: Unless /dev/random is available, this program does not actually
+ * gather 128 bits of random information, so the magic cookie generated
+ * will be considerably easier to guess than one might expect.
*/
-#define SECURE 1
+#ifdef __linux__
+#define HAVE_GETTIMEOFDAY 1
+#endif
#include <stdio.h>
#include <stdlib.h>
-#if SECURE
+#include <fcntl.h>
+#include "md5.h"
+#if HAVE_GETTIMEOFDAY
#include <sys/time.h>
#include <unistd.h>
#endif
-int main( void )
+#define MAXBUFFERSIZE 512
+
+struct rngs {
+ const char *path;
+ int length;
+} rngs[] = {
+ { "/dev/random", 16 },
+ { "/dev/urandom", 128 },
+ { "/proc/stat", MAXBUFFERSIZE },
+ { "/proc/loadavg", MAXBUFFERSIZE },
+ { "/dev/audio", MAXBUFFERSIZE },
+};
+#define RNGS (sizeof(rngs)/sizeof(struct rngs))
+
+int Verbose = 0;
+
+int main( int argc, char **argv )
{
- int i;
-#if SECURE
- struct timeval tv;
- struct timezone tz;
+ int i;
+ struct MD5Context ctx;
+ unsigned char digest[16];
+ unsigned char buf[MAXBUFFERSIZE];
+ int fd;
+ int c;
+ pid_t pid;
+ char *file = NULL;
+ int r;
+#if HAVE_GETTIMEOFDAY
+ struct timeval tv;
+ struct timezone tz;
+#else
+ long int t;
+#endif
+ while ((c = getopt( argc, argv, "vf:" )) != EOF)
+ switch (c) {
+ case 'v': ++Verbose; break;
+ case 'f': file = optarg; break;
+ }
+
+ MD5Init( &ctx );
+
+#if HAVE_GETTIMEOFDAY
gettimeofday( &tv, &tz );
- srand( tv.tv_sec + tv.tv_usec );
+ MD5Update( &ctx, (unsigned char *)&tv, sizeof( tv ) );
#else
- long int t;
-
time( &t );
- srand( t );
+ MD5Update( &ctx, (unsigned char *)&t, sizeof( t ) );
#endif
+ pid = getppid();
+ MD5Update( &ctx, (unsigned char *)&pid, sizeof( pid ));
+ pid = getpid();
+ MD5Update( &ctx, (unsigned char *)&pid, sizeof( pid ));
- for (i = 0; i < 32; i++) {
- int r = (rand() & 0x0f0) >> 4;
+ if (file) {
+ int count = 0;
+
+ if (file[0] == '-' && !file[1]) fd = fileno(stdin);
+ else if ((fd = open( file, O_RDONLY )) <0) {
+ fprintf( stderr, "Could not open %s\n" );
+ }
- if (r < 10) putchar( '0' + r );
- else putchar( 'a' + r - 10 );
+ while ((r = read( fd, buf, sizeof( buf ) )) > 0) {
+ MD5Update( &ctx, buf, r );
+ count += r;
+ }
+ if (Verbose)
+ fprintf( stderr, "Got %d bytes from %s\n", count, file );
+
+ if (file[0] != '-' || file[1]) close( fd );
}
+
+ for (i = 0; i < RNGS; i++) {
+ if ((fd = open( rngs[i].path, O_RDONLY )) >= 0) {
+ r = read( fd, buf, sizeof( buf ) );
+ MD5Update( &ctx, buf, r );
+ close( fd );
+ if (Verbose)
+ fprintf( stderr, "Got %d bytes from %s\n", r, rngs[i].path );
+ if (r >= rngs[i].length) break;
+ } else if (Verbose)
+ fprintf( stderr, "Could not open %s\n", rngs[i].path );
+ }
+
+ MD5Final( digest, &ctx );
+ for (i = 0; i < 16; i++) printf( "%02x", digest[i] );
putchar ( '\n' );
return 0;
diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index 0424af0b8..750576187 100644
--- a/misc-utils/namei.c
+++ b/misc-utils/namei.c
@@ -42,7 +42,7 @@ chdir to /, or if it encounters an unknown file type.
-------------------------------------------------------------*/
#ifndef lint
-static char *RCSid = "namei.c,v 1.1.1.1 1995/02/22 19:09:16 faith Exp";
+static char *RCSid = "$Id: namei.c,v 1.4 1995/03/12 01:35:45 faith Exp $";
#endif
#include <stdio.h>
diff --git a/misc-utils/procs.c b/misc-utils/procs.c
index 1d232415c..4d0ea7aca 100644
--- a/misc-utils/procs.c
+++ b/misc-utils/procs.c
@@ -6,9 +6,9 @@
* modify it under the terms of the gnu general public license.
* there is no warranty.
*
- * faith
- * 1.2
- * 1995/02/23 01:20:40
+ * $Author: faith $
+ * $Revision: 1.2 $
+ * $Date: 1995/03/12 02:55:24 $
*
*/
diff --git a/misc-utils/reset.1 b/misc-utils/reset.1
index 06ce4b2b7..46aea01ee 100644
--- a/misc-utils/reset.1
+++ b/misc-utils/reset.1
@@ -14,7 +14,13 @@ with the
arguments. This causes
.B tput
to send appropriate reset strings to the terminal based on information in
-.IR /etc/termcap .
+.I /etc/termcap
+(for the GNU or BSD
+.BR tput )
+or in the terminfo database
+(for the
+.B ncurses
+.BR tput ).
This sequence seems to be sufficient to reset the Linux VC's when they
start printing "funny-looking" characters. For good measure,
.BR stty (1)
diff --git a/misc-utils/write.1 b/misc-utils/write.1
index 5125e156b..9ff7aae61 100644
--- a/misc-utils/write.1
+++ b/misc-utils/write.1
@@ -1,5 +1,5 @@
-.\" Copyright (c) 1989 The Regents of the University of California.
-.\" All rights reserved.
+.\" Copyright (c) 1989, 1993
+.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Jef Poskanzer and Craig Leres of the Lawrence Berkeley Laboratory.
@@ -32,79 +32,66 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)write.1 6.5 (Berkeley) 4/24/91
+.\" @(#)write.1 8.1 (Berkeley) 6/6/93
.\"
-.\" Modified for Linux, Mon Mar 8 18:22:44 1993, faith@cs.unc.edu
+.\" Modified for Linux, Sun Mar 12 10:21:01 1995, faith@cs.unc.edu
.\"
-.Dd March 8, 1993
-.Dt WRITE 1
-.Os "Linux 0.99"
-.Sh NAME
-.Nm write
-.Nd send a message to another user
-.Sh SYNOPSIS
-.Nm write
-.Ar user
-.Op Ar ttyname
-.Sh DESCRIPTION
-.Nm Write
+.TH WRITE 1 "12 March 1995" "" "Linux Programmer's Manual"
+.SH NAME
+write \- send a message to another user
+.SH SYNOPSIS
+.BI write " user " [ ttyname ]
+.SH DESCRIPTION
+.B Write
allows you to communicate with other users, by copying lines from
your terminal to theirs.
-.Pp
+.PP
When you run the
-.Nm write
+.B write
command, the user you are writing to gets a message of the form:
-.Pp
-.Dl Message from yourname@yourhost on yourtty at hh:mm ...
-.Pp
+.PP
+.RS
+Message from yourname@yourhost on yourtty at hh:mm ...
+.RE
+.PP
Any further lines you enter will be copied to the specified user's
-terminal.
-If the other user wants to reply, they must run
-.Nm write
+terminal. If the other user wants to reply, they must run
+.B write
as well.
-.Pp
-When you are done, type an end-of-file or interrupt character.
-The other user will see the message
-.Ql EOF
-indicating that the
-conversation is over.
-.Pp
-You can prevent people (other than the super-user) from writing to you
-with the
-.Xr mesg 1
-command.
-Some commands, for example
-.Xr nroff 1
+.PP
+When you are done, type an end-of-file or interrupt character. The other
+user will see the message
+.B EOF
+indicating that the conversation is over.
+.PP
+You can prevent people (other than the super-user) from writing to you with
+the
+.BR mesg (1)
+command. Some commands, for example
+.BR nroff (1)
and
-.Xr pr 1 ,
-disallow writing automatically, so that your output isn't overwritten.
-.Pp
+.BR pr (1),
+may disallow writing automatically, so that your output isn't overwritten.
+.PP
If the user you want to write to is logged in on more than one terminal,
you can specify which terminal to write to by specifying the terminal
name as the second operand to the
-.Nm write
-command.
-Alternatively, you can let
-.Nm write
-select one of the terminals \- it will pick the one with the shortest
-idle time.
-This is so that if the user is logged in at work and also dialed up from
-home, the message will go to the right place.
-.Pp
-The traditional protocol for writing to someone is that the string
-.Ql \-o ,
+.B write
+command. Alternatively, you can let
+.B write
+select one of the terminals \- it will pick the one with the shortest idle
+time. This is so that if the user is logged in at work and also dialed up
+from home, the message will go to the right place.
+.PP
+The traditional protocol for writing to someone is that the string `\-o',
either at the end of a line or on a line by itself, means that it's the
-other person's turn to talk.
-The string
-.Ql oo
-means that the person believes the conversation to be
-over.
-.Sh SEE ALSO
-.Xr mesg 1 ,
-.Xr talk 1 ,
-.Xr who 1
-.Sh HISTORY
+other person's turn to talk. The string `oo' means that the person
+believes the conversation to be over.
+.SH "SEE ALSO"
+.BR mesg (1),
+.BR talk (1),
+.BR who (1)
+.SH HISTORY
A
-.Nm
-command appeared in
-.At v6 .
+.B write
+command appeared in Version 6 AT&T UNIX.
diff --git a/misc-utils/write.c b/misc-utils/write.c
index f2fe4a086..a1865bd71 100644
--- a/misc-utils/write.c
+++ b/misc-utils/write.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jef Poskanzer and Craig Leres of the Lawrence Berkeley Laboratory.
@@ -40,13 +40,13 @@
*/
#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
- All rights reserved.\n";
+static char copyright[] =
+"@(#) Copyright (c) 1989, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)write.c 4.22 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93";
#endif /* not lint */
#include <sys/param.h>
@@ -61,6 +61,8 @@ static char sccsid[] = "@(#)write.c 4.22 (Berkeley) 6/1/90";
#include <string.h>
#ifdef __linux__
#include <paths.h>
+#include "pathnames.h"
+#include <locale.h>
#endif
extern int errno;
@@ -76,6 +78,10 @@ main(argc, argv)
char tty[MAXPATHLEN], *mytty, *ttyname();
void done();
+#ifdef __linux__
+ setlocale(LC_CTYPE,"");
+#endif
+
/* check that sender has write enabled */
if (isatty(fileno(stdin)))
myttyfd = fileno(stdin);
@@ -329,7 +335,7 @@ wr_fputs(s)
#define PUTC(c) if (putchar(c) == EOF) goto err;
for (; *s != '\0'; ++s) {
- c = toascii(*s);
+ c = *s;
if (c == '\n') {
PUTC('\r');
PUTC('\n');