+ConstStr ExpirePolicyString = {CStrOf(roompolicy) };
+
+ConstStr ExpirePolicyStrings[][2] = {
+ { { CStrOf(roompolicy) } , { strof(roompolicy) "_value", sizeof(strof(roompolicy) "_value") - 1 } },
+ { { CStrOf(floorpolicy) } , { strof(floorpolicy) "_value", sizeof(strof(floorpolicy) "_value") - 1 } },
+ { { CStrOf(sitepolicy) } , { strof(sitepolicy) "_value", sizeof(strof(sitepolicy) "_value") - 1 } },
+ { { CStrOf(mailboxespolicy)} , { strof(mailboxespolicy)"_value", sizeof(strof(mailboxespolicy)"_value") - 1 } }
+};
+
+void LoadExpirePolicy(GPEXWhichPolicy which)
+{
+ StrBuf *Buf;
+ wcsession *WCC = WC;
+ long State;
+ const char *Pos = NULL;
+
+ serv_printf("GPEX %s", ExpirePolicyStrings[which][0].Key);
+ Buf = NewStrBuf();
+ StrBuf_ServGetln(Buf);
+ WCC->Policy[which].loaded = 1;
+ if (GetServerStatus(Buf, &State) == 2) {
+ Pos = ChrPtr(Buf) + 4;
+ WCC->Policy[which].expire_mode = StrBufExtractNext_long(Buf, &Pos, '|');
+ WCC->Policy[which].expire_value = StrBufExtractNext_long(Buf, &Pos, '|');
+ }
+ else if (State == 550)
+ StrBufAppendBufPlain(WCC->ImportantMsg,
+ _("Higher access is required to access this function."), -1, 0);
+ FreeStrBuf(&Buf);
+}
+
+void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which)
+{
+ StrBuf *Buf;
+ long State;
+
+ serv_printf("SPEX %s|%d|%d",
+ ExpirePolicyStrings[which][0].Key,
+ ibcstr( ExpirePolicyStrings[which][1] ),
+ ibcstr( ExpirePolicyStrings[which][1] ) );
+
+ Buf = NewStrBuf();
+ StrBuf_ServGetln(Buf);
+ GetServerStatus(Buf, &State);
+ if (State == 550)
+ StrBufAppendBufPlain(WC->ImportantMsg,
+ _("Higher access is required to access this function."), -1, 0);
+ FreeStrBuf(&Buf);
+}
+
+int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ GPEXWhichPolicy which;
+ int CompareWith;
+
+ which = GetTemplateTokenNumber(Target, TP, 2, 0);
+ CompareWith = GetTemplateTokenNumber(Target, TP, 3, 0);
+
+ if (WCC->Policy[which].loaded == 0) LoadExpirePolicy(which);
+
+ return WCC->Policy[which].expire_mode == CompareWith;
+}
+
+void tmplput_ExpireValue(StrBuf *Target, WCTemplputParams *TP)
+{
+ GPEXWhichPolicy which;
+ wcsession *WCC = WC;
+
+ which = GetTemplateTokenNumber(Target, TP, 2, 0);
+ if (WCC->Policy[which].loaded == 0) LoadExpirePolicy(which);
+ StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_value);
+}
+
+
+void tmplput_ExpireMode(StrBuf *Target, WCTemplputParams *TP)
+{
+ GPEXWhichPolicy which;
+ wcsession *WCC = WC;
+
+ which = GetTemplateTokenNumber(Target, TP, 2, 0);
+ if (WCC->Policy[which].loaded == 0) LoadExpirePolicy(which);
+ StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_mode);
+}
+