arg.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2017 Richard Braun.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. *
  18. * Kernel command line argument parsing.
  19. *
  20. * Arguments are separated by spaces (there is no escape character).
  21. * They can be of the form "name" when used as boolean values (present
  22. * or not), or "name=value".
  23. */
  24. #ifndef KERN_ARG_H
  25. #define KERN_ARG_H
  26. #include <stdbool.h>
  27. #include <kern/init.h>
  28. #define ARG_CMDLINE_MAX_SIZE 256
  29. /*
  30. * Set the command line string.
  31. *
  32. * This function must be called before calling the kernel main entry point.
  33. */
  34. void arg_set_cmdline (const char *cmdline);
  35. /*
  36. * Log command line information.
  37. */
  38. void arg_log_info (void);
  39. /*
  40. * Return true if an argument with the given name is present in the
  41. * command line.
  42. */
  43. bool arg_present (const char *name);
  44. /*
  45. * Return the value of the argument with the given name in the command
  46. * line.
  47. *
  48. * If the argument form is "name", the empty string is returned. If the
  49. * argument isn't present, NULL is returned.
  50. */
  51. const char * arg_value (const char *name);
  52. /*
  53. * This init operation provides :
  54. * - command line arguments can be retrieved
  55. */
  56. INIT_OP_DECLARE (arg_setup);
  57. #endif