Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
nbdkit_parse_int(3)		     NBDKIT		     nbdkit_parse_int(3)

NAME
     nbdkit_parse_int, nbdkit_parse_unsigned, nbdkit_parse_int8_t, nbd-
     kit_parse_int16_t, nbdkit_parse_int32_t, nbdkit_parse_int64_t, nbd-
     kit_parse_uint8_t, nbdkit_parse_uint16_t, nbdkit_parse_uint32_t, nbd-
     kit_parse_uint64_t - parse numbers for nbdkit

SYNOPSIS
      #include <nbdkit-plugin.h>

      int nbdkit_parse_int (const char *what, const char *str, int *r);
      int nbdkit_parse_unsigned (const char *what,
				 const char *str, unsigned *r);
      int nbdkit_parse_int8_t (const char *what,
			       const char *str, int8_t *r);
      int nbdkit_parse_uint8_t (const char *what,
				const char *str, uint8_t *r);
      int nbdkit_parse_int16_t (const char *what,
				const char *str, int16_t *r);
      int nbdkit_parse_uint16_t (const char *what,
				 const char *str, uint16_t *r);
      int nbdkit_parse_int32_t (const char *what,
				const char *str, int32_t *r);
      int nbdkit_parse_uint32_t (const char *what,
				 const char *str, uint32_t *r);
      int nbdkit_parse_int64_t (const char *what,
				const char *str, int64_t *r);
      int nbdkit_parse_uint64_t (const char *what,
				 const char *str, uint64_t *r);

DESCRIPTION
     Parse string "str" into an integer of various types.  These functions parse
     a decimal, hexadecimal ("0x...") or octal ("0...") number.

     These functions deal correctly with overflow, out of range and parse er-
     rors, and you should use them instead of unsafe functions like sscanf(3),
     atoi(3) and similar.

     The "what" parameter is printed in error messages to provide context.  It
     should usually be a short descriptive string of what you are trying to
     parse, eg:

      if (nbdkit_parse_int ("random seed", value, &seed) == -1)
	return -1;

     might print an error:

      random seed: could not parse number: "lalala"

RETURN VALUE
     On success the functions return 0.  If "r != NULL", they set *r to the
     parsed value.  If "r == NULL", the parsing is done but the result is dis-
     carded.

     On error, nbdkit_error(3) is called and the functions return -1.  On error
     *r is always unchanged.

HISTORY
     "nbdkit_parse_int" and the others were added in nbdkit 1.16.

SEE ALSO
     nbdkit(1), nbdkit_parse_bool(3), nbdkit_parse_delay(3), nbdkit_parse_proba-
     bility(3), nbdkit_parse_size(3), nbdkit-plugin(3), nbdkit-filter(3).

AUTHORS
     Richard W.M. Jones

COPYRIGHT
     Copyright Red Hat

LICENSE
     Redistribution and use in source and binary forms, with or without modifi-
     cation, are permitted provided that the following conditions are met:

     *	 Redistributions of source code must retain the above copyright notice,
	 this list of conditions and the following disclaimer.

     *	 Redistributions in binary form must reproduce the above copyright no-
	 tice, this list of conditions and the following disclaimer in the docu-
	 mentation and/or other materials provided with the distribution.

     *	 Neither the name of Red Hat nor the names of its contributors may be
	 used to endorse or promote products derived from this software without
	 specific prior written permission.

     THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EX-
     PRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS-
     CLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DI-
     RECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SER-
     VICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABIL-
     ITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
     THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAM-
     AGE.

nbdkit-1.46.2			   2026-08-30		     nbdkit_parse_int(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=nbdkit_parse_unsigned&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help