windows-nt/Source/XPSP1/NT/windows/feime/tools/array/convert/arcvt.c

279 lines
9.9 KiB
C
Raw Permalink Normal View History

2020-09-26 03:20:57 -05:00
//
// <20><><EFBFBD>C <20><><EFBFBD>Ѹ<EFBFBD><D1B8>T <20><><EFBFBD>X<EFBFBD>D<EFBFBD>{<7B><>
//
// <20><><EFBFBD>Ż<EFBFBD> 1998/03/15
//
#include <windows.h>
#include <commdlg.h>
#include <string.h>
#include <stdlib.h>
#include <direct.h>
#include "resource.h"
#include "function.h"
char szAppName[] = "<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD>T<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>{<7B><>" ;
char *szFilterI = "<EFBFBD><EFBFBD><EFBFBD>r<EFBFBD><EFBFBD> (*.TXT;*.NT)\0*.txt;*.nt\0All Files (*.*)\0*.*\0";
char *szFilterO = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (*.TAB)\0*.tab\0All Files (*.*)\0*.*\0";
char *szFilterH = "<EFBFBD><EFBFBD><EFBFBD>w<EFBFBD><EFBFBD> (*.TBL)\0*.tbl\0All Files (*.*)\0*.*\0";
HANDLE hInst;
//HWND msghwnd;
char szInWordFileName[256];
char szOutWordFileName[256];
char szInHighFileName[256];
char szOutHighFileName[256];
char szInPhrFileName[256];
char szOutPhrFileName[256];
char szIdxFileName[256];
char hlpfile[256];
DWORD line;
long FAR PASCAL CALLBACK WndProc (HWND, UINT, UINT, LONG) ;
int cvtword (char *,char *,DWORD *);
int cvthigh (char *,char *,DWORD *);
int cvtphrase (char *,char *,char *,DWORD *);
void error(HWND hwnd,int ErrCode,int item)
{
char Buffer[255];
char szMsg[255];
if(LoadString(hInst, ErrCode, (LPSTR)Buffer, sizeof(Buffer)))
switch(ErrCode)
{
case IDS_ERROPENFILE:
case IDS_ERRUNICODE:
case IDS_ERRFORMATROOT:
case IDS_ERRFORMATROOTS:
case IDS_ERRFORMATPHRASE:
case IDS_ERRFORMATCODE:
switch(item)
{
case IDM_WORD:
wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szInWordFileName,line);
break;
case IDM_HIGH:
wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szInHighFileName,line);
break;
case IDM_PHRASE:
wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szInPhrFileName,line);
break;
}
break;
case IDS_ERRCREATEFILE:
switch(item)
{
case IDM_WORD:
wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szOutWordFileName,line);
break;
case IDM_HIGH:
wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szOutHighFileName,line);
break;
case IDM_PHRASE:
wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szOutPhrFileName,line);
break;
}
break;
case IDS_ERRCREATEIDX:
wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szIdxFileName);
break;
default:
strcpy(szMsg,"<EFBFBD>o<EFBFBD>ͤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~!");
break;
}
else
strcpy(szMsg,"<EFBFBD>o<EFBFBD>ͤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~!");
MessageBox(hwnd,(LPSTR)szMsg,szAppName,MB_OK | MB_ICONHAND |MB_APPLMODAL);
}
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow)
{
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;//LoadIcon (hInstance, "ICON") ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = "MENU" ;
wndclass.lpszClassName = szAppName ;
RegisterClass (&wndclass) ;
}
hInst=hInstance;
_getcwd( hlpfile, sizeof(hlpfile));
if(hlpfile[strlen(hlpfile)-1]=='\\')
hlpfile[strlen(hlpfile)-1]=0;
strcat(hlpfile,"\\ARCVT.TXT");
hwnd = CreateWindow (szAppName, // window class name
szAppName, // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, nCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
long FAR PASCAL CALLBACK WndProc (HWND hwnd, UINT message, UINT wParam,
LONG lParam)
{
static FARPROC dlgprc;
static HWND msghwnd;
HCURSOR hcurSave;
int ErrCode;
static HFILE hlp;
NPSTR npmem;
WORD Len;
switch (message)
{
case WM_CREATE:
strcpy(szInWordFileName,"arntall.nt");
strcpy(szOutWordFileName,"array30.tab");
strcpy(szInHighFileName,"arhw-nt.nt");
strcpy(szOutHighFileName,"arrayhw.tab");
strcpy(szInPhrFileName,"ar25000.nt");
strcpy(szOutPhrFileName,"arphr.tbl");
strcpy(szIdxFileName,"arptr.tbl");
msghwnd = CreateWindow ("edit", NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
WS_BORDER | ES_LEFT | ES_MULTILINE |
ES_AUTOHSCROLL,
//ES_AUTOVSCROLL, //ES_AUTOHSCROLL |
0, 0, 0,0,
hwnd, (HANDLE)1,
hInst, NULL) ;
SendMessage(msghwnd,EM_SETREADONLY,TRUE,0L);
if((hlp=_lopen((LPSTR)hlpfile, OF_READ))>0)
{
Len = (WORD) FileLen(hlp);
npmem = (NPSTR)LocalAlloc(LMEM_FIXED,Len+1);
_lread(hlp,(LPSTR)npmem,Len);
_lclose(hlp);
*(npmem+Len)=0;
SendMessage(msghwnd,WM_SETTEXT,0,(LPARAM)(LPSTR)npmem);
}
PopFileInit ();
return 0;
case WM_SIZE:
MoveWindow(msghwnd,0, 0, LOWORD(lParam),HIWORD(lParam),TRUE);
return 0;
case WM_COMMAND:
switch(wParam)
{
case IDM_WORD: //<2F><><EFBFBD>r
if(!PopFileOpenDlg(hwnd,szInWordFileName,"<EFBFBD>п<EFBFBD><EFBFBD>ܸ<EFBFBD><EFBFBD>ƨӷ<EFBFBD>",szFilterI))
break;
if((ErrCode=IsUniCode (szInWordFileName))!=0)
{
error(hwnd,ErrCode,wParam);
break;
}
if(!PopFileSaveDlg(hwnd,szOutWordFileName,"<EFBFBD>Ы<EFBFBD><EFBFBD>w<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>ɦW",szFilterO))
break;
hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT));
ErrCode=cvtword(szInWordFileName,szOutWordFileName,&line);
SetCursor(hcurSave);
if(!ErrCode)
MessageBox(hwnd,"<EFBFBD><EFBFBD><EFBFBD>r<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD>T<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I",szAppName,0);
else
error(hwnd,ErrCode,wParam);
break;
case IDM_PHRASE: //<2F><><EFBFBD>y
if(!PopFileOpenDlg(hwnd,szInPhrFileName,"<EFBFBD>п<EFBFBD><EFBFBD>ܸ<EFBFBD><EFBFBD>ƨӷ<EFBFBD>",szFilterI))
break;
if((ErrCode=IsUniCode (szInPhrFileName))!=0)
{
error(hwnd,ErrCode,wParam);
break;
}
if(!PopFileSaveDlg(hwnd,szOutPhrFileName,"<EFBFBD>Ы<EFBFBD><EFBFBD>w<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><EFBFBD><EFBFBD>y<EFBFBD>ɦW",szFilterH))
break;
if(!PopFileSaveDlg(hwnd,szIdxFileName,"<EFBFBD>Ы<EFBFBD><EFBFBD>w<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɦW",szFilterH))
break;
hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT));
ErrCode=cvtphrase(szInPhrFileName,szOutPhrFileName,szIdxFileName,&line);
SetCursor(hcurSave);
if(!ErrCode)
MessageBox(hwnd,"<EFBFBD><EFBFBD><EFBFBD>y<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD>T<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I",szAppName,0);
else
error(hwnd,ErrCode,wParam);
break;
case IDM_HIGH: //²<>X
if(!PopFileOpenDlg(hwnd,szInHighFileName,"<EFBFBD>п<EFBFBD><EFBFBD>ܸ<EFBFBD><EFBFBD>ƨӷ<EFBFBD>",szFilterI))
break;
if((ErrCode=IsUniCode (szInHighFileName))!=0)
{
error(hwnd,ErrCode,wParam);
break;
}
if(!PopFileSaveDlg(hwnd,szOutHighFileName,"<EFBFBD>Ы<EFBFBD><EFBFBD>w<EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>ɦW",szFilterO))
break;
hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT));
ErrCode=cvthigh(szInHighFileName,szOutHighFileName,&line);
SetCursor(hcurSave);
if(!ErrCode)
MessageBox(hwnd,"²<EFBFBD>X<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD>T<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I",szAppName,0);
else
error(hwnd,ErrCode,wParam);
break;
}
return 0;
case WM_DESTROY:
DestroyWindow(msghwnd);
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}