It's not available on all systems and using argc/argv directly does not
complicate the code much.
---
 tools/graph2dot.c |   23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/tools/graph2dot.c b/tools/graph2dot.c
index 6ea2f32..82b2bf2 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,27 @@ 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++];
+
+        if (!opt[0]) {
             usage();
-            return 0;
+            return 1;
+        }
+
+        switch (opt[1]) {
         case 'i':
-            infilename = optarg;
+            infilename = argv[optindex++];
             break;
         case 'o':
-            outfilename = optarg;
+            outfilename = argv[optindex++];
             break;
-        case '?':
+        default:
+            usage();
             return 1;
         }
     }
-- 
1.7.10

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to