| 1 |
/* |
| 2 |
* fstrcmp - fuzzy string compare library |
| 3 |
* Copyright (C) 2009 Peter Miller |
| 4 |
* Written by Peter Miller <[email protected]> |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 3 of the License, or (at |
| 9 |
* your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <ac/getopt.h> |
| 21 |
#include <ac/stdio.h> |
| 22 |
#include <ac/stdlib.h> |
| 23 |
#include <ac/unistd.h> |
| 24 |
|
| 25 |
|
| 26 |
static void |
| 27 |
usage(const char *prog) |
| 28 |
{ |
| 29 |
fprintf(stderr, "Usage: %s [ <option>... ]\n", prog); |
| 30 |
fprintf(stderr, " %s --version\n", prog); |
| 31 |
exit(1); |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
static const struct option options[] = |
| 36 |
{ |
| 37 |
{ "version", 0, 0, 'V' }, |
| 38 |
{ 0, 0, 0, 0 } |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
int |
| 43 |
main(int argc, char **argv) |
| 44 |
{ |
| 45 |
for (;;) |
| 46 |
{ |
| 47 |
int c; |
| 48 |
|
| 49 |
c = getopt_long(argc, argv, "V", options, 0); |
| 50 |
if (c == EOF) |
| 51 |
break; |
| 52 |
switch (c) |
| 53 |
{ |
| 54 |
case 'V': |
| 55 |
fstrcmp_version_print(argv[0]); |
| 56 |
return 0; |
| 57 |
|
| 58 |
default: |
| 59 |
usage(argv[0]); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
...do your thing... |
| 64 |
|
| 65 |
return 0; |
| 66 |
} |