plugin_init.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. *
  3. */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <stdint.h>
  7. #include <assert.h>
  8. #include <faux/faux.h>
  9. #include <klish/kplugin.h>
  10. #include <klish/kcontext.h>
  11. #include "private.h"
  12. const uint8_t kplugin_klish_major = KPLUGIN_MAJOR;
  13. const uint8_t kplugin_klish_minor = KPLUGIN_MINOR;
  14. int kplugin_klish_init(kcontext_t *context)
  15. {
  16. kplugin_t *plugin = NULL;
  17. ksym_t *sym = NULL;
  18. assert(context);
  19. plugin = kcontext_plugin(context);
  20. assert(plugin);
  21. // Misc
  22. kplugin_add_syms(plugin, ksym_new_ext("nop", klish_nop,
  23. KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
  24. kplugin_add_syms(plugin, ksym_new("tsym", klish_tsym));
  25. // Navigation
  26. // Navigation must be permanent (no dry-run) and sync. Because unsync
  27. // actions will be fork()-ed so it can't change current path.
  28. kplugin_add_syms(plugin, ksym_new_ext("nav", klish_nav,
  29. KSYM_PERMANENT, KSYM_SYNC));
  30. // PTYPEs
  31. // These PTYPEs are simple and fast so set SYNC flag
  32. kplugin_add_syms(plugin, ksym_new_ext("COMMAND", klish_ptype_COMMAND,
  33. KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
  34. kplugin_add_syms(plugin, ksym_new_ext("COMMAND_CASE", klish_ptype_COMMAND_CASE,
  35. KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
  36. kplugin_add_syms(plugin, ksym_new_ext("INT", klish_ptype_INT,
  37. KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
  38. kplugin_add_syms(plugin, ksym_new_ext("UINT", klish_ptype_UINT,
  39. KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
  40. return 0;
  41. }
  42. int kplugin_klish_fini(kcontext_t *context)
  43. {
  44. // fprintf(stderr, "Plugin 'klish' fini\n");
  45. context = context;
  46. return 0;
  47. }