to English and to convert some #defines to enums.
* ifdata: patch from Adam Lackorzynski to avoid printing info for
bogus interface. Closes: #360433
* Add zrun, contributed by Chung-chieh Shan (you might prefer to alias it to
"z").
BINS=isutf8 ifdata pee sponge
-PERLSCRIPTS=vidir vipe ts combine
-MANS=sponge.1 vidir.1 vipe.1 isutf8.1 ts.1 combine.1 ifdata.1 pee.1
+PERLSCRIPTS=vidir vipe ts combine zrun
+MANS=sponge.1 vidir.1 vipe.1 isutf8.1 ts.1 combine.1 ifdata.1 pee.1 zrun.1
CFLAGS=-O2 -g -Wall
all: $(BINS) $(MANS)
get network interface info without parsing ifconfig output
pee
tee standard input to pipes
-
+zrun
+ automatically uncompress arguments to command
Your suggestions of additional tools to add to this collection are
apprecitated. Here are some that are under consideration but have not yet
(More useful than file(1) in many cases but would add a lot of
gnome libraries to the package's dependency chain.)
-z
- makes another program understand compressed files
- ex: z zxgv file.bmp.gz
-
- (Dare I take the "z" name?)
-
tmp
puts stdin into a temp file and passes it to the specified program
ex: zcat file.bmp.gz | tmp zxgv
+moreutils (0.10) UNRELEASED; urgency=low
+
+ * ifdata: patch from Adam Lackorzynski to translate French error messages
+ to English and to convert some #defines to enums.
+ * ifdata: patch from Adam Lackorzynski to avoid printing info for
+ bogus interface. Closes: #360433
+ * Add zrun, contributed by Chung-chieh Shan (you might prefer to alias it to
+ "z").
+
+ -- Joey Hess <joeyh@debian.org> Sun, 2 Apr 2006 16:15:35 -0400
+
moreutils (0.9) unstable; urgency=low
* ifdata: robustness patch from Adam Lackorzynski, in particular deal with
- combine: combine the lines in two files using boolean operations
- ifdata: get network interface info without parsing ifconfig output
- pee: tee standard input to pipes
+ - zrun: automatically uncompress arguments to command
pee is Copyright (c) Miek Gieben, 2006, under the terms of the GPL.
+zrun is Copyright (c) Chung-chieh Shan, under the terms of the GPL, version
+2 or later.
+
Everything else is copyright 2006 by Joey Hess, under the terms of GPL.
The full text of the GNU GPL can be found in /usr/share/common-licenses/GPL
on Debian systems.
dh_md5sums
dh_builddeb
+# Not intended for use by anyone except the author.
+announcedir:
+ @echo ${HOME}/src/joeywiki/code/moreutils/news
+
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary
#include <string.h>
#include <unistd.h>
#include <ctype.h>
-//#include <linux/socket.h>
-#define DO_EXISTS 1
-#define DO_PEXISTS 2
-#define DO_PADDRESS 3
-#define DO_PMASK 4
-#define DO_PMTU 5
-#define DO_PCAST 6
-#define DO_PALL 7
-#define DO_PFLAGS 8
-#define DO_SINPACKETS 9
-#define DO_SINBYTES 10
-#define DO_SINERRORS 11
-#define DO_SINDROPS 12
-#define DO_SINALL 13
-#define DO_SINFIFO 14
-#define DO_SINFRAME 15
-#define DO_SINCOMPRESSES 16
-#define DO_SINMULTICAST 17
-#define DO_SOUTALL 18
-#define DO_SOUTBYTES 19
-#define DO_SOUTPACKETS 20
-#define DO_SOUTERRORS 21
-#define DO_SOUTDROPS 22
-#define DO_SOUTFIFO 23
-#define DO_SOUTCOLLS 24
-#define DO_SOUTCARRIER 25
-#define DO_SOUTMULTICAST 26
-#define DO_PNETWORK 27
-#define DO_PHWADDRESS 28
+enum {
+ DO_EXISTS = 1,
+ DO_PEXISTS,
+ DO_PADDRESS,
+ DO_PMASK,
+ DO_PMTU,
+ DO_PCAST,
+ DO_PALL,
+ DO_PFLAGS,
+ DO_SINPACKETS,
+ DO_SINBYTES,
+ DO_SINERRORS,
+ DO_SINDROPS,
+ DO_SINALL,
+ DO_SINFIFO,
+ DO_SINFRAME,
+ DO_SINCOMPRESSES,
+ DO_SINMULTICAST,
+ DO_SOUTALL,
+ DO_SOUTBYTES,
+ DO_SOUTPACKETS,
+ DO_SOUTERRORS,
+ DO_SOUTDROPS,
+ DO_SOUTFIFO,
+ DO_SOUTCOLLS,
+ DO_SOUTCARRIER,
+ DO_SOUTMULTICAST,
+ DO_PNETWORK,
+ DO_PHWADDRESS,
+};
struct if_stat {
unsigned long long int in_packets;
PREPARE_SOCK(iface);
CALL_IOCTL(SIOCGIFHWADDR);
- if (res < 0) {
- CALL_ERROR();
- }
+ CALL_ERROR(return);
hwaddr = (unsigned char *)req.ifr_hwaddr.sa_data;
printf("%02X:%02X:%02X:%02X:%02X:%02X",
hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]);
return req.ifr_mtu;
}
-#define START 1
-#define SKIP_LINE 2
-#define START_LINE 3
-#define START_IFNAME 4
-#define IFACE_FOUND 5
-#define RX_BYTES 6
-#define WAIT_RX_PACKETS 7
-#define RX_PACKETS 8
-#define WAIT_RX_ERRORS 9
-#define RX_ERRORS 10
-#define WAIT_RX_DROPS 11
-#define RX_DROPS 12
-#define WAIT_RX_FIFO 13
-#define RX_FIFO 14
-#define WAIT_RX_FRAME 15
-#define RX_FRAME 16
-#define WAIT_RX_COMPRESS 17
-#define RX_COMPRESS 18
-#define WAIT_RX_MULTICAST 19
-#define RX_MULTICAST 20
-#define WAIT_TX_BYTES 21
-#define TX_BYTES 22
-#define WAIT_TX_PACKETS 23
-#define TX_PACKETS 24
-#define WAIT_TX_ERRORS 25
-#define TX_ERRORS 26
-#define WAIT_TX_DROPS 27
-#define TX_DROPS 28
-#define WAIT_TX_FIFO 29
-#define TX_FIFO 30
-#define WAIT_TX_COLLS 31
-#define TX_COLLS 32
-#define WAIT_TX_CARRIER 33
-#define TX_CARRIER 34
-#define WAIT_TX_MULTICAST 35
-#define TX_MULTICAST 36
+enum {
+ START = 1,
+ SKIP_LINE,
+ START_LINE,
+ START_IFNAME,
+ IFACE_FOUND,
+ RX_BYTES,
+ WAIT_RX_PACKETS, RX_PACKETS,
+ WAIT_RX_ERRORS, RX_ERRORS,
+ WAIT_RX_DROPS, RX_DROPS,
+ WAIT_RX_FIFO, RX_FIFO,
+ WAIT_RX_FRAME, RX_FRAME,
+ WAIT_RX_COMPRESS, RX_COMPRESS,
+ WAIT_RX_MULTICAST, RX_MULTICAST,
+ WAIT_TX_BYTES, TX_BYTES,
+ WAIT_TX_PACKETS, TX_PACKETS,
+ WAIT_TX_ERRORS, TX_ERRORS,
+ WAIT_TX_DROPS, TX_DROPS,
+ WAIT_TX_FIFO, TX_FIFO,
+ WAIT_TX_COLLS, TX_COLLS,
+ WAIT_TX_CARRIER, TX_CARRIER,
+ WAIT_TX_MULTICAST, TX_MULTICAST,
+};
#define FIRST_DIGIT(val,digit) do {val=digit-'0'; } while(0)
#define NEXT_DIGIT(val,digit) do {val*=10; val+=digit-'0'; } while(0)
READ_INT(TX_CARRIER,res->out_carrier,WAIT_TX_MULTICAST);
READ_INT(TX_MULTICAST,res->out_carrier,SKIP_LINE);
default:
- fprintf(stderr,"Mon totomate est po bon!\n");
+ fprintf(stderr,"Internal state machine error!\n");
break;
}
}
struct sockaddr *sadr;
struct if_stat *stats=NULL;
if (!ndo) return;
-// printf("J'ai %d actions a réaliser\n",ndo);
+// printf("I have %d items in my queue.\n",ndo);
for (i=0; i<ndo; i++) {
switch (todo[i]) {
case DO_EXISTS:
stats->out_multicast);
break;
default:
- printf("Je comprends pas ce que je dois faire: %d\n",todo[i]);
+ printf("Unknown command: %d\n",todo[i]);
break;
}
printf("\n");
usage(me);
return 1;
}
-// printf("Je travaille sur l'interface %s\n",ifname);
+// printf("Interface %s\n",ifname);
please_do(ndo,todo,ifname);
return 0;
}
--- /dev/null
+#!/usr/bin/perl
+
+=head1 NAME
+
+zrun - automatically uncompress arguments to command
+
+=head1 SYNOPSIS
+
+zrun command file.gz [...]
+
+=head1 DESCRIPTION
+
+Prefixing a shell command with "zrun" causes any compressed files that are
+arguments of the command to be transparently uncompressed to temp files
+(not pipes) and the uncompressed files fed to the command.
+
+This is a quick way to run a command that does not itself support
+compressed files, without manually uncompressing the files.
+
+=head1 BUGS
+
+Modifications to the uncompressed temporary file are not fed back into the
+input file, so using this as a quick way to make an editor support
+compressed files won't work.
+
+=head1 AUTHOR
+
+Copyright 2006 by Chung-chieh Shan <ccshan@post.harvard.edu>
+
+=cut
+
+use warnings;
+use strict;
+use IO::Handle;
+use File::Temp qw{tempfile};
+
+my $program = shift;
+
+my @argument;
+my %child;
+foreach my $argument (@ARGV) {
+ if ($argument =~ m{^(.*/)?([^/]*)\.(gz|Z|bz2)$}s) {
+ my $suffix = "-$2";
+ my @preprocess = $3 eq "bz2" ? qw(bzip2 -d -c) : qw(gzip -d -c);
+
+ my ($fh, $tmpname) = tempfile(SUFFIX => $suffix, UNLINK => 1)
+ or die "zrun: cannot create temporary file: $!\n";
+
+ if (my $child = fork) {
+ $child{$child} = $argument;
+ $argument = $tmpname;
+ }
+ elsif (defined $child) {
+ STDOUT->fdopen($fh, "w");
+ exec @preprocess, $argument;
+ }
+ else {
+ die "zrun: cannot fork to handle $argument: $!\n";
+ }
+ }
+ push @argument, $argument;
+}
+
+while (%child and (my $pid = wait) != -1) {
+ if (defined(my $argument = delete $child{$pid})) {
+ if ($? & 255) {
+ die "zrun: preprocessing for $argument terminated abnormally: $?\n";
+ }
+ elsif (my $code = $? >> 8) {
+ die "zrun: preprocessing for $argument terminated with code $code\n";
+ }
+ }
+}
+
+my $status = system $program ($program, @argument);
+if ($status & 255) {
+ die "zrun: $program terminated abnormally: $?\n";
+}
+else {
+ my $code = $? >> 8;
+ exit $code;
+}