home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- From: <dfs@doe.carleton.ca> (David F. Skoll)
- Subject: v36i003: remind - A replacement for calendar, Patch04c/3
- Message-ID: <1993Mar8.040403.21176@sparky.imd.sterling.com>
- X-Md4-Signature: 4db955a78f5a214dae23847369452b30
- Date: Mon, 8 Mar 1993 04:04:03 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: <dfs@doe.carleton.ca> (David F. Skoll)
- Posting-number: Volume 36, Issue 3
- Archive-name: remind/patch04c
- Environment: UNIX, MS-DOS
- Patch-To: remind: Volume 33, Issue 58-69
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: finnish.h sort.c
- # Wrapped by kent@sparky on Sun Mar 7 21:51:02 1993
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 3 (of 3)."'
- if test -f 'finnish.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'finnish.h'\"
- else
- echo shar: Extracting \"'finnish.h'\" \(5690 characters\)
- sed "s/^X//" >'finnish.h' <<'END_OF_FILE'
- X/***************************************************************/
- X/* */
- X/* FINNISH.H */
- X/* */
- X/* Support for the Finnish language. */
- X/* */
- X/* Author: Mikko Silvonen (Mikko.Silvonen@Helsinki.FI) */
- X/* */
- X/* This file is part of REMIND. */
- X/* Copyright (C) 1992, 1993 by David F. Skoll. */
- X/* */
- X/***************************************************************/
- X
- X/* All Finnish words in this file are in "7-bit Finnish ASCII";
- X they can be converted to other character sets if needed. */
- X
- X/* The very first define in a language support file must be L_LANGNAME: */
- X#define L_LANGNAME "Finnish"
- X
- X/* Day names */
- X#define L_SUNDAY "sunnuntai"
- X#define L_MONDAY "maanantai"
- X#define L_TUESDAY "tiistai"
- X#define L_WEDNESDAY "keskiviikko"
- X#define L_THURSDAY "torstai"
- X#define L_FRIDAY "perjantai"
- X#define L_SATURDAY "lauantai"
- X
- X/* Day initials - first letter only */
- X#define L_DAYINIT "SMTKTPL"
- X
- X/* Month names */
- X#define L_JAN "tammikuu"
- X#define L_FEB "helmikuu"
- X#define L_MAR "maaliskuu"
- X#define L_APR "huhtikuu"
- X#define L_MAY "toukokuu"
- X#define L_JUN "kes{kuu"
- X#define L_JUL "hein{kuu"
- X#define L_AUG "elokuu"
- X#define L_SEP "syyskuu"
- X#define L_OCT "lokakuu"
- X#define L_NOV "marraskuu"
- X#define L_DEC "joulukuu"
- X
- X/* Today and tomorrow */
- X#define L_TODAY "t{n{{n"
- X#define L_TOMORROW "huomenna"
- X
- X/* The default banner */
- X#define L_BANNER "Viestit %wna, %d. %mta %y%o:"
- X
- X/* "am" and "pm" */
- X#define L_AM "ap"
- X#define L_PM "ip"
- X
- X/*** The following are only used in dosubst.c ***/
- X#ifdef L_IN_DOSUBST
- X
- X/* Ago and from now */
- X#define L_AGO "sitten"
- X#define L_FROMNOW "kuluttua"
- X
- X/* "in %d days' time" */
- X#define L_INXDAYS "%d p{iv{n kuluttua"
- X
- X/* "on" as in "on date...", but in Finnish it is a case ending;
- X L_PARTIT is the partitive ending appended to -kuu and -tai */
- X#define L_ON "na"
- X#define L_PARTIT "ta"
- X
- X/* Pluralizing - this is a problem for many languages and may require
- X a more drastic fix */
- X/* The partitive ending of "day" */
- X#define L_PLURAL "{"
- X
- X/* Minutes, hours, at, etc */
- X#define L_NOW "nyt"
- X#define L_AT "klo"
- X#define L_MINUTE "minuutti"
- X#define L_HOUR "tunti"
- X#define L_IS "on"
- X#define L_WAS "oli"
- X#define L_AND "ja"
- X
- X/* What to add to make "hour" plural (or actually partitive) */
- X#define L_HPLU "a"
- X/* What to add to make "minute" plural (or actually partitive) */
- X#define L_MPLU "a"
- X
- X/* Genitive form of "hour" */
- X#define L_HGEN "tunnin"
- X/* Genitive form of "minute" */
- X#define L_MGEN "minuutin"
- X
- X/* Define any overrides here, such as L_ORDINAL_OVERRIDE, L_A_OVER, etc.
- X See the file dosubst.c for more info. */
- X
- X#define L_ORDINAL_OVERRIDE switch(d) { \
- X case 1: plu = ":sen{"; break; \
- X case 2: plu = ":sena"; break; \
- X default: \
- X switch(d%10) { \
- X case 2: \
- X case 3: \
- X case 6: \
- X case 8: plu = ":ntena"; break; \
- X default: plu = ":nten{"; break; \
- X } \
- X }
- X#define L_A_OVER sprintf(s, "%s%s, %d. %s%s %d", DayName[jul%7], L_ON, d, \
- X MonthName[m], L_PARTIT, y);
- X#define L_C_OVER sprintf(s, "%s%s", DayName[jul%7], L_ON);
- X#define L_E_OVER sprintf(s, "%02d%c%02d%c%04d", d, DATESEP, m+1, DATESEP, \
- X y);
- X#define L_F_OVER sprintf(s, "%02d%c%02d%c%04d", m+1, DATESEP, d, DATESEP, y);
- X#define L_G_OVER sprintf(s, "%s%s, %d. %s%s", DayName[jul%7], L_ON, d, \
- X MonthName[m], L_PARTIT);
- X#define L_H_OVER sprintf(s, "%02d%c%02d", d, DATESEP, m+1);
- X#define L_I_OVER sprintf(s, "%02d%c%02d", m+1, DATESEP, d);
- X#define L_J_OVER sprintf(s, "%s%s, %sn %d%s %d", DayName[jul%7], L_ON, \
- X MonthName[m], d, plu, y);
- X#define L_K_OVER sprintf(s, "%s%s, %sn %d%s", DayName[jul%7], L_ON, \
- X MonthName[m], d, plu);
- X#define L_L_OVER sprintf(s, "%04d%c%02d%c%02d", y, DATESEP, m+1, DATESEP, d);
- X#define L_Q_OVER sprintf(s, "n");
- X#define L_U_OVER sprintf(s, "%s%s, %d%s %s%s %d", DayName[jul%7], L_ON, \
- X d, plu, MonthName[m], L_PARTIT, y);
- X#define L_V_OVER sprintf(s, "%s%s, %d%s %s%s", DayName[jul%7], L_ON, d, \
- X plu, MonthName[m], L_PARTIT);
- X#define L_1_OVER if (tdiff == 0) \
- X sprintf(s, L_NOW); \
- X else { \
- X if (hdiff != 0) { \
- X if (tdiff < 0) \
- X sprintf(s, "%d %s%s ", hdiff, L_HOUR, hplu); \
- X else \
- X sprintf(s, "%d %s ", hdiff, L_HGEN); \
- X s += strlen(s); \
- X } \
- X if (mdiff != 0) { \
- X if (tdiff < 0) \
- X sprintf(s, "%d %s%s ", mdiff, L_MINUTE, \
- X mplu); \
- X else \
- X sprintf(s, "%d %s ", mdiff, L_MGEN); \
- X s += strlen(s); \
- X } \
- X sprintf(s, when); \
- X }
- X#endif /* L_IN_DOSUBST */
- END_OF_FILE
- if test 5690 -ne `wc -c <'finnish.h'`; then
- echo shar: \"'finnish.h'\" unpacked with wrong size!
- fi
- # end of 'finnish.h'
- fi
- if test -f 'sort.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sort.c'\"
- else
- echo shar: Extracting \"'sort.c'\" \(6263 characters\)
- sed "s/^X//" >'sort.c' <<'END_OF_FILE'
- X/***************************************************************/
- X/* */
- X/* SORT.C */
- X/* */
- X/* Routines for sorting reminders by trigger date */
- X/* */
- X/* This file is part of REMIND. */
- X/* Copyright (C) 1992, 1993 by David F. Skoll. */
- X/* */
- X/***************************************************************/
- X#include "config.h"
- X
- X#ifdef HAVE_STDLIB_H
- X#include <stdlib.h>
- X#endif
- X
- X#ifdef HAVE_MALLOC_H
- X#include <malloc.h>
- X#endif
- X
- X#include <stdio.h>
- X#include <string.h>
- X#include "types.h"
- X#include "protos.h"
- X#include "expr.h"
- X#include "globals.h"
- X#include "err.h"
- X
- X/* The structure of a sorted entry */
- Xtypedef struct sortrem {
- X struct sortrem *next;
- X char *text;
- X int trigdate;
- X int trigtime;
- X int typ;
- X} Sortrem;
- X
- X/* The sorted reminder queue */
- Xstatic Sortrem *SortedQueue = (Sortrem *) NULL;
- X
- XPRIVATE Sortrem *MakeSortRem ARGS ((int jul, int tim, char *body, int typ));
- XPRIVATE void IssueSortBanner ARGS ((int jul));
- X
- X/***************************************************************/
- X/* */
- X/* MakeSortRem */
- X/* */
- X/* Create a new Sortrem entry - return NULL on failure. */
- X/* */
- X/***************************************************************/
- X#ifdef HAVE_PROTOS
- XPRIVATE Sortrem *MakeSortRem(int jul, int tim, char *body, int typ)
- X#else
- Xstatic Sortrem *MakeSortRem(jul, tim, body, typ)
- Xint jul, tim;
- Xchar *body;
- Xint typ;
- X#endif
- X{
- X Sortrem *new = NEW(Sortrem);
- X if (!new) return NULL;
- X
- X new->text = StrDup(body);
- X if (!new->text) {
- X free(new);
- X return NULL;
- X }
- X
- X new->trigdate = jul;
- X new->trigtime = tim;
- X new->typ = typ;
- X new->next = NULL;
- X return new;
- X}
- X
- X/***************************************************************/
- X/* */
- X/* InsertIntoSortBuffer */
- X/* */
- X/* Insert a reminder into the sort buffer */
- X/* */
- X/***************************************************************/
- X#ifdef HAVE_PROTOS
- XPUBLIC int InsertIntoSortBuffer(int jul, int tim, char *body, int typ)
- X#else
- Xint InsertIntoSortBuffer(jul, tim, body, typ)
- Xint jul;
- Xint tim;
- Xchar *body;
- Xint typ;
- X#endif
- X{
- X Sortrem *new = MakeSortRem(jul, tim, body, typ);
- X Sortrem *cur = SortedQueue, *prev = NULL;
- X int ShouldGoAfter;
- X
- X if (!new) {
- X Eprint("Out of memory for sorting.");
- X IssueSortedReminders();
- X SortByDate = 0;
- X SortByTime = 0;
- X return E_NO_MEM;
- X }
- X
- X /* Find the correct place in the sorted list */
- X if (!SortedQueue) {
- X SortedQueue = new;
- X return OK;
- X }
- X while (cur) {
- X if (cur->trigdate == new->trigdate) {
- X ShouldGoAfter =
- X (SortByTime == SORT_ASCEND) ?
- X (new->trigtime >= cur->trigtime) :
- X ((new->trigtime == NO_TIME) || (new->trigtime <= cur->trigtime));
- X } else {
- X ShouldGoAfter =
- X (SortByDate == SORT_ASCEND) ?
- X (new->trigdate >= cur->trigdate) :
- X (new->trigdate <= cur->trigdate);
- X }
- X
- X if (ShouldGoAfter) {
- X prev = cur;
- X cur = cur->next;
- X } else {
- X if (prev) {
- X prev->next = new;
- X new->next = cur;
- X } else {
- X SortedQueue = new;
- X new->next = cur;
- X }
- X return OK;
- X }
- X
- X }
- X prev->next = new;
- X new->next = cur; /* For safety - actually redundant */
- X return OK;
- X}
- X
- X
- X/***************************************************************/
- X/* */
- X/* IssueSortedReminders */
- X/* */
- X/* Issue all of the sorted reminders and free memory. */
- X/* */
- X/***************************************************************/
- X#ifdef HAVE_PROTOS
- XPUBLIC void IssueSortedReminders(void)
- X#else
- Xvoid IssueSortedReminders()
- X#endif
- X{
- X Sortrem *cur = SortedQueue;
- X Sortrem *next;
- X int olddate = NO_DATE;
- X
- X while (cur) {
- X next = cur->next;
- X if (cur->typ == MSG_TYPE) {
- X if (!MsgCommand) {
- X if (cur->trigdate != olddate) {
- X IssueSortBanner(cur->trigdate);
- X olddate = cur->trigdate;
- X }
- X printf("%s\n", cur->text);
- X } else {
- X char buf[LINELEN+TOKSIZE];
- X sprintf(buf, MsgCommand, cur->text);
- X system(buf);
- X }
- X } else { /* Must be RUN_TYPE */
- X system(cur->text);
- X }
- X free(cur->text);
- X free(cur);
- X cur = next;
- X }
- X}
- X/***************************************************************/
- X/* */
- X/* IssueSortBanner */
- X/* */
- X/* Issue a daily banner if the function sortbanner() is */
- X/* defined to take one argument. */
- X/* */
- X/***************************************************************/
- X#ifdef HAVE_PROTOS
- XPRIVATE void IssueSortBanner(int jul)
- X#else
- Xstatic void IssueSortBanner(jul)
- Xint jul;
- X#endif
- X{
- X char BanExpr[25];
- X int y, m, d;
- X Value v;
- X char *s = BanExpr;
- X
- X if (UserFuncExists("sortbanner") != 1) return;
- X
- X FromJulian(jul, &y, &m, &d);
- X sprintf(BanExpr, "sortbanner('%04d/%02d/%02d')", y, m+1, d);
- X y = EvalExpr(&s, &v);
- X if (y) return;
- X if (DoCoerce(STR_TYPE, &v)) return;
- X if (!DoSubstFromString(v.v.str, SubstBuffer, jul, NO_TIME))
- X if (*SubstBuffer) printf("%s\n", SubstBuffer);
- X DestroyValue(&v);
- X}
- END_OF_FILE
- if test 6263 -ne `wc -c <'sort.c'`; then
- echo shar: \"'sort.c'\" unpacked with wrong size!
- fi
- # end of 'sort.c'
- fi
- echo shar: End of archive 3 \(of 3\).
- cp /dev/null ark3isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-