Question for Vodz about getopt_ulflags

Vladimir N. Oleynik dzo at simtreas.ru
Wed May 3 13:09:47 UTC 2006


Tito,

> Hi Vodz,
> I am trying to use bb_getopt_ulflags in hdparm,
> but it seems to me that unsigned long opts
> returned by bb_getopt_ulflags is not big enough
> to hold the value for all the options.
> 
> For test:
> int hdparm_main(int argc, char **argv)
> {
> 	unsigned long opts;
> 
> 	opts = bb_getopt_ulflags(argc, argv, hdparm_options);
> 	printf("opts %ld\n", opts);
> 	return 0;
> }
> 
> ./busybox hdparm -Z
> opts 1073741824
> ./busybox hdparm -U
> opts -2147483648
> ./busybox hdparm -R
> BusyBox v1.2.0-pre0 (2006.04.28-12:28+0000) multi-call binary
> 
> Usage: hdparm [options] [device] ..
> 
> The opt strings is:
> 
> static const char hdparm_options[]= "VvgfqunprmckaBtThdSDPXKALWCyYzZURQwxb";
> 
> Is there a solution?

The small patch for getopt_ulflags attached.
Usage example also added:

If applet_opts have more sizeof(long) count a chars, use this trik.

static const char hdparm_options1[]= "VvgfqunprmckaBtThdSDPXKALWCyYzZURQwxb";
static const char hdparm_options2[]= "RQwxb";
flags1 = bb_getopt_ulflags(argc, argv, hdparm_options1);
optind = 0;
flags2 = bb_getopt_ulflags(argc, argv, hdparm_options2);


--w
vodz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getopt_ulflags.diff
Type: text/x-patch
Size: 2427 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060503/bcc1cfc3/attachment.bin 


More information about the busybox mailing list