plugin_init.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. context = context; // Happy compiler
  37. return 0;
  38. }
  39. int kplugin_klish_fini(kcontext_t *context)
  40. {
  41. // fprintf(stderr, "Plugin 'klish' fini\n");
  42. context = context;
  43. return 0;
  44. }