summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sade/variable.c
diff options
context:
space:
mode:
authortrhodes <trhodes@FreeBSD.org>2003-07-12 15:33:09 +0000
committertrhodes <trhodes@FreeBSD.org>2003-07-12 15:33:09 +0000
commit4a60e6fdcf08a2fc18660ec0368725323beccdda (patch)
tree42f719473a177a09a0f1f36b5703fba9e89aa4c7 /usr.sbin/sade/variable.c
parent2e230106526ab9f82db2931cd43a99d4798f3024 (diff)
downloadFreeBSD-src-4a60e6fdcf08a2fc18660ec0368725323beccdda.zip
FreeBSD-src-4a60e6fdcf08a2fc18660ec0368725323beccdda.tar.gz
Give users the ability to select an alternative MTA during the installation.
This option adds Postfix and Exim to the list, however, qmail is not added due to license restrictions. Collaborated with: Simon L. Nielsen <simon@nitro.dk> Reviewed by: jhb, re@, -audit.
Diffstat (limited to 'usr.sbin/sade/variable.c')
-rw-r--r--usr.sbin/sade/variable.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/usr.sbin/sade/variable.c b/usr.sbin/sade/variable.c
index d7f0e1b..e132862 100644
--- a/usr.sbin/sade/variable.c
+++ b/usr.sbin/sade/variable.c
@@ -174,14 +174,25 @@ variable_get_value(char *var, char *prompt, int dirty)
}
/* Check if value passed in data (in the form "variable=value") is
- equal to value of variable stored in env */
+ * valid, and it's status compared to the value of variable stored in
+ * env
+ *
+ * Possible return values :
+ * -3: Invalid line, the data string is NOT set as an env variable
+ * -2: Invalid line, the data string is set as an env variable
+ * -1: Invalid line
+ * 0: Valid line, is NOT equal to env version
+ * 1: Valid line, is equal to env version
+ * 2: Valid line, value empty - e.g. foo=""
+ * 3: Valid line, does not exist in env
+*/
int
-variable_check(char *data)
+variable_check2(char *data)
{
char *cp, *cp2, *cp3, tmp[256];
- if (!data)
- return FALSE;
+ if (data == NULL)
+ return -1;
SAFE_STRCPY(tmp, data);
if ((cp = index(tmp, '=')) != NULL) {
*(cp++) = '\0';
@@ -193,19 +204,38 @@ variable_check(char *data)
else if ((cp3 = index(cp, ',')) != NULL)
*cp3 = '\0';
cp2 = variable_get(tmp);
- if (cp2) {
- if (!*cp)
- return TRUE;
+ if (cp2 != NULL) {
+ if (*cp == NULL)
+ return 2;
else
- return !strcmp(cp, cp2);
+ return strcmp(cp, cp2) == 0 ? 1 : 0;
}
else
- return FALSE;
+ return 3;
}
else
- return variable_get(tmp) ? TRUE : FALSE;
+ return variable_get(tmp) != NULL ? -2 : -3;
}
+/* Check if the value passed in data (in the form "variable=value") is
+ equal to the value of variable stored in env */
+int
+variable_check(char *data)
+{
+ int ret;
+ ret = variable_check2(data);
+
+ switch(ret) {
+ case -2:
+ case 1:
+ case 2:
+ return TRUE;
+ /* NOT REACHED */
+ default:
+ return FALSE;
+ }
+}
+
int
dump_variables(dialogMenuItem *unused)
{
OpenPOWER on IntegriCloud