|
@@ -1,23 +1,49 @@
|
|
#include <libmegapixels.h>
|
|
#include <libmegapixels.h>
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
#include <limits.h>
|
|
#include <limits.h>
|
|
|
|
+#include <getopt.h>
|
|
|
|
+#include <ctype.h>
|
|
|
|
|
|
int
|
|
int
|
|
-main()
|
|
|
|
|
|
+main(int argc, char *argv[])
|
|
{
|
|
{
|
|
|
|
+ int c;
|
|
|
|
+
|
|
char configpath[PATH_MAX];
|
|
char configpath[PATH_MAX];
|
|
int ret = libmegapixels_find_config(configpath);
|
|
int ret = libmegapixels_find_config(configpath);
|
|
|
|
|
|
|
|
+ while ((c = getopt(argc, argv, "c:")) != -1) {
|
|
|
|
+ switch (c) {
|
|
|
|
+ case 'c':
|
|
|
|
+ sprintf(configpath, "%s", optarg);
|
|
|
|
+ ret = 1;
|
|
|
|
+ break;
|
|
|
|
+ case '?':
|
|
|
|
+ if (optopt == 'd' || optopt == 'l') {
|
|
|
|
+ fprintf(stderr, "Option -%c requires an argument.\n", optopt);
|
|
|
|
+ } else if (isprint(optopt)) {
|
|
|
|
+ fprintf(stderr, "Unknown option '-%c'\n", optopt);
|
|
|
|
+ } else {
|
|
|
|
+ fprintf(stderr, "Unknown option character x%x\n", optopt);
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+ default:
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
libmegapixels_devconfig *config = {0};
|
|
libmegapixels_devconfig *config = {0};
|
|
|
|
|
|
- if (ret) {
|
|
|
|
- printf("Using config: %s\n", configpath);
|
|
|
|
- libmegapixels_load_file(&config, configpath);
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (!ret) {
|
|
printf("No config found\n");
|
|
printf("No config found\n");
|
|
- libmegapixels_load_file(&config, "config/uvc.conf");
|
|
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
+ printf("Using config: %s\n", configpath);
|
|
|
|
+
|
|
|
|
+ if (!libmegapixels_load_file(&config, configpath)) {
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
printf("Device: %s %s\n", config->make, config->model);
|
|
printf("Device: %s %s\n", config->make, config->model);
|
|
printf("Found %d cameras\n", config->count);
|
|
printf("Found %d cameras\n", config->count);
|
|
|
|
|