# endif
#endif
#include <dirent.h>
+#include <assert.h>
#include <libcitadel.h>
pCfg->Str.len = len;
pCfg->IsSingleLine = uniq;
pCfg->nSegments = nSegments;
- if (CfgTypeHash == NULL)
+ if (CfgTypeHash == NULL) {
CfgTypeHash = NewHash(1, NULL);
+ }
Put(CfgTypeHash, Name, len, pCfg, NULL);
}
OneRoomNetCfg *ParseRoomNetConfigFile(char *serialized_data)
{
const char *Pos = NULL;
- const char *CPos = NULL;
const CfgLineType *pCfg = NULL;
StrBuf *Line = NULL;
StrBuf *InStr = NULL;
StrBuf *Cfg = NULL;
OneRoomNetCfg *OneRNCfg = NULL;
+ int num_lines = 0;
+ int i = 0;
OneRNCfg = malloc(sizeof(OneRoomNetCfg));
memset(OneRNCfg, 0, sizeof(OneRoomNetCfg));
Line = NewStrBuf();
InStr = NewStrBuf();
Cfg = NewStrBufPlain(serialized_data, -1);
+ num_lines = num_tokens(ChrPtr(Cfg), '\n');
- while (StrBufSipLine(Line, Cfg, &CPos)) {
-
+ for (i=0; i<num_lines; ++i) {
+ StrBufExtract_token(Line, Cfg, i, '\n');
if (StrLength(Line) > 0) {
Pos = NULL;
StrBufExtract_NextToken(InStr, Line, &Pos, '|');
{
const CfgLineType *pCfg;
pCfg = GetCfgTypeByEnum(eCfg, CfgIt);
- if (pCfg->IsSingleLine)
+ if (pCfg)
{
- pCfg->Serializer(pCfg, OutBuffer, OneRNCfg, NULL);
- }
- else
- {
- RoomNetCfgLine *pName = OneRNCfg->NetConfigs[pCfg->C];
- while (pName != NULL)
+ if (pCfg->IsSingleLine)
{
- pCfg->Serializer(pCfg, OutBuffer, OneRNCfg, pName);
- pName = pName->next;
+ pCfg->Serializer(pCfg, OutBuffer, OneRNCfg, NULL);
+ }
+ else
+ {
+ RoomNetCfgLine *pName = OneRNCfg->NetConfigs[pCfg->C];
+ while (pName != NULL)
+ {
+ pCfg->Serializer(pCfg, OutBuffer, OneRNCfg, pName);
+ pName = pName->next;
+ }
}
-
-
}
}