1
0

argv__get_argv.c 729 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * argv__get_argv.c
  3. */
  4. #include <stdlib.h>
  5. #include "private.h"
  6. /*--------------------------------------------------------- */
  7. const char *
  8. lub_argv__get_line(const lub_argv_t *this)
  9. {
  10. return this->line;
  11. }
  12. /*--------------------------------------------------------- */
  13. char **
  14. lub_argv__get_argv(const lub_argv_t *this, char *argv0)
  15. {
  16. char **result = NULL;
  17. unsigned i;
  18. unsigned a = 0;
  19. if(argv0)
  20. a = 1;
  21. result = malloc(sizeof(char *) * (this->argc + 1 + a));
  22. if(argv0)
  23. result[0] = argv0;
  24. for(i = 0; i < this->argc; i++)
  25. result[i + a] = this->argv[i].arg;
  26. result[i + a] = NULL;
  27. return result;
  28. }
  29. /*--------------------------------------------------------- */