Commit 72318c65 72318c654bc9f60dede18ba510065a9f0632346e by Sean 'Shaleh' Perry

removed extra from.c and changelog.pl

1 parent 1cee2a45
2000-01-17 Sean 'Shaleh' Perry
* examples/from.c: remove extraneous copyright notice
1999-12-15 Alain Magloire
* url/url_mbox.h url/url_pop.h url/url_imap.h url/url_mailto.h
......
#!/usr/bin/perl
# changelog: update the changelog using your favorite visual editor
#
# When creating a new changelog section, if either of the environment
# variables CVS_EMAIL or EMAIL is set, changelog will use this as the
# uploader's email address (with the former taking precedence), and if
# CVS_FULLNAME is set, it will use this as the uploader's full name.
# Otherwise, it will just copy the values from the previous changelog
# entry.
#
# Originally by Christoph Lameter <clameter@debian.org>
# Modified extensively by Julian Gilbey <jdg@debian.org>
# Now a changelog script for GNU projects
# Sean 'Shaleh' Perry <shaleh@debian.org>
#
# Copyright 1999 by Julian Gilbey
#
# 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
use 5.003; # We're using function prototypes
use Getopt::Std;
use File::Copy;
use Cwd;
# Predeclare functions
sub fatal($);
my $progname;
($progname=$0) =~ s|.*/||;
sub usage {
print <<EOF
Usage: $progname [-h] [changelog entry]
Options:
-h Display this help message and exit
EOF
}
# Look for the changelog
if (! -e "ChangeLog")
{
die("Cannot find ChangeLog anywhere! " .
"Are you in the source code tree?");
}
if ( -e "ChangeLog.dch" ) {
die("The backup file ChangeLog.dch already exists --\n" .
"please move it before trying again");
} else {
$tmpchk=1;
}
sub BEGIN {
# Initialise the variable
$tmpchk=0;
}
sub END {
unlink "ChangeLog.dch" or
warn "Could not remove ChangeLog.dch"
if $tmpchk;
}
open S, "ChangeLog" or fatal "Cannot open ChangeLog:" . " $!";
open O, ">ChangeLog.dch"
or fatal "Cannot write to temporary file:" . " $!";
getopts('h')
or die sprintf
("Usage: %s [-h] [changelog entry]\n", $progname);
if ($opt_h) { usage(); exit(0); }
# Get a possible changelog entry from the command line
$SAVETEXT=$TEXT="@ARGV";
# Get the date
chomp($DATE=`date +%Y-%m-%d`);
$MAINTAINER = $ENV{'CVS_FULLNAME'} || $MAINTAINER;
if ($MAINTAINER eq '') {
fatal "Could not figure out maintainer's name:" . " $!";
}
$EMAIL = $ENV{'CVS_EMAIL'} || $ENV{'EMAIL'} || $EMAIL;
if ($EMAIL eq '') {
fatal "Could not figure out maintainer's email address:" . " $!";
}
print O "$DATE $MAINTAINER <$EMAIL>\n\n";
if ($TEXT) { write O } else { print O "\t* \n\n"; $line=3; }
# Rewind the current changelog to the beginning of the file
seek S,0,0 or fatal "Couldn't rewind ChangeLog:" . " $!";
# Copy the rest of the changelog file to new one
while (<S>) { print O; }
close S or fatal "Error closing ChangeLog:" . " $!";
close O or fatal "Error closing temporary ChangeLog:" . " $!";
# Now Run the Editor
if (! $SAVETEXT) {
$EDITOR=$ENV{"EDITOR"} || $ENV{"VISUAL"} || '/usr/bin/editor';
system("$EDITOR +$line ChangeLog.dch") / 256 == 0 or
fatal "Error editing the ChangeLog:" . " $!";
}
copy("ChangeLog.dch","ChangeLog") or
fatal "Couldn't replace ChangeLog with new ChangeLog:" . " $!";
# Format for standard ChangeLogs
format O =
* ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$TEXT
~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$TEXT
.
sub fatal($) {
my ($pack,$file,$line);
($pack,$file,$line) = caller();
(my $msg = sprintf("%s: fatal error at line %d:\n",
$progname, $line) . "@_\n") =~ tr/\0//d;
$msg =~ s/\n\n$/\n/;
die $msg;
}
/**
* Code in the public domain, Sean 'Shaleh' Perry <shaleh@debian.org>, 1999
*
* Created as an example of using libmailbox
*
**/
#include <mailbox.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
mailbox *mail;
unsigned int i;
char *from, *date;
char *user;
char mailpath[256];
user = getenv("USER");
if (user == NULL)
{
fprintf(stderr, "who am I?\n");
exit(-1);
}
if (!strcmp(user, "root") && argc == 2)
user = argv[1];
else if (argc > 2)
{
fprintf(stderr,
"Usage: from [username] (argument valid when ran as root)\n");
exit(-1);
}
snprintf (mailpath, 256, "%s/%s", _PATH_MAILDIR, user);
mail = mbox_open(mailpath);
if( mail == NULL ) {
perror("mbox_open");
exit(-1);
}
for(i = 0; i < mail->messages; ++i) {
from = mbox_header_line(mail, i, "From");
if (from == NULL)
{
perror("mbox_header_line");
exit(-1);
}
date = mbox_header_line(mail, i, "Received");
if (date == NULL)
{
perror("mbox_header_line");
exit(-1);
}
printf("%s %s\n", from, date);
free(from);
free(date);
}
mbox_close(mail);
exit(0);
}
......@@ -38,14 +38,12 @@
# include <paths.h>
#endif
#include <paths.h>
#ifndef _PATH_MAILDIR
# define _PATH_MAILDIR "/var/spool/mail"
#endif
#ifndef VERSION
# define VERSION "unknow"
# define VERSION "unknown"
#endif
#include "getopt.h"
......