Path: sranha!sranhc!sramha!sramha!kamide From: kamide@sra.co.jp (Akiyoshi Kamide - JS1CPW) Newsgroups: fj.sources Subject: xskyroot (ver.920428): realtime sky drawer for X Message-ID: Date: 28 Apr 92 09:00:58 GMT Sender: news@sra.co.jp (USENET News) Followup-To: fj.sources.d Distribution: fj Organization: Software Research Associates, Inc., Japan Lines: 1140 xskyroot の新しいバージョンです。 色の値の変化が逆転しているときに2重に alloc/free して しまうために XFreeColors() で落ちる、というバグをとりました。 パッチを送ってくださった nozoe@mtc.telcom.oki.co.jp 野副さんに 感謝します。_o_ さらに、毎度おなじみの色調整(きりがない :-)をまた行いました。 彡彡彡 ………………………………………………………………………………… Q Q 上出 昭義 (Akiyoshi Kamide) 点 kamide@sra.co.jp(JUNET) / kamide@js1cpw.ymt.prug.or.jp(寺子屋) 〇 ………………………………………………………………………………… --------------------- cut here --------------------- #!/bin/sh # This is a shell archive (produced by shar 3.49) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # made 04/28/1992 08:46 UTC by kamide@ext518 # Source directory /r/sras28/sd2g/home/mmb/kamide/src/X11/xskyroot # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 150 -rw-r--r-- Imakefile # 3636 -rw-r--r-- README # 5440 -rw-r--r-- astro.c # 2094 -rw-r--r-- colorname.c # 7724 -rw-r--r-- draw.c # 783 -rw-r--r-- mathlocal.h # 3841 -rw-r--r-- xskyroot.c # # ============= Imakefile ============== if test -f 'Imakefile' -a X"$1" != X"-c"; then echo 'x - skipping Imakefile (File already exists)' else echo 'x - extracting Imakefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' && X SYS_LIBRARIES = -lX11 -lm X SRCS = xskyroot.c draw.c colorname.c astro.c OBJS = xskyroot.o draw.o colorname.o astro.o X ComplexProgramTarget(xskyroot) SHAR_EOF chmod 0644 Imakefile || echo 'restore of Imakefile failed' Wc_c="`wc -c < 'Imakefile'`" test 150 -eq "$Wc_c" || echo 'Imakefile: original size 150, current size' "$Wc_c" fi # ============= README ============== if test -f 'README' -a X"$1" != X"-c"; then echo 'x - skipping README (File already exists)' else echo 'x - extracting README (Text)' sed 's/^X//' << 'SHAR_EOF' > 'README' && X *** xskyroot (ver.920428): realtime sky drawer for X *** X X 上出昭義 (Akiyoshi Kamide; kamide@sra.co.jp) X X空と太陽をXのルートウィンドウに映し出し、時刻や季節などに X合わせて徐々に変化させるプログラムです。昼はルートウィンドウが X青空に、夜は星空になります。視野が日没地点を向いていると、 X日没時には美しい夕焼けの中で夕日が沈む姿が現れます。 X X正確に計算されている天体は太陽だけで、星の位置はデタラメです。 Xまた、垂直方向の視野の外は黒くなりますが、上端は逆方向の X地平線ではなく、天頂であることに注意してください。 X Xプラネタリウムとしてではなく、単なる芸術的アクセサリーとして X使うのに向いています。 X Xオプションには次のようなものが使えます: X X -display X ディスプレイ名を指定します。 X X -refresh X 空の書換え周期を<秒>で指定します。デフォルトは 60 です。 X 太陽の位置を変更する周期は、このオプションによらず X 常に1秒です。 X X -verbose X これを指定すると、空の書換えをするごとに数値を表示します。 X X -locate [NS]/[EW] X 緯度と経度を S10/W100 のように指定します。 X デフォルトは旧東京天文台 (N35.654/E139.74469) です。 X X -width X 視界の幅を<度>で指定します。 X 垂直方向の視界、太陽の視直径、高さに応じた空の色も X これに追従します。デフォルトは 360(水平全体)です。 X X -center X 画面中央の方角を<度>で指定します。 X 北が 0、東が 90 です。デフォルトは 180(南向き)です。 X X -horizon X 画面の底辺に対する地平線の位置を<ドット数>で X 指定します。デフォルトは0です。 X X -vcell X 色ごとの長方形領域の高さを<ドット数>で指定します。 X デフォルトは 16 です。 X 小さくするほど滑らかになりますが、その代わり X 色数を多く消費します。 X X -hcell X ルートウィンドウに貼りつける Pixmap の幅を<ドット数>で X 指定します。デフォルトは 400 です。 X Pixmap の高さは、常にルートウィンドウの高さに合わせ X られます。 X X -lesscolor X 背景の全ドットで空の色を同じにします。 X これを指定すると夕焼けや星空は出なくなります。 X X -cloudy X 曇り空にします。 X これを指定すると自動的に -lesscolor も指定されます。 X X X夕焼けを美しく映し出すためには、次のようなオプションが Xおすすめです: X X xskyroot -width 36 -center 270 X X沈む夕日を見えるようにするためには、-center の次の値を X5〜7月頃は 285、11〜1月頃は 255、その他の時期は 270 に Xするとよいでしょう。 X Xあとはこれを走らせたまま、夕方になるのを待ちます。 X待ち切れない場合は、オプションで緯度と経度を指定して、 X夕方の地域へ「移動」してください。 X X X太陽の位置を計算するアルゴリズムには、sunclock のものを流用しています。 X /* X X Sun clock X X Designed and implemented by John Walker in November of 1988. X X Version for the Sun Workstation. X X The algorithm used to calculate the position of the Sun is given in X Chapter 18 of: X X "Astronomical Formulae for Calculators" by Jean Meeus, Third Edition, X Richmond: Willmann-Bell, 1985. This book can be obtained from: X X Willmann-Bell X P.O. Box 35025 X Richmond, VA 23235 X USA X Phone: (804) 320-7016 X X This program was written by: X X John Walker X Autodesk, Inc. X 2320 Marinship Way X Sausalito, CA 94965 X USA X Fax: (415) 389-9418 X Voice: (415) 332-2344 Ext. 2829 X Usenet: {sun,well,uunet}!acad!kelvin X or: kelvin@acad.uu.net X X This program is in the public domain: "Do what thou wilt shall be the X whole of the law". I'd appreciate receiving any bug fixes and/or X enhancements, which I'll incorporate in future versions of the X program. Please leave the original attribution information intact so X that credit and blame may be properly apportioned. X X Revision history: X X 1.0 12/21/89 Initial version. X 8/24/89 Finally got around to submitting. X */ SHAR_EOF chmod 0644 README || echo 'restore of README failed' Wc_c="`wc -c < 'README'`" test 2702 -eq "$Wc_c" || echo 'README: original size 2702, current size' "$Wc_c" fi # ============= astro.c ============== if test -f 'astro.c' -a X"$1" != X"-c"; then echo 'x - skipping astro.c (File already exists)' else echo 'x - extracting astro.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'astro.c' && /* X * Astronomical routines. X */ X #include #include #include #include "mathlocal.h" X long time(); long jdate(); double jtime(); double gmst(); X /* JDATE -- Convert internal GMT date and time to Julian day X and fraction. */ X long jdate(t) struct tm *t; { X long c, m, y; X X y = t->tm_year + 1900; X m = t->tm_mon + 1; X if (m > 2) X m = m - 3; X else { X m = m + 9; X y--; X } X c = y / 100L; /* Compute century */ X y -= 100L * c; X return t->tm_mday + (c * 146097L) / 4 + (y * 1461L) / 4 + X (m * 153L + 2) / 5 + 1721119L; } X /* JTIME -- Convert internal GMT date and time to astronomical X Julian time (i.e. Julian date plus day fraction, X expressed as a double). */ X double jtime(t) struct tm *t; { X return (jdate(t) - 0.5) + X (((long) t->tm_sec) + X 60L * (t->tm_min + 60L * t->tm_hour)) / 86400.0; } X /* GMST -- Calculate Greenwich Mean Siderial Time for a given X instant expressed as a Julian date and fraction. */ X double gmst(jd) double jd; { X double t, theta0; X X X /* Time, in Julian centuries of 36525 ephemeris days, X measured from the epoch 1900 January 0.5 ET. */ X X t = ((floor(jd + 0.5) - 0.5) - 2415020.0) / 36525.0; X X theta0 = 6.6460656 + 2400.051262 * t + 0.00002581 * t * t; X X t = (jd + 0.5) - (floor(jd + 0.5)); X X theta0 += (t * 24.0) * 1.002737908; X X theta0 = (theta0 - 24.0 * (floor(theta0 / 24.0))); X X return theta0; } X /* KEPLER -- Solve the equation of Kepler. */ X double kepler(m, ecc) double m, ecc; { X double e, delta; #define EPSILON 1E-6 X X e = m = dtr(m); X do { X delta = e - ecc * sin(e) - m; X e -= delta / (1 - ecc * cos(e)); X } while (abs(delta) > EPSILON); X return e; } X /*==================== sun ==================*/ X /* SUNPOS -- Calculate position of the Sun. JD is the Julian date X of the instant for which the position is desired and X APPARENT should be nonzero if the apparent position X (corrected for nutation and aberration) is desired. X The Sun's co-ordinates are returned in RA and DEC, X both specified in degrees (divide RA by 15 to obtain X hours). The radius vector to the Sun in astronomical X units is returned in RV and the Sun's longitude (true X or apparent, as desired) is returned as degrees in X SLONG. */ X sunpos(jd, apparent, ra, dec, rv, slong) double jd; int apparent; double *ra, *dec, *rv, *slong; { X double t, t2, t3, l, m, e, ea, v, theta, omega, X eps; X X /* Time, in Julian centuries of 36525 ephemeris days, X measured from the epoch 1900 January 0.5 ET. */ X X t = (jd - 2415020.0) / 36525.0; X t2 = t * t; X t3 = t2 * t; X X /* Geometric mean longitude of the Sun, referred to the X mean equinox of the date. */ X X l = fixangle(279.69668 + 36000.76892 * t + 0.0003025 * t2); X X /* Sun's mean anomaly. */ X X m = fixangle(358.47583 + 35999.04975*t - 0.000150*t2 - 0.0000033*t3); X X /* Eccentricity of the Earth's orbit. */ X X e = 0.01675104 - 0.0000418 * t - 0.000000126 * t2; X X /* Eccentric anomaly. */ X X ea = kepler(m, e); X X /* True anomaly */ X X v = fixangle(2 * rtd(atan(sqrt((1 + e) / (1 - e)) * tan(ea / 2)))); X X /* Sun's true longitude. */ X X theta = l + v - m; X X /* Obliquity of the ecliptic. */ X X eps = 23.452294 - 0.0130125 * t - 0.00000164 * t2 + 0.000000503 * t3; X X /* Corrections for Sun's apparent longitude, if desired. */ X X if (apparent) { X omega = fixangle(259.18 - 1934.142 * t); X theta = theta - 0.00569 - 0.00479 * sin(dtr(omega)); X eps += 0.00256 * cos(dtr(omega)); X } X X /* Return Sun's longitude and radius vector */ X X *slong = theta; X *rv = (1.0000002 * (1 - e * e)) / (1 + e * cos(dtr(v))); X X /* Determine solar co-ordinates. */ X X *ra = X fixangle(rtd(atan2(cos(dtr(eps)) * sin(dtr(theta)), cos(dtr(theta))))); X *dec = rtd(asin(sin(dtr(eps)) * sin(dtr(theta)))); } X /* X * sunpos_local - calculates earth-oriented sun position X * X * x : North X * y : East X * z : Height X */ X sunpos_local X (t_gmt, curr_lon, curr_lat, X p_sun_hour, p_sun_lon, p_sun_lat, X px,py,pz ) X struct tm *t_gmt; /* current gmt time */ X double curr_lon, curr_lat; /* longitude/latitude on earth */ X double *p_sun_hour; X double *p_sun_lon, *p_sun_lat; X double *px, *py, *pz; { X double gt, jt, sunra, sundec, sunrv, sunlong, sunra_local, x,y,z; X X jt = jtime(t_gmt); X sunpos(jt, FALSE, &sunra, &sundec, &sunrv, &sunlong); X gt = gmst(jt); X sunra_local = fixangle2( 180 + gt*15 + curr_lon - sunra ); X #ifdef DEBUG X printf("\n"); X printf X ("jt=%f gt=%f - %s", jt, gt, asctime(t_gmt) ); X printf X ("sunra=%f, sundec=%f\nsunra_local=%f\nsunrv=%f, sunlong=%f\n", X sunra, sundec, sunra_local, sunrv, sunlong ); #endif DEBUG /* X N90 X x = cos( dtr(sunra) ); X y = sin( dtr(sunra) ); X z = sin( dtr(sundec) ); X 0 X x = sin( dtr(sundec) ); X y = sin( dtr(sunra) ); X z = -cos( dtr(sunra) ); X S90 X x = -cos( dtr(sunra) ); X y = sin( dtr(sunra) ); X z = -sin( dtr(sundec) ); */ X x = cos(dtr(sunra_local))*sin(dtr(curr_lat)) X + sin(dtr(sundec))*cos(dtr(curr_lat)); X y = sin(dtr(sunra_local)); X z = sin(dtr(sundec))*sin(dtr(curr_lat)) X + (-cos(dtr(sunra_local)))*cos(dtr(curr_lat)); X X if( p_sun_hour ) X *p_sun_hour = sunra_local/15; X if( p_sun_lon ) X *p_sun_lon = (y == 0 && x == 0) ? 0.0 : rtd(atan2(y, x)); X if( p_sun_lat ) X *p_sun_lat = rtd(asin(z>1?1:z)); X if( px ) *px = x; X if( py ) *py = y; X if( pz ) *pz = z; } SHAR_EOF chmod 0644 astro.c || echo 'restore of astro.c failed' Wc_c="`wc -c < 'astro.c'`" test 5440 -eq "$Wc_c" || echo 'astro.c: original size 5440, current size' "$Wc_c" fi # ============= colorname.c ============== if test -f 'colorname.c' -a X"$1" != X"-c"; then echo 'x - skipping colorname.c (File already exists)' else echo 'x - extracting colorname.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'colorname.c' && X #include #include "mathlocal.h" X #define LOGISTIC(a) (1/( 1 + exp(-(a)) )) #define LOGISTIC2(a) (2/( exp(a) + exp(-(a)) )) X extern int cloudy; X char * MakeColorName( buf, r, g, b ) X char *buf; X double r, g, b; { X sprintf( buf, "#%02X%02X%02X", X (unsigned int)(LOGISTIC(r) * 254)+1, X (unsigned int)(LOGISTIC(g) * 254)+1, X (unsigned int)(LOGISTIC(b) * 254)+1); X X return buf; } X void GetSkyColor( rp, gp, bp, z, h, t, sun_h ) X double *rp, *gp, *bp; X double z; /* 1:Noon ... -1:Midnight */ X double h; /* 1:Heaven ... 0:Horizon */ X double t; /* 1:Sunward ... 0: */ X double sun_h; /* 1:sun at heaven ... 0:at horizon */ { X double r, g, b, white; X X white = LOGISTIC(25*(z+0.15)); X white *= z * pow( 1-h, 5.0 ) + (0.3*t+0.7)*LOGISTIC2(3.0*(h-sun_h)) + 2.55; X white += -2.50; X X r = g = b = white; X X if( !cloudy ) { X double yellow, orange, red, e; X X e = t * LOGISTIC2(3.5*(z+0.00)); X yellow = e * LOGISTIC2(6.5*(h-0.20)); X red = e * LOGISTIC2(12.0*(h+0.01)); X X g *= 1.10; X X r += (-2.60 + 4.20*yellow + 3.20*red) / 3; X g += ( 0.00 - 0.75*yellow - 1.80*red) / 3; X b += ( 2.20 - 5.20*yellow - 5.40*red) / 3; X } X X if( rp ) *rp = r; X if( gp ) *gp = g; X if( bp ) *bp = b; } X char * GetSkyColorName( buf, z, h, t, sun_h ) X char *buf; X double z; X double h; X double t; X double sun_h; { X double r, g, b; X X if( h>1 || h<0 ) { X strcpy( buf, "#000000" ); X return buf; X } X X if( sun_h < 0 ) X sun_h = 0; X else if( sun_h > 1 ) X sun_h = 1; X X GetSkyColor( &r, &g, &b, z, h, t, sun_h ); X X return MakeColorName( buf, r, g, b ); } char * GetSolarColorName( buf, z ) X char *buf; X double z; /* 1:Noon ... -1:Midnight */ { X double r,g,b; X X r = 20; X g = 21 - 21*LOGISTIC2(2.4*(z+0.02)); X b = 20 - 25*LOGISTIC2(2.4*(z+0.02)); X X return MakeColorName( buf, r, g, b ); } char * GetStarColorName( buf, z ) X char *buf; X double z; /* 1:Noon ... -1:Midnight */ { X double red, green, blue; X X red = 100; X green = 100; X blue = 100; X X return MakeColorName( buf, red, green, blue ); } SHAR_EOF chmod 0644 colorname.c || echo 'restore of colorname.c failed' Wc_c="`wc -c < 'colorname.c'`" test 2094 -eq "$Wc_c" || echo 'colorname.c: original size 2094, current size' "$Wc_c" fi # ============= draw.c ============== if test -f 'draw.c' -a X"$1" != X"-c"; then echo 'x - skipping draw.c (File already exists)' else echo 'x - extracting draw.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'draw.c' && X #include X #include #include #include X #define NULL_PIXEL -1 X #include #include "mathlocal.h" X extern int program_name; extern unsigned refresh_period; extern int multi_color; extern int cloudy; extern int view_horizon_dots, v_cell_dots, h_cell_dots; extern double view_center; X static int refresh_count=0; static double dot_per_degree, view_left; X static Display *dpy; static int screen; static Window root_window; static XWindowAttributes root_attr; X static GC sun_gc=NULL, sky_gc=NULL, star_gc=NULL; static XGCValues sun_gcv, sky_gcv, star_gcv; X static unsigned long sun_pixel, star_pixel; X static unsigned long *pixel_list = NULL; static unsigned int n_pixel_max = 0, n_pixel = 0; X static char **color_name_list; X static Pixmap sky_pixmap = NULL; X #define NUM_STAR 2048 static XPoint stars[NUM_STAR]; X #define VISIBLE(x,y,d) \ X ((x)>-(d) && \ X (y)>-(d) && \ X (x)0; i--, pl++ ) X *pl = NULL_PIXEL; X X /* X * Allocation for color names X */ X color_name_list = (char **)malloc(sizeof(char*)*n_pixel_max); X if( !color_name_list ) { X fprintf( stderr, "%s: alloc error\n", program_name ); X exit(-1); X } X for( p = color_name_list, i=n_pixel_max; i>0; i--, p++ ) X if( !(*p = (char *)malloc(sizeof(char)*(2*3+1))) ) { X fprintf( stderr, "%s: alloc error\n", program_name ); X exit(-1); X } X X /* X * make fixed star position X */ X if( multi_color ) X for( i=0; i 0 && !cloudy ) { X if( star_gc ) X XFreeGC( dpy, star_gc ); X star_gc = XCreateGC( dpy, sky_pixmap, GCForeground, &star_gcv ); X star_pixel = AllocColor( GetStarColorName(star_color_name,z) ); X XSetForeground( dpy, star_gc, star_pixel ); X XDrawPoints X ( dpy, sky_pixmap, star_gc, stars, nstar, CoordModeOrigin ); X } X XSetWindowBackgroundPixmap( dpy, root_window, sky_pixmap ); X } } X void MakeNewSun(z) X double z; { X char color_name[64]; X if( sun_gc ) X XFreeGC( dpy, sun_gc ); X sun_gc = XCreateGC( dpy, root_window, GCForeground, &sun_gcv ); X sun_pixel = AllocColor( GetSolarColorName( color_name, z ) ); X XSetForeground( dpy, sun_gc, sun_pixel ); } X int SkyUpdate( lon, z ) X double lon, z; { X int sun_x, sun_y; X unsigned refresh_count_old; X register i; X unsigned long *pl; X double t, sun_h; X static int first = TRUE; X X sun_x = (unsigned int)(fixangle(lon - view_left) * dot_per_degree); X sun_h = fixangle2( rtd(asin(z>1?1:z)) + (1-z*z*z)*35.1/60.0 ); X sun_y = root_attr.height - (int)(sun_h * dot_per_degree); X t = ( 1 + cos(dtr(fixangle(lon - view_center))) ) / 2; X #ifdef DEBUG X fprintf( stderr, "diam=%d, x=%d, y=%d\n", sun_diam, sun_x, sun_y ); #endif DEBUG X X if( MakeSkyColorNames(z, t, sun_h) && !refresh_count || first ) { X first = FALSE; X FreeSolarColor(); X FreeSkyColors(); X MakeNewSky(z); X XClearWindow(dpy, root_window); X if( VISIBLE( sun_x, sun_y, sun_diam ) && !cloudy ) X MakeNewSun(z); X } X if( !cloudy ) X DrawSun( sun_x, sun_y, view_horizon_dots ); X XFlush(dpy); X X refresh_count_old = refresh_count; X refresh_count = (refresh_count+1) % refresh_period ; X X return refresh_count_old; } X X X X X SHAR_EOF chmod 0644 draw.c || echo 'restore of draw.c failed' Wc_c="`wc -c < 'draw.c'`" test 7724 -eq "$Wc_c" || echo 'draw.c: original size 7724, current size' "$Wc_c" fi # ============= mathlocal.h ============== if test -f 'mathlocal.h' -a X"$1" != X"-c"; then echo 'x - skipping mathlocal.h (File already exists)' else echo 'x - extracting mathlocal.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'mathlocal.h' && X /* Constants */ X #define FALSE 0 #define TRUE 1 X #define PI 3.14159265358979323846 X /* Handy mathematical functions */ X #define sgn(x) (((x) < 0) ? -1 : ((x) > 0 ? 1 : 0)) /* Extract sign */ #define abs(x) ((x) < 0 ? (-(x)) : (x)) /* Absolute val */ #define fixangle(a) ((a) - 360.0 * (floor((a) / 360.0))) /* Fix to 0..360 */ #define torad(d) ((d) * (PI / 180.0)) /* Deg->Rad */ #define todeg(d) ((d) * (180.0 / PI)) /* Rad->Deg */ #define dtr(x) ((x) * (PI / 180.0)) /* Degree->Radian */ #define rtd(x) ((x) / (PI / 180.0)) /* Radian->Degree */ #define dsin(x) (sin(torad((x)))) /* Sin from deg */ #define dcos(x) (cos(torad((x)))) /* Cos from deg */ X #define fixangle2(a) ((a) - 360.0 * (floor((a) / 360.0 + 0.5))) /* Fix to -180..+180 */ X SHAR_EOF chmod 0644 mathlocal.h || echo 'restore of mathlocal.h failed' Wc_c="`wc -c < 'mathlocal.h'`" test 783 -eq "$Wc_c" || echo 'mathlocal.h: original size 783, current size' "$Wc_c" fi # ============= xskyroot.c ============== if test -f 'xskyroot.c' -a X"$1" != X"-c"; then echo 'x - skipping xskyroot.c (File already exists)' else echo 'x - extracting xskyroot.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xskyroot.c' && X #include #include #include X #include #include "mathlocal.h" X char *program_name = "xskyroot"; int verbose = 0; int multi_color = 1; int cloudy = 0; char *display_name = ""; unsigned refresh_period = 60; double view_width = 360, view_center = 180; double curr_lon=139.74469, curr_lat=35.654; int view_horizon_dots = 0; int v_cell_dots = 16; int h_cell_dots = 400; X parse_locate(s,lon,lat) X char *s; X double *lon, *lat; { X double k, *x; X X /* locate format: Ann/Bnnn */ X X while( *s ) { X while( *s=='/' ) X s++; X switch( *s++ ) { X case 'N': X case 'n': X x=lat; k = 1; break; X case 'S': X case 's': X x=lat; k = -1; break; X case 'E': X case 'e': X x=lon; k = 1; break; X case 'W': X case 'w': X x=lon; k = -1; break; X default: X ; X } X if(x) X *x = k * atof(s); X while( *s && *s != '/' ) X s++; X } } X usage() { X fprintf( stderr, "Usage: %s [options]\n", program_name ); X fprintf( stderr, " Options are:\n" ); X fprintf( stderr, " -display \n" ); X fprintf( stderr, " -verbose\n" ); X fprintf( stderr, " -lesscolor\n" ); X fprintf( stderr, " -cloudy\n" ); X fprintf( stderr, " -refresh \n" ); X fprintf( stderr, " -locate [NS]/[EW]\n" ); X fprintf( stderr, " -width \n" ); X fprintf( stderr, " -center \n" ); X fprintf( stderr, " -horizon \n" ); X fprintf( stderr, " -hcell \n" ); X fprintf( stderr, " -vcell \n" ); X exit(1); } X main(argc,argv) X int argc; X char *argv[]; { X double h,hdash,lon,lat, x, y, z; X register i; X struct tm *t_gmt, *t_local; X long tval; X int refreshed; X X /* parse arguments */ X for( i=1; itm_hour X + (double)t_gmt->tm_min/60 X + (double)t_gmt->tm_sec/3600; X h += curr_lon/15; X printf(" "); print_h(h); printf(" "); X print_h(hdash); printf("\n"); X printf("lon=%f, lat=%f, x=%f, y=%f, z=%f\n", lon,lat, x,y,z ); X } X sleep(1); X } } X print_h(h) X double h; { X if( h > 24 ) X h-=24; X else if( h < 0 ) X h+=24; X printf X ("%02d:%02d:%02d", X (int)h, (int)(h*60)%60, (int)(h*3600)%60 ); } SHAR_EOF chmod 0644 xskyroot.c || echo 'restore of xskyroot.c failed' Wc_c="`wc -c < 'xskyroot.c'`" test 3841 -eq "$Wc_c" || echo 'xskyroot.c: original size 3841, current size' "$Wc_c" fi exit 0