Annotation of OpenXM_contrib2/asir2000/builtin/help.c, Revision 1.1.1.1
1.1 noro 1: /* $OpenXM: OpenXM/src/asir99/builtin/help.c,v 1.1.1.1 1999/11/10 08:12:25 noro Exp $ */
2: #include "ca.h"
3: #include "parse.h"
4:
5: void Phelp();
6: void ghelp(void);
7:
8: struct ftab help_tab[] = {
9: {"help",Phelp,-1},
10: {0,0,0},
11: };
12:
13: void Phelp(arg,rp)
14: NODE arg;
15: Obj *rp;
16: {
17: if ( !arg || !ARG0(arg) )
18: help(0);
19: else
20: switch (OID(ARG0(arg))) {
21: case O_P:
22: help(NAME(VR((P)ARG0(arg))));
23: break;
24: case O_STR:
25: help(BDY((STRING)ARG0(arg)));
26: break;
27: default:
28: break;
29: }
30: *rp = 0;
31: }
32:
33: static char *ghelpstr[] = {
34: "<expression> ';' : eval and print",
35: "<expression> '$' : eval",
36: "end (quit) : close the current input stream",
37: "debug : enter the debug mode",
38: 0
39: };
40:
41: void help(s)
42: char *s;
43: {
44: extern char *asir_libdir;
45: extern char *asir_pager;
46:
47: if ( !s )
48: ghelp();
49: else {
50: #if !defined(VISUAL)
51: int i;
52: FUNC f;
53: char name[BUFSIZ],com[BUFSIZ];
54: FILE *fp;
55:
56: sprintf(name,"%s/help/%s",asir_libdir,s);
57: if ( fp = fopen(name,"r") ) {
58: fclose(fp);
59: sprintf(com,"%s %s",asir_pager,name);
60: system(com);
61: } else {
62: searchf(usrf,s,&f);
63: if ( f && f->f.usrf->desc )
64: fprintf(stderr,"%s\n",f->f.usrf->desc);
65: }
66: #endif
67: }
68: }
69:
70: void ghelp() {
71: int i;
72:
73: for ( i = 0; ghelpstr[i]; i++ )
74: fprintf(stderr,"%s\n",ghelpstr[i]);
75: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>