Agilent Technologies E4406A VSA manual Programming Examples, Chapter

Models: E4406A VSA

1 406
Download 406 pages 63.49 Kb
Page 169
Image 169
Manual background

Programming Examples

Using C Programming Over Socket LAN (Windows NT)

getopt places in optind the argv index of the next argument to be processed. The external variable optind is initialized to 1 before the first call to the function getopt.

When all options have been processed (i.e., up to the first non-option argument), getopt returns EOF. The special option -- can be used to delimit the end of the options; EOF is returned, and -- is skipped.

***************************************************************************/

#include <stdio.h>

/* For NULL, EOF */

#include <string.h>

/* For strchr() */

char

*optarg;

/* Global argument pointer. */

int

optind = 0;

/* Global argv index. */

static char

*scan = NULL; /* Private scan pointer. */

int getopt( int argc, char * const argv[], const char* optstring)

{

char c; char *posn;

optarg = NULL;

if (scan == NULL *scan == ’\0’) { if (optind == 0)

optind++;

if (optind >= argc argv[optind][0] != ’-’ argv[optind][1] == ’\0’) return(EOF);

if (strcmp(argv[optind], "--")==0) { optind++;

return(EOF);

Chapter 3

169

Page 169
Image 169
Agilent Technologies E4406A VSA manual Programming Examples, Using C Programming Over Socket LAN Windows NT, Chapter