[BACK]Return to help.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / builtin

Annotation of OpenXM_contrib2/asir2000/builtin/help.c, Revision 1.2

1.2     ! noro        1: /* $OpenXM: OpenXM_contrib2/asir2000/builtin/help.c,v 1.1.1.1 1999/12/03 07:39:07 noro Exp $ */
1.1       noro        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;
1.2     ! noro       46:        char *e;
        !            47:        static char helpdir[16];
        !            48:
        !            49:        if ( !helpdir[0] ) {
        !            50:                e = (char *)getenv("LANG");
        !            51:                if ( !e )
        !            52:                        strcpy(helpdir,"help");
        !            53:                else if ( !strncmp(e,"japan",strlen("japan"))
        !            54:                        || !strncmp(e,"ja_JP",strlen("ja_JP")) )
        !            55:                        strcpy(helpdir,"help-jp");
        !            56:                else
        !            57:                        strcpy(helpdir,"help-eg");
        !            58:        }
1.1       noro       59:
                     60:        if ( !s )
                     61:                ghelp();
                     62:        else {
                     63: #if !defined(VISUAL)
                     64:                int i;
                     65:                FUNC f;
                     66:                char name[BUFSIZ],com[BUFSIZ];
                     67:                FILE *fp;
                     68:
1.2     ! noro       69:                sprintf(name,"%s/%s/%s",asir_libdir,helpdir,s);
1.1       noro       70:                if ( fp = fopen(name,"r") ) {
                     71:                        fclose(fp);
                     72:                        sprintf(com,"%s %s",asir_pager,name);
                     73:                        system(com);
                     74:                } else {
                     75:                        searchf(usrf,s,&f);
                     76:                        if ( f && f->f.usrf->desc )
                     77:                                fprintf(stderr,"%s\n",f->f.usrf->desc);
                     78:                }
                     79: #endif
                     80:        }
                     81: }
                     82:
                     83: void ghelp() {
                     84:        int i;
                     85:
                     86:        for ( i = 0; ghelpstr[i]; i++ )
                     87:                fprintf(stderr,"%s\n",ghelpstr[i]);
                     88: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>