| 3 |
#include <wx/dir.h> |
#include <wx/dir.h> |
| 4 |
#include <wx/regex.h> |
#include <wx/regex.h> |
| 5 |
#include <iconv.h> |
#include <iconv.h> |
| 6 |
|
#include <ctype.h> |
| 7 |
|
|
| 8 |
static void toLower(char* string); |
static void toLower(char* string); |
| 9 |
static char* decode(const char* string); |
static char* decode(const char* string); |
| 66 |
tokenList[i] = (char*)malloc(strlen(token)+1); |
tokenList[i] = (char*)malloc(strlen(token)+1); |
| 67 |
snprintf(tokenList[i], strlen(token)+1, "%s", token); |
snprintf(tokenList[i], strlen(token)+1, "%s", token); |
| 68 |
i++; |
i++; |
| 69 |
|
if(i >= MAX_TOKEN) break; |
| 70 |
} |
} |
| 71 |
return true; |
return true; |
| 72 |
} |
} |
| 83 |
fullPathName = *wikiDataDir + wxT("/") + *fileName; |
fullPathName = *wikiDataDir + wxT("/") + *fileName; |
| 84 |
fp = fopen((const char*)fullPathName.mb_str(), "r"); |
fp = fopen((const char*)fullPathName.mb_str(), "r"); |
| 85 |
if(fp == NULL) { |
if(fp == NULL) { |
| 86 |
MN_FATAL_ERROR(wxT("fopen faild")); |
return false; /* because of removed */ |
| 87 |
} |
} |
| 88 |
|
|
| 89 |
/* TYPE search */ |
/* TYPE search */ |
| 109 |
return ans; |
return ans; |
| 110 |
} |
} |
| 111 |
|
|
| 112 |
|
void mnModel::readAll( void ) |
| 113 |
|
{ |
| 114 |
|
int i; |
| 115 |
|
wxDir* dir; |
| 116 |
|
WikiData* wikiData; |
| 117 |
|
wxString* fileName = new wxString(); |
| 118 |
|
char* tokenList[MAX_TOKEN]; |
| 119 |
|
|
| 120 |
|
memset(tokenList, 0, sizeof(char*)*MAX_TOKEN); |
| 121 |
|
tokenList[0] = ""; |
| 122 |
|
|
| 123 |
|
dir = new wxDir(*wikiDataDir); |
| 124 |
|
if ( !dir->IsOpened() ) |
| 125 |
|
{ |
| 126 |
|
MN_FATAL_ERROR(wxT("wxDir has faild\n")); |
| 127 |
|
return ; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
bool cont = dir->GetFirst(fileName, wxT("*.txt"), wxDIR_FILES); |
| 131 |
|
while(cont){ |
| 132 |
|
|
| 133 |
|
matchWithToken(fileName, tokenList); /* match with token list, but never match, just read. */ |
| 134 |
|
|
| 135 |
|
cont = dir->GetNext(fileName); |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
delete dir; |
| 139 |
|
delete fileName; |
| 140 |
|
} |
| 141 |
|
|
| 142 |
WikiList* mnModel::search(const char* searchStr) |
WikiList* mnModel::search(const char* searchStr) |
| 143 |
{ |
{ |
| 144 |
int i; |
int i; |
| 146 |
WikiData* wikiData; |
WikiData* wikiData; |
| 147 |
WikiList* list = new WikiList(); |
WikiList* list = new WikiList(); |
| 148 |
wxString* fileName = new wxString(); |
wxString* fileName = new wxString(); |
| 149 |
char* tokenList[32]; |
char* tokenList[MAX_TOKEN]; |
| 150 |
|
|
| 151 |
memset(tokenList, 0, sizeof(char*)*32); |
memset(tokenList, 0, sizeof(char*)*MAX_TOKEN); |
| 152 |
if( makeSearchToken(searchStr, tokenList) == false) return list; |
if( makeSearchToken(searchStr, tokenList) == false) return list; |
| 153 |
|
|
| 154 |
dir = new wxDir(*wikiDataDir); |
dir = new wxDir(*wikiDataDir); |
| 177 |
return list; |
return list; |
| 178 |
} |
} |
| 179 |
|
|
| 180 |
|
/* |
| 181 |
|
* add malon-type:xxx to search list |
| 182 |
|
*/ |
| 183 |
void mnModel::group() |
void mnModel::group() |
| 184 |
{ |
{ |
| 185 |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
| 233 |
iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
| 234 |
|
|
| 235 |
typeToken = new wxString(outbuf, conv); |
typeToken = new wxString(outbuf, conv); |
| 236 |
addSearchStr(typeToken); |
if( addSearchStr(typeToken) ) { |
| 237 |
|
WikiList* wikiList = search(typeToken->mb_str()); |
| 238 |
|
addSearchList(typeToken, wikiList); |
| 239 |
|
} |
| 240 |
delete typeToken; |
delete typeToken; |
| 241 |
ptr = NULL; |
ptr = NULL; |
| 242 |
} |
} |
| 308 |
return false; |
return false; |
| 309 |
} |
} |
| 310 |
|
|
| 311 |
void mnModel::addSearchStr(wxString* searchStr) |
bool mnModel::addSearchStr(wxString* searchStr) |
| 312 |
{ |
{ |
| 313 |
wxString *string; |
wxString *string; |
| 314 |
|
|
| 316 |
string = new wxString(searchStr->c_str()); |
string = new wxString(searchStr->c_str()); |
| 317 |
searchStrList->Add(*string, 1); |
searchStrList->Add(*string, 1); |
| 318 |
//searchStrList->Insert(*string, 0); |
//searchStrList->Insert(*string, 0); |
| 319 |
|
return true; /* Add */ |
| 320 |
} |
} |
| 321 |
|
return false; /* does'nt add because of duplicating */ |
| 322 |
} |
} |
| 323 |
|
|
| 324 |
void mnModel::addSearchList(wxString* searchStr, WikiList* list) |
void mnModel::addSearchList(wxString* searchStr, WikiList* list) |
| 330 |
{ |
{ |
| 331 |
if(searchStrList->Index(searchStr.c_str()) != wxNOT_FOUND) { |
if(searchStrList->Index(searchStr.c_str()) != wxNOT_FOUND) { |
| 332 |
searchStrList->Remove(searchStr.c_str()); |
searchStrList->Remove(searchStr.c_str()); |
| 333 |
|
wikiHash[*searchStr] = NULL; |
| 334 |
} |
} |
| 335 |
} |
} |
| 336 |
|
|
| 343 |
itemStr.sprintf(wxT("%s"), newStr->c_str()); |
itemStr.sprintf(wxT("%s"), newStr->c_str()); |
| 344 |
} |
} |
| 345 |
} |
} |
| 346 |
|
|
| 347 |
|
void mnModel::clearSearchStrList() |
| 348 |
|
{ |
| 349 |
|
searchStrList->Clear(); |
| 350 |
|
} |
| 351 |
|
|
| 352 |
|
void mnModel::clearSearchResultList() |
| 353 |
|
{ |
| 354 |
|
wikiHash.clear(); |
| 355 |
|
} |
| 356 |
|
|
| 357 |
const wxString* mnModel::getWikiDataDir() |
const wxString* mnModel::getWikiDataDir() |
| 358 |
{ |
{ |
| 359 |
return wikiDataDir; |
return wikiDataDir; |
| 382 |
WikiList::Node* node; |
WikiList::Node* node; |
| 383 |
WikiData* data; |
WikiData* data; |
| 384 |
|
|
| 385 |
node = wikiList->GetFirst(); |
if(wikiList == NULL) { |
| 386 |
if(!node) { |
MN_FATAL_ERROR(wxT("wikiList is null")); |
| 387 |
MN_FATAL_ERROR(wxT("Search Result List is empty")); |
return; |
| 388 |
} |
} |
| 389 |
|
|
| 390 |
|
node = wikiList->GetFirst(); |
| 391 |
while(node) { |
while(node) { |
| 392 |
data = node->GetData(); |
data = node->GetData(); |
| 393 |
if(data == addData) return; |
if(data == addData) return; |
| 394 |
if( *(data->getSubject()) == *(addData->getSubject()) ) { |
if( *(data->getSubject()) == *(addData->getOldSubject()) ) { |
| 395 |
if(wikiList->DeleteObject(data)) { |
if(wikiList->DeleteObject(data)) { |
| 396 |
delete data; |
//delete data; /* may be wrong.. */ |
| 397 |
break; |
break; |
| 398 |
} |
} |
| 399 |
else { |
else { |
| 407 |
wikiList->Sort(compWikiData); |
wikiList->Sort(compWikiData); |
| 408 |
} |
} |
| 409 |
|
|
| 410 |
|
bool mnModel::delSearchResultList(wxString* searchStr, WikiData* delData) |
| 411 |
|
{ |
| 412 |
|
WikiList* wikiList = wikiHash[*searchStr]; |
| 413 |
|
WikiList::Node* node; |
| 414 |
|
WikiData* data; |
| 415 |
|
bool found = false; |
| 416 |
|
|
| 417 |
|
if(wikiList == NULL) { |
| 418 |
|
MN_FATAL_ERROR(wxT("wikiList is null")); |
| 419 |
|
return false; |
| 420 |
|
} |
| 421 |
|
|
| 422 |
|
node = wikiList->GetFirst(); |
| 423 |
|
while(node) { |
| 424 |
|
data = node->GetData(); |
| 425 |
|
if(data == delData) { |
| 426 |
|
if(!wikiList->DeleteObject(data)) { |
| 427 |
|
MN_FATAL_ERROR(wxT("Can't find delete data")); |
| 428 |
|
} |
| 429 |
|
found = true; |
| 430 |
|
break; |
| 431 |
|
} |
| 432 |
|
else if( *(data->getSubject()) == *(delData->getOldSubject()) ) { |
| 433 |
|
if(wikiList->DeleteObject(data)) { |
| 434 |
|
//delete data; /* may be wrong.. */ |
| 435 |
|
found = true; |
| 436 |
|
break; |
| 437 |
|
} |
| 438 |
|
else { |
| 439 |
|
MN_FATAL_ERROR(wxT("Can't find delete data")); |
| 440 |
|
} |
| 441 |
|
} |
| 442 |
|
node = node->GetNext(); |
| 443 |
|
} |
| 444 |
|
wikiList->Sort(compWikiData); |
| 445 |
|
return found; |
| 446 |
|
} |
| 447 |
|
|
| 448 |
/******* WikiData ************************/ |
/******* WikiData ************************/ |
| 449 |
WikiData::WikiData(wxString* dataDir, wxString* inFileName) |
WikiData::WikiData(wxString* dataDir, wxString* inFileName) |
| 450 |
{ |
{ |
| 466 |
|
|
| 467 |
text = NULL; |
text = NULL; |
| 468 |
memset(outbuf, 0, MAX_BUF_SIZE); |
memset(outbuf, 0, MAX_BUF_SIZE); |
| 469 |
fileName = new wxString(*inFileName); |
fileName = new wxString(inFileName->mb_str(), conv); |
| 470 |
dataDirName = dataDir; |
dataDirName = new wxString(dataDir->mb_str(), conv); |
| 471 |
decodeStr = decode(fileName->mb_str()); |
decodeStr = decode(fileName->mb_str()); |
| 472 |
inbufSize = strlen(decodeStr); |
inbufSize = strlen(decodeStr); |
| 473 |
outbufSize = sizeof(outbuf); |
outbufSize = sizeof(outbuf); |
| 474 |
iconv(codeSet, (ICONV_CONST char**)&decodeStr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
iconv(codeSet, (ICONV_CONST char**)&decodeStr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
| 475 |
subject = new wxString((const char*)outbuf, conv); |
subject = new wxString((const char*)outbuf, conv); |
| 476 |
|
oldSubject = new wxString((const char*)outbuf, conv); |
| 477 |
iconv_close(codeSet); |
iconv_close(codeSet); |
| 478 |
|
|
| 479 |
date = NULL; |
date = NULL; |
| 492 |
} |
} |
| 493 |
} |
} |
| 494 |
fclose(fp); |
fclose(fp); |
| 495 |
|
|
| 496 |
|
isWriteToFile = true; |
| 497 |
} |
} |
| 498 |
|
|
| 499 |
WikiData::WikiData(wxString* dataDir) { |
WikiData::WikiData(wxString* dataDir) { |
| 500 |
|
FILE* fp; |
| 501 |
time_t now; |
time_t now; |
| 502 |
char buf[MAX_BUF_SIZE]; |
char buf[MAX_BUF_SIZE]; |
| 503 |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
char fname[MAX_BUF_SIZE]; |
| 504 |
|
char templateBuf[MAX_BUF_SIZE]; |
| 505 |
|
char* inbufPtr; |
| 506 |
|
int inbufSize; |
| 507 |
|
char outbuf[MAX_BUF_SIZE]; |
| 508 |
|
char* outbufPtr; |
| 509 |
|
int outbufSize; |
| 510 |
|
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
| 511 |
|
|
| 512 |
dataDirName = dataDir; |
dataDirName = new wxString(dataDir->mb_str(), conv); |
| 513 |
|
|
| 514 |
time(&now); |
time(&now); |
| 515 |
memset(buf, 0, sizeof(buf)); |
memset(buf, 0, sizeof(buf)); |
| 516 |
strftime(buf, sizeof(buf), "%Y/%m/%d-%H%M%S",localtime(&now)); |
strftime(buf, sizeof(buf), "%Y/%m/%d-%H%M%S",localtime(&now)); |
| 517 |
subject = new wxString(buf, conv); |
subject = new wxString(buf, conv); |
| 518 |
|
oldSubject = new wxString(buf, conv); |
| 519 |
|
|
| 520 |
fileName = new wxString(encode(buf), conv); |
fileName = new wxString(encode(buf), conv); |
| 521 |
fileName->Append(wxT(EXT_TAG)); |
fileName->Append(wxT(EXT_TAG)); |
| 523 |
memset(buf, 0, sizeof(buf)); |
memset(buf, 0, sizeof(buf)); |
| 524 |
strftime(buf, sizeof(buf), DATE_TAG "%Y/%m/%d %H:%M:%S",localtime(&now)); |
strftime(buf, sizeof(buf), DATE_TAG "%Y/%m/%d %H:%M:%S",localtime(&now)); |
| 525 |
date = new wxString(buf, conv); |
date = new wxString(buf, conv); |
| 526 |
|
|
| 527 |
|
/* try to open template file */ |
| 528 |
|
snprintf(fname, sizeof(fname), "%s/%s", (const char*)(dataDir->mb_str()), NEW_DATA_TEMPLATE); |
| 529 |
|
fp = fopen(fname, "r"); |
| 530 |
|
if(fp == NULL){ |
| 531 |
|
memset(buf, 0, sizeof(buf)); |
| 532 |
|
strftime(buf, sizeof(buf), NEW_DATA,localtime(&now)); |
| 533 |
|
} |
| 534 |
|
else { |
| 535 |
|
memset(buf, 0, sizeof(buf)); |
| 536 |
|
memset(templateBuf, 0, sizeof(templateBuf)); |
| 537 |
|
memset(outbuf, 0, sizeof(outbuf)); |
| 538 |
|
fread(templateBuf, sizeof(templateBuf), 1, fp); |
| 539 |
|
|
| 540 |
memset(buf, 0, sizeof(buf)); |
iconv_t codeSet = iconv_open(CODE_SET_SYSTEM, CODE_SET_EUC_JP); |
| 541 |
strftime(buf, sizeof(buf), NEW_DATA,localtime(&now)); |
if(codeSet == (iconv_t)-1) { |
| 542 |
|
MN_FATAL_ERROR(wxT("failed iconv_open")); |
| 543 |
|
} |
| 544 |
|
inbufPtr = templateBuf; |
| 545 |
|
outbufPtr = outbuf; |
| 546 |
|
inbufSize = strlen(templateBuf); |
| 547 |
|
outbufSize = sizeof(outbuf); |
| 548 |
|
iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
| 549 |
|
|
| 550 |
|
strftime(buf, sizeof(buf), outbuf,localtime(&now)); |
| 551 |
|
|
| 552 |
|
} |
| 553 |
text = new wxString(buf, conv); |
text = new wxString(buf, conv); |
| 554 |
|
|
| 555 |
|
if(fp) fclose(fp); |
| 556 |
|
|
| 557 |
|
isWriteToFile = false; |
| 558 |
} |
} |
| 559 |
|
|
| 560 |
WikiData::~WikiData() |
WikiData::~WikiData() |
| 561 |
{ |
{ |
| 562 |
delete subject; |
delete subject; |
| 563 |
|
delete oldSubject; |
| 564 |
delete fileName; |
delete fileName; |
| 565 |
delete date; |
delete date; |
| 566 |
delete text; |
delete text; |
| 567 |
|
delete dataDirName; |
| 568 |
} |
} |
| 569 |
|
|
| 570 |
const wxString* WikiData::getFileName() |
const wxString* WikiData::getFileName() |
| 577 |
return subject; |
return subject; |
| 578 |
} |
} |
| 579 |
|
|
| 580 |
|
const wxString* WikiData::getOldSubject() |
| 581 |
|
{ |
| 582 |
|
return oldSubject; |
| 583 |
|
} |
| 584 |
|
|
| 585 |
|
void WikiData::setOldSubjectFromCurrent() |
| 586 |
|
{ |
| 587 |
|
oldSubject = new wxString(*subject); |
| 588 |
|
} |
| 589 |
|
|
| 590 |
void WikiData::modSubject(wxString* newSubject) |
void WikiData::modSubject(wxString* newSubject) |
| 591 |
{ |
{ |
| 592 |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
| 593 |
wxString* oldFileName = fileName; |
wxString* oldFileName = fileName; |
|
wxString* oldSubject = subject; |
|
| 594 |
char oldFullPath[MAX_BUF_SIZE]; |
char oldFullPath[MAX_BUF_SIZE]; |
| 595 |
char newFullPath[MAX_BUF_SIZE]; |
char newFullPath[MAX_BUF_SIZE]; |
| 596 |
iconv_t codeSet; |
iconv_t codeSet; |
| 602 |
int outbufSize = sizeof(outbuf); |
int outbufSize = sizeof(outbuf); |
| 603 |
FILE* fp; |
FILE* fp; |
| 604 |
|
|
| 605 |
|
oldSubject = subject; |
| 606 |
|
|
| 607 |
memset(outbuf, 0, outbufSize); |
memset(outbuf, 0, outbufSize); |
| 608 |
memset(inbuf, 0, sizeof(inbuf)); |
memset(inbuf, 0, sizeof(inbuf)); |
| 609 |
strcpy(inbuf, (const char*)newSubject->mb_str()); |
strcpy(inbuf, (const char*)newSubject->mb_str()); |
| 632 |
fclose(fp); |
fclose(fp); |
| 633 |
} |
} |
| 634 |
|
|
|
delete oldSubject; |
|
| 635 |
delete oldFileName; |
delete oldFileName; |
| 636 |
} |
} |
| 637 |
|
|
| 660 |
MN_FATAL_ERROR(wxT("failed iconv_open")); |
MN_FATAL_ERROR(wxT("failed iconv_open")); |
| 661 |
} |
} |
| 662 |
|
|
| 663 |
if(text) { |
if(text && isWriteToFile == true) { |
| 664 |
iconv_close(codeSet); |
delete text; |
| 665 |
|
text = NULL; |
| 666 |
|
} |
| 667 |
|
else if(text && isWriteToFile == false) { |
| 668 |
return text; |
return text; |
| 669 |
} |
} |
| 670 |
|
|
| 676 |
} |
} |
| 677 |
|
|
| 678 |
while(fgets(buf, MAX_BUF_SIZE, fp)) { |
while(fgets(buf, MAX_BUF_SIZE, fp)) { |
|
#ifdef __WXMAC__ |
|
|
for(int i = 0; buf[i] != 0; i++) if(buf[i] == (char)MAC_BACKSLASH) buf[i] = '\\'; |
|
|
#endif |
|
| 679 |
inbufPtr = buf; |
inbufPtr = buf; |
| 680 |
inbufSize = sizeof(buf); |
inbufSize = sizeof(buf); |
| 681 |
outbufPtr = outbuf; |
outbufPtr = outbuf; |
| 697 |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
wxCSConv conv(wxT(CODE_SET_SYSTEM)); |
| 698 |
delete text; |
delete text; |
| 699 |
//text = new wxString(intext->c_str()); |
//text = new wxString(intext->c_str()); |
| 700 |
text = new wxString(*intext); |
//text = new wxString(*intext); |
| 701 |
//text = new wxString(intext->mb_str(), conv); |
text = new wxString(intext->mb_str(), conv); |
| 702 |
} |
} |
| 703 |
|
|
| 704 |
void WikiData::removeDataFile() |
void WikiData::removeDataFile() |
| 716 |
char fullPath[MAX_BUF_SIZE]; |
char fullPath[MAX_BUF_SIZE]; |
| 717 |
FILE* fp; |
FILE* fp; |
| 718 |
iconv_t codeSet; |
iconv_t codeSet; |
| 719 |
char inbuf[MAX_WIKI_TEXT_SIZE]; |
char* inbuf; |
| 720 |
char outbuf[MAX_WIKI_TEXT_SIZE]; |
char* outbuf; |
| 721 |
const char* inbufPtr; |
const char* inbufPtr; |
| 722 |
char* outbufPtr; |
char* outbufPtr; |
| 723 |
int inbufSize; |
int inbufSize; |
| 724 |
int outbufSize; |
int outbufSize; |
| 725 |
|
|
| 726 |
|
inbuf = (char*)malloc(MAX_WIKI_TEXT_SIZE); |
| 727 |
|
outbuf = (char*)malloc(MAX_WIKI_TEXT_SIZE); |
| 728 |
|
if(inbuf == NULL || outbuf == NULL) { |
| 729 |
|
MN_FATAL_ERROR(wxT("It's too big data. Max size is 5MB.")); |
| 730 |
|
} |
| 731 |
|
|
| 732 |
codeSet = iconv_open(CODE_SET_EUC_JP, CODE_SET_SYSTEM); |
codeSet = iconv_open(CODE_SET_EUC_JP, CODE_SET_SYSTEM); |
| 733 |
if(codeSet == (iconv_t)-1) { |
if(codeSet == (iconv_t)-1) { |
| 734 |
MN_FATAL_ERROR(wxT("failed iconv_open")); |
MN_FATAL_ERROR(wxT("failed iconv_open")); |
| 740 |
MN_FATAL_ERROR(wxT("File open error.")); |
MN_FATAL_ERROR(wxT("File open error.")); |
| 741 |
} |
} |
| 742 |
|
|
| 743 |
memset(inbuf, 0, sizeof(inbuf)); |
memset(inbuf, 0, MAX_WIKI_TEXT_SIZE); |
| 744 |
strcpy(inbuf,(const char*)text->mb_str()); |
strcpy(inbuf,(const char*)text->mb_str()); |
| 745 |
|
|
| 746 |
#ifdef __WXMAC__ |
//#ifdef __WXMAC__ |
| 747 |
for(int i = 0; inbuf[i] != 0; i++) if(inbuf[i] == (char)MAC_BACKSLASH) inbuf[i] = '\\'; |
// for(int i = 0; inbuf[i] != 0; i++) if(inbuf[i] == (char)MAC_BACKSLASH) inbuf[i] = '\\'; |
| 748 |
#endif |
//#endif |
| 749 |
|
|
| 750 |
inbufPtr = inbuf; |
inbufPtr = inbuf; |
| 751 |
inbufSize = strlen(inbufPtr); |
inbufSize = strlen(inbufPtr); |
| 752 |
outbufPtr = outbuf; |
outbufPtr = outbuf; |
| 753 |
outbufSize = sizeof(outbuf); |
outbufSize = MAX_WIKI_TEXT_SIZE; |
| 754 |
memset(outbuf, 0, outbufSize); |
memset(outbuf, 0, outbufSize); |
| 755 |
iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize); |
| 756 |
fwrite(outbuf, sizeof(outbuf)-outbufSize, 1, fp); |
if(inbufSize != 0) { // iconv error |
| 757 |
|
wxMessageBox(wxT("Fail to save, because this memo include KISHU-IZON-MOJI.\nPlease remove KISHU-IZON-MOJI, and try again"), wxT("Fail to save"), wxOK|wxICON_WARNING); |
| 758 |
|
} |
| 759 |
|
fwrite(outbuf, MAX_WIKI_TEXT_SIZE-outbufSize, 1, fp); |
| 760 |
fclose(fp); |
fclose(fp); |
| 761 |
iconv_close(codeSet); |
iconv_close(codeSet); |
| 762 |
|
|
| 763 |
|
free(inbuf); |
| 764 |
|
free(outbuf); |
| 765 |
|
|
| 766 |
|
isWriteToFile = true; |
| 767 |
} |
} |
| 768 |
|
|
| 769 |
/******* Tools ************************/ |
/******* Tools ************************/ |