util.h 763 B

1234567891011121314151617181920212223
  1. #ifndef _UTIL_H_
  2. #define _UTIL_H_
  3. /*
  4. * Collection of utility functions to share between unit tests.
  5. *
  6. * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
  7. *
  8. * This work is licensed under the terms of the GNU LGPL, version 2.
  9. */
  10. /*
  11. * parse_keyval extracts the integer from a string formatted as
  12. * string=integer. This is useful for passing expected values to
  13. * the unit test on the command line, i.e. it helps parse QEMU
  14. * command lines that include something like -append var1=1 var2=2
  15. * @s is the input string, likely a command line parameter, and
  16. * @val is a pointer to where the integer will be stored.
  17. *
  18. * Returns the offset of the '=', or -1 if no keyval pair is found.
  19. */
  20. extern int parse_keyval(char *s, long *val);
  21. #endif