Sinisa Milivojevic wrote:
>
> Van writes:
> > Greetings:
> >
> > With the following code, I have 3 problems:
> > 1. ./client -psecret works, but, ./client --password=secret does not;
> > 2. After calling load_defaults, the argument vector is getting parsed,
> > but, it's not making it into the switch processing. The values
> > from my global char *password = NULL values are being used;
> > 3. Compiler warnings related to the struct variables. I've also tried:
> > {"password", optional_argument, 0, "p"},
> > with the same result. I didn't see anything in getopt.h that would
> > explain this. Using the one from sampdb/capi used in Paul's book.
> >
> > main.c:38: warning: initialization makes integer from pointer without a cast
> >
> > Can anyone see where the error(s) is/are?
> > Full source is at http://az.dedserius.com/main.c/
> > Regards,
> > Van
>
> Hi!
>
> What you have described works just fine with mysql client program.
>
> Just copy the relevant parts from it and your program will work in the
> same fashion.
>
> --
> Regards,
> __ ___ ___ ____ __
> / |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic <[EMAIL PROTECTED]>
> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, FullTime Developer
> /_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
> <___/ www.mysql.com
Sinisa:
Thanks for the response. The flawed version was:
struct option long_options[] =
{
{"CALL_TYPE", optional_argument, NULL, "T"},
{"HOSTNAME", optional_argument, NULL, "H"},
{"user", optional_argument, NULL, "u"},
{"CLIENT_BUSINESS", optional_argument, NULL, "C"},
{"BTIME_HOST", optional_argument, NULL, "B"},
{"password", optional_argument, NULL, "p"},
{"showvars", no_argument, NULL, "s"},
{"testing", no_argument, NULL, "t"},
{"repair", no_argument, NULL, "r"},
{"help", no_argument, NULL, "h"},
{"version", no_argument, NULL, "v"},
{0,0,0,0}
};
Correct version:
struct option long_options[] =
{
{"CALL_TYPE", optional_argument, NULL, 'T'},
{"HOSTNAME", optional_argument, NULL, 'H'},
{"user", optional_argument, NULL, 'u'},
{"CLIENT_BUSINESS", optional_argument, NULL, "C'},
{"BTIME_HOST", optional_argument, NULL, 'B'},
{"password", optional_argument, NULL, 'p'},
{"showvars", no_argument, NULL, 's'},
{"testing", no_argument, NULL, 't'},
{"repair", no_argument, NULL, 'r'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{0,0,0,0}
};
Single quotes need to be around the 4th argument, not double quotes.
Regards,
Van
--
=================================================================
Linux rocks!!! http://www.dedserius.com/
=================================================================
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php