ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/freezethaw.C
(Generate patch)

Comparing deliantra/server/server/freezethaw.C (file contents):
Revision 1.7 by root, Tue Jan 23 03:56:45 2007 UTC vs.
Revision 1.8 by root, Thu Feb 1 19:15:39 2007 UTC

111 static const char eof[] = "\n\n\n\0\0\0"; 111 static const char eof[] = "\n\n\n\0\0\0";
112 112
113 av = 0; 113 av = 0;
114 text = 0; 114 text = 0;
115 line = 0; 115 line = 0;
116 linenum = 0;
116 117
117 if (path) 118 if (path)
118 { 119 {
119 CALL_BEGIN (1); 120 CALL_BEGIN (1);
120 CALL_ARG_SV (newSVpv (path, 0)); 121 CALL_ARG_SV (newSVpv (path, 0));
215 if (av) SvREFCNT_dec (av); 216 if (av) SvREFCNT_dec (av);
216 217
217 free ((void *)name); 218 free ((void *)name);
218} 219}
219 220
221//TODO: remove
220char * 222char *
221fgets (char *s, int n, object_thawer &thawer) 223fgets (char *s, int n, object_thawer &thawer)
222{ 224{
223 char *p = thawer.line; 225 char *p = thawer.line;
224 char *q = s; 226 char *q = s;
232 break; 234 break;
233 235
234 *q++ = *p; 236 *q++ = *p;
235 237
236 if (*p++ == '\n') 238 if (*p++ == '\n')
239 {
240 ++thawer.linenum;
237 break; 241 break;
242 }
238 } 243 }
239 244
240 *q = 0; 245 *q = 0;
241 thawer.line = p; 246 thawer.line = p;
242 247
243 return s == q ? 0 : s; 248 return s == q ? 0 : s;
249}
250
251bool
252object_thawer::parse_error (keyword kw, const char *type, const char *name, bool skip)
253{
254 if (!type) type = "file section";
255 if (!name) name = "generic";
256
257 switch (kw)
258 {
259 case KW_EOF:
260 LOG (llevError, "%s:%d end of file while reading %s '%s', aborting load.\n",
261 this->name, linenum, type, name);
262 return false;
263
264 case KW_ERROR:
265 LOG (llevError, "%s:%d errornous line (%s) while reading %s '%s', aborting load.\n",
266 this->name, linenum,
267 last_keyword ? last_keyword : "<null>",
268 type, name);
269 return false;
270
271 default:
272 LOG (llevError, "%s:%d unexpected line (%s) while reading %s '%s', %s.\n",
273 this->name, linenum,
274 last_keyword ? last_keyword : "<null>",
275 last_value ? last_value : "<null>",
276 type, name,
277 skip ? "skipping line" : "aborting load");
278 return skip;
279 }
244} 280}
245 281
246keyword 282keyword
247object_thawer::get_kv () 283object_thawer::get_kv ()
248{ 284{
276 *p++ = 0; 312 *p++ = 0;
277 } 313 }
278 else 314 else
279 last_value = 0; 315 last_value = 0;
280 316
317 ++linenum;
281 line [klen] = 0; 318 line [klen] = 0;
282 keyword_idx *kw = kw_lex::match (line, klen); 319 keyword_idx *kw = kw_lex::match (line, klen);
283 320
284 //printf ("KV %d<%s,%s>\n", kw ? kw->index : 0, line, last_value);//D 321 //printf ("KV %d<%s,%s>\n", kw ? kw->index : 0, line, last_value);//D
285 322
330 kw [0] = '\n'; 367 kw [0] = '\n';
331 memcpy (kw + 1, keyword_str [kend], klen); 368 memcpy (kw + 1, keyword_str [kend], klen);
332 kw [klen + 1] = '\n'; 369 kw [klen + 1] = '\n';
333 kw [klen + 2] = 0; 370 kw [klen + 2] = 0;
334 371
372 ++linenum;
373
335 // first test for completely empty msg... "endXXX\n" 374 // first test for completely empty msg... "endXXX\n"
336 if (!strncmp (line, kw + 1, klen + 1)) 375 if (!strncmp (line, kw + 1, klen + 1))
337 { 376 {
338 sh = 0; 377 sh = 0;
339 378
354 } 393 }
355 394
356 *end = 0; 395 *end = 0;
357 sh = line; 396 sh = line;
358 397
398 // count line numbers
399 while (line < end)
400 linenum += *line++ == '\n';
401
359 line = end + keyword_len [kend] + 1; 402 line += keyword_len [kend];
360 403
361 while (*line++ != '\n') 404 while (*line++ != '\n')
362 ; 405 ;
406
407 ++linenum;
363 } 408 }
364} 409}
365 410
366sint32 411sint32
367object_thawer::get_sint32 () const 412object_thawer::get_sint32 () const

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines