argv__get_argv.c 688 B

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