156
Chapter 3
Programming Examples
Using C Programming Over Socket LAN (Windows NT)
Example:
/***************************************************************************
getopt(3C) getopt(3C)
NAME
getopt - get option letter from argument vector
SYNOPSIS
int getopt(int argc, char * const argv[], const char *optstring);
extern char *optarg;
extern int optind, opterr, optopt;
DESCRIPTION
getopt returns the next option letter in argv (starting from argv[1])
that matches a letter in optstring. optstring is a string of
recognized option letters; if a letter is followed by a colon, the
option is expected to have an argument that may or may not be
separated from it by white space. optarg is set to point to the start
of the option argument on return from getopt.
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)
+;
Summary of Contents for E4406A VSA Series
Page 4: ...4 ...
Page 59: ...59 2 Programming Fundamentals ...
Page 124: ...124 Chapter2 Programming Fundamentals Using the LAN to Control the Analyzer ...
Page 125: ...125 3 Programming Examples ...
Page 164: ...164 Chapter3 Programming Examples Using Java Programming Over Socket LAN ...
Page 165: ...165 4 Programming Command Cross References ...
Page 379: ...379 6 Error Messages ...
Page 412: ...412 Chapter6 Error Messages Error Message Descriptions ...