mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
-- Fixed CalcMinsFromUTC to work with unsigned time_t
-- Added rem2html.
This commit is contained in:
16
WHATSNEW.30
16
WHATSNEW.30
@@ -2,16 +2,22 @@ CHANGES TO REMIND
|
||||
|
||||
* Version 3.0 Patch 17
|
||||
|
||||
+ MINOR ENHANCEMENTS
|
||||
|
||||
- Added www/rem2html, a Perl script which converts the output of
|
||||
`remind -p ...' to an HTML table. The script was contributed by
|
||||
Don Schwarz <darkowl@mcs.net>
|
||||
|
||||
+ BUG FIXES
|
||||
|
||||
- Added romanian.h to the manifest. Sorry.
|
||||
|
||||
- CalcMinsFromUTC was failing if time_t was unsigned. I really _should_
|
||||
use difftime(), but not all systems have it. Also, defs.rem was rearranged
|
||||
- CalcMinsFromUTC was failing if time_t was unsigned. I now use
|
||||
difftime(), but not all systems have it. Also, defs.rem was rearranged
|
||||
so PostScript stuff works better, and new target "emxomf" was added to
|
||||
makefile.ost which uses OMF linking and a dynamically-linked C library.
|
||||
All three of these fixes are courtesy of Christopher J. Madsen
|
||||
<madsen@iglobal.net>. Thanks, Christopher.
|
||||
makefile.os2 which uses OMF linking and a dynamically-linked C
|
||||
library. All three of these fixes are courtesy of Christopher
|
||||
J. Madsen <madsen@iglobal.net>. Thanks, Christopher.
|
||||
|
||||
* Version 3.0 Patch 16
|
||||
|
||||
|
||||
13
main.c
13
main.c
@@ -11,7 +11,7 @@
|
||||
/***************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
static char const RCSID[] = "$Id: main.c,v 1.6 1997-03-31 22:13:09 dfs Exp $";
|
||||
static char const RCSID[] = "$Id: main.c,v 1.7 1997-07-06 14:34:37 dfs Exp $";
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
@@ -1260,11 +1260,18 @@ int jul, tim, *mins, *isdst;
|
||||
temp = localtime(&loc_t);
|
||||
/* Compute difference between local time and UTC in seconds.
|
||||
Be careful, since time_t might be unsigned. */
|
||||
tdiff = (loc_t < utc_t) ? -1*((int)(utc_t-loc_t)) : (loc_t-utc_t);
|
||||
#ifdef HAVE_MKTIME
|
||||
/* Should use difftime */
|
||||
/* If we have mktime(), then we have difftime(), so use it! */
|
||||
tdiff = (int) difftime(loc_t, utc_t);
|
||||
if (mins) *mins = (int)(((temp->tm_isdst) ? 60 : 0) + tdiff / 60 );
|
||||
#else
|
||||
/* If we don't have mktime(), we probably don't have difftime(),
|
||||
so use this rather non-portable code. */
|
||||
if (loc_t < utc_t) {
|
||||
tdiff = - (int) (utc_t - loc_t);
|
||||
} else {
|
||||
tdiff = (int) (loc_t - utc_t);
|
||||
}
|
||||
if (mins) *mins = (int)(tdiff / 60);
|
||||
#endif
|
||||
if (isdst) *isdst = temp->tm_isdst;
|
||||
|
||||
15
www/README.rem2html
Normal file
15
www/README.rem2html
Normal file
@@ -0,0 +1,15 @@
|
||||
REM2HTML
|
||||
$Id: README.rem2html,v 1.1 1997-07-06 14:34:41 dfs Exp $
|
||||
|
||||
Rem2HTML is a Perl script which transforms the output of
|
||||
`remind -p ...' to an HTML table. Type `perl rem2html --help' for
|
||||
usage information.
|
||||
|
||||
Typical usage: remind -p ~/.reminders | rem2html > file.html
|
||||
|
||||
Rem2HTML was contributed by Don Schwarz <darkowl@mcs.net>. It
|
||||
produces HTML compatible with most modern browsers, but *not* with
|
||||
browsers which don't support tables (like Lynx, as of this writing.)
|
||||
|
||||
--
|
||||
David F. Skoll
|
||||
@@ -1,6 +1,6 @@
|
||||
<HTML>
|
||||
<!-- Sample HTML file with links to the calendar stuff -->
|
||||
<!-- $Id: calendar.html-DIST,v 1.2 1997-03-30 19:08:01 dfs Exp $ -->
|
||||
<!-- $Id: calendar.html-DIST,v 1.3 1997-07-06 14:34:41 dfs Exp $ -->
|
||||
<HEAD>
|
||||
<TITLE>David Skoll's Calendar Server</TITLE>
|
||||
</HEAD>
|
||||
@@ -25,3 +25,4 @@ PostScript Calendar with Jewish Holidays</a> (Approximately 35 kB)<P>
|
||||
Get the Remind software</a> that provides this service.<P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
298
www/rem2html
Executable file
298
www/rem2html
Executable file
@@ -0,0 +1,298 @@
|
||||
#!/bin/perl
|
||||
|
||||
# rem2html
|
||||
#
|
||||
# $Id: rem2html,v 1.1 1997-07-06 14:34:41 dfs Exp $
|
||||
#
|
||||
# A script to convert from the output of "remind -p" to Hyper-Text Markup
|
||||
# Language (HTML), the text format used in WWW documents. By default, it
|
||||
# outputs a stand-alone file which can be fed directly into a web browser.
|
||||
# The output uses nested <TABLE> blocks, so it will only work in a browser
|
||||
# which supports tables (Netscape, MSIE, etc, NOT Lynx).
|
||||
#
|
||||
# This script works well on my computer (Linux 2.0.27) under Perl 5.003 and
|
||||
# 5.004. It should work fine on other unices but I have no idea whether
|
||||
# it will run under VMS, OS/2, Windows, etc.
|
||||
#
|
||||
# This file is Copyright (C) 1997 by Don Schwarz <darkowl@mcs.net>.
|
||||
|
||||
use Getopt::Long;
|
||||
|
||||
@months = (January,February,March,April,May,June,July,August,September,October,November,December);
|
||||
|
||||
$rem2html_version = "1.0";
|
||||
|
||||
&parse_options();
|
||||
|
||||
if ($Options{'help'}) {
|
||||
&show_usage();
|
||||
} elsif ($Options{'version'}) {
|
||||
print "Rem2HTML Version $rem2html_version.\n";
|
||||
} else {
|
||||
&parse_input();
|
||||
|
||||
&output_header();
|
||||
&output_data();
|
||||
&output_footer();
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
sub show_usage {
|
||||
print STDERR <<EndOfUsage;
|
||||
Rem2HTML: Produce a HTML calendar from the output of Remind.
|
||||
|
||||
Usage: rem2html [options]
|
||||
|
||||
Options:
|
||||
|
||||
--help, -h Print this information
|
||||
--version Version information
|
||||
-p file Prepend the specified HTML file to the beginning of the
|
||||
output
|
||||
-f[shted] font Set font for small cal, hdr, title, cal entries,day numbers
|
||||
-s[hted] size Set size for header, title, calendar entries and/or day
|
||||
numbers
|
||||
--backurl url Make the title on the previous month's small calendar entry
|
||||
a hyperlink to <url>
|
||||
--forwurl url Same as --backurl, but with the next month's small calendar
|
||||
--tableonly Output the results as a <TABLE> block only, no <HTML>, etc.
|
||||
--border,-b size Set the border thickness of the table
|
||||
--cellspace,-t size Set the line thickness of the table
|
||||
--bgcolor,-g color Set the background color for the day entries
|
||||
|
||||
EndOfUsage
|
||||
|
||||
}
|
||||
|
||||
sub parse_options {
|
||||
%Options = ();
|
||||
|
||||
GetOptions (\%Options, "help|h",
|
||||
"version",
|
||||
"border|b=i",
|
||||
"cellspace|t=i",
|
||||
"backurl|bu:s", "forwurl|fu:s",
|
||||
"tableonly|to",
|
||||
"prologue|p=s",
|
||||
"bgcolor|g=s",
|
||||
"fs=s", "fh=s", "ft=s", "fe=s", "fd=s",
|
||||
"sh=i", "st=i", "se=i", "sd=i",
|
||||
);
|
||||
|
||||
$Options{'border'} = "BORDER=" . ($Options{'border'} || 1);
|
||||
$Options{'cellspace'} &&= "CELLSPACING=$Options{'cellspace'}";
|
||||
$Options{'bgcolor'} &&= "BGCOLOR=$Options{'bgcolor'}";
|
||||
}
|
||||
|
||||
sub parse_input {
|
||||
local $where = 0;
|
||||
local $msg;
|
||||
@days = ();
|
||||
|
||||
while (<>) {
|
||||
chomp($_);
|
||||
if (/rem2(html|ps) begin/) {
|
||||
} elsif (!$where) {
|
||||
next;
|
||||
} elsif ($where == 1) {
|
||||
local ($month, $year);
|
||||
($month, $year, $month_length, $firstday, $mfirst) = split(" ");
|
||||
$caption = "$month, $year";
|
||||
for $i ( 1 .. $month_length) { push(@days, ""); }
|
||||
} elsif ($where == 2) {
|
||||
@prevsc = split(" ");
|
||||
} elsif ($where == 3) {
|
||||
@nextsc = split(" ");
|
||||
} else {
|
||||
last if /rem2(html|ps) end/;
|
||||
next unless m%^(\d*)/*(\d*)/*(\d*) ([^ ]*)?\s*(.*)$%;
|
||||
$msg = $5;
|
||||
$msg = "$4 $msg" if $4;
|
||||
$days[$3] .= "<P>$msg</P>";
|
||||
}
|
||||
$where++;
|
||||
}
|
||||
|
||||
die "Rem2HTML: Could not find any calendar data.\n", unless $where;
|
||||
}
|
||||
|
||||
sub output_header {
|
||||
local ($title, $dayheader);
|
||||
|
||||
if (!$Options{'tableonly'}) {
|
||||
print <<EndOfHTML;
|
||||
<HTML>
|
||||
<HEAD><TITLE>Reminders for $caption</TITLE></HEAD>
|
||||
<BODY>
|
||||
EndOfHTML
|
||||
}
|
||||
|
||||
print <<EndOfHTML;
|
||||
<!-- This output was produced by Rem2HTML $rem2html_version (written by
|
||||
Don Schwarz <darkowl\@mcs.net>) and Remind (written by David F. Skoll). -->
|
||||
EndOfHTML
|
||||
|
||||
if ($Options{'prologue'}) {
|
||||
open(PROLOGUE, "< $Options{'prologue'}");
|
||||
print while ( <PROLOGUE> );
|
||||
close(PROLOGUE);
|
||||
}
|
||||
|
||||
$caption = &format_font($caption, $Options{'ft'}, $Options{'st'} || "+1");
|
||||
|
||||
print <<EndOfHTML;
|
||||
<TABLE $Options{'border'} $Options{'cellspace'} $Options{'bgcolor'} WIDTH=100%>
|
||||
<CAPTION><STRONG>$caption</STRONG></CAPTION>
|
||||
<TR>
|
||||
EndOfHTML
|
||||
|
||||
$mfirst || &print_day_header("Sunday");
|
||||
|
||||
foreach $dayheader (Monday,Tuesday,Wednesday,Thursday,Friday,Saturday) {
|
||||
&print_day_header($dayheader);
|
||||
}
|
||||
|
||||
$mfirst && &print_day_header("Sunday");
|
||||
print " </TR>\n";
|
||||
}
|
||||
|
||||
sub output_footer {
|
||||
print "</TABLE>\n";
|
||||
|
||||
unless ($Options{'tableonly'}) {
|
||||
print <<EndOfHTML;
|
||||
</BODY>
|
||||
</HTML>
|
||||
EndOfHTML
|
||||
}
|
||||
}
|
||||
|
||||
sub output_data {
|
||||
local ($endday, $prevday, $nextday, $week, $weekday);
|
||||
local ($element, $day, $msg, $fday);
|
||||
$firstday -= $mfirst;
|
||||
if ($firstday < 0) { $firstday += 7; }
|
||||
$endday = $firstday + $month_length;
|
||||
$endweek = $endday + (6 - ($endday % 7));
|
||||
$endday %= 7;
|
||||
|
||||
if ( $firstday > 1 ) {
|
||||
$prevday = 0;
|
||||
$nextday = 1;
|
||||
} elsif ($endday ? ($endday < 5) : !$firstday) {
|
||||
$prevday = $endweek - 1;
|
||||
$nextday = $endweek;
|
||||
} else {
|
||||
$prevday = 0;
|
||||
$nextday = $endweek;
|
||||
}
|
||||
|
||||
for $week ( 0..5 ) {
|
||||
print " <TR>\n";
|
||||
for $weekday ( 0..6 ) {
|
||||
$element = ($week * 7) + ($weekday * 1);
|
||||
$day = $element - $firstday + 1;
|
||||
$msg = $days[$day];
|
||||
$msg = $msg ? &format_font($msg, $Options{'fe'}, $Options{'se'})
|
||||
: " <BR> <BR> <BR> <BR>";
|
||||
|
||||
$fday = &format_font($day, $Options{'fd'}, $Options{'sd'} || -1);
|
||||
if ($day > 0 && $day <= $month_length) {
|
||||
|
||||
print <<EndOfHTML;
|
||||
<TD VALIGN=TOP WIDTH=14%>
|
||||
<P ALIGN=RIGHT>$fday</P>
|
||||
$msg
|
||||
</TD>
|
||||
EndOfHTML
|
||||
|
||||
} elsif ($element == $prevday) {
|
||||
&small_calendar(@prevsc, 1, $Options{'backurl'});
|
||||
} elsif ($element == $nextday) {
|
||||
&small_calendar(@nextsc, 2, $Options{'forwurl'});
|
||||
} else {
|
||||
print " <TD WIDTH=14%><BR></TD>";
|
||||
}
|
||||
}
|
||||
print " </TR>\n";
|
||||
last if $day >= $month_length && $element >= $nextday;
|
||||
}
|
||||
}
|
||||
|
||||
sub small_calendar {
|
||||
local ($scname, $scn, $which, $url) = @_;
|
||||
local ($scstart, $l, $week, $weekday, $tday);
|
||||
|
||||
$scname = "<A HREF=\"$url\">$scname</A>", if $url;
|
||||
$scname = &format_font($scname, $Options{'fs'}, -2);
|
||||
|
||||
if ($which == 1) {
|
||||
$scstart = $firstday - ($scn % 7);
|
||||
if ($scstart < 0) { $scstart += 7; }
|
||||
} else {
|
||||
$scstart = $firstday + ($month_length % 7);
|
||||
if ($scstart > 6) { $scstart -= 7; }
|
||||
}
|
||||
|
||||
print <<EndOfHTML;
|
||||
<TD WIDTH=14% VALIGN=TOP>
|
||||
<TABLE WIDTH=100%>
|
||||
<CAPTION><STRONG>$scname</STRONG></CAPTION>
|
||||
<TR>
|
||||
EndOfHTML
|
||||
|
||||
$mfirst || &print_day_header("S", 1);
|
||||
|
||||
foreach $l (M,T,W,T,F,S) {
|
||||
&print_day_header($l, 1);
|
||||
}
|
||||
|
||||
$mfirst && &print_day_header("S", 1);
|
||||
print "</TR>\n";
|
||||
|
||||
for $week ( 0..5 ) {
|
||||
print " <TR>\n";
|
||||
for $weekday ( 0..6 ) {
|
||||
$tday = ($week * 7) + ($weekday * 1) - $scstart + 1;
|
||||
$tday = "", if $tday <= 0 || $tday > $scn;
|
||||
print " <TD WIDTH=14%><FONT SIZE=-2>$tday</FONT></TD>\n";
|
||||
}
|
||||
print " </TR>\n";
|
||||
last if $tday >= $scn;
|
||||
}
|
||||
|
||||
print <<EndOfHTML;
|
||||
</TABLE>
|
||||
</TD>
|
||||
EndOfHTML
|
||||
|
||||
}
|
||||
|
||||
sub format_font {
|
||||
local ($text, $font, $size) = @_;
|
||||
|
||||
if (!$text) {
|
||||
return "";
|
||||
} elsif ($font && $size) {
|
||||
return "<FONT FACE=$font SIZE=$size>$text</FONT>";
|
||||
} elsif ($font) {
|
||||
return "<FONT FACE=$font>$text</FONT>";
|
||||
} elsif ($size) {
|
||||
return "<FONT SIZE=$size>$text</FONT>";
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
sub print_day_header {
|
||||
local ($dheader, $small) = @_;
|
||||
|
||||
if ($small) {
|
||||
$dheader = &format_font($dheader, $Options{'fs'}, -2);
|
||||
} else {
|
||||
$dheader = &format_font($dheader, $Options{'fh'}, $Options{'sh'});
|
||||
}
|
||||
|
||||
print " <TH WIDTH=14%>$dheader</TH>\n";
|
||||
}
|
||||
Reference in New Issue
Block a user