home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.20 / text0148.txt < prev    next >
Encoding:
Internet Message Format  |  1990-08-02  |  1.3 KB

  1. From:  mcgrath%tully.Berkeley.EDU@ucbvax.Berkeley.EDU (Roland McGrath)
  2.  
  3. In article <10461@cs.utexas.edu> rfg@lupine.uucp (Ron Guilmette) writes:
  4.    What I appear to need here is either:
  5.  
  6.        a)  a standard way to convert a va_list into a list of pointers
  7.            (to argument values), or
  8.  
  9.        b)  a standard way to modify one element of a va_list *and* a
  10.            standard function like:
  11.  
  12.            int vexeclp (char *name, va_list vargs);
  13.  
  14.    None of these things are a part of standard ANSI C (as far as I know).
  15.    Are any of them a part of POSIX?  If not, why not?
  16.  
  17. A would fall under the C standard, and B under 1003.1.  However, neither of
  18. these exist.  I imagine the answer the appropriate committees would give would
  19. be "insufficient utility".
  20.  
  21. At any rate, you can handle the case in question by doing A manually, since
  22. `execlp' has a defined way of determining its number of arguments:
  23.  
  24. {
  25.   char **argv[ARG_MAX];
  26.   register unsigned int i = 0;
  27.   va_list args;
  28.  
  29.   va_start(args, lastarg);
  30.  
  31.   do
  32.     argv[i] = va_arg(args, char *);
  33.   while (argv[i++] != NULL);
  34. }
  35.  
  36. (Actually, I would suggest dynamically allocating ARGV to avoid eating all your
  37. memory if ARG_MAX is very large.)
  38. --
  39.     Roland McGrath
  40.     Free Software Foundation, Inc.
  41. roland@ai.mit.edu, uunet!ai.mit.edu!roland
  42.  
  43. Volume-Number: Volume 20, Number 146
  44.  
  45.