This file is indexed.

/usr/include/OpenImageIO/argparse.h is in libopenimageio-dev 1.6.17~dfsg0-1+b2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
  Copyright 2008 Larry Gritz and the other authors and contributors.
  All Rights Reserved.
  Based on BSD-licensed software Copyright 2004 NVIDIA Corp.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are
  met:
  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
  * Neither the name of the software's owners nor the names of its
    contributors may be used to endorse or promote products derived from
    this software without specific prior written permission.
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

  (This is the Modified BSD License)
*/


/// \file
/// \brief Simple parsing of program command-line arguments.


#ifndef OPENIMAGEIO_ARGPARSE_H
#define OPENIMAGEIO_ARGPARSE_H

#if defined(_MSC_VER)
// Ignore warnings about DLL exported classes with member variables that are template classes.
// This happens with the std::string m_errmessage member of ArgParse below.
#  pragma warning (disable : 4251)
#endif

#include <vector>

#include "export.h"
#include "oiioversion.h"
#include "tinyformat.h"


OIIO_NAMESPACE_BEGIN


class ArgOption;   // Forward declaration



/////////////////////////////////////////////////////////////////////////////
///
/// \class ArgParse
///
/// Argument Parsing
///
/// The parse function takes a list of options and variables or functions
/// for storing option values and return <0 on failure:
///
/// \code
///    static int parse_files (int argc, const char *argv[])
///    {
///        for (int i = 0;  i < argc;  i++)
///            filenames.push_back (argv[i]);
///        return 0;
///    }
///
///    static int blah_callback (int argc, const char *argv[])
///    {
///        std::cout << "blah argument was " << argv[1] << "\n";
///        return 0;
///    }
/// 
///    ...
///
///    ArgParse ap;
///
///    ap.options ("Usage: myapp [options] filename...",
///            "%*", parse_objects, "",
///            "-camera %f %f %f", &camera[0], &camera[1], &camera[2],
///                  "set the camera position",
///            "-lookat %f %f %f", &lx, &ly, &lz,
///                  "set the position of interest",
///            "-oversampling %d", &oversampling,  "oversamping rate",
///            "-passes %d", &passes, "number of passes",
///            "-lens %f %f %f", &aperture, &focalDistance, &focalLength,
///                   "set aperture, focal distance, focal length",
///            "-format %d %d %f", &width, &height, &aspect,
///                   "set width, height, aspect ratio",
///            "-v", &verbose, "verbose output",
///            "-q %!", &verbose, "quiet mode",
///            "--blah %@ %s", blahcallback, "Make the callback",
///            NULL);
///
///    if (ap.parse (argc, argv) < 0) {
///        std::cerr << ap.geterror() << std::endl;
///        ap.usage ();
///        return EXIT_FAILURE;
///    }
/// \endcode
///
/// The available argument types are:
///    - no \% argument - bool flag
///    - \%! - a bool flag, but set it to false if the option is set
///    - \%d - 32bit integer
///    - \%f - 32bit float
///    - \%F - 64bit float (double)
///    - \%s - std::string
///    - \%L - std::vector<std::string>  (takes 1 arg, appends to list)
///    - \%@ - a function pointer for a callback function will be invoked
///            immediately.  The prototype for the callback is
///                  int callback (int argc, char *argv[])
///    - \%* - catch all non-options and pass individually as an (argc,argv) 
///            sublist to a callback, each immediately after it's found
///
/// There are several special format tokens:
///    - "<SEPARATOR>" - not an option at all, just a description to print
///                     in the usage output.
///
/// Notes:
///   - If an option doesn't have any arguments, a bool flag argument is
///     assumed.
///   - No argument destinations are initialized.
///   - The empty string, "", is used as a global sublist (ie. "%*").
///   - Sublist functions are all of the form "int func(int argc, char **argv)".
///   - If a sublist function returns -1, parse() will terminate early.
///   - It is perfectly legal for the user to append ':' and more characters
///     to the end of an option name, it will match only the portion before
///     the semicolon (but a callback can detect the full string, this is
///     useful for making arguments:  myprog --flag:myopt=1 foobar
///
/////////////////////////////////////////////////////////////////////////////


class OIIO_API ArgParse {
public:
    ArgParse (int argc=0, const char **argv=NULL);
    ~ArgParse ();

    /// Declare the command line options.  After the introductory
    /// message, parameters are a set of format strings and variable
    /// pointers.  Each string contains an option name and a scanf-like
    /// format string to enumerate the arguments of that option
    /// (eg. "-option %d %f %s").  The format string is followed by a
    /// list of pointers to the argument variables, just like scanf.  A
    /// NULL terminates the list.  Multiple calls to options() will
    /// append additional options.
    int options (const char *intro, ...);

    /// With the options already set up, parse the command line.
    /// Return 0 if ok, -1 if it's a malformed command line.
    int parse (int argc, const char **argv);

    /// Return any error messages generated during the course of parse()
    /// (and clear any error flags).  If no error has occurred since the
    /// last time geterror() was called, it will return an empty string.
    std::string geterror () const;
    
    /// Print the usage message to stdout.  The usage message is
    /// generated and formatted automatically based on the command and
    /// description arguments passed to parse().
    void usage () const;

    /// Print a brief usage message to stdout.  The usage message is
    /// generated and formatted automatically based on the command and
    /// description arguments passed to parse().
    void briefusage () const;

    /// Return the entire command-line as one string.
    ///
    std::string command_line () const;

private:
    int m_argc;                           // a copy of the command line argc
    const char **m_argv;                  // a copy of the command line argv
    mutable std::string m_errmessage;     // error message
    ArgOption *m_global;                  // option for extra cmd line arguments
    std::string m_intro;
    std::vector<ArgOption *> m_option;

    ArgOption *find_option(const char *name);
    // void error (const char *format, ...)
    TINYFORMAT_WRAP_FORMAT (void, error, /**/,
        std::ostringstream msg;, msg, m_errmessage = msg.str();)

    int found (const char *option);      // number of times option was parsed
};



// Define symbols that let client applications determine if newly added
// features are supported.
#define OIIO_ARGPARSE_SUPPORTS_BRIEFUSAGE 1


OIIO_NAMESPACE_END


#endif // OPENIMAGEIO_ARGPARSE_H