1 /* Copyright (C) 2002 by  Red Hat, Incorporated. All rights reserved.
2  *
3  * Permission to use, copy, modify, and distribute this software
4  * is freely granted, provided that this notice is preserved.
5  */
6 
7 #include <stddef.h>
8 #include <argz.h>
9 #include <sys/types.h>
10 
11 void
argz_extract(char * argz,size_t argz_len,char ** argv)12 argz_extract (char *argz,
13        size_t argz_len,
14        char **argv)
15 {
16   size_t i = 0;
17   size_t j = 0;
18   const size_t count = argz_count(argz, argz_len);
19 
20   if (argz_len > 1)
21     for (i = argz_len - 2; i > 0; i--)
22       {
23 	if (argz[i] == '\0')
24 	  {
25 	    j++;
26 	    argv[count - j] = &argz[i + 1];
27 	  }
28       }
29   argv[0] = &argz[0];
30   argv[count] = NULL;
31 }
32