1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
=head1 NAME
nbdkit_parse_delay - parse human-readable delays and sleeps for nbdkit
=head1 SYNOPSIS
#include <nbdkit-plugin.h>
int nbdkit_parse_delay (const char *what, const char *str,
unsigned *sec, unsigned *nsec);
=head1 DESCRIPTION
The utility function C<nbdkit_parse_delay> can be used to parse
configuration parameters on the L<nbdkit(1)> command line specifying
delays and sleeps.
The C<str> parameter is a string in one of the following formats:
=over 4
=item C<1>
=item C<1.2>
=item C<1.2s>
Seconds
=item C<1.2ms>
=item C<120ms>
Milliseconds
=item C<1.2us>
=item C<1.2μs>
=item C<120μs>
Microseconds
=item C<1ns>
Nanoseconds, the smallest possible time division for this function.
=back
The C<what> parameter is printed in error messages to provide context.
The output (C<sec>, C<nsec>) can be passed straight to
L<nbdkit_nanosleep(3)>.
=head1 RETURN VALUE
On success the function returns C<0> and sets C<*sec> and C<*nsec> to
the seconds and nanoseconds parsed.
If there is an error it calls L<nbdkit_error(3)> and returns C<-1>.
In this case, C<*sec> and C<*nsec> are not touched.
=head1 LANGUAGE BINDINGS
In L<nbdkit-ocaml-plugin(3)>:
NBDKit.parse_delay : string -> string -> int * int
In L<nbdkit-python-plugin(3)>:
import nbdkit
(sec, nsec) = nbdkit.parse_delay(what, str)
=head1 HISTORY
C<nbdkit_parse_delay> was added in nbdkit 1.40.
=head1 SEE ALSO
L<nbdkit(1)>,
L<nbdkit_parse_bool(3)>,
L<nbdkit_parse_int(3)>,
L<nbdkit_parse_probability(3)>,
L<nbdkit_parse_size(3)>,
L<nbdkit_nanosleep(3)>,
L<nbdkit-plugin(3)>,
L<nbdkit-filter(3)>,
L<nbdkit-delay-filter(1)>.
=head1 AUTHORS
Richard W.M. Jones
=head1 COPYRIGHT
Copyright Red Hat
|