summaryrefslogtreecommitdiff
path: root/contrib/vdr2jpeg/tools.cpp
blob: 9e73352f6ed380b40bea0442582ccf7ea0ccc427 (plain)
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
/*
 * Simple program to grab images from VDR Recording
 *
 * Copyright(c) 2007-2008 Andreas Brachold
 *
 * This code is distributed under the terms and conditions of the
 * GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
 *
 */

#include <string.h>
#include "tools.h"

int option(int argc, char *argv[], const char opt, bool bParam,
    std::string & param, int n)
{
    for(int i = n; i < argc; ++i)
    {
        if(argv[i] && strlen(argv[i]) > 1)
        {
            switch(*(argv[i] + 0))
            {
                case '-':
                {
                    if(*(argv[i] + 1) == opt)
                    {
                        if(!bParam)
                            return i + 1;
                        if(i + 1 < argc)
                        {
                            param = argv[i + 1];
                            return i + 2;
                        }
                    }
                }
            }
        }
    }
    return -1;
}