]> git.pond.sub.org Git - empserver/blob - src/lib/subs/show.c
Make sector maintenance cost configurable
[empserver] / src / lib / subs / show.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
22  *  See files README, COPYING and CREDITS in the root of the source
23  *  tree for related information and legal notices.  It is expected
24  *  that future projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  show.c: General show routines
29  *
30  *  Known contributors to this file:
31  *     Julian Onions, 1988
32  *     Jeff Bailey, 1990
33  *     Steve McClure, 1996
34  *     Ron Koenderink, 2005-2009
35  *     Markus Armbruster, 2006-2008
36  */
37
38 #include <config.h>
39
40 #include <math.h>
41 #include "file.h"
42 #include "game.h"
43 #include "item.h"
44 #include "land.h"
45 #include "nat.h"
46 #include "news.h"
47 #include "nuke.h"
48 #include "optlist.h"
49 #include "plane.h"
50 #include "player.h"
51 #include "product.h"
52 #include "prototypes.h"
53 #include "sect.h"
54 #include "server.h"
55 #include "ship.h"
56
57 static char *fmttime2822(time_t);
58
59 struct look_list {
60     union {
61         struct lchrstr *lp;
62         struct plchrstr *pp;
63         struct mchrstr *mp;
64     } l_u;
65     int tech;
66 };
67
68 /*
69  * Change this if there are ever more than 200 ships, plane or land
70  * unit types.
71  */
72 static struct look_list lookup_list[200];
73 static int lookup_list_cnt = 0;
74
75 static void
76 sort_lookup_list(void)
77 {
78     struct natstr *np = getnatp(player->cnum);
79     struct look_list tmp;
80     int i;
81     int j;
82
83     if (!(np->nat_flags & NF_TECHLISTS))
84         return;
85     for (i = 0; i < lookup_list_cnt; i++) {
86         for (j = i; j < lookup_list_cnt; j++) {
87             if (lookup_list[j].tech < lookup_list[i].tech) {
88                 tmp = lookup_list[j];
89                 lookup_list[j] = lookup_list[i];
90                 lookup_list[i] = tmp;
91             }
92         }
93     }
94 }
95
96 static void
97 make_new_list(int tlev, int type)
98 {
99     struct plchrstr *pp;
100     struct lchrstr *lp;
101     struct mchrstr *mp;
102
103     lookup_list_cnt = 0;
104     if (type == EF_PLANE) {
105         for (pp = plchr; pp->pl_name; pp++) {
106             if (pp->pl_tech > tlev)
107                 continue;
108             lookup_list[lookup_list_cnt].l_u.pp = pp;
109             lookup_list[lookup_list_cnt].tech = pp->pl_tech;
110             lookup_list_cnt++;
111         }
112     } else if (type == EF_SHIP) {
113         for (mp = mchr; mp->m_name; mp++) {
114             if (mp->m_tech > tlev)
115                 continue;
116             lookup_list[lookup_list_cnt].l_u.mp = mp;
117             lookup_list[lookup_list_cnt].tech = mp->m_tech;
118             lookup_list_cnt++;
119         }
120     } else if (type == EF_LAND) {
121         for (lp = lchr; lp->l_name; lp++) {
122             if (lp->l_tech > tlev)
123                 continue;
124             lookup_list[lookup_list_cnt].l_u.lp = lp;
125             lookup_list[lookup_list_cnt].tech = lp->l_tech;
126             lookup_list_cnt++;
127         }
128     } else
129         return;
130
131     sort_lookup_list();
132 }
133
134 void
135 show_bridge(int tlev)
136 {
137     if (tlev < buil_bt)
138         return;
139     pr("Bridges require %g tech, %d hcm, 0 workers,\n",
140        buil_bt, buil_bh);
141     pr("%d available workforce, and cost $%g\n",
142        (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100,
143        buil_bc);
144 }
145
146 void
147 show_tower(int tlev)
148 {
149     if (tlev < buil_tower_bt)
150         return;
151     pr("Bridge Towers require %g tech, %d hcm, 0 workers,\n",
152        buil_tower_bt, buil_tower_bh);
153     pr("%d available workforce, and cost $%g\n",
154        (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100,
155        buil_tower_bc);
156 }
157
158 void
159 show_nuke_stats(int tlev)
160 {
161     show_nuke_capab(tlev);
162 }
163
164 void
165 show_nuke_build(int tlev)
166 {
167     struct nchrstr *np;
168     int avail;
169
170     pr("%13s lcm hcm  oil  rad avail tech res $\n", "");
171
172     for (np = nchr; np->n_name; np++) {
173         avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
174         if (np->n_tech > tlev)
175             continue;
176         pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
177            np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
178            np->n_rad, avail, np->n_tech,
179            drnuke_const > MIN_DRNUKE_CONST ?
180                 ceil(np->n_tech * drnuke_const) : 0.0,
181            np->n_cost);
182     }
183 }
184
185 void
186 show_nuke_capab(int tlev)
187 {
188     struct nchrstr *np;
189     int i, j;
190     char *p;
191
192     pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
193
194     for (np = nchr; np->n_name; np++) {
195         if (np->n_tech > tlev)
196             continue;
197         pr("%-13.13s %4d %3d %3d %4d %3.0f $%7d ",
198            np->n_name, np->n_blast, np->n_dam,
199            np->n_weight, np->n_tech,
200            drnuke_const > MIN_DRNUKE_CONST ?
201                 ceil(np->n_tech * drnuke_const) : 0.0,
202            np->n_cost);
203         for (i = j = 0; i < 32; i++) {
204             if (!(np->n_flags & bit(i)))
205                 continue;
206             if (NULL != (p = symbol_by_value(bit(i), nuke_chr_flags))) {
207                 if (j++ > 0)
208                     pr(" ");
209                 pr("%s", p);
210             }
211         }
212         pr("\n");
213     }
214 }
215
216 void
217 show_ship_build(int tlev)
218 {
219     struct mchrstr *mp;
220     int n;
221
222     pr("%25s lcm hcm avail tech $\n", "");
223     make_new_list(tlev, EF_SHIP);
224     for (n = 0; n < lookup_list_cnt; n++) {
225         mp = (struct mchrstr *)lookup_list[n].l_u.mp;
226         /* Can't show trade ships unless it's turned on */
227         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
228             continue;
229
230         pr("%-25.25s %3d %3d %5d %4d $%d\n",
231            mp->m_name, mp->m_lcm, mp->m_hcm,
232            SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
233     }
234 }
235
236 void
237 show_ship_stats(int tlev)
238 {
239     struct mchrstr *mp;
240     int scount;
241
242     pr("%25s      s  v  s  r  f  l  p  h  x", "");
243     pr("\n");
244
245     pr("%25s      p  i  p  n  i  n  l  e  p", "");
246     pr("\n");
247
248     pr("%25s def  d  s  y  g  r  d  n  l  l", "");
249     pr("\n");
250
251
252     make_new_list(tlev, EF_SHIP);
253     for (scount = 0; scount < lookup_list_cnt; scount++) {
254         mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
255         /* Can't show trade ships unless it's turned on */
256         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
257             continue;
258
259         pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
260            mp->m_name, m_armor(mp, tlev), m_speed(mp, tlev),
261            m_visib(mp, tlev), mp->m_vrnge,
262            m_frnge(mp, tlev), m_glim(mp, tlev));
263
264         pr("%2d ", mp->m_nland);
265         pr("%2d ", mp->m_nplanes);
266         pr("%2d ", mp->m_nchoppers);
267         pr("%2d ", mp->m_nxlight);
268         pr("\n");
269     }
270 }
271
272 void
273 show_ship_capab(int tlev)
274 {
275     struct mchrstr *mp;
276     i_type i;
277     int j;
278     int scount;
279     int n;
280     char *p;
281
282     pr("%25s cargos & capabilities\n", "");
283
284     make_new_list(tlev, EF_SHIP);
285     for (scount = 0; scount < lookup_list_cnt; scount++) {
286         mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
287         /* Can't show trade ships unless it's turned on */
288         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
289             continue;
290
291         pr("%-25.25s ", mp->m_name);
292
293         for (i = I_NONE + 1; i <= I_MAX; ++i)
294             if (mp->m_item[i])
295                 pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
296         pr(" ");
297         for (j = n = 0; j < 32; j++) {
298             if (!(mp->m_flags & bit(j)))
299                 continue;
300             if (NULL != (p = symbol_by_value(bit(j), ship_chr_flags))) {
301                 if (n++ > 0)
302                     pr(" ");
303                 pr("%s", p);
304             }
305         }
306         pr("\n");
307     }
308 }
309
310 void
311 show_plane_stats(int tlev)
312 {
313     struct plchrstr *pp;
314     int pcount;
315
316     pr("%25s acc load att def ran fuel stlth\n", "");
317     make_new_list(tlev, EF_PLANE);
318     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
319         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
320         pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
321            pp->pl_name, pl_acc(pp, tlev), pl_load(pp, tlev),
322            pl_att(pp, tlev), pl_def(pp, tlev), pl_range(pp, tlev),
323            pp->pl_fuel);
324         pr("%4d%% ", pp->pl_stealth);
325         pr("\n");
326     }
327 }
328
329 void
330 show_plane_capab(int tlev)
331 {
332     struct plchrstr *pp;
333     int i;
334     int pcount;
335     int n;
336     char *p;
337
338     pr("%25s capabilities\n", "");
339     make_new_list(tlev, EF_PLANE);
340     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
341         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
342         pr("%-25.25s  ", pp->pl_name);
343
344         for (i = n = 0; i < 32; i++) {
345             if (!(pp->pl_flags & bit(i)))
346                 continue;
347             if (NULL != (p = symbol_by_value(bit(i), plane_chr_flags))) {
348                 if (n++ > 0)
349                     pr(" ");
350                 pr("%s", p);
351             }
352         }
353         pr("\n");
354     }
355 }
356
357 void
358 show_plane_build(int tlev)
359 {
360     struct plchrstr *pp;
361     int pcount;
362
363     pr("%25s lcm hcm crew avail tech $\n", "");
364     make_new_list(tlev, EF_PLANE);
365     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
366         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
367         pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
368            pp->pl_name, pp->pl_lcm,
369            pp->pl_hcm, pp->pl_crew,
370            PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
371     }
372 }
373
374 void
375 show_land_build(int tlev)
376 {
377     struct lchrstr *lp;
378     int n;
379
380     pr("%25s lcm hcm guns avail tech $\n", "");
381     make_new_list(tlev, EF_LAND);
382     for (n = 0; n < lookup_list_cnt; n++) {
383         lp = (struct lchrstr *)lookup_list[n].l_u.lp;
384         if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
385             continue;
386         pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
387            lp->l_name, lp->l_lcm,
388            lp->l_hcm,
389            lp->l_gun,
390            LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
391     }
392 }
393
394 void
395 show_land_capab(int tlev)
396 {
397     struct lchrstr *lcp;
398     int lcount;
399     i_type i;
400     int j, n;
401     char *p;
402
403     pr("%25s capabilities\n", "");
404
405     make_new_list(tlev, EF_LAND);
406     for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
407         lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
408         if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
409             continue;
410
411         pr("%-25s ", lcp->l_name);
412
413         for (i = I_NONE + 1; i <= I_MAX; ++i)
414             if (lcp->l_item[i])
415                 pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
416         pr(" ");
417         for (j = n = 0; j < 32; j++) {
418             if (!(lcp->l_flags & bit(j)))
419                 continue;
420             if (NULL != (p = symbol_by_value(bit(j), land_chr_flags))) {
421                 if (n++ > 0)
422                     pr(" ");
423                 pr("%s", p);
424             }
425         }
426         pr("\n");
427     }
428 }
429
430 void
431 show_land_stats(int tlev)
432 {
433     struct lchrstr *lcp;
434     int lcount;
435
436     pr("%25s              s  v  s  r  r  a  f  a  a  x  l\n", "");
437     pr("%25s              p  i  p  a  n  c  i  m  a  p  n\n", "");
438     pr("%25s att def vul  d  s  y  d  g  c  r  m  f  l  d\n", "");
439
440     make_new_list(tlev, EF_LAND);
441     for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
442         lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
443         if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
444             continue;
445
446         pr("%-25s %1.1f %1.1f %3d ",
447            lcp->l_name,
448            l_att(lcp, tlev), l_def(lcp, tlev), l_vul(lcp, tlev));
449         pr("%2d %2d %2d %2d ",
450            l_spd(lcp, tlev), lcp->l_vis, lcp->l_spy, lcp->l_rad);
451         pr("%2d %2d %2d %2d %2d ",
452            l_frg(lcp, tlev), l_acc(lcp, tlev), l_dam(lcp, tlev),
453            lcp->l_ammo, lcp->l_aaf);
454         pr("\n");
455     }
456 }
457
458 void
459 show_sect_build(int foo)
460 {
461     int i, first;
462
463     pr("                        desig   build 100%% eff  maint\n"
464        "sector type                 $   lcm  hcm     $      $\n");
465     for (i = 0; dchr[i].d_name; i++) {
466         if (dchr[i].d_mnem == 0)
467             continue;
468         if (dchr[i].d_mob0 < 0)
469             continue;
470         if (dchr[i].d_cost <= 0 && dchr[i].d_build == 1
471             && dchr[i].d_lcms == 0 && dchr[i].d_hcms == 0
472             && dchr[i].d_maint == 0)
473             continue;           /* the usual, skip */
474         pr("%c %-21.21s", dchr[i].d_mnem, dchr[i].d_name);
475         if (dchr[i].d_cost < 0)
476             pr(" can't");
477         else
478             pr(" %5d", dchr[i].d_cost);
479         pr(" %5d%5d %5d  %5d\n",
480            100 * dchr[i].d_lcms,
481            100 * dchr[i].d_hcms,
482            100 * dchr[i].d_build,
483            dchr[i].d_maint * etu_per_update);
484     }
485     pr("any other                   0     0    0   100      0\n");
486
487     first = 1;
488     for (i = 0; intrchr[i].in_name; i++) {
489         if (!intrchr[i].in_enable)
490             continue;
491         if (first)
492             pr("\nInfrastructure building - adding 1 point of efficiency costs:\n"
493                "       type          lcms    hcms    mobility    $$$$\n");
494         pr("%-20s %4d    %4d    %8d    %4d\n",
495            intrchr[i].in_name, intrchr[i].in_lcms, intrchr[i].in_hcms,
496            intrchr[i].in_mcost, intrchr[i].in_dcost);
497         first = 0;
498     }
499 }
500
501 void
502 show_sect_stats(int foo)
503 {
504     int i;
505     struct natstr *natp = getnatp(player->cnum);
506
507     pr("                        mob cost   max   max   naviga    packing   max\n");
508     pr("  sector type            0%% 100%%   off   def   bility      bonus   pop\n");
509
510     for (i = 0; dchr[i].d_name; i++) {
511         if (dchr[i].d_mnem == 0)
512             continue;
513         pr("%c %-21.21s", dchr[i].d_mnem, dchr[i].d_name);
514         if (dchr[i].d_mob0 < 0)
515             pr("  no way ");
516         else
517             pr(" %3.1f  %3.1f", dchr[i].d_mob0, dchr[i].d_mob1);
518         pr("  %5.2f %5.2f %7.7s %10.10s %5d\n",
519            dchr[i].d_ostr, dchr[i].d_dstr,
520            symbol_by_value(dchr[i].d_nav, sector_navigation),
521            symbol_by_value(dchr[i].d_pkg, packing),
522            max_population(natp->nat_level[NAT_RLEV], i, 100));
523     }
524 }
525
526 void
527 show_sect_capab(int foo)
528 {
529     int i;
530
531     pr("  sector type             product  p.e.\n");
532
533     for (i = 0; dchr[i].d_name; i++) {
534         if (dchr[i].d_mnem == 0 || dchr[i].d_prd < 0)
535             continue;
536         pr("%c %-23s %-7s %4d%%\n",
537            dchr[i].d_mnem, dchr[i].d_name, pchr[dchr[i].d_prd].p_sname,
538            dchr[i].d_peffic);
539     }
540 }
541
542 void
543 show_item(int tlev)
544 {
545     struct ichrstr *ip;
546
547     pr("item value sell lbs    packing     melt  item\n");
548     pr("mnem                in no wh ur bk deno  name\n");
549
550     for (ip = ichr; ip->i_name; ip++) {
551         pr("   %c %5d %4s %3d %2d %2d %2d %2d %2d %4d  %s\n",
552            ip->i_mnem, ip->i_value, ip->i_sell ? "yes" : "no", ip->i_lbs,
553            ip->i_pkg[IPKG], ip->i_pkg[NPKG], ip->i_pkg[WPKG],
554            ip->i_pkg[UPKG], ip->i_pkg[BPKG],
555            ip->i_melt_denom, ip->i_name);
556     }
557 }
558
559 void
560 show_product(int tlev)
561 {
562     struct pchrstr *pp;
563     int i;
564     char *lev;
565
566     pr("product    cost  raw materials  reso dep  level p.e.\n");
567
568     for (pp = pchr; pp->p_sname; pp++) {
569         pr("%7.7s %c  $%-3d ",
570            pp->p_sname,
571            pp->p_type < 0 ? ' ' : ichr[pp->p_type].i_mnem,
572            pp->p_cost);
573         (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
574         for (i = 0; i < 3; i++) {
575             if (i < MAXPRCON && pp->p_camt[i]
576                 && pp->p_ctype[i] > I_NONE && pp->p_ctype[i] <= I_MAX)
577                 pr(" %2d%c", pp->p_camt[i], ichr[pp->p_ctype[i]].i_mnem);
578             else
579                 pr("    ");
580         }
581         if (pp->p_nrndx)
582             pr("   %5.5s %3d  ",
583                symbol_by_value(pp->p_nrndx, resources), pp->p_nrdep);
584         else
585             pr("              ");
586         if (pp->p_nlndx < 0)
587             pr("1.0\n");
588         else {
589             lev = symbol_by_value(pp->p_nlndx, level);
590             pr("(%.4s%+d)/(%.4s%+d)\n",
591                lev, -pp->p_nlmin, lev, pp->p_nllag - pp->p_nlmin);
592         }
593     }
594 }
595
596 void
597 show_news(int tlev)
598 {
599     int i, j;
600
601     pr("id category           good will\n");
602     pr("    messsages\n");
603
604     for (i = 1; i < N_MAX_VERB + 1; i++) {
605         if (rpt[i].r_newspage == N_NOTUSED)
606             continue;
607         pr("%-2d %-20.20s %4d\n", rpt[i].r_uid,
608             page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will);
609         for (j = 0; j < NUM_RPTS; j++)
610             pr("    %s\n", rpt[i].r_newstory[j]);
611     }
612 }
613
614 /*
615  * Show update policy and up to N scheduled updates.
616  */
617 void
618 show_updates(int n)
619 {
620     struct gamestr *game = game_tick_tick();
621     int demand = 0;
622     int i;
623
624     pr("%s, Turn %d, ETU %d\n", fmttime2822(time(NULL)),
625        game->game_turn, game->game_tick);
626
627     if (update_time[0]) {
628         if (update_demand == UPD_DEMAND_SCHED) {
629             pr("Demand updates occur according to schedule:\n");
630             demand = 1;
631         } else
632             pr("Updates occur according to schedule:\n");
633         for (i = 0; i < n && update_time[i]; i++)
634             pr("%3d.  %s\n", game->game_turn + i,
635                fmttime2822(update_time[i]));
636         if (update_window) {
637             pr("Updates occur within %d seconds after the scheduled time\n",
638                update_window);
639         }
640     } else
641         pr("There are no updates scheduled.\n");
642
643     if (update_demand == UPD_DEMAND_ASYNC) {
644         pr("Demand updates occur right after the demand is set.\n");
645         if (*update_demandtimes != 0) {
646             pr("Demand updates are allowed during: %s\n",
647                update_demandtimes);
648         }
649         demand = 1;
650     }
651
652     if (demand) {
653         pr("Demand updates require %d country(s) to want one.\n",
654            update_wantmin);
655     }
656
657     if (updates_disabled())
658         pr("\nUPDATES ARE DISABLED!\n");
659 }
660
661 /*
662  * Return T formatted according to RFC 2822.
663  * The return value is statically allocated and overwritten on
664  * subsequent calls.
665  */
666 static char *
667 fmttime2822(time_t t)
668 {
669     static char buf[32];
670 #if defined(_WIN32)
671     size_t n;
672     int nn;
673     TIME_ZONE_INFORMATION tzi;
674     long time_offset;
675     struct tm *time;
676
677     time = localtime(&t);
678
679     n = strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S", time);
680     if (CANT_HAPPEN(n == 0)) {
681         buf[0] = 0;
682         return buf;
683     }
684     GetTimeZoneInformation(&tzi);
685     time_offset = -(tzi.Bias +
686         (time->tm_isdst ? tzi.DaylightBias : tzi.StandardBias));
687
688     nn = _snprintf(buf + n, sizeof(buf) - n, " %+03d%02d",
689         time_offset/60, abs(time_offset) % 60);
690     if (CANT_HAPPEN(nn <= 0 || nn + n >= sizeof(buf)))
691         buf[0] = 0;
692 #else
693     size_t n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z",
694                      localtime(&t));
695     if (CANT_HAPPEN(n == 0))
696         buf[0] = 0;
697 #endif
698     return buf;
699 }