summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:41 +0100
committerKarel Zak2006-12-07 00:25:41 +0100
commiteb63b9b8f4cecb34c2478282567862bc48ef256d (patch)
tree99243f8eecb44c2bb6a559982b99c680fcb649e7 /misc-utils
parentImported from util-linux-2.9v tarball. (diff)
downloadkernel-qcow2-util-linux-eb63b9b8f4cecb34c2478282567862bc48ef256d.tar.gz
kernel-qcow2-util-linux-eb63b9b8f4cecb34c2478282567862bc48ef256d.tar.xz
kernel-qcow2-util-linux-eb63b9b8f4cecb34c2478282567862bc48ef256d.zip
Imported from util-linux-2.10f tarball.
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/Makefile18
-rw-r--r--misc-utils/cal.15
-rw-r--r--misc-utils/cal.c23
-rwxr-xr-xmisc-utils/chkdupexe.pl11
-rw-r--r--misc-utils/ddate.c10
-rw-r--r--misc-utils/ddate.doc73
-rw-r--r--misc-utils/kill.c32
-rw-r--r--misc-utils/logger.116
-rw-r--r--misc-utils/logger.c7
-rw-r--r--misc-utils/look.16
-rw-r--r--misc-utils/look.c18
-rw-r--r--misc-utils/namei.c7
-rw-r--r--misc-utils/rename.140
-rw-r--r--misc-utils/rename.c97
-rw-r--r--misc-utils/setterm.11
-rw-r--r--misc-utils/setterm.c57
-rwxr-xr-xmisc-utils/sparc-solaris-hostid.sh13
-rw-r--r--misc-utils/tsort.c5
18 files changed, 331 insertions, 108 deletions
diff --git a/misc-utils/Makefile b/misc-utils/Makefile
index eeaf56764..088d2ccee 100644
--- a/misc-utils/Makefile
+++ b/misc-utils/Makefile
@@ -10,8 +10,8 @@ include ../MCONFIG
# Where to put man pages?
MAN1= cal.1 chkdupexe.1 ddate.1 kill.1 \
- logger.1 look.1 mcookie.1 namei.1 script.1 \
- tsort.1 whereis.1 write.1
+ logger.1 look.1 mcookie.1 namei.1 rename.1 script.1 \
+ whereis.1 write.1
# Where to put binaries?
# See the "install" rule for the links. . .
@@ -19,12 +19,7 @@ MAN1= cal.1 chkdupexe.1 ddate.1 kill.1 \
BIN= kill
USRBIN= cal chkdupexe ddate logger look mcookie \
- namei script tsort whereis write
-
-ifeq "$(HAVE_CLEAR)" "no"
-USRBIN:=$(USRBIN) clear
-MAN1:=$(MAN1) clear.1
-endif
+ namei rename script whereis write
ifeq "$(HAVE_RESET)" "no"
USRBIN:=$(USRBIN) reset
@@ -36,6 +31,11 @@ USRBIN:=$(USRBIN) setterm
MAN1:=$(MAN1) setterm.1
endif
+ifeq "$(HAVE_TSORT)" "no"
+USRBIN:=$(USRBIN) tsort
+MAN1:=$(MAN1) tsort.1
+endif
+
# For script only
LIBPTY=
ifeq "$(HAVE_OPENPTY)" "yes"
@@ -69,9 +69,9 @@ $(NEEDS_OPENPTY):
# Rules for everything else
+cal.o: $(LIB)/errs.h
cal: cal.o $(ERR_O)
chkdupexe: chkdupexe.pl
-clear: clear.sh
kill: kill.o procs.o
logger: logger.o
mcookie: mcookie.o md5.o
diff --git a/misc-utils/cal.1 b/misc-utils/cal.1
index 9d41dc5ed..6a5ec5ae5 100644
--- a/misc-utils/cal.1
+++ b/misc-utils/cal.1
@@ -52,9 +52,10 @@ the current month is displayed.
The options are as follows:
.Bl -tag -width Ds
.It Fl m
-Display monday as the first day of the week.
+Display Monday as the first day of the week.
+(The default is Sunday.)
.It Fl j
-Display julian dates (days one-based, numbered from January 1).
+Display Julian dates (days one-based, numbered from January 1).
.It Fl y
Display a calendar for the current year.
.El
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index e3acf74b1..fe35e1851 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -44,13 +44,13 @@
#include <sys/types.h>
#include <ctype.h>
-#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <locale.h>
+#include "errs.h"
#include "nls.h"
#include "../defines.h"
@@ -138,6 +138,7 @@ void trim_trailing_spaces __P((char *));
void usage __P((void));
void yearly __P((int));
void headers_init(void);
+extern char *__progname;
int
main(argc, argv)
@@ -147,17 +148,17 @@ main(argc, argv)
struct tm *local_time;
time_t now;
int ch, month, year, yflag;
+ char *progname, *p;
+
+ progname = argv[0];
+ if ((p = strrchr(progname, '/')) != NULL)
+ progname = p+1;
+ __progname = progname;
-#ifdef __linux__
- extern char *__progname;
- __progname = argv[0];
-#endif
-
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- setlocale(LC_ALL,"");
yflag = 0;
while ((ch = getopt(argc, argv, "mjy")) != EOF)
switch(ch) {
@@ -170,6 +171,10 @@ main(argc, argv)
case 'y':
yflag = 1;
break;
+ case 'V':
+ printf(_("%s from %s\n"),
+ progname, util_linux_version);
+ return 0;
case '?':
default:
usage();
@@ -254,7 +259,7 @@ monthly(month, year)
int month, year;
{
int col, row, len, days[MAXDAYS];
- char *p, lineout[30];
+ char *p, lineout[300];
day_array(month, year, days);
len = sprintf(lineout, "%s %d", full_month[month - 1], year);
@@ -481,6 +486,6 @@ void
usage()
{
- (void)fprintf(stderr, _("usage: cal [-mjy] [[month] year]\n"));
+ (void)fprintf(stderr, _("usage: cal [-mjyV] [[month] year]\n"));
exit(1);
}
diff --git a/misc-utils/chkdupexe.pl b/misc-utils/chkdupexe.pl
index 82ee9e98b..e5fae6847 100755
--- a/misc-utils/chkdupexe.pl
+++ b/misc-utils/chkdupexe.pl
@@ -29,13 +29,18 @@ $execdirs='/bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin '.
'/usr/TeX/bin /usr/tex/bin /usr/games '.
'/usr/local/games';
+# Turn off buffering for the output channel.
+$|=1;
+
# Values from /usr/include/linux/errno.h. Existence of linux/errno.ph is not
# something to count on... :-(
$ENOENT=2;
%didthis=();
-foreach $dir (split(/\s+/, "$execdirs")) {
+foreach $dir (split(/\s+/, "$execdirs"), "\0", split(/:/, $ENV{PATH})) {
+
+ if ($dir eq "\0") { $checkingpath = 1; next; }
# It's like this: One directory corresponds to one $device,$inode tuple
# If a symlink points to a directory we already checked that directory
@@ -52,7 +57,7 @@ foreach $dir (split(/\s+/, "$execdirs")) {
print "Dangling symlink: $dir\n";
next;
}
- # warn "Nonexistent directory: $dir\n";
+ warn "Nonexistent directory: $dir\n" if ($checkingpath);
next;
}
@@ -90,7 +95,7 @@ foreach $dir (split(/\s+/, "$execdirs")) {
closedir(DIR);
}
-open(LS,"| xargs ls -ldU");
+open(LS,"| xargs -r ls -ldU");
while (($prog,$paths)=each %progs) {
print LS "$paths\n" if ($count{$prog}>1);
}
diff --git a/misc-utils/ddate.c b/misc-utils/ddate.c
index 7f12e86fd..f00a8fd07 100644
--- a/misc-utils/ddate.c
+++ b/misc-utils/ddate.c
@@ -30,6 +30,7 @@
- added Native Language Support
*/
+#include "../defines.h" /* for util-linux-version */
/* configuration options VVVVV READ THIS!!! */
@@ -150,6 +151,11 @@ main (int argc, char *argv[])
struct disc_time hastur;
char schwa[23*17], *fnord=0;
int pi;
+ char *progname, *p;
+
+ progname = argv[0];
+ if ((p = strrchr(progname, '/')) != NULL)
+ progname = p+1;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -162,6 +168,8 @@ main (int argc, char *argv[])
case '+': fnord=argv[pi]+1; break;
case '-':
switch(argv[pi][1]) {
+ case 'V':
+ printf(_("%s from %s\n"), progname, util_linux_version);
default: goto usage;
}
default: goto thud;
@@ -281,7 +289,7 @@ struct disc_time makeday(int imonth,int iday,int iyear) /*i for input */
funkychickens.day=dayspast+iday-1;
funkychickens.season=0;
if((funkychickens.year%4)==2) {
- if (funkychickens.day==59) funkychickens.day=-1;
+ if (funkychickens.day==59 && iday==29) funkychickens.day=-1;
}
funkychickens.yday=funkychickens.day;
/* note: EQUAL SIGN...hopefully that fixes it */
diff --git a/misc-utils/ddate.doc b/misc-utils/ddate.doc
new file mode 100644
index 000000000..87d0fb8bb
--- /dev/null
+++ b/misc-utils/ddate.doc
@@ -0,0 +1,73 @@
+
+PERPETUAL DATE CONVERTER FROM GREGORIAN TO POEE CALENDAR
+
+SEASONS
+ 1. Chaos -- Patron Apostle Hung Mung
+ 2. Discord -- Patron Apostle Dr. Van Van Mojo
+ 3. Confusion -- Patron Apostle Sri Syadasti
+ 4. Bureaucracy -- Patron Apostle Zarathud
+ 5. The Aftermath -- Patron Apostle the Elder Malaclypse
+
+DAYS OF THE WEEK*
+ 1. Sweetmorn *The DAYS OF THE WEEK
+ 2. Boomtime are named from the five
+ 3. Pungenday basic elements: SWEET,
+ 4. Prickle-Prickle BOOM, PUNGENT, PRICKLE,
+ 5. Setting Orange and ORANGE.
+
+HOLYDAYS
+A. Apostle Holydays B. Seasons Holydays
+ 1. Mungday 1. Chaoflux
+ 2. Mojoday 2. Discoflux
+ 3. Syaday 3. Confuflux
+ 4. Zaraday 4. Bureflux
+ 5. Maladay 5. Afflux
+Each occurs on the 5th Each occurs on the 50th
+day of the Season day of the Season
+
+C. Saint Tib's Day -- occurs once every four years (1 + 4 = 5) and is
+ inserted between the 59th and 60th days of the Season of Chaos
+
+ ST BT PD PP SO SM BT PD PP SO
+Jan 1 2 3 4 5 1 2 3 4 5 Chs Jul 5 6 7 8 9 40 41 42 43 44 Cfn
+ 6 7 8 9 10 6 7 8 9 10 10 11 12 13 14 45 46 47 48 49
+ 11 12 13 14 15 11 12 13 14 15 15 16 17 18 19 50 51 52 53 54
+ 16 17 18 19 20 16 17 18 19 20 20 21 22 23 24 55 56 57 58 59
+ 21 22 23 24 25 21 22 23 24 25 25 26 27 28 29 60 61 62 63 64
+ 26 27 28 29 30 26 27 28 29 30 30 31 1 2 3 65 66 67 68 69
+ 31 1 2 3 4 31 32 33 34 35 Aug 4 5 6 7 8 70 71 72 73 1 Bcy
+Feb 5 6 7 8 9 36 37 38 39 40 9 10 11 12 13 2 3 4 5 6
+ 10 11 12 13 14 41 42 43 44 45 14 15 16 17 18 7 8 9 10 11
+ 15 16 17 18 19 46 47 48 49 50 19 20 21 22 23 12 13 14 15 16
+ 20 21 22 23 24 51 52 53 54 55 24 25 26 27 28 17 18 19 20 21
+ 25 26 27 28* 1 56 57 58 59 60 29 30 31 1 2 22 23 24 25 26
+Mar 2 3 4 5 6 61 62 63 64 65 Sep 3 4 5 6 7 27 28 29 30 31
+ 7 8 9 10 11 66 67 68 69 70 8 9 10 11 12 32 33 34 35 36
+ 12 13 14 15 16 71 72 73 1 2 Dsc 13 14 15 16 17 37 38 39 40 41
+ 17 18 19 20 21 3 4 5 6 7 18 19 20 21 22 42 43 44 45 46
+ 22 23 24 25 26 8 9 10 11 12 23 24 25 26 27 47 48 49 50 51
+ 27 28 29 30 31 13 14 15 16 17 28 29 30 1 2 52 53 54 55 56
+Apr 1 2 3 4 5 18 19 20 21 22 Oct 3 4 5 6 7 57 58 59 60 61
+ 6 7 8 9 10 23 24 25 26 27 8 9 10 11 12 62 63 64 65 66
+ 11 12 13 14 15 28 29 30 31 32 13 14 15 16 17 67 68 69 70 71
+ 16 17 18 19 20 33 34 35 36 37 18 19 20 21 22 72 73 1 2 3 Afm
+ 21 22 23 24 25 38 39 40 41 42 23 24 25 26 27 4 5 6 7 8
+ 26 27 28 29 30 43 44 45 46 47 28 29 30 31 1 9 10 11 12 13
+May 1 2 3 4 5 48 49 50 51 52 Nov 2 3 4 5 6 14 15 16 17 18
+ 6 7 8 9 10 53 54 55 56 57 7 8 9 10 11 19 20 21 22 23
+ 11 12 13 14 15 58 59 60 61 62 12 13 14 15 16 24 25 26 27 28
+ 16 17 18 19 20 63 64 65 66 67 17 18 19 20 21 29 30 31 32 33
+ 21 22 23 24 25 68 69 70 71 72 22 23 24 25 26 34 35 36 37 38
+ 26 27 28 29 30 73 1 2 3 4 Cfn 27 28 29 30 1 39 40 41 42 43
+ 31 1 2 3 4 5 6 7 8 9 Dec 2 3 4 5 6 44 45 46 47 48
+Jun 5 6 7 8 9 10 11 12 13 14 7 8 9 10 11 49 50 51 52 53
+ 10 11 12 13 14 15 16 17 18 19 12 13 14 15 16 54 55 56 57 58
+ 15 16 17 18 19 20 21 22 23 24 17 18 19 20 21 59 60 61 62 63
+ 20 21 22 23 24 25 26 27 28 29 22 23 24 25 26 64 65 66 67 68
+ 25 26 27 28 29 30 31 32 33 34 27 28 29 30 31 69 70 71 72 73
+ 30 1 2 3 4 35 36 37 38 39 [1970 = 3136] [Next St. Tib's Day in 3138]
+
+ SACRED DOCUMENT OF THE FROGS (old Erisian poem):
+ 73 Days hath
+ Chaos, Discord, Confusion, Bureaucracy, and Aftermath
+
diff --git a/misc-utils/kill.c b/misc-utils/kill.c
index 768f5deab..5372f5216 100644
--- a/misc-utils/kill.c
+++ b/misc-utils/kill.c
@@ -38,6 +38,8 @@
* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org>
* - added Native Language Support
*
+ * 1999-11-13 aeb Accept signal numers 128+s.
+ *
*/
#include <stdio.h>
@@ -137,7 +139,7 @@ struct signv {
int main (int argc, char *argv[]);
extern char *mybasename(char *);
int signame_to_signum (char *sig);
-int arg_to_signum (char *arg);
+int arg_to_signum (char *arg, int mask);
void nosig (char *name);
void printsig (int sig);
void printsignals (FILE *fp);
@@ -146,16 +148,19 @@ int kill_verbose (char *procname, int pid, int sig);
extern int *get_pids (char *, int);
-char version_string[] = "kill v2.0\n";
char *whoami;
int main (int argc, char *argv[])
{
int errors, numsig, pid;
- char *ep, *arg;
+ char *ep, *arg, *progname, *p;
int do_pid, do_kill, check_all;
int *pids, *ip;
+ progname = argv[0];
+ if ((p = strrchr(progname, '/')) != NULL)
+ progname = p+1;
+
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@@ -174,11 +179,16 @@ int main (int argc, char *argv[])
if (*arg != '-') {
break;
}
+ if (! strcmp (arg, "--")) {
+ argc--, argv++;
+ break;
+ }
if (! strcmp (arg, "-u")) {
return usage (0);
}
- if (! strcmp (arg, "-v")) {
- fputs (version_string, stdout);
+ if (! strcmp (arg, "-v") || ! strcmp (arg, "-V") ||
+ ! strcmp (arg, "--version")) {
+ printf(_("%s from %s\n"), progname, util_linux_version);
return 0;
}
if (! strcmp (arg, "-a")) {
@@ -193,9 +203,9 @@ int main (int argc, char *argv[])
if (argc > 2) {
return usage (1);
}
- /* argc == 2 */
+ /* argc == 2, accept "kill -l $?" */
arg = argv[1];
- if ((numsig = arg_to_signum (arg)) < 0) {
+ if ((numsig = arg_to_signum (arg, 1)) < 0) {
fprintf (stderr, _("%s: unknown signal %s\n"), whoami, arg);
return 1;
}
@@ -217,7 +227,7 @@ int main (int argc, char *argv[])
return usage (1);
argc--, argv++;
arg = *argv;
- if ((numsig = arg_to_signum (arg)) < 0) {
+ if ((numsig = arg_to_signum (arg, 0)) < 0) {
nosig (arg);
return 1;
}
@@ -231,7 +241,7 @@ int main (int argc, char *argv[])
if (do_kill)
break;
arg++;
- if ((numsig = arg_to_signum (arg)) < 0) {
+ if ((numsig = arg_to_signum (arg, 0)) < 0) {
return usage (1);
}
do_kill++;
@@ -284,13 +294,15 @@ int signame_to_signum (char *sig)
return (-1);
}
-int arg_to_signum (char *arg)
+int arg_to_signum (char *arg, int maskbit)
{
int numsig;
char *ep;
if (isdigit (*arg)) {
numsig = strtol (arg, &ep, 10);
+ if (numsig >= NSIG && maskbit && (numsig & 128) != 0)
+ numsig -= 128;
if (*ep != 0 || numsig < 0 || numsig >= NSIG)
return (-1);
return (numsig);
diff --git a/misc-utils/logger.1 b/misc-utils/logger.1
index 82df6be7a..b5459ed4c 100644
--- a/misc-utils/logger.1
+++ b/misc-utils/logger.1
@@ -31,6 +31,8 @@
.\"
.\" @(#)logger.1 8.1 (Berkeley) 6/6/93
.\"
+.\" Section on valid facitily and level strings added by
+.\" and1000@debian.org, 26 Oct 1997.
.Dd June 6, 1993
.Dt LOGGER 1
.Os BSD 4.3
@@ -78,6 +80,11 @@ Mark every line in the log with the specified
Write to socket as specified with
.Ar socket
instead of builtin syslog routines.
+.It --
+End the argument list. This is to allow the
+.Ar message
+to start with a hyphen (\-). This feature was not present in the
+original BSD logger command; it is a GNU-specific extra.
.It Ar message
Write the message to log; if not specified, and the
.Fl f
@@ -88,6 +95,15 @@ provided, standard input is logged.
The
.Nm logger
utility exits 0 on success, and >0 if an error occurs.
+.Pp
+Valid facility names are: auth, authpriv (for security information of
+a sensitive nature), cron, daemon, ftp, kern, lpr, mail, news,
+security (deprecated synonym for auth), syslog, user, uucp, and local0
+to local7, inclusive.
+.Pp
+Valid level names are: alert, crit, debug, emerg, err, error
+(deprecated synonym for err), info, notice, panic (deprecated synonym
+for emerg), warning, warn (deprecated synonym for warning).
.Sh EXAMPLES
.Bd -literal -offset indent -compact
logger System rebooted
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 4c881c968..9d848a660 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -210,6 +210,13 @@ main(argc, argv)
}
} else
while (fgets(buf, sizeof(buf), stdin) != NULL) {
+ /* glibc is buggy and adds an additional newline,
+ so we have to remove it here until glibc is fixed */
+ int len = strlen(buf);
+
+ if (len > 0 && buf[len - 1] == '\n')
+ buf[len - 1] = '\0';
+
if (!usock)
syslog(pri, "%s", buf);
else
diff --git a/misc-utils/look.1 b/misc-utils/look.1
index 872d4af75..2ab162c86 100644
--- a/misc-utils/look.1
+++ b/misc-utils/look.1
@@ -55,7 +55,11 @@ As
.Nm look
performs a binary search, the lines in
.Ar file
-must be sorted.
+must be sorted (where
+.Xr sort 1
+got the same options \-d and/or \-f that
+.Nm look
+is invoked with).
.Pp
If
.Ar file
diff --git a/misc-utils/look.c b/misc-utils/look.c
index 9e6c15bf8..a8e826fa4 100644
--- a/misc-utils/look.c
+++ b/misc-utils/look.c
@@ -74,7 +74,7 @@ char *string;
char *comparbuf;
static char *binary_search (char *, char *);
-static int compare (char *, char *, int);
+static int compare (char *, char *);
static void err (const char *fmt, ...);
static char *linear_search (char *, char *);
static int look (char *, char *);
@@ -192,10 +192,6 @@ look(char *front, char *back)
* back points to the beginning of a line at or after the first
* matching line.
*
- * Base of the Invariants.
- * front = NULL;
- * back = EOF;
- *
* Advancing the Invariants:
*
* p = first newline after halfway point from front to back.
@@ -232,7 +228,7 @@ binary_search(char *front, char *back)
* infinitely loop.
*/
while (p < back && back > front) {
- if (compare(p, back, 1) == GREATER)
+ if (compare(p, back) == GREATER)
front = p;
else
back = p;
@@ -257,7 +253,7 @@ char *
linear_search(char *front, char *back)
{
while (front < back) {
- switch (compare(front, back, 1)) {
+ switch (compare(front, back)) {
case EQUAL: /* Found it. */
return (front);
break;
@@ -280,8 +276,8 @@ print_from(char *front, char *back)
{
int eol;
- while (front < back && compare(front, back, 1) == EQUAL) {
- if (compare(front, back, fflag) == EQUAL) {
+ while (front < back && compare(front, back) == EQUAL) {
+ if (compare(front, back) == EQUAL) {
eol = 0;
while (front < back && !eol) {
if (putchar(*front) == EOF)
@@ -311,7 +307,7 @@ print_from(char *front, char *back)
* in other locales.
*/
int
-compare(char *s2, char *s2end, int nocase) {
+compare(char *s2, char *s2end) {
int i;
char *p;
@@ -326,7 +322,7 @@ compare(char *s2, char *s2end, int nocase) {
*p = 0;
/* and compare */
- if (nocase)
+ if (fflag)
i = strncasecmp(comparbuf, string, stringlen);
else
i = strncmp(comparbuf, string, stringlen);
diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index f110e6385..2541d03bc 100644
--- a/misc-utils/namei.c
+++ b/misc-utils/namei.c
@@ -255,11 +255,12 @@ register int lev;
(void)printf(" l %s -> %s", buf, sym);
if(symcount > 0 && symcount++ > MAXSYMLINKS){
- (void)printf(_(" *** EXCEEDED UNIX LIMIT OF SYMLINKS ***"));
+ (void)printf(_(" *** EXCEEDED UNIX LIMIT OF SYMLINKS ***\n"));
symcount = -1;
+ } else {
+ (void)printf("\n");
+ namei(sym, lev + 1);
}
- (void)printf("\n");
- namei(sym, lev + 1);
break;
case S_IFCHR:
diff --git a/misc-utils/rename.1 b/misc-utils/rename.1
new file mode 100644
index 000000000..37f99cc1b
--- /dev/null
+++ b/misc-utils/rename.1
@@ -0,0 +1,40 @@
+.\" Written by Andries E. Brouwer (aeb@cwi.nl)
+.\" Placed in the public domain
+.\"
+.TH RENAME 1 "1 Januari 2000" "" "Linux Programmer's Manual"
+.SH NAME
+rename \- Rename files
+.SH SYNOPSIS
+.BI rename " from to file..."
+.SH DESCRIPTION
+.B rename
+will rename the specified files by replacing the first occurrence of
+.I from
+in their name by
+.IR to .
+
+For example, given the files
+.IR foo1 ", ..., " foo9 ", " foo10 ", ..., " foo278 ,
+the commands
+
+.RS
+.nf
+rename foo foo0 foo?
+rename foo foo0 foo??
+.fi
+.RE
+
+will turn them into
+.IR foo001 ", ..., " foo009 ", " foo010 ", ..., " foo278 .
+
+And
+.RS
+.nf
+rename .htm .html *.htm
+.fi
+.RE
+
+will fix the extension of your html files.
+
+.SH "SEE ALSO"
+.BR mv (1)
diff --git a/misc-utils/rename.c b/misc-utils/rename.c
new file mode 100644
index 000000000..af5ba44cc
--- /dev/null
+++ b/misc-utils/rename.c
@@ -0,0 +1,97 @@
+/*
+ * rename.c - aeb 2000-01-01
+ *
+--------------------------------------------------------------
+#!/bin/sh
+if [ $# -le 2 ]; then echo call: rename from to files; exit; fi
+FROM="$1"
+TO="$2"
+shift
+shift
+for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done
+--------------------------------------------------------------
+ * This shell script will do renames of files, but may fail
+ * in cases involving special characters. Here a C version.
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "nls.h"
+
+static char *progname;
+
+int
+do_rename(char *from, char *to, char *s) {
+ char *newname, *where, *p, *q;
+ int flen, tlen, slen;
+
+ where = strstr(s, from);
+ if (where == NULL)
+ return 0;
+
+ flen = strlen(from);
+ tlen = strlen(to);
+ slen = strlen(s);
+ newname = malloc(tlen+slen+1);
+ if (newname == NULL) {
+ fprintf(stderr, _("%s: out of memory\n"), progname);
+ exit(1);
+ }
+
+ p = s;
+ q = newname;
+ while (p < where)
+ *q++ = *p++;
+ p = to;
+ while (*p)
+ *q++ = *p++;
+ p = where+flen;
+ while (*p)
+ *q++ = *p++;
+ *p = 0;
+
+ if (rename(s, newname) != 0) {
+ int errsv = errno;
+ fprintf(stderr, _("%s: renaming %s to %s failed: %s\n"),
+ progname, s, newname, strerror(errsv));
+ exit(1);
+ }
+
+ return 1;
+}
+
+int
+main(int argc, char **argv) {
+ char *from, *to, *p;
+ int i, ct;
+
+ progname = argv[0];
+ if ((p = strrchr(progname, '/')) != NULL)
+ progname = p+1;
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ if (argc == 2) {
+ if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) {
+ printf(_("%s from %s\n"),
+ progname, util_linux_version);
+ return 0;
+ }
+ }
+
+ if (argc < 3) {
+ fprintf(stderr, _("call: %s from to files...\n"), progname);
+ exit(1);
+ }
+
+ from = argv[1];
+ to = argv[2];
+
+ ct = 0;
+ for (i=3; i<argc; i++)
+ ct += do_rename(from, to, argv[i]);
+ return 0;
+}
diff --git a/misc-utils/setterm.1 b/misc-utils/setterm.1
index 3853a7132..0dbbdf42e 100644
--- a/misc-utils/setterm.1
+++ b/misc-utils/setterm.1
@@ -11,7 +11,6 @@ setterm \- set terminal attributes
.B "setterm [ \-reset ]"
.B "setterm [ \-initialize ]"
.B "setterm [ \-cursor [on|off] ]"
-.B "setterm [ \-keyboard pc|olivetti|dutch|extended ]"
.B "setterm [ \-repeat [on|off] ]"
.B "setterm [ \-appcursorkeys [on|off] ]"
.B "setterm [ \-linewrap [on|off] ]"
diff --git a/misc-utils/setterm.c b/misc-utils/setterm.c
index b9e4c0dad..36d3be190 100644
--- a/misc-utils/setterm.c
+++ b/misc-utils/setterm.c
@@ -12,7 +12,7 @@
*
* Sanity increases by Cafeine Addict [sic].
*
- * Powersave features by, todd j. derr <tjd@wordsmith.org>
+ * Powersave features by todd j. derr <tjd@wordsmith.org>
*
* Converted to terminfo by Kars de Jong (jongk@cs.utwente.nl)
*
@@ -27,7 +27,6 @@
* [ -reset ]
* [ -initialize ]
* [ -cursor [on|off] ]
- * [ -keyboard pc|olivetti|dutch|extended ]
* [ -repeat [on|off] ]
* [ -appcursorkeys [on|off] ]
* [ -linewrap [on|off] ]
@@ -162,7 +161,7 @@ extern int klogctl(int type, char *buf, int len);
/* Static variables. */
/* Option flags. Set if the option is to be invoked. */
-int opt_term, opt_reset, opt_initialize, opt_cursor, opt_keyboard;
+int opt_term, opt_reset, opt_initialize, opt_cursor;
int opt_linewrap, opt_snow, opt_softscroll, opt_default, opt_foreground;
int opt_background, opt_bold, opt_blink, opt_reverse, opt_underline;
int opt_store, opt_clear, opt_blank, opt_snap, opt_snapfile, opt_standout;
@@ -252,33 +251,6 @@ int *bad_arg; /* Set to true if an error is detected. */
}
}
-#if 0
-void parse_keyboard(argc, argv, option, opt_keyboard, bad_arg)
-int argc; /* Number of arguments for this option. */
-char *argv[]; /* Arguments for this option. */
-int *option; /* Keyboard flag to set. */
-int *opt_keyboard; /* Keyboard type to set. */
-int *bad_arg; /* Set to true if an error is detected. */
-{
-/* Parse a -keyboard specification. */
-
- if (argc != 1 || *option) *bad_arg = TRUE;
- *option = TRUE;
- if (argc == 1) {
- if (strcmp(argv[0], "pc") == 0)
- *opt_keyboard = PC;
- else if (strcmp(argv[0], "olivetti") == 0)
- *opt_keyboard = OLIVETTI;
- else if (strcmp(argv[0], "dutch") == 0)
- *opt_keyboard = DUTCH;
- else if (strcmp(argv[0], "extended") == 0)
- *opt_keyboard = EXTENDED;
- else
- *bad_arg = TRUE;
- }
-}
-#endif
-
void par_color(argc, argv, option, opt_color, bad_arg)
int argc; /* Number of arguments for this option. */
char *argv[]; /* Arguments for this option. */
@@ -659,10 +631,6 @@ int *bad_arg; /* Set to true if an error is detected. */
parse_none(argc, argv, &opt_initialize, bad_arg);
else if (STRCMP(option, "cursor") == 0)
parse_switch(argc, argv, &opt_cursor, &opt_cu_on, bad_arg);
-#if 0
- else if (STRCMP(option, "keyboard") == 0)
- parse_keyboard(argc, argv, &opt_keyboard, &opt_ke_type, bad_arg);
-#endif
else if (STRCMP(option, "repeat") == 0)
parse_switch(argc, argv, &opt_repeat, &opt_rep_on, bad_arg);
else if (STRCMP(option, "appcursorkeys") == 0)
@@ -752,7 +720,6 @@ char *prog_name; /* Name of this program. */
#if 0
fprintf(stderr, _(" [ -snow [on|off] ]\n"));
fprintf(stderr, _(" [ -softscroll [on|off] ]\n"));
- fprintf(stderr, _(" [ -keyboard pc|olivetti|dutch|extended ]\n"));
#endif
fprintf(stderr, _(" [ -repeat [on|off] ]\n"));
fprintf(stderr, _(" [ -appcursorkeys [on|off] ]\n"));
@@ -833,26 +800,6 @@ int vcterm; /* Set if terminal is a virtual console. */
putp(ti_entry("civis"));
}
-#if 0
- /* -keyboard pc|olivetti|dutch|extended. Vc only. */
- if (opt_keyboard && vcterm) {
- switch (opt_ke_type) {
- case PC:
- printf("%s%s%s", DCS, _("keyboard.pc"), ST);
- break;
- case OLIVETTI:
- printf("%s%s%s", DCS, _("keyboard.olivetti"), ST);
- break;
- case DUTCH:
- printf("%s%s%s", DCS, _("keyboard.dutch"), ST);
- break;
- case EXTENDED:
- printf("%s%s%s", DCS, _("keyboard.extended"), ST);
- break;
- }
- }
-#endif
-
/* -linewrap [on|off]. Vc only (vt102) */
if (opt_linewrap && vcterm) {
if (opt_li_on)
diff --git a/misc-utils/sparc-solaris-hostid.sh b/misc-utils/sparc-solaris-hostid.sh
new file mode 100755
index 000000000..7ce28ac5e
--- /dev/null
+++ b/misc-utils/sparc-solaris-hostid.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# This script reproduces the output of the Solaris hostid program.
+# It might be put in /usr/bin/hostid or so.
+# Note that the hostid program does not have any known uses
+# and does not exist on other architectures.
+# Copyright 1999 Peter Jones, <pjones@redhat.com> .
+# GPL and all that good stuff apply.
+(
+idprom=`cat /proc/openprom/idprom`
+echo $idprom|dd bs=1 skip=2 count=2
+echo $idprom|dd bs=1 skip=27 count=6
+echo
+) 2>/dev/null
diff --git a/misc-utils/tsort.c b/misc-utils/tsort.c
index 627897667..a1fab2a9e 100644
--- a/misc-utils/tsort.c
+++ b/misc-utils/tsort.c
@@ -39,6 +39,7 @@
*/
#include <sys/types.h>
+#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <ctype.h>
@@ -87,7 +88,7 @@ typedef struct _buf {
NODE *add_node(), *find_node();
void add_arc(), no_memory(), remove_node(), tsort();
-char *grow_buf(), *malloc();
+char *grow_buf();
int find_cycle(NODE *, NODE *, int, int);
extern int errno;
@@ -168,8 +169,6 @@ grow_buf(bp, size)
char *bp;
int size;
{
- char *realloc();
-
if (!(bp = realloc(bp, (u_int)size)))
no_memory();
return(bp);