arg.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2003,2005,2007 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef GRUB_ARG_HEADER
  19. #define GRUB_ARG_HEADER 1
  20. #include <grub/symbol.h>
  21. #include <grub/err.h>
  22. #include <grub/types.h>
  23. enum grub_arg_type
  24. {
  25. ARG_TYPE_NONE,
  26. ARG_TYPE_STRING,
  27. ARG_TYPE_INT,
  28. ARG_TYPE_DEVICE,
  29. ARG_TYPE_FILE,
  30. ARG_TYPE_DIR,
  31. ARG_TYPE_PATHNAME
  32. };
  33. typedef enum grub_arg_type grub_arg_type_t;
  34. /* Flags for the option field op grub_arg_option. */
  35. #define GRUB_ARG_OPTION_OPTIONAL (1 << 1)
  36. /* Flags for an option that can appear multiple times. */
  37. #define GRUB_ARG_OPTION_REPEATABLE (1 << 2)
  38. enum grub_key_type
  39. {
  40. GRUB_KEY_ARG = -1,
  41. GRUB_KEY_END = -2
  42. };
  43. typedef enum grub_key_type grub_arg_key_type_t;
  44. struct grub_arg_option
  45. {
  46. const char *longarg;
  47. int shortarg;
  48. int flags;
  49. const char *doc;
  50. const char *arg;
  51. grub_arg_type_t type;
  52. };
  53. struct grub_arg_list
  54. {
  55. int set;
  56. union {
  57. char *arg;
  58. char **args;
  59. };
  60. };
  61. struct grub_extcmd;
  62. int grub_arg_parse (struct grub_extcmd *cmd, int argc, char **argv,
  63. struct grub_arg_list *usr, char ***args, int *argnum);
  64. void EXPORT_FUNC(grub_arg_show_help) (struct grub_extcmd *cmd);
  65. struct grub_arg_list* grub_arg_list_alloc (struct grub_extcmd *cmd,
  66. int argc, char *argv[]);
  67. #endif /* ! GRUB_ARG_HEADER */