}
#endif
+
+void ParsePref(HashList **List, StrBuf *ReadBuf)
+{
+ StrBuf *Key;
+ StrBuf *Data = NULL;
+ StrBuf *LastData = NULL;
+
+ Key = NewStrBuf();
+ while (StrBuf_ServGetln(ReadBuf),
+ strcmp(ChrPtr(ReadBuf), "000"))
+ {
+ if ((ChrPtr(ReadBuf)[0] == ' ') &&
+ (Data != NULL)) {
+ StrBufAppendBuf(Data, ReadBuf, 1);
+ }
+ else {
+ LastData = Data = NewStrBuf();
+ StrBufExtract_token(Key, ReadBuf, 0, '|');
+ StrBufExtract_token(Data, ReadBuf, 1, '|');
+ if (!IsEmptyStr(ChrPtr(Key)))
+ {
+ Put(*List,
+ ChrPtr(Key), StrLength(Key),
+ Data,
+ HFreeStrBuf);
+ }
+ else
+ {
+ FreeStrBuf(&Data);
+ LastData = NULL;
+ }
+ }
+ }
+ FreeStrBuf(&Key);
+}
+
+
/*
* display preferences dialog
*/
-void load_preferences(void) {
+void load_preferences(void)
+{
+ StrBuf *ReadBuf;
char buf[SIZ];
long msgnum = 0L;
- StrBuf *ReadBuf;
serv_printf("GOTO %s", USERCONFIGROOM);
serv_getln(buf, sizeof buf);
strcmp(ChrPtr(ReadBuf), "000"))) {
}
if (!strcmp(ChrPtr(ReadBuf), "text")) {
- StrBuf *Key;
- StrBuf *Data = NULL;
- StrBuf *LastData = NULL;
-
- Key = NewStrBuf();
- while (StrBuf_ServGetln(ReadBuf),
- strcmp(ChrPtr(ReadBuf), "000"))
- {
- if ((ChrPtr(ReadBuf)[0] == ' ') &&
- (Data != NULL)) {
- StrBufAppendBuf(Data, ReadBuf, 1);
- }
- else {
- LastData = Data = NewStrBuf();
- StrBufExtract_token(Key, ReadBuf, 0, '|');
- StrBufExtract_token(Data, ReadBuf, 1, '|');
- if (!IsEmptyStr(ChrPtr(Key)))
- {
- Put(WC->hash_prefs,
- ChrPtr(Key), StrLength(Key),
- Data,
- HFreeStrBuf);
- }
- else
- {
- FreeStrBuf(&Data);
- LastData = NULL;
- }
- }
- }
- FreeStrBuf(&Key);
+ ParsePref(&WC->hash_prefs, ReadBuf);
}
- FreeStrBuf(&ReadBuf);
}
+ FreeStrBuf(&ReadBuf);
}
/* Go back to the room we're supposed to be in */
return(0);
}
+void WritePrefsToServer(HashList *Hash)
+{
+ long len;
+ HashPos *HashPos;
+ void *Value;
+ const char *Key;
+ StrBuf *Buf;
+ StrBuf *SubBuf = NULL;
+
+ Hash = WC->hash_prefs;
+#ifdef DBG_PREFS_HASH
+ dbg_PrintHash(Hash, PrintPref, NULL);
+#endif
+ HashPos = GetNewHashPos(Hash, 0);
+ while (GetNextHashPos(Hash, HashPos, &len, &Key, &Value)!=0)
+ {
+ size_t nchars;
+ Buf = (StrBuf*) Value;
+ if (Buf == NULL)
+ continue;
+ nchars = StrLength(Buf);
+ if (nchars > 80){
+ int n = 0;
+ size_t offset, nchars;
+ if (SubBuf == NULL)
+ SubBuf = NewStrBuf();
+ nchars = 1;
+ offset = 0;
+ while (nchars > 0) {
+ if (n == 0)
+ nchars = 70;
+ else
+ nchars = 80;
+
+ nchars = StrBufSub(SubBuf, Buf, offset, nchars);
+
+ if (n == 0)
+ serv_printf("%s|%s", Key, ChrPtr(SubBuf));
+ else
+ serv_printf(" %s", ChrPtr(SubBuf));
+
+ offset += nchars;
+ nchars = StrLength(Buf) - offset;
+ n++;
+ }
+
+ }
+ else
+ serv_printf("%s|%s", Key, ChrPtr(Buf));
+
+ }
+ if (SubBuf != NULL)
+ FreeStrBuf(&SubBuf);
+ DeleteHashPos(&HashPos);
+}
+
/**
* \brief save the modifications
*/
serv_printf("ENT0 1||0|1|__ WebCit Preferences __|");
serv_getln(buf, sizeof buf);
if (buf[0] == '4') {
- long len;
- HashPos *HashPos;
- HashList *Hash;
- void *Value;
- const char *Key;
- StrBuf *Buf;
- StrBuf *SubBuf = NULL;
-
- Hash = WC->hash_prefs;
-#ifdef DBG_PREFS_HASH
- dbg_PrintHash(Hash, PrintPref, NULL);
-#endif
- HashPos = GetNewHashPos(Hash, 0);
- while (GetNextHashPos(Hash, HashPos, &len, &Key, &Value)!=0)
- {
- size_t nchars;
- Buf = (StrBuf*) Value;
- if (Buf == NULL)
- continue;
- nchars = StrLength(Buf);
- if (nchars > 80){
- int n = 0;
- size_t offset, nchars;
- if (SubBuf == NULL)
- SubBuf = NewStrBuf();
- nchars = 1;
- offset = 0;
- while (nchars > 0) {
- if (n == 0)
- nchars = 70;
- else
- nchars = 80;
-
- nchars = StrBufSub(SubBuf, Buf, offset, nchars);
-
- if (n == 0)
- serv_printf("%s|%s", Key, ChrPtr(SubBuf));
- else
- serv_printf(" %s", ChrPtr(SubBuf));
-
- offset += nchars;
- nchars = StrLength(Buf) - offset;
- n++;
- }
-
- }
- else
- serv_printf("%s|%s", Key, ChrPtr(Buf));
-
- }
- if (SubBuf != NULL)
- FreeStrBuf(&SubBuf);
+
+ WritePrefsToServer(WC->hash_prefs);
serv_puts("");
serv_puts("000");
- DeleteHashPos(&HashPos);
}
/** Go back to the room we're supposed to be in */