xref: /kvm-unit-tests/lib/util.c (revision 421814158396cabf4bb805c4f736d3c7c9f71351)
1 /*
2  * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
3  *
4  * This work is licensed under the terms of the GNU LGPL, version 2.
5  */
6 #include <libcflat.h>
7 #include <stdlib.h>
8 #include "util.h"
9 
parse_keyval(char * s,long * val)10 int parse_keyval(char *s, long *val)
11 {
12 	char *p;
13 
14 	p = strchr(s, '=');
15 	if (!p)
16 		return -1;
17 
18 	*val = strtol(p+1, NULL, 0);
19 	return p - s;
20 }
21