Commit d6057e64 authored by Alexandre Julliard's avatar Alexandre Julliard

wmc: Add support for long command-line options.

parent 1458856c
......@@ -25,6 +25,9 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#endif
#include "wmc.h"
#include "utils.h"
......@@ -44,17 +47,17 @@ static const char usage[] =
" -c Set 'custom-bit' in values\n"
" -d Use decimal values in output\n"
" -D Set debug flag\n"
" -h This message\n"
" -H file Write headerfile to file (default is inputfile.h)\n"
" -h, --help Print this message\n"
" -H FILE Write header file to FILE (default is inputfile.h)\n"
" -i Inline messagetable(s)\n"
" -o file Output to file (default is inputfile.rc)\n"
" -O fmt Set output format (rc, res, pot)\n"
" -P dir Directory where to find po files\n"
" -u Inputfile is in unicode\n"
" -o, --output=FILE Output to FILE (default is infile.rc)\n"
" -O, --output-format=FORMAT The output format (`rc', `res', or `pot')\n"
" -P, --po-dir=DIR Directory containing po files for translations\n"
" -u Input file is in unicode\n"
" -U Output unicode messagetable(s)\n"
" -v Show supported codepages and languages\n"
" -V Print version end exit\n"
" -W Enable pedantic warnings\n"
" -V, --version Print version end exit\n"
" -W, --pedantic Enable pedantic warnings\n"
"Input is taken from stdin if no inputfile is specified.\n"
"Byteorder of unicode input is based upon the first couple of\n"
"bytes read, which should be 0x0000..0x00ff.\n"
......@@ -128,7 +131,17 @@ static enum
FORMAT_POT
} output_format;
int getopt (int argc, char *const *argv, const char *optstring);
static const char short_options[] = "B:cdDhH:io:O:P:uUvVW";
static const struct option long_options[] =
{
{ "help", 0, NULL, 'h' },
{ "output", 1, NULL, 'o' },
{ "output-format", 1, NULL, 'O' },
{ "pedantic", 0, NULL, 'W' },
{ "po-dir", 1, NULL, 'P' },
{ "version", 0, NULL, 'v' }
};
static void segvhandler(int sig);
static void cleanup_files(void)
......@@ -147,6 +160,7 @@ int main(int argc,char *argv[])
extern char* optarg;
extern int optind;
int optc;
int opti = 0;
int lose = 0;
int ret;
int i;
......@@ -176,7 +190,7 @@ int main(int argc,char *argv[])
strcat(cmdline, " ");
}
while((optc = getopt(argc, argv, "B:cdDhH:io:O:P:uUvVW")) != EOF)
while((optc = getopt_long(argc, argv, short_options, long_options, &opti)) != EOF)
{
switch(optc)
{
......@@ -325,7 +339,7 @@ int main(int argc,char *argv[])
write_bin_files();
break;
case FORMAT_RES:
if (po_dir) add_translations( po_dir );
add_translations( po_dir );
write_res_file( output_name );
break;
case FORMAT_POT:
......
......@@ -34,8 +34,8 @@ NON-FUNCTIONAL; Use decimal values in output
.B \-D
Set debug flag. This results is a parser trace and a lot of extra messages.
.TP
.B \-h
Print an informative usage message.
.BR \-h ,\ \-\-help
Print an informative usage message and exits.
.TP
.BI \-H\ file
Write headerfile to \fIfile\fR. Default is \fIinputfile.h\fR.
......@@ -45,14 +45,14 @@ Inline messagetable(s). This option skips the generation of all \fI.bin\fR files
and writes all output into the \fI.rc\fR file. This encoding is parsable with
wrc(1).
.TP
.BI \-o\ file
.BR \-o ,\ \-\-output =\fIfile
Output to \fIfile\fR. Default is \fIinputfile.rc\fR.
.TP
.BI \-O\ format
.BR \-O ,\ \-\-output\-format =\fIformat
Set the output format. Supported formats are \fBrc\fR (the default),
\fBres\fR, and \fBpot\fR.
.TP
.BI \-P\ directory
.BR \-P ,\ \-\-po-dir =\fIdirectory
Enable the generation of resource translations based on po files
loaded from the specified directory. That directory must follow the
gettext convention, in particular in must contain one \fI.po\fR file for
......@@ -67,10 +67,10 @@ Write resource output in unicode formatted messagetable(s).
.B \-v
Show all supported codepages and languages.
.TP
.B \-V
.BR \-V ,\ \-\-version
Print version end exit.
.TP
.B \-W
.BR \-W ,\ \-\-pedantic
Enable pedantic warnings.
.SH EXTENSIONS
The original syntax is extended to support codepages more smoothly. Normally,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment