Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. /*
  3. ** Get command line argument.
  4. ** Entry: n    = Number of the argument.
  5. **        s    = Destination string pointer.
  6. **        size = Size of destination string.
  7. **        argc = Argument count from main().
  8. **        argv = Argument vector(s) from main().
  9. ** Returns number of characters moved on success,
  10. ** else EOF.
  11. */
  12. getarg(n,s,size,argc,argv)
  13.  int n; char *s; int size,argc,argv[];
  14. {char *str;
  15.  int i;
  16.  
  17.  if(n<0 | n>=argc)
  18.  {*s=NULL;
  19.   return EOF;
  20.  }
  21.  i=0;
  22.  str=argv[n];
  23.  while(i<size)
  24.  {if((s[i]=str[i])==NULL) break;
  25.   ++i;
  26.  }
  27.  s[i]=NULL;
  28.  return i;
  29. }
  30.