cfgfiles: Introduce an after_update callback

This allows individual preferences to take action when their value is
changed.

Signed-off-by: Ben Gamari <ben@smart-cactus.org>
This commit is contained in:
Ben Gamari 2016-05-14 12:20:44 +02:00 committed by Patrick Griffis
parent 6a0e131b88
commit a970c1ae2e
2 changed files with 15 additions and 0 deletions

View File

@ -1046,6 +1046,11 @@ save_config (void)
return 0; return 0;
} }
} }
if (vars[i].after_update != NULL)
{
vars[i].after_update();
}
i++; i++;
} }
while (vars[i].name); while (vars[i].name);
@ -1293,6 +1298,11 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
{ {
set_showval (sess, &vars[i], tbuf); set_showval (sess, &vars[i], tbuf);
} }
if (vars[i].after_update != NULL)
{
vars[i].after_update();
}
break; break;
} }
} }

View File

@ -71,6 +71,11 @@ struct prefs
unsigned short offset; unsigned short offset;
unsigned short len; unsigned short len;
unsigned short type; unsigned short type;
/*
* an optional function which will be called after the preference value has
* been updated.
*/
void (*after_update)(void);
}; };
#define TYPE_STR 0 #define TYPE_STR 0