Mercurial > otakunoraifu
comparison system/system_config.cc @ 52:15a18fbe6f21
* Known bugs added to the README
* Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author | thib |
---|---|
date | Sat, 18 Apr 2009 18:35:39 +0000 |
parents | 35ce1a30f3f9 |
children | ddbcbd000206 |
comparison
equal
deleted
inserted
replaced
51:cbb301016a4e | 52:15a18fbe6f21 |
---|---|
69 } | 69 } |
70 else return a.hash < b.hash; | 70 else return a.hash < b.hash; |
71 } | 71 } |
72 }; | 72 }; |
73 HashStr::HashStr(const char* s ) { | 73 HashStr::HashStr(const char* s ) { |
74 if (s == 0 || s[0] == '\0') { | 74 if (s == NULL || s[0] == '\0') { |
75 str = 0; hash = 0; return; /* invalid string */ | 75 str = NULL; |
76 hash = 0; | |
77 return; /* invalid string */ | |
76 } | 78 } |
77 char* new_str = new char[strlen(s)+1]; | 79 char* new_str = new char[strlen(s)+1]; |
78 strcpy(new_str, s); | 80 strcpy(new_str, s); |
79 str = new_str; | 81 str = new_str; |
80 /* calc hash... 適当 */ | 82 /* calc hash... 適当 */ |
84 s++; | 86 s++; |
85 } | 87 } |
86 hash = (unsigned int)h; | 88 hash = (unsigned int)h; |
87 } | 89 } |
88 HashStr::HashStr(const HashStr& orig) { | 90 HashStr::HashStr(const HashStr& orig) { |
89 if (orig.str == 0 || orig.str[0] == '\0') { | 91 if (orig.str == NULL || orig.str[0] == '\0') { |
90 str = 0; hash = 0; return; /* invalid */ | 92 str = NULL; |
93 hash = 0; return; /* invalid */ | |
91 } | 94 } |
92 char* new_str = new char[strlen(orig.str)+1]; | 95 char* new_str = new char[strlen(orig.str)+1]; |
93 strcpy(new_str, orig.str); | 96 strcpy(new_str, orig.str); |
94 str = new_str; | 97 str = new_str; |
95 hash = orig.hash; | 98 hash = orig.hash; |
128 char* original_data; | 131 char* original_data; |
129 char* old_data; | 132 char* old_data; |
130 char* new_data; | 133 char* new_data; |
131 public: | 134 public: |
132 AyuSysConfigStringItem(void) { | 135 AyuSysConfigStringItem(void) { |
133 original_data = 0; | 136 original_data = NULL; |
134 old_data = 0; | 137 old_data = NULL; |
135 new_data = 0; | 138 new_data = NULL; |
136 } | 139 } |
137 ~AyuSysConfigStringItem(void) { | 140 ~AyuSysConfigStringItem(void) { |
138 if (original_data) delete[] original_data; | 141 if (original_data) delete[] original_data; |
139 if (old_data) delete[] old_data; | 142 if (old_data) delete[] old_data; |
140 if (new_data) delete[] new_data; | 143 if (new_data) delete[] new_data; |
141 } | 144 } |
142 AyuSysConfigStringItem(const AyuSysConfigStringItem& o) { | 145 AyuSysConfigStringItem(const AyuSysConfigStringItem& o) { |
143 original_data = 0; old_data = 0; new_data = 0; | 146 original_data = NULL; |
147 old_data = NULL; | |
148 new_data = NULL; | |
144 if (o.original_data) { | 149 if (o.original_data) { |
145 original_data = new char[strlen(o.original_data)+1]; | 150 original_data = new char[strlen(o.original_data)+1]; |
146 strcpy(original_data, o.original_data); | 151 strcpy(original_data, o.original_data); |
147 } | 152 } |
148 if (o.old_data) { | 153 if (o.old_data) { |
183 /* オリジナルからの変化の調査 : | 188 /* オリジナルからの変化の調査 : |
184 ** DiffOriginal で変化を文字列で取り出し、PatchOriginal で | 189 ** DiffOriginal で変化を文字列で取り出し、PatchOriginal で |
185 ** 変化を反映 | 190 ** 変化を反映 |
186 */ | 191 */ |
187 int DiffOriginalLen(void) { | 192 int DiffOriginalLen(void) { |
188 if (new_data == 0) return 0; | 193 if (new_data == NULL) return 0; |
189 return strlen(new_data)+1; | 194 return strlen(new_data)+1; |
190 } | 195 } |
191 void DiffOriginal(string& data) { | 196 void DiffOriginal(string& data) { |
192 if (new_data == 0) { /* あり得ない */ | 197 if (new_data == NULL) { /* あり得ない */ |
193 fprintf(stderr,"AyuSysConfigStringItem::DiffOriginal : this method must not called if not required!\n"); | 198 fprintf(stderr,"AyuSysConfigStringItem::DiffOriginal : this method must not called if not required!\n"); |
194 return; | 199 return; |
195 } | 200 } |
196 char* out_data = new char[strlen(new_data)*2+1]; | 201 char* out_data = new char[strlen(new_data)*2+1]; |
197 char* buf = out_data; | 202 char* buf = out_data; |
216 delete[] out_data; | 221 delete[] out_data; |
217 return; | 222 return; |
218 } | 223 } |
219 const char* PatchOriginal(const char* data) { | 224 const char* PatchOriginal(const char* data) { |
220 static const char* table = "?\"',.:;=<>"; | 225 static const char* table = "?\"',.:;=<>"; |
221 if (new_data) delete[] new_data; | 226 if (new_data != NULL) delete[] new_data; |
222 if (old_data) delete[] old_data; | 227 if (old_data != NULL) delete[] old_data; |
223 new_data = 0; old_data = 0; | 228 old_data = NULL; |
224 new_data = new char[1024]; | 229 new_data = new char[1024]; |
225 int i,j = 0; | 230 int i,j = 0; |
226 for (i=0; i<1020; i++) { | 231 for (i=0; i<1020; i++) { |
227 switch(data[j]) { | 232 switch(data[j]) { |
228 case '?': | 233 case '?': |
242 return data; | 247 return data; |
243 } | 248 } |
244 void SetOriginal(void) { | 249 void SetOriginal(void) { |
245 if (new_data) delete[] new_data; | 250 if (new_data) delete[] new_data; |
246 if (old_data) delete[] old_data; | 251 if (old_data) delete[] old_data; |
247 new_data = 0; old_data = 0; | 252 new_data = NULL; |
253 old_data = NULL; | |
248 } | 254 } |
249 void Dump(FILE* f) const { | 255 void Dump(FILE* f) const { |
250 if (original_data) fprintf(f, "original %s ",original_data); | 256 if (original_data) fprintf(f, "original %s ",original_data); |
251 if (old_data) fprintf(f, "old_data %s ",old_data); | 257 if (old_data) fprintf(f, "old_data %s ",old_data); |
252 if (new_data) fprintf(f, "new_data %s ",new_data); | 258 if (new_data) fprintf(f, "new_data %s ",new_data); |
264 int* old_data; | 270 int* old_data; |
265 int* new_data; | 271 int* new_data; |
266 public: | 272 public: |
267 AyuSysConfigIntlistItem(void) { | 273 AyuSysConfigIntlistItem(void) { |
268 item_deal = 0; | 274 item_deal = 0; |
269 original_data = 0; | 275 original_data = NULL; |
270 old_data = 0; | 276 old_data = NULL; |
271 new_data = 0; | 277 new_data = NULL; |
272 } | 278 } |
273 ~AyuSysConfigIntlistItem(void) { | 279 ~AyuSysConfigIntlistItem(void) { |
274 if (original_data) delete[] original_data; | 280 if (original_data) delete[] original_data; |
275 if (old_data) delete[] old_data; | 281 if (old_data) delete[] old_data; |
276 if (new_data) delete[] new_data; | 282 if (new_data) delete[] new_data; |
277 } | 283 } |
278 AyuSysConfigIntlistItem(const AyuSysConfigIntlistItem& o) { | 284 AyuSysConfigIntlistItem(const AyuSysConfigIntlistItem& o) { |
279 item_deal = o.item_deal; | 285 item_deal = o.item_deal; |
280 original_data = 0; old_data = 0; new_data = 0; | 286 original_data = NULL; |
287 old_data = NULL; | |
288 new_data = NULL; | |
281 if (o.original_data) { | 289 if (o.original_data) { |
282 original_data = new int[item_deal]; | 290 original_data = new int[item_deal]; |
283 memcpy(original_data, o.original_data, sizeof(int)*item_deal); | 291 memcpy(original_data, o.original_data, sizeof(int)*item_deal); |
284 } | 292 } |
285 if (o.old_data) { | 293 if (o.old_data) { |
292 } | 300 } |
293 } | 301 } |
294 /* 設定:Init で初期化、Set で変更、Get で変更を優先して取り出す */ | 302 /* 設定:Init で初期化、Set で変更、Get で変更を優先して取り出す */ |
295 void Init(int deal, const int* list) { /* deal は無視 */ | 303 void Init(int deal, const int* list) { /* deal は無視 */ |
296 if (original_data) delete[] original_data; | 304 if (original_data) delete[] original_data; |
297 original_data = 0; | 305 original_data = NULL; |
298 if (deal <= 0) { | 306 if (deal <= 0) { |
299 item_deal = 0; return; | 307 item_deal = 0; return; |
300 } | 308 } |
301 item_deal = deal; | 309 item_deal = deal; |
302 original_data = new int[item_deal]; | 310 original_data = new int[item_deal]; |
307 if (new_data) delete[] new_data; | 315 if (new_data) delete[] new_data; |
308 new_data = new int[item_deal]; | 316 new_data = new int[item_deal]; |
309 memcpy(new_data, list, sizeof(int)*item_deal); | 317 memcpy(new_data, list, sizeof(int)*item_deal); |
310 } | 318 } |
311 const int* Get(int deal) const {/* deal は無視 */ | 319 const int* Get(int deal) const {/* deal は無視 */ |
312 if (item_deal == 0) return 0; | 320 if (item_deal == 0) return NULL; |
313 if (deal > item_deal) { | 321 if (deal > item_deal) { |
314 fprintf(stderr,"AyuSysConfigIntlistItem::Get : invalid items deal %d (correct: %d)\n",deal,item_deal); | 322 fprintf(stderr,"AyuSysConfigIntlistItem::Get : invalid items deal %d (correct: %d)\n",deal,item_deal); |
315 return 0; | 323 return NULL; |
316 } | 324 } |
317 if (new_data) return new_data; | 325 if (new_data) return new_data; |
318 else if (old_data) return old_data; | 326 else if (old_data) return old_data; |
319 return original_data; | 327 return original_data; |
320 } | 328 } |
321 const int* GetOriginal(int deal) const {/* deal は無視 */ | 329 const int* GetOriginal(int deal) const {/* deal は無視 */ |
322 if (item_deal == 0) return 0; | 330 if (item_deal == 0) return NULL; |
323 if (deal > item_deal) { | 331 if (deal > item_deal) { |
324 fprintf(stderr,"AyuSysConfigIntlistItem::Get : invalid items deal %d (correct: %d)\n",deal,item_deal); | 332 fprintf(stderr,"AyuSysConfigIntlistItem::Get : invalid items deal %d (correct: %d)\n",deal,item_deal); |
325 return 0; | 333 return NULL; |
326 } | 334 } |
327 return original_data; | 335 return original_data; |
328 } | 336 } |
329 int Deal(void) const { | 337 int Deal(void) const { |
330 return item_deal; | 338 return item_deal; |
332 /* オリジナルからの変化の調査 : | 340 /* オリジナルからの変化の調査 : |
333 ** DiffOriginal で変化を文字列で取り出し、PatchOriginal で | 341 ** DiffOriginal で変化を文字列で取り出し、PatchOriginal で |
334 ** 変化を反映 | 342 ** 変化を反映 |
335 */ | 343 */ |
336 int DiffOriginalLen(void) { | 344 int DiffOriginalLen(void) { |
337 if (new_data == 0) return 0; | 345 if (new_data == NULL) return 0; |
338 return 12 * item_deal + 1; | 346 return 12 * item_deal + 1; |
339 } | 347 } |
340 void DiffOriginal(string& data) { | 348 void DiffOriginal(string& data) { |
341 if (new_data == 0) { /* あり得ない */ | 349 if (new_data == NULL) { /* あり得ない */ |
342 fprintf(stderr,"AyuSysConfigStringItem::DiffOriginal : this method must not called if not required!\n"); | 350 fprintf(stderr,"AyuSysConfigStringItem::DiffOriginal : this method must not called if not required!\n"); |
343 return; | 351 return; |
344 } | 352 } |
345 int i; char buf[1024]; | 353 int i; char buf[1024]; |
346 for (i=0; i<item_deal; i++) { | 354 for (i=0; i<item_deal; i++) { |
350 return; | 358 return; |
351 } | 359 } |
352 const char* PatchOriginal(const char* data) { | 360 const char* PatchOriginal(const char* data) { |
353 if (old_data) delete[] old_data; | 361 if (old_data) delete[] old_data; |
354 if (new_data) delete[] new_data; | 362 if (new_data) delete[] new_data; |
355 old_data = 0; new_data = 0; | 363 old_data = NULL; |
356 new_data = new int[item_deal]; | 364 new_data = new int[item_deal]; |
357 int i; | 365 int i; |
358 for (i=0; i<item_deal; i++) { | 366 for (i=0; i<item_deal; i++) { |
359 new_data[i] = atoi(data); | 367 new_data[i] = atoi(data); |
360 if (strchr(data, ',') == 0) break; | 368 if (strchr(data, ',') == NULL) break; |
361 data = strchr(data, ',') + 1; | 369 data = strchr(data, ',') + 1; |
362 } | 370 } |
363 return data; | 371 return data; |
364 } | 372 } |
365 void SetOriginal(void) { | 373 void SetOriginal(void) { |
366 if (new_data) delete[] new_data; | 374 if (new_data) delete[] new_data; |
367 if (old_data) delete[] old_data; | 375 if (old_data) delete[] old_data; |
368 new_data = 0; old_data = 0; | 376 new_data = NULL; |
377 old_data = NULL; | |
369 } | 378 } |
370 void Dump(FILE* f) const { | 379 void Dump(FILE* f) const { |
371 fprintf(f, "item deal %d, ",item_deal); | 380 fprintf(f, "item deal %d, ",item_deal); |
372 if (original_data) { | 381 if (original_data) { |
373 fprintf(f, "(%d", original_data[0]); | 382 fprintf(f, "(%d", original_data[0]); |
408 typedef typename maptype::iterator mapiterator; | 417 typedef typename maptype::iterator mapiterator; |
409 typedef typename maptype::const_iterator const_mapiterator; | 418 typedef typename maptype::const_iterator const_mapiterator; |
410 maptype data; | 419 maptype data; |
411 public: | 420 public: |
412 void SetOrig(HashStr& name, int deal, const DataType* str) { | 421 void SetOrig(HashStr& name, int deal, const DataType* str) { |
413 if (str == 0) return; /* 無効 */ | 422 if (str == NULL) return; /* 無効 */ |
414 data[name].Init(deal, str); | 423 data[name].Init(deal, str); |
415 } | 424 } |
416 void Set(HashStr& name, int deal, const DataType* new_data) { | 425 void Set(HashStr& name, int deal, const DataType* new_data) { |
417 if (new_data == 0) return; /* 無効 */ | 426 if (new_data == NULL) return; /* 無効 */ |
418 /* 設定を検索 */ | 427 /* 設定を検索 */ |
419 mapiterator it = data.find(name); | 428 mapiterator it = data.find(name); |
420 /* 設定が元設定に見つからないなら失敗 */ | 429 /* 設定が元設定に見つからないなら失敗 */ |
421 if (it == data.end()) { | 430 if (it == data.end()) { |
422 fprintf(stderr,"AyuSysConfigItem::Set : there is no '%s' parameter\n",name.c_str()); | 431 fprintf(stderr,"AyuSysConfigItem::Set : there is no '%s' parameter\n",name.c_str()); |
426 it->second.Set(deal, new_data); | 435 it->second.Set(deal, new_data); |
427 } | 436 } |
428 /* 新しい設定を優先して返す */ | 437 /* 新しい設定を優先して返す */ |
429 const DataType* Get(int deal, HashStr& name) const { | 438 const DataType* Get(int deal, HashStr& name) const { |
430 const_mapiterator it = data.find(name); | 439 const_mapiterator it = data.find(name); |
431 if (it == data.end()) return 0; | 440 if (it == data.end()) return NULL; |
432 return it->second.Get(deal); | 441 return it->second.Get(deal); |
433 } | 442 } |
434 const DataType* GetOriginal(int deal, HashStr& name) const { | 443 const DataType* GetOriginal(int deal, HashStr& name) const { |
435 const_mapiterator it = data.find(name); | 444 const_mapiterator it = data.find(name); |
436 if (it == data.end()) return 0; | 445 if (it == data.end()) return NULL; |
437 return it->second.GetOriginal(deal); | 446 return it->second.GetOriginal(deal); |
438 } | 447 } |
439 int Deal(HashStr& name) const { | 448 int Deal(HashStr& name) const { |
440 const_mapiterator it = data.find(name); | 449 const_mapiterator it = data.find(name); |
441 if (it == data.end()) return 0; | 450 if (it == data.end()) return NULL; |
442 return it->second.Deal(); | 451 return it->second.Deal(); |
443 } | 452 } |
444 /* オリジナルからの変化の調査 : | 453 /* オリジナルからの変化の調査 : |
445 ** DiffOriginal で変化を文字列で取り出し、PatchOriginal で | 454 ** DiffOriginal で変化を文字列で取り出し、PatchOriginal で |
446 ** 変化を反映 | 455 ** 変化を反映 |
461 } | 470 } |
462 const char* PatchOriginal(const char* diff_data) { | 471 const char* PatchOriginal(const char* diff_data) { |
463 while(*diff_data != ';') { | 472 while(*diff_data != ';') { |
464 char name[1024]; | 473 char name[1024]; |
465 const char* data_start = strchr(diff_data, '='); | 474 const char* data_start = strchr(diff_data, '='); |
466 if (data_start == 0) break; | 475 if (data_start == NULL) break; |
467 strncpy(name, diff_data, data_start-diff_data); | 476 strncpy(name, diff_data, data_start-diff_data); |
468 name[data_start-diff_data] = 0; | 477 name[data_start-diff_data] = 0; |
469 data_start++; | 478 data_start++; |
470 mapiterator it = data.find(name); | 479 mapiterator it = data.find(name); |
471 if (it != data.end()) { | 480 if (it != data.end()) { |
525 /* XXX.015.XXX の類のキー名を XXX.000.XXX の形に規格化して再検索 */ | 534 /* XXX.015.XXX の類のキー名を XXX.000.XXX の形に規格化して再検索 */ |
526 char name_copy[1024]; | 535 char name_copy[1024]; |
527 strncpy(name_copy, name, 1000); | 536 strncpy(name_copy, name, 1000); |
528 name_copy[1000] = 0; | 537 name_copy[1000] = 0; |
529 char* s; | 538 char* s; |
530 for (s=name_copy; s != 0; s = strchr(s,'.')) { | 539 for (s=name_copy; s != NULL; s = strchr(s,'.')) { |
531 if (isdigit(s[1]) && isdigit(s[2]) && isdigit(s[3])) { | 540 if (isdigit(s[1]) && isdigit(s[2]) && isdigit(s[3])) { |
532 s[1] = '0'; s[2] = '0'; s[3] = '0'; | 541 s[1] = '0'; s[2] = '0'; s[3] = '0'; |
533 } | 542 } |
534 s++; | 543 s++; |
535 } | 544 } |
539 else return 0; | 548 else return 0; |
540 } | 549 } |
541 const char* AyuSysConfig::GetParaStr(const char* name) const{ | 550 const char* AyuSysConfig::GetParaStr(const char* name) const{ |
542 HashStr str(name); | 551 HashStr str(name); |
543 const char* ret = str_config->orig.Get(1,str); | 552 const char* ret = str_config->orig.Get(1,str); |
544 if (ret == 0) { | 553 if (ret == NULL) { |
545 // fprintf(stderr,"Cannot find config name '%s'\n",name); | 554 // fprintf(stderr,"Cannot find config name '%s'\n",name); |
546 } | 555 } |
547 return ret; | 556 return ret; |
548 } | 557 } |
549 int AyuSysConfig::GetParam(const char* name, int deal, ...) const{ | 558 int AyuSysConfig::GetParam(const char* name, int deal, ...) const{ |
550 HashStr str(name); | 559 HashStr str(name); |
551 va_list va; int i; | 560 va_list va; int i; |
552 const int* vars = int_config->orig.Get(deal, str); | 561 const int* vars = int_config->orig.Get(deal, str); |
553 if (vars == 0) { | 562 if (vars == NULL) { |
554 // fprintf(stderr,"Cannot find config name '%s'\n",name); | 563 // fprintf(stderr,"Cannot find config name '%s'\n",name); |
555 va_start(va, deal); | 564 va_start(va, deal); |
556 for (i=0; i<deal; i++) { | 565 for (i=0; i<deal; i++) { |
557 int* var = va_arg(va, int*); | 566 int* var = va_arg(va, int*); |
558 if (var != NULL) *var = 0; | 567 if (var != NULL) *var = 0; |
571 } | 580 } |
572 int AyuSysConfig::GetOriginalParam(const char* name, int deal, ...) const{ | 581 int AyuSysConfig::GetOriginalParam(const char* name, int deal, ...) const{ |
573 HashStr str(name); | 582 HashStr str(name); |
574 va_list va; int i; | 583 va_list va; int i; |
575 const int* vars = int_config->orig.GetOriginal(deal, str); | 584 const int* vars = int_config->orig.GetOriginal(deal, str); |
576 if (vars == 0) { | 585 if (vars == NULL) { |
577 // fprintf(stderr,"Cannot find config name '%s'\n",name); | 586 // fprintf(stderr,"Cannot find config name '%s'\n",name); |
578 va_start(va, deal); | 587 va_start(va, deal); |
579 for (i=0; i<deal; i++) { | 588 for (i=0; i<deal; i++) { |
580 int* var = va_arg(va, int*); | 589 int* var = va_arg(va, int*); |
581 if (var != NULL) *var = 0; | 590 if (var != NULL) *var = 0; |
592 } | 601 } |
593 return 0; | 602 return 0; |
594 } | 603 } |
595 const int* AyuSysConfig::GetParamArray(const char* name, int& deal) const{ | 604 const int* AyuSysConfig::GetParamArray(const char* name, int& deal) const{ |
596 HashStr str(name); | 605 HashStr str(name); |
597 if (int_config->orig.Deal(str) == 0) { deal = 0; return 0; } | 606 if (int_config->orig.Deal(str) == 0) { |
607 deal = 0; | |
608 return NULL; | |
609 } | |
598 deal = int_config->orig.Deal(str); | 610 deal = int_config->orig.Deal(str); |
599 const int* vars = int_config->orig.Get(deal, str); | 611 const int* vars = int_config->orig.Get(deal, str); |
600 if (vars == 0) { deal = 0; return 0; } | 612 if (vars == NULL) { |
613 deal = 0; | |
614 return NULL; | |
615 } | |
601 return vars; | 616 return vars; |
602 } | 617 } |
603 void AyuSysConfig::SetParaStr(const char* name, const char* var) { | 618 void AyuSysConfig::SetParaStr(const char* name, const char* var) { |
604 HashStr str(name); | 619 HashStr str(name); |
605 dirty_flag = 1; change_flag = 1; | 620 dirty_flag = 1; change_flag = 1; |
880 | 895 |
881 ARCINFO* info = file_searcher.Find(FILESEARCH::ROOT, "gameexe.ini"); | 896 ARCINFO* info = file_searcher.Find(FILESEARCH::ROOT, "gameexe.ini"); |
882 if (info == NULL) return false; | 897 if (info == NULL) return false; |
883 int size = info->Size(); | 898 int size = info->Size(); |
884 unsigned char* buf_orig = (unsigned char*)info->Read(); | 899 unsigned char* buf_orig = (unsigned char*)info->Read(); |
885 if (size <= 0 || buf_orig == 0) { | 900 if (size <= 0 || buf_orig == NULL) { |
886 delete info; return false; | 901 delete info; return false; |
887 } | 902 } |
888 unsigned char* buf_end = buf_orig + size; | 903 unsigned char* buf_end = buf_orig + size; |
889 int line_count = 0; | 904 int line_count = 0; |
890 while(buf_orig < buf_end) { | 905 while(buf_orig < buf_end) { |
905 else if (*buf_orig == '\r' || *buf_orig == '\n') buf_orig++; | 920 else if (*buf_orig == '\r' || *buf_orig == '\n') buf_orig++; |
906 line_count++; | 921 line_count++; |
907 continue; | 922 continue; |
908 } | 923 } |
909 /* 初期化 */ | 924 /* 初期化 */ |
910 token_deal = 1; tokens[0] = buf; buf_ptr = 0; | 925 token_deal = 1; |
926 tokens[0] = buf; | |
927 buf_ptr = NULL; | |
911 int in_quote = 0; | 928 int in_quote = 0; |
912 | 929 |
913 while(buf_orig < buf_end && buf_ptr < 1023) { | 930 while(buf_orig < buf_end && buf_ptr < 1023) { |
914 if (in_quote) { | 931 if (in_quote) { |
915 /* "" の中 */ | 932 /* "" の中 */ |
928 *buf_orig != '\n' && *buf_orig != '\r') buf_orig++; | 945 *buf_orig != '\n' && *buf_orig != '\r') buf_orig++; |
929 int c = *buf_orig; | 946 int c = *buf_orig; |
930 if (c == '\n' || c == '\r') break; | 947 if (c == '\n' || c == '\r') break; |
931 /* = なら次の token */ | 948 /* = なら次の token */ |
932 if (c == '=') { | 949 if (c == '=') { |
933 c = 0; tokens[token_deal++] = buf+buf_ptr+1; | 950 c = 0; |
951 tokens[token_deal++] = buf+buf_ptr+1; | |
934 if (token_deal >= MAXTOKEN) break; | 952 if (token_deal >= MAXTOKEN) break; |
935 } else if (c == '\"') { | 953 } else if (c == '\"') { |
936 in_quote = 1; buf_orig++; continue; | 954 in_quote = 1; buf_orig++; continue; |
937 } | 955 } |
938 buf[buf_ptr++] = c; | 956 buf[buf_ptr++] = c; |
1067 /* #DSTRACK=00000000-99999000-00782556="filename" ="name" */ | 1085 /* #DSTRACK=00000000-99999000-00782556="filename" ="name" */ |
1068 /* #DSTRACK=00000000-99999000-00782556="name" */ | 1086 /* #DSTRACK=00000000-99999000-00782556="name" */ |
1069 /* 第二トークンの3つめのパラメータを得る(繰り返しの時の再生開始位置) */ | 1087 /* 第二トークンの3つめのパラメータを得る(繰り返しの時の再生開始位置) */ |
1070 int start_pt = 0; | 1088 int start_pt = 0; |
1071 const char* tk1 = strchr(tokens[1], '-'); | 1089 const char* tk1 = strchr(tokens[1], '-'); |
1072 const char* tk2 = 0; | 1090 const char* tk2 = NULL; |
1073 if (tk1 && *tk1) tk2 = strchr(tk1+1, '-'); | 1091 if (tk1 && *tk1) tk2 = strchr(tk1+1, '-'); |
1074 if (tk2 && *tk2) start_pt = atoi(tk2+1); | 1092 if (tk2 && *tk2) start_pt = atoi(tk2+1); |
1075 if (token_deal == 3) { | 1093 if (token_deal == 3) { |
1076 track_name.AddWave(tokens[2], tokens[2], start_pt); | 1094 track_name.AddWave(tokens[2], tokens[2], start_pt); |
1077 dprintf(("Set Wave track, name %s\n",tokens[2])); | 1095 dprintf(("Set Wave track, name %s\n",tokens[2])); |
1222 char buf[1024]; | 1240 char buf[1024]; |
1223 int i; | 1241 int i; |
1224 for (i=0; name[i]!=0; i++) buf[i]=tolower(name[i]); | 1242 for (i=0; name[i]!=0; i++) buf[i]=tolower(name[i]); |
1225 buf[i]=0; | 1243 buf[i]=0; |
1226 for (i=0; i<deal; i++) { | 1244 for (i=0; i<deal; i++) { |
1227 if (track[i] == 0) return 0; | 1245 if (track[i] == 0) return NULL; |
1228 if (strcmp(track[i], buf) == 0) { | 1246 if (strcmp(track[i], buf) == 0) { |
1229 return track_wave[i]; | 1247 return track_wave[i]; |
1230 } | 1248 } |
1231 } | 1249 } |
1232 return 0; | 1250 return NULL; |
1233 } | 1251 } |
1234 const char* TrackName::SETrack(int n) { | 1252 const char* TrackName::SETrack(int n) { |
1235 if (n < 0 || n >= se_deal) return 0; | 1253 if (n < 0 || n >= se_deal) return NULL; |
1236 return se_track[n]; | 1254 return se_track[n]; |
1237 } | 1255 } |
1238 void TrackName::AddSE(int n, char* file) { | 1256 void TrackName::AddSE(int n, char* file) { |
1239 if (se_deal <= n) ExpandSE(n); | 1257 if (se_deal <= n) ExpandSE(n); |
1240 if (se_track[n]) delete[] se_track[n]; | 1258 if (se_track[n]) delete[] se_track[n]; |