home *** CD-ROM | disk | FTP | other *** search
- /* xldebug - some debug routines */
-
- #ifdef CI_86
- #include "a:stdio.h"
- #include "xlisp.h"
- #endif
-
- #ifdef AZTEC
- #include "a:stdio.h"
- #include "xlisp.h"
- #endif
-
- #ifdef unix
- #include <stdio.h>
- #include <xlisp.h>
- #endif
-
-
-
- int debug_level = 0;
- FILE *debug_fp = NULL;
-
-
-
- /***************************************************
- * xldbgmsg : Display a message in the debug file *
- ***************************************************/
-
- xldbgmsg(s)
- char *s;
- {
- if (debug_fp)
- fprintf(debug_fp, "\n%s", s);
- }
-
-
- /*******************************************
- * xldump : dump a node to the debug file *
- *******************************************/
-
- xldump(nptr)
- struct node *nptr;
- {
-
- if (debug_fp == NULL) /* Debug file open ? */
- return;
-
- fprintf(debug_fp, "\n@%4x : %2x ", nptr, nptr->n_flags);
-
- switch(nptr->n_type)
- {
- case FREE:
- fprintf(debug_fp, "FREE node");
- return;
-
- case SYM:
- fprintf(debug_fp, "SYM %s = @%4x", nptr->n_symname, nptr->n_symvalue);
- return;
-
- case LIST:
- fprintf(debug_fp, "LIST @%4x , @%4x", nptr->n_listvalue,
- nptr->n_listnext);
- return;
-
- case SUBR:
- fprintf(debug_fp, "SUBR %4x", nptr->n_subr);
- return;
-
- case INT:
- fprintf(debug_fp, "INT = %d", nptr->n_int);
- return;
-
- case STR:
- fprintf(debug_fp, "STRING = %s", nptr->n_str);
- return;
-
- case OBJ:
- fprintf(debug_fp, "OBJ @%4x , @%4x", nptr->n_obclass,
- nptr->n_obdata);
- return;
-
- case FPTR:
- fprintf(debug_fp, "FILE %4x", nptr->n_fp);
- return;
-
- case KMAP:
- fprintf(debug_fp, "KMAP");
- return;
-
- #ifdef REALS
- case REAL:
- fprintf(debug_fp, "REAL = %g", nptr->n_real);
- return;
- #endif
-
- default:
- fprintf(debug_fp, "Type %d ?????????", nptr->n_type);
- return;
- }
- }
-
-
- /************************************************
- * debug : xlisp function to set debug options *
- ************************************************/
-
- static struct node *debug(args)
- struct node *args;
- {
- debug_level = xlevmatch(INT, &args)->n_int;
-
- if (args != NULL)
- {
- if (debug_fp)
- fclose(debug_fp);
- if ((debug_fp = fopen(xlevmatch(STR, &args)->n_str, "w")) == NULL)
- xlfail("Cannot open debug file");
- xllastarg(args);
- }
-
- return (NULL);
- }
-
-
- /*******************************************
- * xldebuginit : initialize debug package *
- *******************************************/
-
- xldebuginit()
- {
- debug_leval = 0;
- debug_fp = NULL;
-
- xlsubr("debug", debug);
- }