home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-02-13 | 35.0 KB | 1,324 lines |
- Newsgroups: comp.sources.misc
- From: art@Cayman.COM (Art Mellor)
- Subject: v28i035: ticktalk - display time in English, French or Afrikaans, Part01/01
- Message-ID: <1992Feb10.221732.24128@sparky.imd.sterling.com>
- X-Md4-Signature: b9fa12213822603df88fdfdbfe22db12
- Date: Mon, 10 Feb 1992 22:17:32 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: art@Cayman.COM (Art Mellor)
- Posting-number: Volume 28, Issue 35
- Archive-name: ticktalk/part01
- Environment: UNIX, X11, tty
-
- Ticktalk is a program to display the time in words in various languages.
- Currently the only languages supported are:
- English
- French (thanks to Kaveh Kardan)
- Afrikaans (thanks to Linda Matthew)
-
- I am making this program available in hopes of extending the capabilities
- to include as many languages as possible (see the README discussion as to
- how to add languages if you are interested).
-
- This will give you 3 programs:
- 1. ticktalk
- This program displays the time to the terminal
- 2. xticktalk
- This program puts up an X window and displays the time
- 3. testtalk
- This program prints all possible times (this is for testing,
- you can delete it if you're not adding languages)
-
- Both xticktalk and ticktalk take a number of optional arguments:
- -help Print help strings
- -version Get version of program
- -before Print "Twenty To One" rather than "Twelve Forty"
- -approximate Round to nearest 5 minutes
- -noampm Don't indicate am or pm (when appropriate)
- -english Print time in English (default)
- -french Print time in French
- -afrikaans Print time in Afrikaans
-
- The ticktalk version with no additional arguments prints the current
- time in words in the selected language to stdout, but if given 2 arguments
- representing hour and minute (as numbers) it will print that time to
- stdout. E.g.
- % ticktalk 1 0
- One O'Clock am
-
- The xticktalk version takes additional arguments:
- -update secs The number of seconds to wait between updates (def 30)
- X Options Standard X windows options (e.g. -fn, -display, etc.)
-
- Problems, complaints and compliments to: art@cayman.com
- If you want to be added to a mailing list to receive updates as new languages
- are added, send me mail and I will add you.
-
- Art Mellor
- -------------------------------------------------------------------------------
- #! /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".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: README Makefile bundle ticktalk.c xticktalk.xbm
- # Wrapped by kent@sparky on Mon Feb 10 16:07:13 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 1 (of 1)."'
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(3905 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XREADME for ticktalk:
- X
- XTicktalk is a program to display the time in words in various languages.
- XCurrently the only languages supported are:
- X English
- X French (thanks to Kaveh Kardan)
- X Afrikaans (thanks to Linda Matthew)
- XBut I am making this program available in hopes of extending the capabilities
- Xto include as many languages as possible (see below how to add languages
- Xif you are interested).
- X
- XTo build:
- X 1. unshar the file (you've probably already done this):
- X % sh file
- X 2. Take a quick look at the Makefile and change things as
- X necessary.
- X 3. set things up for the build:
- X % make clean
- X 4. build 'em:
- X % make all
- X
- XThis will give you 3 programs:
- X 1. ticktalk
- X This program displays the time to the terminal
- X 2. xticktalk
- X This program puts up an X window and displays the time
- X 3. testtalk
- X This program prints all possible times (this is for testing,
- X you can delete it if you're not adding languages)
- XTo run:
- X % ticktalk
- X % xticktalk
- X (this one looks best with large fonts, e.g. :
- X -fn -bitstream-charter-medium-r-normal--33-240-100-100-p-183-iso8859-1)
- X
- XBoth programs take a number of optional arguments:
- X -help Print help strings
- X -version Get version of program
- X -before Print "Twenty To One" rather than "Twelve Forty"
- X -approximate Round to nearest 5 minutes
- X -noampm Don't indicate am or pm (when appropriate)
- X -english Print time in English (default)
- X -french Print time in French
- X -afrikaans Print time in Afrikaans
- X
- XThe ticktalk version with no additional arguments prints the current
- Xtime in words in the selected language to stdout, but if given 2 arguments
- Xrepresenting hour and minute (as numbers) it will print that time to
- Xstdout. E.g.
- X % ticktalk 1 0
- X One O'Clock am
- X
- XThe xticktalk version takes additional arguments:
- X -update secs The number of seconds to wait between updates (def 30)
- X X Options Standard X windows options (e.g. -fn, -display, etc.)
- X
- X-------------------------------------------------------------------------------
- XProblems, complaints and compliments to: art@cayman.com
- XIf you want to be added to a mailing list to receive updates as new languages
- Xare added, send me mail and I will add you.
- X-------------------------------------------------------------------------------
- X
- XDo you know another language? Do you want to be famous and go down in history
- Xas having added that language to this program? Here's how to do it for language
- X'Newlanguage':
- X
- X
- X0. Now really, are you fluent? Please don't try to remember high school
- X language class - I don't want to be flooded with flames from
- X native speakers telling me the program is wrong :-)
- X1. Take a look at how 'Time2WordEnglish' and 'Number2WordEnglish' work.
- X2. Write the routine 'Time2WordNewlanguage' (you will probably need to
- X also write 'Number2WordNewlanguage' to do this).
- X Don't forget to do the right things for approximate and before flags.
- X3. Add a #define NEWLANGUAGE n to the file
- X4. Add the language to the list in 'Usage'
- X5. Add the flag -newlanguage to 'ProcessArgs'
- X6. Add case to 'Time2Word' for 'NEWLANGUAGE'
- X7. Use 'make testtalk' to test your code.
- X % make testtalk
- X % testtalk -newlanguage hour min
- X will allow you to test individual times
- X % testtalk -newlanguage
- X will print all possible times to stdout. Redirect to a file or pipe
- X to more to verify everything looks ok. Don't forget to test with
- X the -before and -approximate flags!
- X8. Send me 'Time2WordNewlanguage' and 'Number2WordNewlanguage' and I will
- X integrate your changes into the latest version and send out an update.
- X Please also indicate your fluency: native,lived there,other
- X My email address is art@cayman.com (617/494-1999)
- X
- X PLEASE DON'T SEND DIFFS! I am not archiving old versions so what you
- X diff against and what I have may not be the same.
- X
- XIf anyone knows how to easily add languages that use different character
- Xsets, please let me know (or better yet, add one and send me the code).
- END_OF_FILE
- if test 3905 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(3101 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- X#
- X# Important constants
- X#
- X
- X# If you don't have gcc, then comment out next 2 lines and uncomment the
- X# the 2 lines after them (and then go get gcc :-)
- X#CC = gcc
- X#CFLAGS = -g -O
- XCC = cc
- XCFLAGS = -O
- X
- XDEPENDFILE = depends
- XPRINTER = ch
- XMV = mv
- X
- X#
- X# Individual programs
- X#
- X
- XTICKTALK = ticktalk
- XTICKTALK_C = ticktalk.c
- XTICKTALK_H =
- XTICKTALK_O = $(TICKTALK_C:.c=.o)
- X
- XXTICKTALK = xticktalk
- XXTICKTALK_C = ticktalk.c
- XXTICKTALK_H =
- XXTICKTALK_O = xticktalk.o
- XXLIBS = -lXaw -lXmu -lXt -lXext -lX11
- X# Uncomment the following two lines if you are using OpenWindows
- X# XINCLUDEFLAGS = -I/usr/openwin/include
- X# XLIBRARYFLAGS = -L/usr/openwin/lib
- X
- XTESTTALK = testtalk
- XTESTTALK_C = ticktalk.c
- XTESTTALK_H =
- XTESTTALK_O = testtalk.o
- X
- X#
- X# All the programs
- X#
- X
- XALL = $(TICKTALK) $(XTICKTALK) $(TESTTALK)
- XALL_C = $(TICKTALK_C) $(XTICKTALK_C) $(TESTTALK_C)
- XALL_H = $(TICKTALK_H) $(XTICKTALK_H) $(TESTTALK_H)
- XALL_O = $(TICKTALK_O) $(XTICKTALK_O) $(TESTTALK_O)
- X
- X#
- X# Help user with what this file contains
- X#
- X
- Xhelp: always
- X @echo "make [target], where [target] is one of:"
- X @echo " help - print this message"
- X @echo " deps - make the dependicies file"
- X @echo " clean - rm object files and temporary files"
- X @echo " clobber - do a clean and then remove executables"
- X @echo " tags - make tags for all the source files"
- X @echo ""
- X @echo " ticktalk.sh - make a bundle file to send to someone"
- X @echo " all - make all the following programs:"
- X @echo " ticktalk - a program to print the time in words"
- X @echo " xticktalk - a program to display the time in words"
- X @echo " testtalk - program to test ticktalk"
- X @echo ""
- X @echo " Printing source use (prints to $(PRINTER)):"
- X @echo " print-ticktalk - print the source to ticktalk"
- X @echo " print-xticktalk - print the source to xticktalk"
- X @echo " print-testtalk - print the source to testtalk"
- X
- X#
- X# Individual programs
- X#
- X
- X$(TICKTALK): $(TICKTALK_O)
- X $(CC) -o $(TICKTALK) $(TICKTALK_O)
- X$(TICKTALK_O): $(TICKTALK_C)
- X $(CC) $(CFLAGS) -c -DTEXT $(TICKTALK_C)
- Xprint-ticktalk: always
- X lpscript -t4 -F Makefile $(TICKTALK_H) $(TICKTALK_C) | lpr -P$(PRINTER)
- X
- X$(XTICKTALK): $(XTICKTALK_O)
- X $(CC) -o $(XTICKTALK) $(XTICKTALK_O) $(XLIBRARYFLAGS) $(XLIBS)
- X$(XTICKTALK_O): $(TICKTALK_C)
- X $(CC) $(CFLAGS) -c $(XINCLUDEFLAGS) $(TICKTALK_C)
- X $(MV) $(TICKTALK_O) $(XTICKTALK_O)
- Xprint-xticktalk: always
- X lpscript -t4 -F Makefile $(XTICKTALK_H) $(XTICKTALK_C) | lpr -P$(PRINTER)
- X
- X$(TESTTALK): $(TESTTALK_O)
- X $(CC) -o $(TESTTALK) $(TESTTALK_O)
- X$(TESTTALK_O): $(TICKTALK_C)
- X $(CC) $(CFLAGS) -DTEST -c $(TICKTALK_C)
- X $(MV) $(TICKTALK_O) $(TESTTALK_O)
- Xprint-testtalk: always
- X lpscript -t4 -F Makefile $(TESTTALK_H) $(TESTTALK_C) | lpr -P$(PRINTER)
- X
- Xticktalk.sh: $(TICKTALK_C) README bundle Makefile xticktalk.xbm
- X bundle README Makefile $(TICKTALK_C) bundle xticktalk.xbm > ticktalk.sh
- X
- X#
- X# For every file
- X#
- X
- Xall: $(ALL)
- X
- Xdeps: always
- X $(CC) $(CFLAGS) -M $(ALL_C) > $(DEPENDFILE)
- X
- Xclean: always
- X rm -f $(ALL_O) $(DEPENDFILE) core *~ .*~
- X touch $(DEPENDFILE)
- X $(MAKE) deps
- X
- Xclobber: clean
- X rm -f $(ALL) ticktalk.sh
- X
- Xtags: always
- X etags -t $(ALL_H) $(ALL_C)
- X
- Xalways:
- X
- Xinclude $(DEPENDFILE)
- END_OF_FILE
- if test 3101 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'bundle' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bundle'\"
- else
- echo shar: Extracting \"'bundle'\" \(218 characters\)
- sed "s/^X//" >'bundle' <<'END_OF_FILE'
- X#!/bin/sh
- X# bundle: group files into distribution package
- X
- Xecho '#!/bin/sh'
- Xecho '# To unbundle, sh this file. E.g. % sh file'
- Xfor i do
- X echo "echo $i 1>&2"
- X echo "cat >$i <<'End of $i'"
- X cat $i
- X echo "End of $i"
- Xdone
- END_OF_FILE
- if test 218 -ne `wc -c <'bundle'`; then
- echo shar: \"'bundle'\" unpacked with wrong size!
- fi
- # end of 'bundle'
- fi
- if test -f 'ticktalk.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ticktalk.c'\"
- else
- echo shar: Extracting \"'ticktalk.c'\" \(19104 characters\)
- sed "s/^X//" >'ticktalk.c' <<'END_OF_FILE'
- X/*
- X ticktalk
- X
- X A clock that displays time in various languages
- X
- X History -
- X
- X 01/20/92: Art Mellor
- X Released Version 1.0
- X 01/20/92: Kaveh Kardan
- X Added before mode for french and fixed some typos
- X 01/07/91: Kaveh Kardan
- X Added approximate mode to french and made some corrections.
- X 01/02/91: Alan Steele (neptune@fenchurch.mit.edu)
- X Added code to imbed icon in application
- X 12/31/91: Art Mellor
- X Added -noampm flag at request of Dave Baker (dvb@inmet.inmet.com)
- X 12/31/91: Linda Matthew (linder@watson.ibm.com), Art Mellor
- X Added Afrikaans (Linda language, Art coding) v0.4
- X 12/27/91: Art Mellor
- X Added TEXT,TEST mode
- X Added -update,-before,-approximate,-help flags
- X 12/26/91: Art Mellor
- X Changed French to runtime option
- X 11/29/91: Kaveh Kardan (kaveh%taarna%icule@larry.mcrcim.mcgill.edu)
- X Added French version as compile time option
- X 5/6/91: Art Mellor (art@cayman.com)
- X Initial version
- X*/
- X
- X/*
- X There are 3 types of compiles:
- X
- X For X windows - has no defines of TEST or TEXT
- X For testing - has TEST and TEXT defined
- X For text output - has TEXT defined
- X*/
- X
- X#ifdef TEST
- X# define TEXT
- X#endif TEST
- X
- X#include <stdio.h>
- X#include <time.h>
- X#include <ctype.h>
- X
- X#ifndef TEXT
- X# include <X11/Intrinsic.h>
- X# include <X11/StringDefs.h>
- X# include <X11/Shell.h>
- X# include <X11/Xaw/Label.h>
- X# include "xticktalk.xbm"
- X#else
- X# define FALSE 0
- X# define TRUE (!FALSE)
- X#endif !TEXT
- X
- X#define MAX_TIMESTRING 256 /* size of strings */
- X#define MAXARGS 10 /* for X widgets */
- X
- X/* These are all the languages defined */
- X#define ENGLISH 0
- X#define FRENCH 1
- X#define AFRIKAANS 2
- X
- Xint timeOut = 30; /* how often to update X clock display */
- Xint language = -1; /* language chosen by user */
- Xint before = FALSE; /* use "before" syntax when min > 30 */
- Xint approximate = FALSE; /* round to nearest 5 minutes */
- Xint noampm = FALSE; /* don't put am/pm on the end */
- X#ifdef TEXT
- Xint hour = -1, minute = -1; /* optional args for TEXT/TEST modes */
- X#endif TEXT
- X
- Xchar *programName; /* store argv[0] here for error messages */
- X#define VERSION_MAJOR 1 /* version numbers */
- X#define VERSION_MINOR 0
- Xchar versionString[MAX_TIMESTRING];
- X
- X/*
- X Call this routine to help unclued users
- X*/
- Xvoid Usage()
- X{
- X static char *usageStrings[] = {
- X " [-help] [-version] [-before] [-<language>] [-approximate] \\\n",
- X " [-noampm] ",
- X#ifdef TEXT
- X "[hour(0-23) min(0-59)]\n",
- X#else
- X "[-update secs] [X Options]\n",
- X#endif TEXT
- X " where <language> is one of the following:\n",
- X " english | french | afrikaans\n",
- X (char *)0};
- X char **uPtr = usageStrings;
- X
- X fprintf(stderr,"usage: %s ", programName);
- X while(*uPtr){
- X fprintf(stderr, "%s", *uPtr);
- X uPtr++;
- X }
- X}
- X
- X/*
- X Call this routine to explain things in more detail
- X*/
- Xvoid PrintHelp()
- X{
- X static char *helpStrings[] = {
- X "Options:\n",
- X "-help Print this text\n",
- X "-version Print the current version and exit\n",
- X "-before Print time after the half hour as relative to next hour\n",
- X " (not appropriate for some languages)\n",
- X "-approximate Round time off to nearest 5 minutes\n",
- X "-<language> The language to print the time in\n",
- X "-noampm Don't put am/pm on the time string (if present otherwise)\n",
- X#ifdef TEXT
- X "hour min Print the time corresponding to hour:min\n",
- X#ifdef TEST
- X "With no arguments all time values are printed to stdout for verification\n",
- X#else
- X "With no arguments prints the current time to stdout\n",
- X#endif TEST
- X#else
- X "-update secs How frequently to update the display\n",
- X "X Options Standard X windows options\n",
- X#endif TEXT
- X (char *)0};
- X char **hPtr = helpStrings;
- X
- X Usage();
- X while(*hPtr){
- X fprintf(stderr, " %s", *hPtr);
- X hPtr++;
- X }
- X}
- X
- X/*
- X Handle the args to the function
- X*/
- Xvoid ProcessArgs(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X programName = argv[0];
- X sprintf(versionString,"%s v%d.%d",programName,VERSION_MAJOR,VERSION_MINOR);
- X
- X argv++;
- X while(--argc){
- X if(**argv != '-'){
- X break;
- X }
- X if(strcmp("-english", *argv) == 0){
- X if(language != -1){
- X Usage();
- X exit(-1);
- X }
- X language = ENGLISH;
- X }
- X else if(strcmp("-french", *argv) == 0){
- X if(language != -1){
- X Usage();
- X exit(-1);
- X }
- X language = FRENCH;
- X }
- X else if(strcmp("-afrikaans", *argv) == 0){
- X if(language != -1){
- X Usage();
- X exit(-1);
- X }
- X language = AFRIKAANS;
- X }
- X else if(strcmp("-version", *argv) == 0){
- X printf("%s (bugs/enhancements to art@cayman.com)\n", versionString);
- X exit(0);
- X }
- X else if(strcmp("-before", *argv) == 0){
- X before = TRUE;
- X }
- X else if(strcmp("-help", *argv) == 0){
- X PrintHelp();
- X exit(0);
- X }
- X else if(strcmp("-approximate", *argv) == 0){
- X approximate = TRUE;
- X }
- X else if(strcmp("-noampm", *argv) == 0){
- X noampm = TRUE;
- X }
- X#ifndef TEXT
- X else if(strcmp("-update", *argv) == 0){
- X --argc; argv++;
- X if(!argc || !IsNumber(*argv) || ((timeOut = atoi(*argv)) <= 0)){
- X Usage();
- X exit(-1);
- X }
- X }
- X#endif !TEXT
- X else{
- X Usage();
- X exit(-1);
- X }
- X argv++;
- X }
- X
- X /* Default to English */
- X if(language == -1){
- X language = ENGLISH;
- X }
- X
- X if(argc == 0){
- X return;
- X }
- X#ifdef TEXT
- X else if(argc == 2){
- X if(IsNumber(argv[0]) && IsNumber(argv[1])){
- X hour = atoi(argv[0]);
- X minute = atoi(argv[1]);
- X if((hour < 24) && (minute < 60)){
- X return;
- X }
- X }
- X }
- X#endif TEXT
- X
- X Usage();
- X exit(-1);
- X}
- X
- X#ifndef TEXT
- X/*
- X Stuff timeString into the widget label
- X*/
- XSetLabelString(label, timeString)
- XWidget label;
- Xchar *timeString;
- X{
- X Arg args[MAXARGS];
- X int nargs;
- X
- X nargs = 0;
- X XtSetArg(args[nargs],XtNlabel,timeString); nargs++;
- X XtSetValues(label, args, nargs);
- X}
- X
- X/*
- X Callback to set the time string every so often
- X*/
- XXtTimerCallbackProc CheckTime(label, ignored)
- XWidget label;
- XXtIntervalId *ignored;
- X{
- X char timeString[MAX_TIMESTRING];
- X
- X GetTimeString(language, timeString);
- X SetLabelString(label, timeString);
- X XtAddTimeOut(timeOut * 1000, CheckTime, (caddr_t)label);
- X}
- X
- Xvoid CreateIcon(shell)
- XWidget shell;
- X{
- X Pixmap icon_pixmap = (Pixmap) 0;
- X Arg arg;
- X
- X /* User sets iconPixmap resource, converter does the right thing.. */
- X XtSetArg(arg, XtNiconPixmap, &icon_pixmap);
- X XtGetValues(shell, &arg, 1);
- X if (icon_pixmap == (Pixmap) 0) {
- X XtSetArg(arg, XtNiconPixmap,
- X XCreateBitmapFromData(
- X XtDisplay(shell), XtScreen(shell)->root,
- X xticktalk_bits, xticktalk_width, xticktalk_height));
- X XtSetValues(shell, &arg, 1);
- X }
- X}
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X Widget shell, label;
- X Arg args[MAXARGS];
- X int nargs, i;
- X
- X /* Create shell and process X options */
- X shell = XtInitialize(argv[0], versionString,
- X NULL, 0, &argc, argv);
- X nargs = 0;
- X XtSetArg(args[nargs],XtNallowShellResize,True); nargs++;
- X XtSetValues(shell,args,nargs);
- X
- X /* Process remaining args */
- X ProcessArgs(argc, argv);
- X
- X /* Create icon */
- X CreateIcon(shell);
- X
- X /* Make the label */
- X nargs = 0;
- X label = XtCreateManagedWidget("label", labelWidgetClass, shell,
- X args, nargs);
- X
- X /* Set the timer going */
- X CheckTime((caddr_t)label, (XtIntervalId *)NULL);
- X
- X /* Put 'em up */
- X XtRealizeWidget(shell);
- X XtMainLoop();
- X}
- X#else
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X int h, m, len, longest = 0;
- X char timeString[MAX_TIMESTRING], longTime[MAX_TIMESTRING];
- X
- X /* Process args */
- X ProcessArgs(argc, argv);
- X
- X if(hour != -1){
- X Time2Word(language, hour, minute, timeString);
- X printf("%s\n", timeString);
- X exit(0);
- X }
- X#ifdef TEST
- X for(h = 0, m = 0; !((h == 23) && (m == 59));){
- X Time2Word(language, h, m, timeString);
- X printf("%s\n", timeString);
- X if((len = strlen(timeString)) > longest){
- X strcpy(longTime, timeString);
- X longest = len;
- X }
- X m = (m + 1)%60;
- X if(m == 0){
- X h++;
- X }
- X }
- X printf("Longest: %s @ %d characters\n", longTime, longest);
- X#else
- X GetTimeString(language, timeString);
- X printf("%s\n", timeString);
- X#endif TEST
- X exit(0);
- X}
- X
- X#endif !TEXT
- X
- X/*
- X Increment the hour (based on 12 hour clock with am/pm flag)
- X AM/PM changes at the 11/12 border
- X*/
- Xvoid TimeIncrement(hPtr, pmPtr)
- Xint *hPtr, *pmPtr;
- X{
- X if(*hPtr == 11){
- X *pmPtr = !*pmPtr;
- X }
- X *hPtr = *hPtr%12 + 1;
- X}
- X
- X/*
- X Is this string all digits?
- X*/
- XIsNumber(str)
- Xchar *str;
- X{
- X char *ptr = str;
- X
- X while(*ptr && isdigit(*ptr)) ptr++;
- X return(*ptr == '\0');
- X}
- X
- X/*
- X Stuff the current time in as a string in specified language
- X*/
- XGetTimeString(tongue, string)
- Xint tongue;
- Xchar *string;
- X{
- X long t;
- X struct tm *timeVal;
- X
- X t = time(0);
- X timeVal = localtime(&t);
- X Time2Word(tongue, timeVal->tm_hour, timeVal->tm_min, string);
- X}
- X
- X/*
- X Convert the specified time into a string in the specified language
- X*/
- XTime2Word(tongue, hour, minutes, word)
- Xint tongue, hour, minutes;
- Xchar *word;
- X{
- X switch(tongue){
- X case ENGLISH:
- X return Time2WordEnglish(hour, minutes, word);
- X case FRENCH:
- X return Time2WordFrench(hour, minutes, word);
- X case AFRIKAANS:
- X return Time2WordAfrikaans(hour, minutes, word);
- X default:
- X fprintf(stderr, "Unknown language: %d\n", tongue);
- X Usage();
- X exit(-1);
- X }
- X}
- X
- X/*****************************************************************************
- X English Time Routines
- X *****************************************************************************/
- X
- X/*
- X Converts a number from 0 to 59 into an english string equivalent
- X*/
- XNumber2WordEnglish(number, word)
- Xint number;
- Xchar *word;
- X{
- X static char *underTwenty[] = {
- X "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven",
- X "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen",
- X "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"
- X };
- X static char *overNineteen[] = {
- X "", "Teen", "Twenty", "Thirty", "Forty", "Fifty"
- X };
- X int guzzinto, remainder;
- X
- X *word = '\0';
- X
- X if ((number < 0) || (number > 59)){
- X return FALSE;
- X }
- X
- X if (number < 20){
- X strcat(word, underTwenty[number]);
- X return TRUE;
- X }
- X
- X guzzinto = number/10;
- X remainder = number%10;
- X
- X strcat(word, overNineteen[guzzinto]);
- X
- X if(remainder != 0){
- X strcat(word, "-");
- X strcat(word, underTwenty[remainder]);
- X }
- X
- X return TRUE;
- X}
- X
- X/*
- X Turns 24 hour time (with minutes) into english representation
- X*/
- XTime2WordEnglish(hour, minutes, word)
- Xint hour, minutes;
- Xchar *word;
- X{
- X int pm, rounded = 0;
- X char hourWord[MAX_TIMESTRING], minuteWord[MAX_TIMESTRING];
- X
- X *word = '\0';
- X
- X pm = (hour > 11);
- X
- X if (pm) {
- X hour -= 12;
- X }
- X if (hour == 0){
- X hour = 12;
- X }
- X
- X /* Round to nearest 5 minutes */
- X if(approximate){
- X if((rounded = minutes%5) >= 3){
- X minutes += (5 - rounded);
- X /* If round to next hour, handle correctly */
- X if(minutes == 60){
- X minutes = 0;
- X TimeIncrement(&hour, &pm);
- X }
- X }
- X else if(rounded > 0){
- X minutes -= rounded;
- X }
- X
- X strcat(word, rounded?"About ":"");
- X }
- X
- X Number2WordEnglish(hour, hourWord);
- X Number2WordEnglish(minutes, minuteWord);
- X
- X /*
- X Try to do some cute things with the time
- X */
- X if(minutes == 0){
- X if(hour == 12){
- X strcat(word, pm?"Noon":"Midnight");
- X return TRUE;
- X }
- X else{
- X strcat(word, hourWord);
- X strcat(word, " O'Clock");
- X }
- X }
- X else if((minutes >= 1) && (minutes <= 9)){
- X strcat(word, minuteWord);
- X strcat(word, " Past ");
- X strcat(word, hourWord);
- X }
- X else if(minutes == 15){
- X strcat(word, "Quarter Past ");
- X strcat(word, hourWord);
- X }
- X else if(minutes == 30){
- X strcat(word, "Half Past ");
- X strcat(word, hourWord);
- X }
- X else if(minutes == 45){
- X strcat(word, "Quarter To ");
- X TimeIncrement(&hour, &pm);
- X Number2WordEnglish(hour, hourWord);
- X strcat(word, hourWord);
- X }
- X else if((minutes > 30) && before){
- X TimeIncrement(&hour, &pm);
- X minutes = 60 - minutes;
- X Number2WordEnglish(hour, hourWord);
- X Number2WordEnglish(minutes, minuteWord);
- X strcat(word, minuteWord);
- X strcat(word, " To ");
- X strcat(word, hourWord);
- X }
- X else{
- X strcat(word, hourWord);
- X strcat(word, " ");
- X strcat(word, minuteWord);
- X }
- X
- X if(!noampm){
- X strcat(word, pm?" pm":" am");
- X }
- X
- X return TRUE;
- X}
- X
- X/*****************************************************************************
- X French Time Routines
- X*****************************************************************************/
- X
- XNumber2WordFrench(number, word)
- Xint number;
- Xchar *word;
- X{
- X static char *underTwenty[] = {
- X "Zero", "Un", "Deux", "Trois", "Quatre", "Cinq", "Six", "Sept",
- X "Huit", "Neuf", "Dix", "Onze", "Douze", "Treize", "Quatorze",
- X "Quinze", "Seize", "Dix-Sept", "Dix-Huit", "Dix-Neuf"
- X };
- X static char *overNineteen[] = {
- X "", "", "Vingt", "Trente", "Quarante", "Cinquante"
- X };
- X int guzzinto, remainder;
- X
- X *word = '\0';
- X
- X if ((number < 0) || (number > 59)){
- X return FALSE;
- X }
- X
- X if (number < 20){
- X strcat(word, underTwenty[number]);
- X return TRUE;
- X }
- X
- X guzzinto = number/10;
- X remainder = number%10;
- X
- X strcpy(word, overNineteen[guzzinto]);
- X
- X if(remainder != 0){
- X if (remainder == 1)
- X {
- X strcat(word, "-et-");
- X }
- X else
- X {
- X strcat(word, "-");
- X }
- X strcat(word, underTwenty[remainder]);
- X }
- X
- X return TRUE;
- X}
- X
- X/*
- X Turns 24 hour time (with minutes) into French representation
- X*/
- XTime2WordFrench(hour, minutes, word)
- Xint hour, minutes;
- Xchar *word;
- X{
- X int pm, rounded = 0;
- X char hourWord[MAX_TIMESTRING], minuteWord[MAX_TIMESTRING];
- X
- X /* leave hour in 24 hour format; it's the FRENCH way! */
- X
- X *word = '\0';
- X
- X if(approximate){
- X if((rounded = minutes%5) >= 3){
- X minutes += (5 - rounded);
- X if(minutes == 60){
- X minutes = 0;
- X hour = (hour+1)%24;
- X }
- X }
- X else if(rounded > 0){
- X minutes -= rounded;
- X }
- X
- X strcat(word, rounded?"Environ ":"");
- X }
- X
- X if (hour == 0){
- X strcpy(hourWord, "Minuit ");
- X }
- X else if (hour == 12){
- X strcpy(hourWord, "Midi ");
- X }
- X else{
- X Number2WordFrench(hour, hourWord);
- X }
- X if (!strcmp(hourWord, "Un")){
- X strcpy(hourWord, "Une");
- X }
- X if (!strcmp(hourWord, "Vingt-et-Un")){
- X strcpy(hourWord, "Vingt-et-Une");
- X }
- X Number2WordFrench(minutes, minuteWord);
- X
- X /*
- X Try to do some cute things with the time
- X */
- X if(minutes == 0){
- X if(hour == 12){
- X strcat(word, "Midi");
- X }
- X else{
- X strcat(word, hourWord);
- X if (!strcmp(hourWord, "Une")){
- X strcat(word, " Heure");
- X }
- X else if (strcmp(hourWord, "Midi ") &&
- X strcmp(hourWord, "Minuit ")){
- X strcat(word, " Heures");
- X }
- X }
- X }
- X else if(minutes == 15){
- X strcat(word, hourWord);
- X if (!strcmp(hourWord, "Une")){
- X strcat(word, " Heure Et Quart");
- X }
- X else if (!strcmp(hourWord, "Midi ") || !strcmp(hourWord, "Minuit ")){
- X strcat(word, "Et Quart");
- X }
- X else{
- X strcat(word, " Heures Et Quart");
- X }
- X }
- X else if(minutes == 30){
- X strcat(word, hourWord);
- X if (!strcmp(hourWord, "Une")){
- X strcat(word, " Heure Et Demi");
- X }
- X else if (!strcmp(hourWord, "Midi ") || !strcmp(hourWord, "Minuit ")){
- X strcat(word, "Et Demi");
- X }
- X else{
- X strcat(word, " Heures Et Demi");
- X }
- X }
- X else if(minutes == 45){
- X hour++;
- X hour = hour%24;
- X if (hour == 0){
- X strcat(word, "Minuit Moins Le Quart");
- X }
- X else if (hour == 1){
- X strcat(word, "Une Heure Moins Le Quart");
- X }
- X else if (hour == 12){
- X strcat(word, "Midi Moins Le Quart");
- X }
- X else{
- X Number2WordFrench(hour, hourWord);
- X strcat(word, hourWord);
- X strcat(word, " Heures Moins Le Quart");
- X }
- X }
- X else if((minutes > 30) && before){
- X hour++;
- X hour = hour%24;
- X minutes = 60 - minutes;
- X
- X if (hour == 0){
- X strcpy(hourWord, "Minuit ");
- X }
- X else if (hour == 12){
- X strcpy(hourWord, "Midi ");
- X }
- X else{
- X Number2WordFrench(hour, hourWord);
- X }
- X if (!strcmp(hourWord, "Un")){
- X strcpy(hourWord, "Une");
- X }
- X if (!strcmp(hourWord, "Vingt-et-Un")){
- X strcpy(hourWord, "Vingt-et-Une");
- X }
- X Number2WordFrench(minutes, minuteWord);
- X
- X strcat(word, hourWord);
- X
- X if (!strcmp(hourWord, "Une")){
- X strcat(word, " Heure");
- X }
- X else if (strcmp(hourWord, "Midi ") &&
- X strcmp(hourWord, "Minuit ")){
- X strcat(word, " Heures");
- X }
- X
- X if (strcmp(hourWord, "Midi ") &&
- X strcmp(hourWord, "Minuit "))
- X strcat(word, " Moins ");
- X else
- X strcat(word, "Moins ");
- X
- X strcat(word, minuteWord);
- X }
- X else{
- X strcat(word, hourWord);
- X if (!strcmp(hourWord, "Une")){
- X strcat(word, " Heure ");
- X }
- X else if (strcmp(hourWord, "Midi ") &&
- X strcmp(hourWord, "Minuit ")){
- X strcat(word, " Heures ");
- X }
- X strcat(word, minuteWord);
- X }
- X
- X return TRUE;
- X}
- X
- X/*****************************************************************************
- X Afrikaans Time Routines
- X *****************************************************************************/
- X
- X/*
- X Converts a number from 0 to 59 into an afrikaans string equivalent
- X*/
- XNumber2WordAfrikaans(number, word)
- Xint number;
- Xchar *word;
- X{
- X static char *underTwenty[] = {
- X "Nul", "Een", "Twee", "Drie", "Vier", "Vyf", "Ses", "Sewe",
- X "Agt", "Nege", "Tien", "Elf", "Twaalf", "Dertien", "Veertien",
- X "Vyftien", "Sestien", "Sewentien", "Agtien", "Neentien"
- X };
- X static char *overNineteen[] = {
- X "", "Tien", "Twintig", "Dertig", "Veertig", "Vyftig"
- X };
- X int guzzinto, remainder;
- X
- X *word = '\0';
- X
- X if ((number < 0) || (number > 59)){
- X return FALSE;
- X }
- X
- X if (number < 20){
- X strcat(word, underTwenty[number]);
- X return TRUE;
- X }
- X
- X guzzinto = number/10;
- X remainder = number%10;
- X
- X if(remainder != 0){
- X strcat(word, underTwenty[remainder]);
- X strcat(word, "-en-");
- X }
- X strcat(word, overNineteen[guzzinto]);
- X
- X return TRUE;
- X}
- X
- X/*
- X Turns 24 hour time (with minutes) into afrikaans representation
- X*/
- XTime2WordAfrikaans(hour, minutes, word)
- Xint hour, minutes;
- Xchar *word;
- X{
- X int pm, rounded = 0;
- X char hourWord[MAX_TIMESTRING], minuteWord[MAX_TIMESTRING];
- X
- X *word = '\0';
- X
- X pm = (hour > 11);
- X
- X if (pm) {
- X hour -= 12;
- X }
- X if (hour == 0){
- X hour = 12;
- X }
- X
- X if(approximate){
- X if((rounded = minutes%5) >= 3){
- X minutes += (5 - rounded);
- X if(minutes == 60){
- X minutes = 0;
- X TimeIncrement(&hour, &pm);
- X }
- X }
- X else if(rounded > 0){
- X minutes -= rounded;
- X }
- X
- X strcat(word, rounded?"Ongeveer ":"");
- X }
- X
- X Number2WordAfrikaans(hour, hourWord);
- X Number2WordAfrikaans(minutes, minuteWord);
- X
- X /*
- X Try to do some cute things with the time
- X */
- X if(minutes == 0){
- X if(hour == 12){
- X strcat(word, pm?"Middag":"Middernag");
- X return TRUE;
- X }
- X else{
- X strcat(word, hourWord);
- X strcat(word, " Uur");
- X }
- X }
- X else if((minutes >= 1) && (minutes <= 9)){
- X strcat(word, minuteWord);
- X strcat(word, " Minute Oor ");
- X strcat(word, hourWord);
- X }
- X else if(minutes == 15){
- X strcat(word, "Kwart Oor ");
- X strcat(word, hourWord);
- X }
- X else if(minutes == 30){
- X strcat(word, "Half ");
- X TimeIncrement(&hour, &pm);
- X Number2WordAfrikaans(hour, hourWord);
- X strcat(word, hourWord);
- X }
- X else if(minutes == 45){
- X strcat(word, "Kwart Voor ");
- X TimeIncrement(&hour, &pm);
- X Number2WordAfrikaans(hour, hourWord);
- X strcat(word, hourWord);
- X }
- X else if((minutes > 30) && before){
- X TimeIncrement(&hour, &pm);
- X minutes = 60 - minutes;
- X Number2WordAfrikaans(hour, hourWord);
- X Number2WordAfrikaans(minutes, minuteWord);
- X strcat(word, minuteWord);
- X if(minutes%5){
- X strcat(word, " Minute");
- X }
- X strcat(word, " Voor ");
- X strcat(word, hourWord);
- X }
- X else{
- X strcat(word, hourWord);
- X strcat(word, " ");
- X strcat(word, minuteWord);
- X }
- X if(!noampm){
- X strcat(word, pm?" nm":" vm");
- X }
- X
- X return TRUE;
- X}
- X
- END_OF_FILE
- if test 19104 -ne `wc -c <'ticktalk.c'`; then
- echo shar: \"'ticktalk.c'\" unpacked with wrong size!
- fi
- # end of 'ticktalk.c'
- fi
- if test -f 'xticktalk.xbm' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'xticktalk.xbm'\"
- else
- echo shar: Extracting \"'xticktalk.xbm'\" \(3290 characters\)
- sed "s/^X//" >'xticktalk.xbm' <<'END_OF_FILE'
- X#define xticktalk_width 64
- X#define xticktalk_height 64
- Xstatic char xticktalk_bits[] = {
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0xc3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x03,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x20, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xff, 0x08,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xff, 0x23,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0xf8, 0x03,
- X 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x90, 0xff, 0x23,
- X 0x00, 0x00, 0xe0, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0xe0, 0x00,
- X 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x98, 0xff, 0x21,
- X 0x00, 0x80, 0xff, 0x3f, 0x00, 0x1c, 0x00, 0x20, 0x00, 0xf0, 0x07, 0xfc,
- X 0x01, 0x06, 0x00, 0x10, 0x00, 0xf8, 0x00, 0xe0, 0x03, 0x03, 0x00, 0x10,
- X 0x00, 0x1e, 0x00, 0x00, 0x0f, 0x03, 0x00, 0x0c, 0x00, 0x0f, 0xc0, 0x00,
- X 0x9e, 0x7f, 0xc0, 0x07, 0x80, 0x03, 0xc0, 0x00, 0x38, 0xc0, 0x7f, 0x00,
- X 0xc0, 0x01, 0xc0, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xc0, 0x00,
- X 0xe0, 0x00, 0x00, 0x00, 0x60, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0x00, 0x00,
- X 0x70, 0x00, 0xc0, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x38, 0x00, 0xc0, 0x00,
- X 0x80, 0x03, 0x00, 0x00, 0x18, 0x00, 0xc0, 0x00, 0x00, 0x03, 0x00, 0x00,
- X 0x18, 0x00, 0xc0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x1c, 0x00, 0xc0, 0x00,
- X 0x00, 0x07, 0x00, 0x00, 0x0c, 0x00, 0xc0, 0x40, 0x00, 0x06, 0x00, 0x00,
- X 0x0c, 0x00, 0xc0, 0x60, 0x00, 0x06, 0x00, 0x00, 0x0e, 0x00, 0xc0, 0x30,
- X 0x00, 0x0e, 0x00, 0x00, 0x06, 0x00, 0xc0, 0x18, 0x00, 0x0c, 0x00, 0x00,
- X 0x06, 0x00, 0xc0, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x06, 0x00, 0xc0, 0x06,
- X 0x00, 0x0c, 0x00, 0x00, 0x06, 0x00, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00,
- X 0x06, 0x00, 0xc0, 0x01, 0x00, 0x0c, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- X 0x00, 0x0c, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
- X 0x0e, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
- X 0x00, 0x06, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
- X 0x1c, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
- X 0x00, 0x03, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
- X 0x38, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
- X 0xc0, 0x01, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00,
- X 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00,
- X 0x70, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
- X 0x00, 0x0f, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
- X 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00,
- X 0x00, 0xf0, 0x07, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x3f,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- END_OF_FILE
- if test 3290 -ne `wc -c <'xticktalk.xbm'`; then
- echo shar: \"'xticktalk.xbm'\" unpacked with wrong size!
- fi
- # end of 'xticktalk.xbm'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- 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...
-