home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2001 January / VPR0101A.BIN / OLS / TAR32053 / tar32053.exe / SRC / TARMSG.C < prev    next >
C/C++ Source or Header  |  1999-05-23  |  5KB  |  158 lines

  1. /*
  2.     TarMsg.c
  3.  
  4.     この中の関数を呼ぶと、SetOwnerWindowで設定されたWindowにメッセージを通知することができる。
  5. */
  6.  
  7. #include "tarmsg.h"
  8. #include "tar32.h"
  9. #include "dfltwin.h"
  10. #include "main.h"
  11. #include <windows.h>
  12.  
  13. /*nMode        wParam の値です。UNLHA32.DLL の処理の状態を表します。
  14.  
  15.     0 : UNLHA32.DLL が該当ファイルの処理を開始することを表します。
  16.     1 : UNLHA32.DLL が該当ファイルの展開中であることを表します。
  17.     2 : UNLHA32.DLL が処理を終え,lpEis のメモリを開放しようとしてい
  18.         ることを表します。
  19.     3 : UNLHA32.DLL が該当書庫の処理を開始することを表します。szSour-
  20.         ceFileName に書庫名が格納されます。
  21.     4 : UNLHA32.DLL がワークファイルの書き戻しを開始することを表しま
  22.         す。szSourceFileName にワークファイル名が格納されます。
  23. */
  24.  
  25. HWND OwnerWindow=NULL;
  26. ARCHIVERPROC *ArchiverProc=NULL;
  27.  
  28. UINT WM_ARCEXTRACT_UINT=0;
  29.  
  30. static HWND OwnerWindowItr=NULL;            /* 解凍状況を通知するウィンドウ */
  31. static ARCHIVERPROC *ArchiverProcItr=NULL;    /* 解凍状況を通知する関数 */
  32.  
  33. static EXTRACTINGINFOEX info;        /* ウインドウにポインタを渡す解凍状況 */
  34. extern HWND api_hwnd;
  35.  
  36. /*****local functions*********/
  37.  
  38. static int TarMsg(int mode,EXTRACTINGINFOEX *pInfo)
  39. {
  40.     int ret1=0,ret2=1;
  41.  
  42.     if(OPTION_display_dialog==0){return 0;}
  43.  
  44.     //MessageBox(api_hwnd,"preSendMEssage","tar32.dll",0);
  45.     ret1=SendMessage(OwnerWindowItr,WM_ARCEXTRACT_UINT,(WPARAM)mode,(LPARAM)pInfo);
  46.     //MessageBox(api_hwnd,"postSendMEssage","tar32.dll",0);
  47.     /*
  48.     if(ret1 != 0){
  49.         char str[1000];
  50.         
  51.         sprintf(str,"SendMessage return=%d",ret1);
  52.         MessageBox(api_hwnd,str,"TAR32.DLL",0);
  53.     }*/
  54.  
  55.     if(ArchiverProcItr!=NULL){
  56.         ret2=(*ArchiverProcItr)(OwnerWindow,WM_ARCEXTRACT_UINT,mode,pInfo);
  57.     }
  58.     return (ret1==0 && ret2 !=0 ? 0 : -1 );
  59. }
  60. static void ExtractingInfoExInit(EXTRACTINGINFOEX *info)
  61. {
  62.     memset(info,0,sizeof(EXTRACTINGINFOEX));
  63. }
  64. static void HeaderToExtractingInfoEx(EXTRACTINGINFOEX *exinfo,HEADER *phead,char *srcfile,char *destfile,int writesize)
  65. {
  66.     INDIVIDUALINFO iinfo;
  67.     extern void HeaderToIndividualInfo(INDIVIDUALINFO *info,HEADER *head,char *fname);
  68.  
  69.     HeaderToIndividualInfo(&iinfo,phead,srcfile);
  70.     exinfo->exinfo.dwFileSize=iinfo.dwOriginalSize;
  71.     exinfo->exinfo.dwWriteSize=writesize;
  72.     strcpy(exinfo->exinfo.szSourceFileName,srcfile);
  73.     strcpy(exinfo->exinfo.szDestFileName,destfile);
  74.     exinfo->dwCompressedSize=iinfo.dwCompressedSize;
  75.     exinfo->dwCRC=iinfo.dwCRC;
  76.     exinfo->uOSType=iinfo.uOSType;
  77.     exinfo->wRatio=iinfo.wRatio;
  78.     exinfo->wDate=iinfo.wDate;
  79.     exinfo->wTime=iinfo.wTime;
  80.     strncpy(exinfo->szAttribute,iinfo.szAttribute,8);
  81.     strncpy(exinfo->szMode,iinfo.szMode,8);
  82. }
  83.  
  84.  
  85. /*****global functions*************/
  86.  
  87. /* メッセージ通知処理の初期化 */
  88. void TarMsg_static_init(void)
  89. {
  90.     OwnerWindowItr=NULL;
  91.     ArchiverProcItr=NULL;
  92.  
  93.     if(WM_ARCEXTRACT_UINT==0){
  94.         WM_ARCEXTRACT_UINT=RegisterWindowMessage(WM_ARCEXTRACT);
  95.     }
  96. }
  97.  
  98.  
  99. /* 書庫ファイル(xxx.tgzなど)の処理開始 */
  100. int TarMsgArcFileBegin(char *arcfile)
  101. {
  102.     if(OPTION_display_dialog==0){return 0;}
  103.     if(OwnerWindow || ArchiverProc){
  104.         OwnerWindowItr=OwnerWindow;
  105.         ArchiverProcItr=ArchiverProc;
  106.  
  107.     }else{
  108.     //MessageBox(api_hwnd,"preownerwindowitr","tar32.dll debug",0);
  109.  
  110.         DefaultWindowInit(&OwnerWindowItr,&ArchiverProcItr);
  111.     //MessageBox(api_hwnd,"post ownerwindowitr","tar32.dll debug",0);
  112.  
  113.     }
  114.     ExtractingInfoExInit(&info);
  115.     strcpy(info.exinfo.szSourceFileName,arcfile);
  116.     return TarMsg(ARCEXTRACT_OPEN,&info);
  117. }
  118.  
  119. /* 書庫ファイル内に格納されたファイルの処理開始 */
  120. int TarMsgFileBegin(HEADER *head,char *szDestFileName,char *szSourceFileName)
  121. {
  122.     if(OPTION_display_dialog==0){return 0;}
  123.     if(OwnerWindowItr == NULL){return 0;}
  124.  
  125.     HeaderToExtractingInfoEx(&info,head,szDestFileName,szSourceFileName,0);
  126.     return TarMsg(ARCEXTRACT_BEGIN,&info);
  127. }
  128.  
  129. /* 書庫ファイル内に格納されたファイルの処理中 */
  130. int TarMsgFileInProcess(HEADER *head,char *szDestFileName,char *szSourceFileName,int done_size)
  131. {
  132.     if(OPTION_display_dialog==0){return 0;}
  133.     if(OwnerWindowItr == NULL){return 0;}
  134.  
  135.     HeaderToExtractingInfoEx(&info,head,szDestFileName,szSourceFileName,done_size);
  136.     return TarMsg(ARCEXTRACT_INPROCESS,&info);
  137. }
  138.  
  139. /* すべての処理を終了 */
  140. void TarMsgEnd(void)
  141. {
  142.     if(OPTION_display_dialog==0){return;}
  143.     if(OwnerWindowItr == NULL){return;}
  144.     
  145.     ExtractingInfoExInit(&info);
  146.     //MessageBox(api_hwnd,"TarMsgEnd1","tar32.dll debug",0);
  147.     TarMsg(ARCEXTRACT_END,&info);
  148.     //MessageBox(api_hwnd,"TarMsgEnd2","tar32.dll debug",0);
  149.     if(OwnerWindow == NULL){
  150.         WaitDefaultWindowEnd();
  151.     }
  152.     //MessageBox(api_hwnd,"TarMsgEnd3","tar32.dll debug",0);
  153.     ArchiverProcItr=NULL;
  154.  
  155.     OwnerWindowItr=NULL;
  156. }
  157.  
  158.