ccutil/getopt.cpp

Go to the documentation of this file.
00001 
00020 #include          "mfcpch.h"     //precompiled headers
00021 #include          <string.h>
00022 #include          <stdio.h>
00023 #include          "getopt.h"
00024 #include          "notdll.h"     //must be last include
00025 
00026 int optind;
00027 char *optarg;
00028 
00029 /* ================== */
00033 int
00034 getopt (                         //parse args
00035 INT32 argc,                      //arg count
00036 char *argv[],                    //args
00037 const char *arglist                    //string of arg chars
00038 ) {
00039   char *arg;                     //arg char
00040 
00041   if (optind == 0)
00042     optind = 1;
00043   if (optind < argc && argv[optind][0] == '-') {
00044     arg = strchr (arglist, argv[optind][1]);
00045     if (arg == NULL || *arg == ':')
00046       return '?';                //dud option
00047     optind++;
00048     optarg = argv[optind];
00049     if (arg[1] == ':') {
00050       if (argv[optind - 1][2] != '\0')
00051                                  //immediately after
00052         optarg = argv[optind - 1] + 2;
00053       else
00054         optind++;
00055     }
00056     return *arg;
00057   }
00058   else
00059     return EOF;
00060 }

Generated on Wed Feb 28 19:49:09 2007 for Tesseract by  doxygen 1.5.1