clish_startup.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * clish_startup.c
  3. */
  4. #ifdef HAVE_CONFIG_H
  5. #include "config.h"
  6. #endif /* HAVE_CONFIG_H */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #ifdef DMALLOC
  11. #include <dmalloc.h>
  12. #endif /* DMALLOC */
  13. #include "private.h"
  14. /*--------------------------------------------------------- */
  15. static void usage(const char *filename)
  16. {
  17. printf("%s [-help] [scriptname]\n", filename);
  18. printf(" -help : display this usage\n");
  19. printf(" scriptname : run the commands in the specified file\n");
  20. printf("\n");
  21. printf("VERSION %s\n\n", PACKAGE_VERSION);
  22. printf("ENVIRONMENT\n");
  23. printf
  24. (" CLISH_PATH : Set to a semicolon separated list of directories\n");
  25. printf
  26. (" which should be searched for XML definition files.\n");
  27. printf(" Current Value: '%s'\n", getenv("CLISH_PATH"));
  28. printf
  29. (" If undefined then '/etc/clish;~/.clish' will be used.\n");
  30. }
  31. /*--------------------------------------------------------- */
  32. void clish_startup(int argc, const char **argv)
  33. {
  34. #ifdef DMALLOC
  35. /*
  36. * Get environ variable DMALLOC_OPTIONS and pass the settings string
  37. * on to dmalloc_debug_setup to setup the dmalloc debugging flags.
  38. */
  39. dmalloc_debug_setup(getenv("DMALLOC_OPTIONS"));
  40. #endif
  41. if (argc > 1) {
  42. const char *help_switch = "-help";
  43. if (strstr(help_switch, argv[1]) == help_switch) {
  44. usage(argv[0]);
  45. exit(1);
  46. }
  47. }
  48. }
  49. /*--------------------------------------------------------- */