]> git.pond.sub.org Git - empserver/blob - src/lib/commands/xdump.c
be70816ebc336ef0bbe497e08617d7f2295b3529
[empserver] / src / lib / commands / xdump.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  xdump.c: Experimental extended dump
29  * 
30  *  Known contributors to this file:
31  *     Markus Armbruster, 2004
32  */
33
34 #include <stddef.h>
35 #include "misc.h"
36 #include "file.h"
37 #include "match.h"
38 #include "news.h"
39 #include "nsc.h"
40 #include "optlist.h"
41
42 /*
43  * Dump everything under the sun
44  *
45  * Static game data (configuration):
46  * - Item characteristics: ichr[]
47  * - Land unit characteristics: lchr[]
48  * - Nuke characteristics: nchr[]
49  * - Plane characteristics: plchr[]
50  * - Product characteristics: pchr[]
51  * - Sector designation characteristics: dchr[]
52  * - Sector infrastructure characteristics: intrchr[]
53  * - Ship characteristics: mchr[]
54  * Less important:
55  * - News item characteristics: rpt[]
56  * - Treaty clause characteristics: tchr[]
57  * - Commands: coms[]
58  * - Options: Options[]
59  * - Configuration: configkeys[]
60  *
61  * Dynamic game data:
62  * - Sectors: EF_SECTOR, sect_ca[] (already have dump)
63  * - Land units: EF_LAND, land_ca[] (already have ldump)
64  * - Lost: EF_LOST, lost_ca[] (already have lost)
65  * - Nukes: EF_NUKE, nuke_ca[] (already have ndump)
66  * - Planes: EF_PLANE, plane_ca[] (already have pdump)
67  * - Ships: EF_SHIP, ship_ca[] (already have sdump)
68  * - News: EF_NEWS, news_ca[]
69  * - Treaties: EF_TREATY, treaty_ca[]
70  * - Power: EF_POWER
71  * - Nations: EF_NATION, nat_ca[]
72  * - Loans: EF_LOAN, loan_ca[]
73  * - Map: EF_MAP
74  * - Bmap: EF_BMAP
75  * - Market: EF_COMM, commodity_ca[]
76  */
77
78 /* FIXME document dump format */
79
80 /* Selector descriptors for characteristics tables */
81 /* FIXME belongs into src/lib/global/ */
82
83 static struct castr dchr_ca[] = {
84     {NSC_STRING, 0, 0, offsetof(struct dchrstr, d_name), "name"},
85     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_mnem), "mnem"},
86     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_prd), "prd"},
87     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_mcst), "mcst"},
88     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_flg), "flg"},
89     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_pkg), "pkg"},
90     {NSC_FLOAT, 0, 0, offsetof(struct dchrstr, d_ostr), "ostr"},
91     {NSC_FLOAT, 0, 0, offsetof(struct dchrstr, d_dstr), "dstr"},
92     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_value), "value"},
93     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_cost), "cost"},
94     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_build), "build"},
95     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_lcms), "lcms"},
96     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_hcms), "hcms"},
97     {NSC_NOTYPE, 0, 0, 0, NULL}
98 };
99
100 static struct castr ichr_ca[] = {
101     {NSC_STRING, 0, 0, offsetof(struct ichrstr, i_name), "name"},
102     {NSC_INT, 0, 0, offsetof(struct ichrstr, i_mnem), "mnem"},
103     {NSC_INT, 0, 0, offsetof(struct ichrstr, i_vtype), "vtype"},
104     {NSC_INT, 0, 0, offsetof(struct ichrstr, i_value), "value"},
105     {NSC_INT, 0, 0, offsetof(struct ichrstr, i_sell), "sell"},
106     {NSC_INT, 0, 0, offsetof(struct ichrstr, i_lbs), "lbs"},
107     {NSC_INT, 0, NUMPKG, offsetof(struct ichrstr, i_pkg), "pkg"},
108     {NSC_NOTYPE, 0, 0, 0, NULL}
109 };
110
111 static struct castr intrchr_ca[] = {
112     {NSC_STRING, 0, 0, offsetof(struct sctintrins, in_name), "name"},
113     {NSC_UCHAR, 0, 0, offsetof(struct sctintrins, in_lcms), "lcms"},
114     {NSC_UCHAR, 0, 0, offsetof(struct sctintrins, in_hcms), "hcms"},
115     {NSC_UCHAR, 0, 0, offsetof(struct sctintrins, in_dcost), "dcost"},
116     {NSC_UCHAR, 0, 0, offsetof(struct sctintrins, in_mcost), "mcost"},
117     {NSC_NOTYPE, 0, 0, 0, NULL}
118 };
119
120 static struct castr rpt_ca[] = {
121     {NSC_STRING, 0, NUM_RPTS, offsetof(struct rptstr, r_newstory), "newstory"},
122     {NSC_INT, 0, 0, offsetof(struct rptstr, r_good_will), "good_will"},
123     {NSC_INT, 0, 0, offsetof(struct rptstr, r_newspage), "newspage"},
124     {NSC_NOTYPE, 0, 0, 0, NULL}
125 };
126
127 static struct castr tchr_ca[] = {
128     {NSC_STRING, 0, 0, offsetof(struct tchrstr, t_name), "name"},
129     {NSC_INT, 0, 0, offsetof(struct tchrstr, t_cond), "cond"},
130     {NSC_NOTYPE, 0, 0, 0, NULL}
131 };
132
133 static struct castr mchr_ca[] = {
134     {NSC_STRING, 0, 0, offsetof(struct mchrstr, m_name), "name"},
135     {NSC_USHORT, 0, I_MAX+1, offsetof(struct mchrstr, m_item), "item"},
136     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_lcm), "lcm"},
137     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_hcm), "hcm"},
138     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_armor), "armor"},
139     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_speed), "speed"},
140     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_visib), "visib"},
141     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_vrnge), "vrnge"},
142     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_frnge), "frnge"},
143     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_glim), "glim"},
144     {NSC_UCHAR, 0, 0, offsetof(struct mchrstr, m_nxlight), "nxlight"},
145     {NSC_UCHAR, 0, 0, offsetof(struct mchrstr, m_nchoppers), "nchoppers"},
146     {NSC_UCHAR, 0, 0, offsetof(struct mchrstr, m_fuelc), "fuelc"},
147     {NSC_UCHAR, 0, 0, offsetof(struct mchrstr, m_fuelu), "fuelu"},
148     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_tech), "tech"},
149     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_cost), "cost"},
150     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_flags), "flags"},
151     {NSC_UCHAR, 0, 0, offsetof(struct mchrstr, m_nplanes), "nplanes"},
152     {NSC_UCHAR, 0, 0, offsetof(struct mchrstr, m_nland), "nland"},
153     {NSC_NOTYPE, 0, 0, 0, NULL}
154 };
155
156 static struct castr pchr_ca[] = {
157     {NSC_STRING, 0, 0, offsetof(struct pchrstr, p_name), "name"},
158     {NSC_STRING, 0, 0, offsetof(struct pchrstr, p_sname), "sname"},
159     {NSC_UCHAR, 0, MAXPRCON, offsetof(struct pchrstr, p_ctype), "ctype"},
160     {NSC_USHORT, 0, MAXPRCON, offsetof(struct pchrstr, p_camt), "camt"},
161     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_type), "type"},
162     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_level), "level"},
163     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_cost), "cost"},
164     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nrndx), "nrndx"},
165     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nrdep), "nrdep"},
166     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nlndx), "nlndx"},
167     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nlmin), "nlmin"},
168     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nllag), "nllag"},
169     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_effic), "effic"},
170     {NSC_NOTYPE, 0, 0, 0, NULL}
171 };
172
173 static struct castr plchr_ca[] = {
174     {NSC_STRING, 0, 0, offsetof(struct plchrstr, pl_name), "name"},
175     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_lcm), "lcm"},
176     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_hcm), "hcm"},
177     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_cost), "cost"},
178     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_tech), "tech"},
179     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_acc), "acc"},
180     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_load), "load"},
181     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_att), "att"},
182     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_def), "def"},
183     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_range), "range"},
184     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_crew), "crew"},
185     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_fuel), "fuel"},
186     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_stealth), "stealth"},
187     {NSC_INT, 0, 0, offsetof(struct plchrstr, pl_flags), "flags"},
188     {NSC_NOTYPE, 0, 0, 0, NULL}
189 };
190
191 static struct castr lchr_ca[] = {
192     {NSC_STRING, 0, 0, offsetof(struct lchrstr, l_name), "name"},
193     {NSC_USHORT, 0, I_MAX+1, offsetof(struct mchrstr, m_item), "item"},
194     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_lcm), "lcm"},
195     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_hcm), "hcm"},
196     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_gun), "gun"},
197     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_shell), "shell"},
198     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_tech), "tech"},
199     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_cost), "cost"},
200     {NSC_FLOAT, 0, 0, offsetof(struct lchrstr, l_att), "att"},
201     {NSC_FLOAT, 0, 0, offsetof(struct lchrstr, l_def), "def"},
202     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_vul), "vul"},
203     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_spd), "spd"},
204     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_vis), "vis"},
205     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_spy), "spy"},
206     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_rad), "rad"},
207     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_frg), "frg"},
208     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_acc), "acc"},
209     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_dam), "dam"},
210     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_ammo), "ammo"},
211     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_aaf), "aaf"},
212     {NSC_UCHAR, 0, 0, offsetof(struct lchrstr, l_fuelc), "fuelc"},
213     {NSC_UCHAR, 0, 0, offsetof(struct lchrstr, l_fuelu), "fuelu"},
214     {NSC_UCHAR, 0, 0, offsetof(struct lchrstr, l_nxlight), "nxlight"},
215     {NSC_UCHAR, 0, 0, offsetof(struct lchrstr, l_mxland), "mxland"},
216     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_flags), "flags"},
217     {NSC_NOTYPE, 0, 0, 0, NULL}
218 };
219
220 static struct castr nchr_ca[] = {
221     {NSC_STRING, 0, 0, offsetof(struct nchrstr, n_name), "name"},
222     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_lcm), "lcm"},
223     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_hcm), "hcm"},
224     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_oil), "oil"},
225     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_rad), "rad"},
226     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_blast), "blast"},
227     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_dam), "dam"},
228     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_cost), "cost"},
229     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_tech), "tech"},
230     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_weight), "weight"},
231     {NSC_INT, 0, 0, offsetof(struct nchrstr, n_flags), "flags"},
232     {NSC_NOTYPE, 0, 0, 0, NULL}
233 };
234
235 /* Characteristics table meta data */
236 struct camap {
237     char *name;                 /* name for lookup */
238     struct castr *ca;           /* selector descriptors */
239     void *chr;                  /* characteristics table */
240     size_t size;                /* size of characteristics table element */
241 };
242
243 /* Table of characteristics tables */
244 static struct camap chr_camap[] = {
245     {"sect chr", dchr_ca, dchr, sizeof(dchr[0])},
246     {"ship chr", mchr_ca, mchr, sizeof(mchr[0])},
247     {"plane chr", plchr_ca, plchr, sizeof(plchr[0])},
248     {"land chr", lchr_ca, lchr, sizeof(lchr[0])},
249     {"nuke chr", nchr_ca, nchr, sizeof(nchr[0])},
250 #if 0
251     /* FIXME rpt[] lacks sentinel, xdchr() doesn't terminate */
252     {"news chr", rpt_ca, rpt, sizeof(rpt[0])},
253 #endif
254     {"treaty chr", tchr_ca, tchr, sizeof(tchr[0])},
255     {"item", ichr_ca, ichr, sizeof(ichr[0])},
256     {"infrastructure", intrchr_ca, intrchr, sizeof(intrchr[0])},
257     {"product", pchr_ca, pchr, sizeof(pchr[0])},
258     {NULL, NULL, NULL, 0}
259 };
260
261 /*
262  * Search chr_camap[] for element named NAME, return its index.
263  * Return M_NOTFOUND if there are no matches, M_NOTUNIQUE if there are
264  * several.
265  */
266 static int
267 chridx_by_name(char *name)
268 {
269     return stmtch(name, chr_camap, offsetof(struct camap, name),
270                   sizeof(chr_camap[0]));
271 }
272
273 /*
274  * Evaluate a attribute of an object into VAL, return VAL.
275  * TYPE is the attribute's type.
276  * PTR points to the context object.
277  * The attribute is stored there at offset OFF + IDX * S, where S is
278  * its size.
279  */
280 static struct valstr *
281 xdeval(struct valstr *val, nsc_type type, void *ptr, ptrdiff_t off, int idx)
282 {
283     val->val_type = type;
284     val->val_cat = NSC_OFF;
285     val->val_as_type = -1;
286     val->val_as.sym.off = off;
287     val->val_as.sym.idx = idx;
288     nstr_exec_val(val, player->cnum, ptr, NSC_NOTYPE);
289     return val;                 /* FIXME nstr_exec_val() should return VAL */
290 }
291
292 /* Dump VAL prefixed with SEP, return " ".  */
293 static char *
294 xdprval(struct valstr *val, char *sep)
295 {
296     unsigned char *s, *e;
297
298     switch (val->val_type) {
299     case NSC_TYPEID:
300     case NSC_LONG:
301         pr("%s%ld", sep, val->val_as.lng);
302         break;
303     case NSC_DOUBLE:
304         pr("%s%g", sep, val->val_as.dbl);
305         break;
306     case NSC_STRING:
307         s = (unsigned char *)val->val_as.str;
308         if (s) {
309             pr("%s\"", sep);
310             while (*s) {
311                 for (e = s; *e != '"' && *e != '\\' && isgraph(*e); ++e) ;
312                 pr("%.*s", (int)(e-s), s);
313                 if (*e)
314                     pr("\\%03o", *e++);
315                 s = e;
316             }
317             prnf("\"");
318         } else
319             pr("%snil", sep);
320         break;
321     default:
322         CANT_HAPPEN("Bad VAL type");
323         pr("0");
324     }
325     return " ";
326 }
327
328 /*
329  * Dump field values of a context object.
330  * CA[] describes fields.
331  * PTR points to context object.
332  */
333 static void
334 xdflds(struct castr ca[], void *ptr)
335 {
336     int i, j, n;
337     struct valstr val;
338     char *sep = "";
339
340     for (i = 0; ca[i].ca_name; ++i) {
341         if (ca[i].ca_flags & NSC_DEITY && !player->god)
342             continue;
343         if (ca[i].ca_flags & NSC_EXTRA)
344             continue;
345         n = ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0;
346         j = 0;
347         do {
348             xdeval(&val, ca[i].ca_type, ptr, ca[i].ca_off, j);
349             sep = xdprval(&val, sep);
350         } while (++j < n);
351     }
352 }
353
354 /* Dump field names; CA[] describes fields.  */
355 static void
356 xdfldnam(struct castr ca[])
357 {
358     int i;
359     char *sep = "";
360
361     for (i = 0; ca[i].ca_name; ++i) {
362         if (ca[i].ca_flags & NSC_DEITY && !player->god)
363             continue;
364         if (ca[i].ca_flags & NSC_EXTRA)
365             continue;
366         pr("%s%s", sep, ca[i].ca_name);
367         if (ca[i].ca_len && ca[i].ca_type != NSC_STRINGY)
368             pr(" %d", ca[i].ca_len);
369         sep = " ";
370     }
371 }
372
373 /* Dump first line of header for dump NAME.  */
374 static void
375 xdhdr1(char *name)
376 {
377     pr("XDUMP %s %ld\n", name, (long)time(NULL));
378 }
379
380 /* Dump header for dump NAME with fields described by CA[].  */
381 static void
382 xdhdr(char *name, struct castr ca[])
383 {
384     xdhdr1(name);
385     xdfldnam(ca);
386     pr("\n");
387 }
388
389 /* Dump footer for a dump that dumped N objects.  */
390 static void
391 xdftr(int n)
392 {
393     pr("dumped %d\n", n);
394 }
395
396 /*
397  * Dump items of type TYPE selected by ARG.
398  * Return RET_OK on success, RET_SYN on error.
399  */
400 static int
401 xditem(int type, char *arg)
402 {
403     struct castr *ca;
404     struct nstr_item ni;
405     int n;
406     s_char buf[2048];           /* FIXME buffer size? */
407
408     ca = ef_cadef(type);
409     if (!ca)
410         return RET_SYN;
411
412     if (!snxtitem(&ni, type, arg))
413         return RET_SYN;
414
415     xdhdr(ef_nameof(type), ca);
416
417     n = 0;
418     while (nxtitem(&ni, buf)) {
419         if (!player->owner)
420             continue;
421         ++n;
422         xdflds(ca, buf);
423         pr("\n");
424     }
425
426     xdftr(n);
427
428     return RET_OK;
429 }
430
431 /*
432  * Dump characteristics described by chr_camap[IDX].
433  * Return RET_OK on success, RET_SYN if IDX < 0.
434  */
435 static int
436 xdchr(int chridx)
437 {
438     struct camap *cm;
439     char *p;
440     struct valstr val;
441     int n;
442
443     if (chridx < 0)
444         return RET_SYN;
445     cm = &chr_camap[chridx];
446
447     xdhdr(cm->name, cm->ca);
448
449     n = 0;
450     for (p = cm->chr; ; p += cm->size) {
451         val.val_type = cm->ca[0].ca_type;
452         val.val_cat = NSC_OFF;
453         val.val_as_type = -1;
454         val.val_as.sym.off = cm->ca[0].ca_off;
455         val.val_as.sym.idx = 0;
456         nstr_exec_val(&val, player->cnum, p, NSC_STRING);
457         if (!val.val_as.str || !*val.val_as.str)
458             break;
459         ++n;
460         xdflds(cm->ca, p);
461         pr("\n");
462     }
463
464     xdftr(n);
465
466     return RET_OK;
467 }
468
469 /* Dump Options[], return RET_OK.  */
470 static int
471 xdopt(void)
472 {
473     int i;
474     char *sep;
475
476     xdhdr1("options");
477
478     sep = "";
479     for (i = 0; Options[i].opt_key; ++i) {
480         pr("%s%s", sep, Options[i].opt_key);
481         sep = " ";
482     }
483     pr("\n");
484     
485     sep = "";
486     for (i = 0; Options[i].opt_key; ++i) {
487         pr("%s%d", sep, *Options[i].opt_valuep);
488         sep = " ";
489     }
490     pr("\n");
491
492     return RET_OK;
493 }
494
495 static int
496 xdver(void)
497 {
498     struct keymatch *kp;
499     char *sep;
500     struct valstr val;
501
502     xdhdr1("version");
503
504     sep = "";
505     for (kp = configkeys; kp->km_key; ++kp) {
506         if (kp->km_type != NSC_NOTYPE && !(kp->km_flags & KM_INTERNAL)) {
507             pr("%s%s", sep, kp->km_key);
508             sep = " ";
509         }
510     }
511     pr("\n");
512     
513     sep = "";
514     for (kp = configkeys; kp->km_key; ++kp) {
515         if (kp->km_type != NSC_NOTYPE && !(kp->km_flags & KM_INTERNAL)) {
516             xdeval(&val, kp->km_type, kp->km_data, 0, 0);
517             sep = xdprval(&val, sep);
518         }
519     }
520     pr("\n");
521
522     return RET_OK;
523 }
524
525 /* Experimental extended dump command */
526 int
527 xdump(void)
528 {
529     s_char *p;
530     char buf[1024];
531     int type;
532
533     p = getstarg(player->argp[1], "What? ", buf);
534     if (!p)
535         return RET_SYN;
536
537     type = ef_byname(p);
538     if (type >= 0) {
539         return xditem(type, player->argp[2]);
540     } else if (!strncmp(p, "chr", strlen(p)) && player->argp[2]) {
541         return xdchr(chridx_by_name(player->argp[2]));
542     } else if (!strncmp(p, "opt", strlen(p))) {
543         return xdopt();
544     } else if (!strncmp(p, "ver", strlen(p))) {
545         return xdver();
546     }
547
548     return RET_SYN;
549 }