该函数遇见位置:V4L2官网中的capture.c文件;
1.函数作用:解析命令行参数,支持长选项,如--device=/dev/video0;
Ubuntu16.04下getopt_long()函数原型:
NAME
getopt, getopt_long, getopt_long_only, optarg, optind, opterr, optopt - Parse command-line options
SYNOPSIS
#include <unistd.h>
int getopt(int argc, char * const argv[],
const char *optstring);
extern char *optarg;
extern int optind, opterr, optopt;
#include <getopt.h>
int getopt_long(int argc, char * const argv[],
const char *optstring,
const struct option *longopts, int *longindex);
int getopt_long_only(int argc, char * const argv[],
const char *optstring,
const struct option *longopts, int *longindex);
2.参数说明:
argc:传入的参数个数;
argv:传入的参数数组;
optstring:如果程序只想接收长选项,optstring应该设置为空字符串("")而不是NULL;
longopts:它是指向定义在<getopt.h>中struct option数组第一个元素的指针, struct option结构体如下:
struct option {
const char *name;
int has_arg;
int *flag;
int val;
};
The mean