- * \params key key whichs value is to be modified
- * \param keylen length of the key string
- * \param value value to set
- * \param save_to_server 1 = flush all data to the server, 0 = cache it for now
+ * key key whichs value is to be modified
+ * keylen length of the key string
+ * value value to set
+ * save_to_server 1 = flush all data to the server, 0 = cache it for now
+ */
+long compare_preference(const Preference *PrefA, const Preference *PrefB)
+{
+ ePrefType TypeA, TypeB;
+
+ if (PrefA->Type != NULL) {
+ TypeA = PrefA->Type->eType;
+ }
+ else {
+ TypeA = PrefA->eFlatPrefType;
+ }
+
+ if (PrefB->Type != NULL) {
+ TypeB = PrefB->Type->eType;
+ }
+ else {
+ TypeB = PrefB->eFlatPrefType;
+ }
+
+ if ( (TypeA != PRF_UNSET)
+ && (TypeB != PRF_UNSET)
+ && (TypeA != TypeB)
+ ) {
+ if (TypeA > TypeB) {
+ return 1;
+ }
+ else { /* (PrefA->Type < PrefB->Type) */
+ return -1;
+ }
+ }
+
+ if (TypeB == PRF_UNSET) {
+ TypeA = PRF_UNSET;
+ }
+
+ switch (TypeA)
+ {
+ default:
+ case PRF_UNSET:
+ case PRF_STRING:
+ return strcmp(ChrPtr(PrefA->Val), ChrPtr(PrefB->Val));
+ case PRF_YESNO:
+ case PRF_INT:
+ if (PrefA->lval == PrefB->lval)
+ return 0;
+ else if (PrefA->lval > PrefB->lval)
+ return 1;
+ else
+ return -1;
+ case PRF_QP_STRING:
+ return strcmp(ChrPtr(PrefA->DeQPed),
+ ChrPtr(PrefB->DeQPed));
+ }
+}
+
+
+/*
+ * Write a key into the webcit preferences database for this user
+ *
+ * key key which value is to be modified
+ * keylen length of the key string
+ * value value to set
+ * save_to_server 1 = flush all data to the server, 0 = cache it for now