[sheepdog] [PATCH 4/6] use sd_getopt instead of getopt_long

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Nov 6 08:30:47 CET 2012


At Tue, 06 Nov 2012 13:53:02 +0800,
Liu Yuan wrote:
> 
> On 11/06/2012 01:48 PM, MORITA Kazutaka wrote:
> >> I am wondering if we can built-in a callback in struct_sd_opt_param.
> >> > Then users of sd_opt will only write body handler, which interpret the
> >> > key-value string.
> > Do you mean to create a callback for each <prefix, key> pair?
> > 
> 
> No. I meant, for example, object:kv-strings and disk:kv-strings, then we
> can pass two handlers for them, one for object, the other for disk in
> its own struct, which interpret the kv-strings only. So we don't need
> init_cache_type(), that user manually write its own routines to
> interpret prefix.

The handler is something like {object,disk}_cache_set in sheep.c?

I'm not sure whether I understand your suggestion correctly, but IIUC,
it means that we create sd_opt_param (including a user-defined handler
to parse a key-value string) for each prefix (not <prefix,key> pair).
Is it correct?  Then, we cannot auto-generate a help message of
key-value pairs, no?

Or you mean that the user should define sd_opt_param for each
<prefix,key> pair, and define the handler outside of sd_opt_param for
each prefix?

Thanks,

Kazutaka



More information about the sheepdog mailing list