# include "basic.h"

// XXX add a warning if ohana_memory is not compiled in 
int memory (int argc, char **argv) {
  
  if (argc < 2) goto usage;

  if (!strcasecmp (argv[1], "all")) {
    ohana_memdump (1);
    return (TRUE);
  }
  if (!strcasecmp (argv[1], "leaks")) {
    ohana_memdump (0);
    return (TRUE);
  }
  if (!strcasecmp (argv[1], "check")) {
    ohana_memcheck (0);
    return (TRUE);
  }
  if (!strcasecmp (argv[1], "checkfree")) {
    ohana_memcheck (1);
    return (TRUE);
  }
  if (!strncasecmp ("variables", argv[1], strlen(argv[1]))) {
    ListVariables ();
    return (TRUE);
  }
  if (!strncasecmp ("vectors", argv[1], strlen(argv[1]))) {
    ListVectors ();
    return (TRUE);
  }
  if (!strncasecmp ("buffers", argv[1], strlen(argv[1]))) {
    PrintBuffers (0);
    return (TRUE);
  }
  if (!strncasecmp ("macros", argv[1], strlen(argv[1]))) {
    ListMacros();
    return (TRUE);
  }
  if (!strncasecmp ("commands", argv[1], strlen(argv[1]))) {
    print_commands (stderr);
    return (TRUE);
  }

usage:
  gprint (GP_ERR, "USAGE: memory (all/leaks)\n");
  return (FALSE);
}
