Introduce gctl_get_paraml() which gets a parameter only if it has the

right length.
This commit is contained in:
Poul-Henning Kamp 2003-04-23 08:03:47 +00:00
parent fb9483af54
commit ca3d750e73
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=113893

View File

@ -268,6 +268,23 @@ gctl_get_param(struct gctl_req *req, const char *param, int *len)
return (NULL);
}
void *
gctl_get_paraml(struct gctl_req *req, const char *param, int len)
{
int i;
void *p;
p = gctl_get_param(req, param, &i);
if (p == NULL)
gctl_error(req, "Missing %s argument", param);
else if (i != len) {
g_free(p);
p = NULL;
gctl_error(req, "Wrong length %s argument", param);
}
return (p);
}
static struct g_class*
gctl_get_class(struct gctl_req *req)
{