友善之臂视频监控方案源码学习(5) - 输入控制(5)
时间:2026-01-26
时间:2026-01-26
1. /* no more options to parse */
2. if (c == -1) break;
3.
4. /* unrecognized option */
5. if (c == '?'){
6. help();
7. return 1;
8. }
9.
10. /* dispatch the given options */
11. switch (option_index) {
12. /* h, help */
13. case 0:
14. case 1:
15. DBG("case 0,1\n");
16. help();
17. return 1;
18. break;
19.
20. /* d, device */
21. case 2:
22. case 3:
23. DBG("case 2,3\n");
24. dev = strdup(optarg);
25. break;
26.
27. /* r, resolution */
28. case 4:
29. case 5:
30. DBG("case 4,5\n");
31. width = -1;
32. height = -1;
33.
34. /* try to find the resolution in lookup table "resolutions" */ 35. for ( i=0; i < LENGTH_OF(resolutions); i++ ) {
36. if ( strcmp(resolutions[i].string, optarg) == 0 ) { 37. width = resolutions[i].width;
38. height = resolutions[i].height;
39. }
40. }
41. /* done if width and height were set */
42. if(width != -1 && height != -1)
43. break;
44. /* parse value as decimal value */