Index: pom.6
===================================================================
--- pom.6 (nonexistent)
+++ pom.6 (revision 5)
@@ -0,0 +1,82 @@
+.\" $NetBSD: pom.6,v 1.12 2003/08/07 09:37:32 agc Exp $
+.\"
+.\" Copyright (c) 1989, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)pom.6 8.1 (Berkeley) 5/31/93
+.\"
+.Dd September 8, 2006
+.Dt POM 6
+.Os
+.Sh NAME
+.Nm pom
+.Nd display the phase of the moon
+.Sh SYNOPSIS
+.Nm
+.Op Fl d Ar num
+.Op Ar [[[[cc]yy]mm]dd]HH
+.Sh DESCRIPTION
+The
+.Nm
+utility displays the current phase of the moon.
+Useful for selecting software completion target dates and predicting
+managerial behavior.
+.Pp
+.Bl -tag -width [-d num]
+.It Ar [-d num]
+Display the percentage with
+.Ar num
+decimals (within reasonable limits).
+The default is to display an integer percentage.
+.El
+.Bl -tag -width [[[[[cc]yy]mm]dd]HH]
+.It Ar [[[[[cc]yy]mm]dd]HH]
+Display the phase of the moon for a given time.
+The format is similar to the canonical representation used by
+.Xr date 1 .
+.El
+.Sh SEE ALSO
+.Xr date 1
+.Sh AUTHOR
+.Nm
+was written by
+.An Keith E. Brandt .
+.Sh BUGS
+Times must be within range of the
+.Ux
+epoch.
+.Pp
+This program does not allow for the difference between the TDT and
+UTC timescales (about one minute at the time of writing).
+.Sh NOTES
+.Nm
+recognizes 3321 as being within reasonable limits.
+.Sh ACKNOWLEDGEMENTS
+This program is based on algorithms from
+.%B Practical Astronomy with Your Calculator, Third Edition
+by Peter Duffett-Smith
+.Aq pjds@mrao.cam.ac.uk .
Index: pom.c
===================================================================
--- pom.c (nonexistent)
+++ pom.c (revision 5)
@@ -0,0 +1,313 @@
+/* $NetBSD: pom.c,v 1.14 2004/01/27 20:30:30 jsm Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software posted to USENET.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
+#endif /* not lint */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)pom.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: pom.c,v 1.14 2004/01/27 20:30:30 jsm Exp $");
+#endif
+#endif /* not lint */
+
+/*
+ * Phase of the Moon. Calculates the current phase of the moon.
+ * Based on routines from `Practical Astronomy with Your Calculator',
+ * by Duffett-Smith. Comments give the section from the book that
+ * particular piece of code was adapted from.
+ *
+ * -- Keith E. Brandt VIII 1984
+ *
+ * Updated to the Third Edition of Duffett-Smith's book, Paul Janzen, IX 1998
+ *
+ * Modified for Slackware by Eric Hameleers <alien@slackware.com> 09-09-2006
+ *
+ */
+
+#include <ctype.h>
+#include <err.h>
+#include <math.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+#ifndef PI
+#define PI 3.14159265358979323846
+#endif
+
+/*
+ * The EPOCH in the third edition of the book is 1990 Jan 0.0 TDT.
+ * In this program, we do not bother to correct for the differences
+ * between UTC (as shown by the UNIX clock) and TDT. (TDT = TAI + 32.184s;
+ * TAI-UTC = 32s in Jan 1999.)
+ */
+#define EPOCH_MINUS_1970 (20 * 365 + 5 - 1) /* 20 years, 5 leaps, back 1 day to Jan 0 */
+#define EPSILONg 279.403303 /* solar ecliptic long at EPOCH */
+#define RHOg 282.768422 /* solar ecliptic long of perigee at EPOCH */
+#define ECCEN 0.016713 /* solar orbit eccentricity */
+#define lzero 318.351648 /* lunar mean long at EPOCH */
+#define Pzero 36.340410 /* lunar mean long of perigee at EPOCH */
+#define Nzero 318.510107 /* lunar mean long of node at EPOCH */
+
+void adj360(double *);
+double dtor(double);
+int main(int, char *[]);
+double potm(double);
+time_t parsetime(char *);
+void badformat(void) __attribute__((__noreturn__));
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ time_t tmpt, now;
+ double days, today, tomorrow, accuracy;
+ char buf[1024];
+ int ch, decimals=0;
+
+ /* Revoke setgid privileges */
+ setregid(getgid(), getgid());
+
+ while ((ch = getopt(argc, argv, "d:h?")) != -1)
+ switch (ch) {
+ case 'd':
+ decimals = atoi(optarg);
+ if (decimals < 0 || (decimals != 3321 && decimals > __DBL_DIG__))
+ errx(1, "illegal argument for -d option");
+ break;
+ case 'h':
+ case '?':
+ (void)fprintf(stderr, "usage: pom [-d digits] [[[[[cc]yy]mm]dd]HH]\n");
+ exit(1);
+ default:
+ break;
+ }
+ argc -= optind;
+ argv += optind;
+
+ accuracy = ( decimals == 3321 ? 0.5: 0.5 / pow(10, decimals) );
+
+ if (time(&now) == (time_t)-1)
+ err(1, "time");
+ if (argc > 0) {
+ tmpt = parsetime(argv[0]);
+ strftime(buf, sizeof(buf), "%a %Y %b %e %H:%M:%S (%Z)",
+ localtime(&tmpt));
+ printf("%s: ", buf);
+ } else {
+ tmpt = now;
+ }
+ days = (tmpt - EPOCH_MINUS_1970 * 86400) / 86400.0;
+ today = potm(days) + accuracy;
+ if (tmpt < now)
+ (void)printf("The Moon was ");
+ else if (tmpt == now)
+ (void)printf("The Moon is ");
+ else
+ (void)printf("The Moon will be ");
+ if ((int)today == 100) {
+ (void)printf("Full\n");
+ if (decimals == 3321)
+ /* (void)printf("Howl!!! Know me, I am PJV.\n"); */
+ /* PJV's number is not 3321, and shan't be revealed here */
+ (void)printf("I saw the best minds of my generation destroyed by\n");
+ }
+ else if (!(int)today)
+ (void)printf("New\n");
+ else {
+ tomorrow = potm(days + 1);
+ if ((int)today == 50)
+ (void)printf("%s\n", tomorrow > today ?
+ "at the First Quarter" : "at the Last Quarter");
+ /* today is "accuracy" too big, but it doesn't matter
+ * here since the phase is changing fast enough
+ */
+ else {
+ today -= accuracy; /* Now it might matter */
+ (void)printf("%s ", tomorrow > today ?
+ "Waxing" : "Waning");
+ if (today > 50)
+ (void)printf("Gibbous (%1.*f%% of Full)\n",
+ decimals, today);
+ else if (today < 50)
+ (void)printf("Crescent (%1.*f%% of Full)\n",
+ decimals, today);
+ }
+ }
+ exit(0);
+}
+
+/*
+ * potm --
+ * return phase of the moon
+ */
+double
+potm(days)
+ double days;
+{
+ double N, Msol, Ec, LambdaSol, l, Mm, Ev, Ac, A3, Mmprime;
+ double A4, lprime, V, ldprime, D, Nm;
+
+ N = 360 * days / 365.242191; /* sec 46 #3 */
+ adj360(&N);
+ Msol = N + EPSILONg - RHOg; /* sec 46 #4 */
+ adj360(&Msol);
+ Ec = 360 / PI * ECCEN * sin(dtor(Msol)); /* sec 46 #5 */
+ LambdaSol = N + Ec + EPSILONg; /* sec 46 #6 */
+ adj360(&LambdaSol);
+ l = 13.1763966 * days + lzero; /* sec 65 #4 */
+ adj360(&l);
+ Mm = l - (0.1114041 * days) - Pzero; /* sec 65 #5 */
+ adj360(&Mm);
+ Nm = Nzero - (0.0529539 * days); /* sec 65 #6 */
+ adj360(&Nm);
+ Ev = 1.2739 * sin(dtor(2*(l - LambdaSol) - Mm)); /* sec 65 #7 */
+ Ac = 0.1858 * sin(dtor(Msol)); /* sec 65 #8 */
+ A3 = 0.37 * sin(dtor(Msol));
+ Mmprime = Mm + Ev - Ac - A3; /* sec 65 #9 */
+ Ec = 6.2886 * sin(dtor(Mmprime)); /* sec 65 #10 */
+ A4 = 0.214 * sin(dtor(2 * Mmprime)); /* sec 65 #11 */
+ lprime = l + Ev + Ec - Ac + A4; /* sec 65 #12 */
+ V = 0.6583 * sin(dtor(2 * (lprime - LambdaSol))); /* sec 65 #13 */
+ ldprime = lprime + V; /* sec 65 #14 */
+ D = ldprime - LambdaSol; /* sec 67 #2 */
+ return(50.0 * (1 - cos(dtor(D)))); /* sec 67 #3 */
+}
+
+/*
+ * dtor --
+ * convert degrees to radians
+ */
+double
+dtor(deg)
+ double deg;
+{
+ return(deg * PI / 180);
+}
+
+/*
+ * adj360 --
+ * adjust value so 0 <= deg <= 360
+ */
+void
+adj360(deg)
+ double *deg;
+{
+ for (;;)
+ if (*deg < 0)
+ *deg += 360;
+ else if (*deg > 360)
+ *deg -= 360;
+ else
+ break;
+}
+
+#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
+time_t
+parsetime(p)
+ char *p;
+{
+ struct tm *lt;
+ int bigyear;
+ int yearset = 0;
+ time_t tval;
+ unsigned char *t;
+
+ for (t = (unsigned char *)p; *t; ++t) {
+ if (isdigit(*t))
+ continue;
+ badformat();
+ }
+
+ tval = time(NULL);
+ lt = localtime(&tval);
+ lt->tm_sec = 0;
+ lt->tm_min = 0;
+
+ switch (strlen(p)) {
+ case 10: /* yyyy */
+ bigyear = ATOI2(p);
+ lt->tm_year = bigyear * 100 - 1900;
+ yearset = 1;
+ /* FALLTHROUGH */
+ case 8: /* yy */
+ if (yearset) {
+ lt->tm_year += ATOI2(p);
+ } else {
+ lt->tm_year = ATOI2(p);
+ if (lt->tm_year < 69) /* hack for 2000 */
+ lt->tm_year += 100;
+ }
+ /* FALLTHROUGH */
+ case 6: /* mm */
+ lt->tm_mon = ATOI2(p);
+ if ((lt->tm_mon > 12) || !lt->tm_mon)
+ badformat();
+ --lt->tm_mon; /* time struct is 0 - 11 */
+ /* FALLTHROUGH */
+ case 4: /* dd */
+ lt->tm_mday = ATOI2(p);
+ if ((lt->tm_mday > 31) || !lt->tm_mday)
+ badformat();
+ /* FALLTHROUGH */
+ case 2: /* HH */
+ lt->tm_hour = ATOI2(p);
+ if (lt->tm_hour > 23)
+ badformat();
+ break;
+ default:
+ badformat();
+ }
+ /* The calling code needs a valid tm_ydays and this is the easiest
+ * way to get one */
+ if ((tval = mktime(lt)) == -1)
+ errx(1, "specified date is outside allowed range");
+ return (tval);
+}
+
+void
+badformat()
+{
+ warnx("illegal time format");
+ (void)fprintf(stderr, "usage: pom [[[[[cc]yy]mm]dd]HH]\n");
+ exit(1);
+}
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 5)
Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~