|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/****************************************************************************/
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/* argv.h: a thread-safe argument vector parser and usage screen generator */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
0f42a8 |
/* Copyright (C) 2015--2017 Z. Gilboa */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/* Released under the Standard MIT License; see COPYING.SOFORT. */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/* This file is (also) part of sofort: portable software project template. */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/****************************************************************************/
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#ifndef ARGV_H
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#define ARGV_H
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#include <stdbool.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#include <stdint.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#include <stddef.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#include <string.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#include <stdlib.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#include <stdio.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
#include <unistd.h>
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#define ARGV_VERBOSITY_NONE 0x00
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#define ARGV_VERBOSITY_ERRORS 0x01
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#define ARGV_VERBOSITY_STATUS 0x02
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#define ARGV_CLONE_VECTOR 0x80
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fe1e15 |
#ifndef ARGV_TAB_WIDTH
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fe1e15 |
#define ARGV_TAB_WIDTH 8
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
8d9552 |
#endif
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
8d9552 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/*******************************************/
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* support of hybrid options */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* ------------------------- */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* hybrid options are very similar to */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* long options, yet are prefixed by */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* a single dash rather than two */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* (i.e. -std, -isystem). */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* hybrid options are supported by this */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* driver for compatibility with legacy */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* tools; note, however, that the use */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* of hybrid options should be strongly */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* discouraged due to the limitations */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* they impose on short options (for */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* example, a driver implementing -std */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* may not provide -s as a short option */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* that takes an arbitrary value). */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* SPACE: -hybrid VALUE (i.e. -MF file) */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* EQUAL: -hybrid=VALUE (i.e. -std=c99) */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
/* COMMA: -hybrid,VALUE (i.e. -Wl,<arg>) */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* ONLY: -opt accepted, --opt rejected */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
/* JOINED: -optVALUE */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/* */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
/*******************************************/
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
#define ARGV_OPTION_HYBRID_NONE 0x00
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
#define ARGV_OPTION_HYBRID_ONLY 0x01
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
#define ARGV_OPTION_HYBRID_SPACE 0x02
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
#define ARGV_OPTION_HYBRID_EQUAL 0x04
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
#define ARGV_OPTION_HYBRID_COMMA 0x08
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
#define ARGV_OPTION_HYBRID_JOINED 0x10
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
#define ARGV_OPTION_HYBRID_CIRCUS (ARGV_OPTION_HYBRID_SPACE \
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
| ARGV_OPTION_HYBRID_JOINED)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
#define ARGV_OPTION_HYBRID_DUAL (ARGV_OPTION_HYBRID_SPACE \
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
| ARGV_OPTION_HYBRID_EQUAL)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
b9cf25 |
#define ARGV_OPTION_HYBRID_SWITCH (ARGV_OPTION_HYBRID_ONLY \
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
b9cf25 |
| ARGV_OPTION_HYBRID_SPACE \
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
| ARGV_OPTION_HYBRID_EQUAL \
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
| ARGV_OPTION_HYBRID_COMMA \
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
| ARGV_OPTION_HYBRID_JOINED)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
enum argv_optarg {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_OPTARG_NONE,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_OPTARG_REQUIRED,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_OPTARG_OPTIONAL,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
enum argv_mode {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_MODE_SCAN,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_MODE_COPY,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
enum argv_error {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_ERROR_OK,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_ERROR_INTERNAL,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_ERROR_SHORT_OPTION,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_ERROR_LONG_OPTION,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_ERROR_OPTARG_NONE,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_ERROR_OPTARG_REQUIRED,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ARGV_ERROR_OPTARG_PARADIGM,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ARGV_ERROR_HYBRID_NONE,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ARGV_ERROR_HYBRID_ONLY,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ARGV_ERROR_HYBRID_SPACE,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ARGV_ERROR_HYBRID_EQUAL,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
ARGV_ERROR_HYBRID_COMMA,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_option {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * long_name;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char short_name;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int tag;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
enum argv_optarg optarg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
int flags;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * paradigm;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * argname;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * description;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_entry {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * arg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int tag;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
bool fopt;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
bool fval;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
bool fnoscan;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
enum argv_error errcode;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_meta {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
4a749a |
char ** argv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_entry * entries;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_meta_impl {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
4a749a |
char ** argv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
char * strbuf;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_meta meta;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_ctx {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int flags;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int mode;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int nentries;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
1687ac |
intptr_t unitidx;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
1687ac |
intptr_t erridx;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
enum argv_error errcode;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * errch;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const struct argv_option * erropt;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * program;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fc0fa2 |
#ifdef ARGV_DRIVER
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
fc0fa2 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
static int argv_optv_init(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option[],
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option **);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static const char * argv_program_name(const char *);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static void argv_usage(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
FILE *,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * header,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option **,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * mode);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static struct argv_meta * argv_get(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
4a749a |
char **,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option **,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int flags);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static void argv_free(struct argv_meta *);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/*------------------------------------*/
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/* implementation of static functions */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/*------------------------------------*/
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
static int argv_optv_init(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option options[],
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** optv)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option * option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
int i;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
for (option=options,i=0; option->long_name || option->short_name; option++)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
optv[i++] = option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
optv[i] = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
return i;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static const struct argv_option * argv_short_option(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * ch,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** optv,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_entry * entry)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const struct argv_option * option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
for (; *optv; optv++) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
option = *optv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (option->short_name == *ch) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
entry->tag = option->tag;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
entry->fopt = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static const struct argv_option * argv_long_option(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * ch,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** optv,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_entry * entry)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const struct argv_option * option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * arg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
size_t len;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
for (; *optv; optv++) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
option = *optv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
len = option->long_name ? strlen(option->long_name) : 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (len && !(strncmp(option->long_name,ch,len))) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
arg = ch + len;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
if (!*arg
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
|| (*arg == '=')
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
|| (option->flags & ARGV_OPTION_HYBRID_JOINED)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
|| ((option->flags & ARGV_OPTION_HYBRID_COMMA)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
&& (*arg == ','))) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
entry->tag = option->tag;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
entry->fopt = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
return option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static inline bool is_short_option(const char * arg)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return (arg[0]=='-') && arg[1] && (arg[1]!='-');
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static inline bool is_long_option(const char * arg)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return (arg[0]=='-') && (arg[1]=='-') && arg[2];
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static inline bool is_last_option(const char * arg)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return (arg[0]=='-') && (arg[1]=='-') && !arg[2];
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
static inline bool is_hybrid_option(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
const char * arg,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** optv)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
const struct argv_option * option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
struct argv_entry entry;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
if (!is_short_option(arg))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
return false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
if (!(option = argv_long_option(++arg,optv,&entry)))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
return false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
if (!(option->flags & ARGV_OPTION_HYBRID_SWITCH))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
if (argv_short_option(arg,optv,&entry))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
return false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
return true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static inline bool is_arg_in_paradigm(const char * arg, const char * paradigm)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
size_t len;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * ch;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
for (ch=paradigm,len=strlen(arg); ch; ) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (!strncmp(arg,ch,len)) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (!*(ch += len))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (*ch == '|')
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if ((ch = strchr(ch,'|')))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static inline const struct argv_option * option_from_tag(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** optv,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int tag)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
for (; *optv; optv++)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
if (optv[0]->tag == tag)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
return optv[0];
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static void argv_scan(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
4a749a |
char ** argv,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** optv,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_ctx * ctx,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_meta * meta)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
4a749a |
char ** parg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * ch;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * val;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const struct argv_option * option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_entry entry;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_entry * mentry;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
enum argv_error ferr;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
bool fval;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
bool fnext;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
bool fshort;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
bool fhybrid;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
bool fnoscan;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
parg = &argv[1];
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch = *parg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OK;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fshort = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fnoscan = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry = meta ? meta->entries : 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
ctx->unitidx = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
ctx->erridx = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
while (ch && (ferr == ARGV_ERROR_OK)) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
option = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
fhybrid = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (fnoscan)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (is_last_option(ch))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fnoscan = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
else if (!fshort && is_hybrid_option(ch,optv))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
fhybrid = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
if (!fnoscan && !fhybrid && (fshort || is_short_option(ch))) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (!fshort)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
if ((option = argv_short_option(ch,optv,&entry))) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (ch[1]) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fnext = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fshort = (option->optarg == ARGV_OPTARG_NONE);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
parg++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch = *parg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fnext = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fshort = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (option->optarg == ARGV_OPTARG_NONE) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
307cae |
if (!fnext && ch && (*ch == '-')) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_NONE;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
307cae |
} else {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
307cae |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
307cae |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
307cae |
} else if (!fnext) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
307cae |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
307cae |
} else if (option->optarg == ARGV_OPTARG_REQUIRED) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (ch && is_short_option(ch))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_REQUIRED;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (ch && is_long_option(ch))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_REQUIRED;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (ch && is_last_option(ch))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_REQUIRED;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (ch)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_REQUIRED;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/* ARGV_OPTARG_OPTIONAL */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (ch && is_short_option(ch))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (ch && is_long_option(ch))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (ch && is_last_option(ch))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
2ff444 |
else if (fnext)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
2ff444 |
fval = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = ch;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
307cae |
} else {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_SHORT_OPTION;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
307cae |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
} else if (!fnoscan && (fhybrid || is_long_option(ch))) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ch += (fhybrid ? 1 : 2);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
if ((option = argv_long_option(ch,optv,&entry))) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
val = ch + strlen(option->long_name);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
/* val[0] is either '=' (or ',') or '\0' */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (!val[0]) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
parg++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch = *parg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
if (fhybrid && !(option->flags & ARGV_OPTION_HYBRID_SWITCH))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_HYBRID_NONE;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
13f711 |
else if (!fhybrid && (option->flags & ARGV_OPTION_HYBRID_ONLY))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
13f711 |
ferr = ARGV_ERROR_HYBRID_ONLY;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
else if (option->optarg == ARGV_OPTARG_NONE) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (val[0]) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_NONE;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->errch = val + 1;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = false;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
13f711 |
} else if (val[0] && (option->flags & ARGV_OPTION_HYBRID_JOINED)) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
fval = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
ch = val;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
} else if (fhybrid && !val[0] && !(option->flags & ARGV_OPTION_HYBRID_SPACE))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_HYBRID_SPACE;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
else if (fhybrid && (val[0]=='=') && !(option->flags & ARGV_OPTION_HYBRID_EQUAL))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_HYBRID_EQUAL;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
else if (fhybrid && (val[0]==',') && !(option->flags & ARGV_OPTION_HYBRID_COMMA))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_HYBRID_COMMA;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
else if (!fhybrid && (val[0]==','))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_HYBRID_COMMA;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
else if (val[0] && !val[1])
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_REQUIRED;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (val[0] && val[1]) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch = ++val;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else if (option->optarg == ARGV_OPTARG_REQUIRED) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (!val[0] && !*parg)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_REQUIRED;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (*parg && is_short_option(*parg))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_REQUIRED;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (*parg && is_long_option(*parg))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_REQUIRED;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (*parg && is_last_option(*parg))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_REQUIRED;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fval = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
/* ARGV_OPTARG_OPTIONAL */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
89e8cb |
fval = val[0];
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_LONG_OPTION;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
if (ferr == ARGV_ERROR_OK)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (option && fval && option->paradigm)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (!is_arg_in_paradigm(ch,option->paradigm))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ferr = ARGV_ERROR_OPTARG_PARADIGM;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
if (ferr == ARGV_ERROR_OK)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
if (!option && !ctx->unitidx)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
ctx->unitidx = parg - argv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
if (ferr != ARGV_ERROR_OK) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ce3e34 |
ctx->errcode = ferr;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->errch = ctx->errch ? ctx->errch : ch;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt = option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
ctx->erridx = parg - argv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else if (ctx->mode == ARGV_MODE_SCAN) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (!fnoscan)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->nentries++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else if (fval)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->nentries++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (fval || !option) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
parg++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch = *parg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else if (ctx->mode == ARGV_MODE_COPY) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (fnoscan) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (fval) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry->arg = ch;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry->fnoscan = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
parg++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch = *parg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else if (option) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry->arg = fval ? ch : 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry->tag = option->tag;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry->fopt = true;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry->fval = fval;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (fval) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
parg++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch = *parg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry->arg = ch;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
mentry++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
parg++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ch = *parg;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static const char * argv_program_name(const char * program_path)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * ch;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (program_path) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if ((ch = strrchr(program_path,'/')))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return *(++ch) ? ch : 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if ((ch = strrchr(program_path,'\\')))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return *(++ch) ? ch : 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return program_path;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static void argv_show_error(struct argv_ctx * ctx)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
char opt_short_name[2] = {0,0};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
if (ctx->erropt && ctx->erropt->short_name)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name[0] = ctx->erropt->short_name;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fprintf(stderr,"%s: error: ",ctx->program);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
switch (ctx->errcode) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
case ARGV_ERROR_SHORT_OPTION:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
9a57db |
fprintf(stderr,"'-%c' is not a valid short option\n",*ctx->errch);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
case ARGV_ERROR_LONG_OPTION:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fprintf(stderr,"'--%s' is not a valid long option\n",ctx->errch);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
case ARGV_ERROR_OPTARG_NONE:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
fprintf(stderr,"'%s' is not a valid option value for [%s%s%s%s%s] "
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
134b58 |
"(option values may not be specified)\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->errch,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name[0] ? "-" : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name[0] ? "," : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->long_name ? "--" : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->long_name);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
case ARGV_ERROR_OPTARG_REQUIRED:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
fprintf(stderr,"option [%s%s%s%s%s] requires %s %s%s%s\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name[0] ? "-" : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name[0] ? "," : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->long_name ? "--" : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->long_name,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->paradigm ? "one of the following values:" : "a value",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->paradigm ? "{" : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->paradigm ? ctx->erropt->paradigm : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->paradigm ? "}" : "");
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
case ARGV_ERROR_OPTARG_PARADIGM:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
fprintf(stderr,"'%s' is not a valid option value for [%s%s%s%s%s]={%s}\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->errch,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name[0] ? "-" : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3f3328 |
opt_short_name[0] ? "," : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->long_name ? "--" : "",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->long_name,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx->erropt->paradigm);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
case ARGV_ERROR_HYBRID_NONE:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
fprintf(stderr,"-%s is not a synonym for --%s\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ctx->erropt->long_name,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ctx->erropt->long_name);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
case ARGV_ERROR_HYBRID_ONLY:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
fprintf(stderr,"--%s is not a synonym for -%s\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ctx->erropt->long_name,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ctx->erropt->long_name);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
case ARGV_ERROR_HYBRID_SPACE:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
case ARGV_ERROR_HYBRID_EQUAL:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
case ARGV_ERROR_HYBRID_COMMA:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
fprintf(stderr,"-%s: illegal value assignment; valid syntax is "
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
"-%s%sVAL\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
ctx->erropt->long_name,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
ctx->erropt->long_name,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
(ctx->erropt->flags & ARGV_OPTION_HYBRID_SPACE)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
? " " : (ctx->erropt->flags & ARGV_OPTION_HYBRID_EQUAL)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
? "=" : (ctx->erropt->flags & ARGV_OPTION_HYBRID_COMMA)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
ae0e7a |
? "," : "");
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
35b2ff |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
3bc17b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
case ARGV_ERROR_INTERNAL:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fputs("internal error",stderr);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
default:
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
break;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static void argv_show_status(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** optv,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_ctx * ctx,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_meta * meta)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int argc;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
4a749a |
char ** argv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_entry * entry;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const struct argv_option * option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
char short_name[2] = {0};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * space = "";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
269baf |
(void)ctx;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
269baf |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fputs("\n\nconcatenated command line:\n",stderr);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
for (argv=meta->argv; *argv; argv++) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fprintf(stderr,"%s%s",space,*argv);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
space = " ";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fputs("\n\nargument vector:\n",stderr);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
for (argc=0,argv=meta->argv; *argv; argc++,argv++)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fprintf(stderr,"argv[%d]: %s\n",argc,*argv);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fputs("\n\nparsed entries:\n",stderr);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
for (entry=meta->entries; entry->arg || entry->fopt; entry++)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (entry->fopt) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
option = option_from_tag(optv,entry->tag);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
short_name[0] = option->short_name;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (entry->fval)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fprintf(stderr,"[-%s,--%s] := %s\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
short_name,option->long_name,entry->arg);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fprintf(stderr,"[-%s,--%s]\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
short_name,option->long_name);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fprintf(stderr,"<program arg> := %s\n",entry->arg);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
fputs("\n\n",stderr);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static struct argv_meta * argv_free_impl(struct argv_meta_impl * imeta)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (imeta->argv)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
free(imeta->argv);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (imeta->strbuf)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
free(imeta->strbuf);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (imeta->meta.entries)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
free(imeta->meta.entries);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
free(imeta);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
4a749a |
static struct argv_meta * argv_alloc(char ** argv, struct argv_ctx * ctx)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_meta_impl * imeta;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
4a749a |
char ** vector;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
char * dst;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
size_t size;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int argc;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int i;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
cb73f2 |
if (!(imeta = calloc(1,sizeof(*imeta))))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (ctx->flags & ARGV_CLONE_VECTOR) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
for (vector=argv,argc=0,size=0; *vector; vector++) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
size += strlen(*vector) + 1;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
argc++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
cb73f2 |
if (!(imeta->argv = calloc(argc+1,sizeof(char *))))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return argv_free_impl(imeta);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
cb73f2 |
else if (!(imeta->strbuf = calloc(1,size+1)))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return argv_free_impl(imeta);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
for (i=0,dst=imeta->strbuf; i
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
strcpy(dst,argv[i]);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
imeta->argv[i] = dst;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
dst += strlen(dst)+1;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
imeta->meta.argv = imeta->argv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
} else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
imeta->meta.argv = argv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
cb73f2 |
if (!(imeta->meta.entries = calloc(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
cb73f2 |
ctx->nentries+1,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
cb73f2 |
sizeof(struct argv_entry))))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return argv_free_impl(imeta);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return &imeta->meta;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static struct argv_meta * argv_get(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
4a749a |
char * argv[],
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** optv,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
int flags)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_meta * meta;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
bc240f |
struct argv_ctx ctx = {flags,ARGV_MODE_SCAN,0,0,0,0,0,0,0};
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
argv_scan(argv,optv,&ctx,0);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (ctx.errcode != ARGV_ERROR_OK) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
dab371 |
ctx.program = argv_program_name(argv[0]);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (ctx.flags & ARGV_VERBOSITY_ERRORS)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
argv_show_error(&ctx;;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (!(meta = argv_alloc(argv,&ctx)))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx.mode = ARGV_MODE_COPY;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
argv_scan(meta->argv,optv,&ctx,meta);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (ctx.errcode != ARGV_ERROR_OK) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
dab371 |
ctx.program = argv[0];
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
ctx.errcode = ARGV_ERROR_INTERNAL;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
argv_show_error(&ctx;;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
argv_free(meta);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (ctx.flags & ARGV_VERBOSITY_STATUS)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
argv_show_status(optv,&ctx,meta);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
return meta;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static void argv_free(struct argv_meta * xmeta)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
struct argv_meta_impl * imeta;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
uintptr_t addr;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
if (xmeta) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
addr = (uintptr_t)xmeta - offsetof(struct argv_meta_impl,meta);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
imeta = (struct argv_meta_impl *)addr;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
argv_free_impl(imeta);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
static void argv_usage(
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
FILE * file,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * header,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** options,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
const char * mode)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
{
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
const struct argv_option ** optv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
const struct argv_option * option;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
bool fshort,flong,fboth;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
size_t len,optlen,desclen;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
char cache;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
char * prefix;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
char * desc;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
char * mark;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
char * cap;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
char description[4096];
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
char optstr [72];
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
const size_t optcap = 64;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
const size_t width = 80;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
const char indent[] = " ";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
const char creset[] = "\x1b[0m";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
const char cbold [] = "\x1b[1m";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
const char cgreen[] = "\x1b[32m";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
const char cblue [] = "\x1b[34m";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
const char ccyan [] = "\x1b[36m";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
const char * color = ccyan;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
bool fcolor;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
fshort = mode ? !strcmp(mode,"short") : 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
flong = fshort ? 0 : mode && !strcmp(mode,"long");
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
fboth = !fshort && !flong;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
7c936b |
fcolor = isatty(fileno(file));
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
if (fcolor)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
7c936b |
fprintf(file,"%s%s",cbold,cgreen);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (header)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
7c936b |
fprintf(file,"%s",header);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
for (optlen=0,optv=options; *optv; optv++) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
option = *optv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* indent + comma */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
len = fboth ? sizeof(indent) + 1 : sizeof(indent);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* -o */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (fshort || fboth)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
len += option->short_name
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
? 2 : 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* --option */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (flong || fboth)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
len += option->long_name
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
? 2 + strlen(option->long_name) : 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* optlen */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (len > optlen)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
optlen = len;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (optlen >= optcap) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
fprintf(stderr,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
"Option strings exceed %zu characters, "
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
"please generate the usage screen manually.\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
optcap);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
return;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
optlen += ARGV_TAB_WIDTH;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
optlen &= (~(ARGV_TAB_WIDTH-1));
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
desclen = (optlen < width / 2) ? width - optlen : optlen;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
for (optv=options; *optv; optv++) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
option = *optv;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
a04059 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
/* color */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
if (fcolor) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
color = (color == ccyan) ? cblue : ccyan;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
7c936b |
fputs(color,file);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* description, using either paradigm or argname if applicable */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
snprintf(description,sizeof(description),option->description,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
option->paradigm
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
? option->paradigm
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
: option->argname ? option->argname : "");
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
description[sizeof(description)-1] = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* long/hybrid option prefix (-/--) */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
prefix = option->flags & ARGV_OPTION_HYBRID_ONLY
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
? " -" : "--";
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* option string */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (fboth && option->short_name && option->long_name)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
sprintf(optstr,"%s-%c,%s%s",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
indent,option->short_name,prefix,option->long_name);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
else if ((fshort || fboth) && option->short_name)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
2cab02 |
sprintf(optstr,"%s-%c",indent,option->short_name);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
else if (flong && option->long_name)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
sprintf(optstr,"%s%s%s",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
indent,prefix,option->long_name);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
else if (fboth && option->long_name)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
sprintf(optstr,"%s %s%s",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
indent,prefix,option->long_name);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
optstr[0] = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* right-indented option buffer */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (description[0]) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
len = strlen(optstr);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
sprintf(&optstr[len],"%-*c",(int)(optlen-len),' ');
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* single line? */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (optlen + strlen(description) < width) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
7c936b |
fprintf(file,"%s%s\n",optstr,description);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
} else {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
desc = description;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
cap = desc + strlen(description);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
while (desc < cap) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
mark = (desc + desclen >= cap)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
? cap : desc + desclen;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
while (*mark && (mark > desc)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
&& (*mark != ' ')
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
57726e |
&& (*mark != '|')
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
&& (*mark != '\t')
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
&& (*mark != '\n'))
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
mark--;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (mark == desc) {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
mark = (desc + desclen >= cap)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
? cap : desc + desclen;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
cache = *mark;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
*mark = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
57726e |
} else if (*mark == '|') {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
57726e |
cache = *mark;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
57726e |
*mark = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
} else {
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
cache = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
*mark = 0;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
/* first line? */
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (desc == description)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
7c936b |
fprintf(file,"%s%s\n",optstr,desc);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
7c936b |
fprintf(file,"%-*c %s\n",
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
57726e |
(*desc == '|')
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
57726e |
? (int)(optlen+1)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
57726e |
: (int)optlen,
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
57726e |
' ',desc);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
if (cache)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
*mark = cache;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
else
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
mark++;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
desc = mark;
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
882f55 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
eca81b |
if (fcolor)
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
7c936b |
fputs(creset,file);
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
}
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#endif
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
|
|
![](https://seccdn.libravatar.org/avatar/010a04b188371137c95e3f06f2c34ffc76c25df631461eee33740684fe5e265f?s=16&d=retro) |
f46039 |
#endif
|