Date: Wed, 16 Apr 2003 17:31:16 -0400 From: Matt Koivisto <MattK@SANDVINE.com> To: "'FreeBSD-gnats-submit@freebsd.org'" <FreeBSD-gnats-submit@FreeBSD.org> Subject: bin/51070: add -p option to pom [PATCH] Message-ID: <FE045D4D9F7AED4CBFF1B3B813C85337017CC19C@mail.sandvine.com> Resent-Message-ID: <200304162140.h3GLe6fi062442@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 51070 >Category: bin >Synopsis: add -p option to pom [PATCH] >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Apr 16 14:40:06 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Matt Koivisto >Release: FreeBSD 4.7-STABLE i386 >Organization: >Environment: >Description: No easy way to use pom from a shell script E.g. Now you can do if [ `pom -p` -gt 50 ] >How-To-Repeat: >Fix: --- /usr/src/games/pom/pom.c Mon Nov 29 22:49:09 1999 +++ ./pom.c Wed Apr 16 17:05:39 2003 @@ -54,12 +54,14 @@ * particular piece of code was adapted from. * * -- Keith E. Brandt VIII 1984 + * -- -p option added by Matt Koivisto 2003 (btw, I was 2 in 1984) * */ #include <time.h> #include <stdio.h> #include <math.h> +#include <unistd.h> #ifndef PI #define PI 3.14159265358979323846 @@ -76,15 +78,32 @@ static void adj360 __P((double *)); static double dtor __P((double)); static double potm __P((double)); +static int parseable = 0; int -main() +main(argc, argv) + int argc; + char *argv[]; { time_t tt; struct tm *GMT; double days, today, tomorrow; int cnt; + int ch; + while ((ch = getopt(argc, argv, "p")) != -1) + switch (ch) { + case 'p': + parseable = 1; + break; + case '?': + default: + (void)fprintf(stderr, "Usage: pom [-p]\n"); + (void)fprintf(stderr, "\tWhere the options are:\n"); + (void)fprintf(stderr, "\t-p : Return pom as a percentage\n"); + break; + } + (void) time(&tt); GMT = gmtime(&tt); days = (GMT->tm_yday + 1) + ((GMT->tm_hour + @@ -92,6 +111,10 @@ for (cnt = EPOCH; cnt < GMT->tm_year; ++cnt) days += isleap(1900 + cnt) ? 366 : 365; today = potm(days) + .5; + if ((int)parseable == 1) { + (void)printf("%1.0f\n", today); + return 0; + } (void)printf("The Moon is "); if ((int)today == 100) (void)printf("Full\n"); --- /usr/src/games/pom/pom.6 Sun Jul 22 07:32:37 2001 +++ pom.6 Wed Apr 16 17:22:24 2003 @@ -32,15 +32,24 @@ .\" @(#)pom.6 8.1 (Berkeley) 5/31/93 .\" $FreeBSD$ .\" -.TH POM 6 "May 31, 1993" -.UC 7 -.SH NAME -pom \- display the phase of the moon -.SH SYNOPSIS -.B pom -.SH DESCRIPTION +.Dd May 31, 1993 +.Dt POM 6 +.Os +.Sh NAME +.Nm pom +.Nd \- display the phase of the moon +.Sh SYNOPSIS +.Nm +.Op Fl p +.Sh DESCRIPTION The .I pom utility displays the current phase of the moon. Useful for selecting software completion target dates and predicting managerial behavior. +.Pp +The following options are available: +.Bl -tag -width indent +.It Fl p +print just the phase as a percent, useful within a shell script. +.El >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FE045D4D9F7AED4CBFF1B3B813C85337017CC19C>