Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

short options? #2

Open
zvezdochiot opened this issue Jun 25, 2023 · 0 comments
Open

short options? #2

zvezdochiot opened this issue Jun 25, 2023 · 0 comments

Comments

@zvezdochiot
Copy link

zvezdochiot commented Jun 25, 2023

Hi @albmac .

Short options: -d, -e, -i, -o. See https://github.com/ImageProcessing-ElectronicPublications/jpeg-decomp .

    struct option long_options[] =
    {
        {"decode",       no_argument,   &decode, 'd'},
        {"encode",       no_argument,   &encode, 'e'},
        {"fin",    required_argument,       0, 'i'},
        {"fout",   required_argument,       0, 'o'},
        {0, 0, 0, 0}
    };
    while ((c = getopt_long (argc, argv, "dei:o:",long_options,&option_index)) != -1)
        switch (c)
        {
        case 'd':   //decode
            decode = 1;
            break;
        case 'e':   //encode
            encode = 1;
            break;
        case 'i':   //fin
            strncpy(filein,optarg,sizeof(filein)-1);
            break;
        case 'o':   //fout
            strncpy(fileout,optarg,sizeof(fileout)-1);
            break;
        case '?':
            fprintf (stderr,"option error");
            return;
        default:

            break;
        }
...
    if(encode==0&&decode==0)
    {
        printf("Usage:\n");
        printf("%s --decode or --encode --fin <file> --fout <file>\n", argv[0]);
        printf("or:\n");
        printf("%s -d|-e -i <file> -o <file>\n", argv[0]);
        return;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant