free(vp);
}
+static struct vclprog *
+mgt_vcc_byname(const char *name)
+{
+ struct vclprog *vp;
+
+ VTAILQ_FOREACH(vp, &vclhead, list)
+ if (!strcmp(name, vp->name))
+ return (vp);
+ return (NULL);
+}
+
+
static int
mgt_vcc_delbyname(const char *name)
{
struct vclprog *vp;
- VTAILQ_FOREACH(vp, &vclhead, list) {
- if (!strcmp(name, vp->name)) {
- mgt_vcc_del(vp);
- return (0);
- }
+ vp = mgt_vcc_byname(name);
+ if (vp != NULL) {
+ mgt_vcc_del(vp);
+ return (0);
}
return (1);
}
char *vf, *p = NULL;
struct vsb *sb;
unsigned status;
+ struct vclprog *vp;
(void)priv;
+ vp = mgt_vcc_byname(av[2]);
+ if (vp != NULL) {
+ cli_out(cli, "Already a VCL program named %s", av[2]);
+ cli_result(cli, CLIS_PARAM);
+ return;
+ }
+
sb = vsb_newauto();
XXXAN(sb);
vf = mgt_VccCompile(sb, av[3], NULL, 0);
struct vsb *sb;
unsigned status;
char *p = NULL;
+ struct vclprog *vp;
(void)priv;
+ vp = mgt_vcc_byname(av[2]);
+ if (vp != NULL) {
+ cli_out(cli, "Already a VCL program named %s", av[2]);
+ cli_result(cli, CLIS_PARAM);
+ return;
+ }
sb = vsb_newauto();
XXXAN(sb);
{
struct vclprog *vp;
- VTAILQ_FOREACH(vp, &vclhead, list)
- if (!strcmp(vp->name, name))
- return (vp);
+ vp = mgt_vcc_byname(name);
+ if (vp != NULL)
+ return (vp);
cli_result(cli, CLIS_PARAM);
cli_out(cli, "No configuration named %s known.", name);
return (NULL);