Changeset 391


Ignore:
Timestamp:
Jan 4, 2005, 12:13:01 AM (18 years ago)
Author:
Sam Hocevar
Message:
  • check for getopt_long; work with simple getopt.
Location:
pwntcha/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pwntcha/trunk/configure.ac

    r389 r391  
    1818AC_C_INLINE
    1919AC_TYPE_SIZE_T
     20
     21AC_CHECK_FUNCS(getopt_long)
    2022
    2123# Use OpenCV?
  • pwntcha/trunk/src/main.c

    r389 r391  
    1818#include "common.h"
    1919
     20#ifdef HAVE_GETOPT_LONG
     21#   define MOREINFO "Try `%s --help' for more information.\n"
     22#else
     23#   define MOREINFO "Try `%s -h' for more information.\n"
     24#endif
     25
    2026int main(int argc, char *argv[])
    2127{
     
    2834    {
    2935        int this_option_optind = optind ? optind : 1;
     36#ifdef HAVE_GETOPT_LONG
    3037        int option_index = 0;
    3138        static struct option long_options[] =
     
    3845
    3946        c = getopt_long(argc, argv, "hm:v", long_options, &option_index);
     47#else
     48        c = getopt(argc, argv, "hm:v");
     49#endif
    4050        if(c == -1)
    4151            break;
     
    4555        case 'h': /* --help */
    4656            printf("Usage: %s [OPTION]... FILE...\n", argv[0]);
     57#ifdef HAVE_GETOPT_LONG
    4758            printf("  -m, --mode      force operating mode\n");
    4859            printf("  -h, --help      display this help and exit\n");
    4960            printf("  -v, --version   output version information and exit\n");
     61#else
     62            printf("  -m     force operating mode\n");
     63            printf("  -h     display this help and exit\n");
     64            printf("  -v     output version information and exit\n");
     65#endif
    5066            return 0;
    5167        case 'm': /* --mode */
     
    5369            break;
    5470        case 'v': /* --version */
    55             printf("pwntcha (CAPTCHA decoder) %s\n", VERSION);
     71            printf("pwntcha (captcha decoder) %s\n", VERSION);
    5672            printf("Written by Sam Hocevar.\n");
    5773            printf("\n");
     
    6177            return 0;
    6278        case '?':
    63             break;
     79            printf(MOREINFO, argv[0]);
     80            return 1;
    6481        default:
    6582            printf("%s: invalid option -- %i\n", argv[0], c);
    66             printf("Try `%s --help' for more information.\n", argv[0]);
     83            printf(MOREINFO, argv[0]);
    6784            return 1;
    6885        }
     
    7289    {
    7390        printf("%s: too few arguments\n", argv[0]);
    74         printf("Try `%s --help' for more information.\n", argv[0]);
     91        printf(MOREINFO, argv[0]);
    7592        return 1;
    7693    }
     
    103120            else
    104121            {
    105                 fprintf(stderr, "%s: could not guess CAPTCHA type\n", argv[0]);
     122                fprintf(stderr, "%s: could not guess captcha type\n", argv[0]);
    106123                printf("\n");
    107124                image_free(img);
Note: See TracChangeset for help on using the changeset viewer.