YAZ  5.34.0
Functions | Variables
options.c File Reference

Implements command line options parsing. More...

#include <stdlib.h>
#include <string.h>
#include <yaz/options.h>

Go to the source code of this file.

Functions

int options (const char *desc, char **argv, int argc, char **arg)
 command-line options parsing for main More...
 

Variables

static int arg_no = 1
 
static size_t arg_off = 0
 
static int eof_options = 0
 

Detailed Description

Implements command line options parsing.

Definition in file options.c.

Function Documentation

◆ options()

int options ( const char *  desc,
char **  argv,
int  argc,
char **  arg 
)

command-line options parsing for main

  • desc command argument description (allowed options)
  • argv main argv
  • argc main argc
  • arg returned argument (for options that take an argument).
    Return values
    0non-option arg (e.g. filename).
    -1unknown option (error). arg is name of unknown option
    -2no more options (end of options)
    coption char
    This function is called repeatedly for each option. Both single char options (-x) as well as GNU long options are supported (–long). The description is a sequence specs where each spec is if the form: [a-zA-Z0-9]({[a-zA-Z0-9]*})+:? . For example: h{help}f{filename}{fname}:

The first char is what is returned when met (single char option char). The second is zero ore more long option values (synonum for single char) If colon is appended, it means the option takes an argument. If argv includes empty long option (–) that means "end of options" : all argv data following that is considered non-options .. (0 returned for each).

Definition at line 21 of file options.c.

References arg_no, arg_off, eof_options, type, YAZ_OPTIONS_EOF, and YAZ_OPTIONS_ERROR.

Referenced by check_options(), process_initRequest(), ZOOM_connection_create(), ZOOM_connection_get_databases(), and ZOOM_connection_package().

Variable Documentation

◆ arg_no

int arg_no = 1
static

Definition at line 17 of file options.c.

Referenced by options().

◆ arg_off

size_t arg_off = 0
static

Definition at line 18 of file options.c.

Referenced by options().

◆ eof_options

int eof_options = 0
static

Definition at line 19 of file options.c.

Referenced by options().