It's not available on all systems and using argc/argv directly does not
complicate the code much.
---
tools/graph2dot.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/tools/graph2dot.c b/tools/graph2dot.c
index 6ea2f32..0a90878 100644
--- a/tools/graph2dot.c
+++ b/tools/graph2dot.c
@@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <unistd.h> /* getopt */
-
#include "libavutil/pixdesc.h"
#include "libavutil/audioconvert.h"
#include "libavfilter/avfiltergraph.h"
@@ -99,22 +97,29 @@ int main(int argc, char **argv)
FILE *infile = NULL;
char *graph_string = NULL;
AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph));
- char c;
+ int optindex = 1;
av_log_set_level(AV_LOG_DEBUG);
- while ((c = getopt(argc, argv, "hi:o:")) != -1) {
- switch (c) {
- case 'h':
+ while (optindex < argc) {
+ char *opt = argv[optindex++];
+ char *arg;
+
+ if (!opt[0] || !opt[1]) {
usage();
- return 0;
+ return 1;
+ }
+ arg = opt[2] ? opt + 2 : argv[optindex++];
+
+ switch (opt[1]) {
case 'i':
- infilename = optarg;
+ infilename = arg;
break;
case 'o':
- outfilename = optarg;
+ outfilename = arg;
break;
- case '?':
+ default:
+ usage();
return 1;
}
}
--
1.7.10
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel