Changeset 350 for trunk/dll/killproc.c


Ignore:
Timestamp:
Jul 26, 2006, 9:01:20 PM (19 years ago)
Author:
root
Message:

Use Runtime_Error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/killproc.c

    r161 r350  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2005 Steven H. Levine
     9  Copyright (c) 2005, 2006 Steven H. Levine
    1010
    1111  24 May 05 SHL Rework Win_Error usage
     12  14 Jul 06 SHL Use Runtime_Error
    1213
    1314***********************************************************************/
     
    1617#define INCL_DOS
    1718#define INCL_WIN
    18 
    1919#include <os2.h>
     20
    2021#include <stdlib.h>
    2122#include <stdio.h>
     
    2526#include <process.h>
    2627#include <limits.h>
     28
    2729#include "procstat.h"
    2830#include "fm3dll.h"
     
    3133
    3234#pragma data_seg(DATA2)
     35
     36static PSZ pszSrcFile = __FILE__;
     37
    3338#pragma alloc_text(KILLPROC,FillKillList,FillKillList2,GetDosPgmName,KillDlgProc)
    3439
    35 
    36 CHAR *GetDosPgmName (PID pid,CHAR *string) {
    37 
     40CHAR *GetDosPgmName (PID pid,CHAR *string)
     41{
    3842  HSWITCH hs;
    3943  SWCNTRL swctl;
     
    6468
    6569
    66 VOID FillKillList2 (VOID *arg) {
    67 
     70VOID FillKillList2 (VOID *arg)
     71{
    6872  HWND          hwnd = *(HWND *)arg;
    6973  CHAR          s[1036];
     
    8084
    8185  WinSendDlgItemMsg(hwnd,KILL_LISTBOX,LM_DELETEALL,MPVOID,MPVOID);
    82   if(!DosAllocMem((PVOID)&pbh,USHRT_MAX + 4096,
    83                   PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) {
     86  rc = DosAllocMem((PVOID)&pbh,USHRT_MAX + 4096,
     87                    PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
     88  if (rc)
     89    Dos_Error(MB_CANCEL,rc,HWND_DESKTOP,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
     90  else {
    8491    rc = DosQProcStatus(pbh,USHRT_MAX);
    85     if(!rc) {
     92    if (!rc) {
    8693      ppi = pbh->ppi;
    8794      while(ppi->ulEndIndicator != PROCESS_END_INDICATOR ) {
     
    100107                strcat(s,GetPString(IDS_UNKNOWNPROCTEXT));
    101108            }
    102             if(WinIsWindow(thab,hwnd))
     109            if (WinIsWindow(thab,hwnd)) {
    103110              WinSendDlgItemMsg(hwnd,KILL_LISTBOX,LM_INSERTITEM,
    104111                                MPFROM2SHORT(LIT_SORTASCENDING,0),
    105112                                             MPFROMP(s));
     113            }
    106114            else
    107115              break;
     
    109117        }
    110118        ppi = (PPROCESSINFO)(ppi->ptiFirst + ppi->usThreadCount);
    111       }
     119      } // while
    112120    }
    113121    DosFreeMem(pbh);
    114122  }
    115 Abort:
     123
    116124  if(WinIsWindow(thab,hwnd))
    117125    PostMsg(hwnd,UM_CONTAINER_FILLED,MPVOID,MPVOID);
     
    121129
    122130
    123 VOID FillKillList (VOID *arg) {
    124 
     131VOID FillKillList (VOID *arg)
     132{
    125133  HWND  hwnd = *(HWND *)arg;
    126134  CHAR  s[1036],progname[1027],*p;
     
    149157  unlinkf("%s",s);
    150158  fp = fopen(s,"w");
    151   if(fp) {
     159  if(!fp) {
     160    Win_Error(NULLHANDLE,HWND_DESKTOP,__FILE__,__LINE__,
     161              GetPString(IDS_REDIRECTERRORTEXT));
     162    goto Abort;
     163  }
     164  else {
    152165    newstdout = -1;
    153     if(DosDupHandle(fileno(stdout),&newstdout))
    154       DosBeep(50,100);
     166    rc = DosDupHandle(fileno(stdout),&newstdout);
     167    if (rc)
     168      Dos_Error(MB_CANCEL,rc,hwnd,__FILE__,__LINE__,"DosDupHandle");
    155169    oldstdout = fileno(stdout);
    156170    DosDupHandle(fileno(fp),&oldstdout);
     
    173187    }
    174188  }
    175   else {
    176     Win_Error(NULLHANDLE,HWND_DESKTOP,__FILE__,__LINE__,
    177               GetPString(IDS_REDIRECTERRORTEXT));
    178     goto Abort;
    179   }
    180189  fp = fopen(s,"r");
    181190  if(fp) {
     
    225234
    226235
    227 MRESULT EXPENTRY KillDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    228 
     236MRESULT EXPENTRY KillDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     237{
    229238  SHORT           sSelect;
    230239  PID             pid;
     
    387396                if(SHORT1FROMMP(mp1) == DID_OK) {
    388397                  error = DosKillProcess(DKP_PROCESS,pid);
    389                   if(error && error != ERROR_INVALID_PROCID)
     398                  if(error && error != ERROR_INVALID_PROCID) {
    390399                    Dos_Error(MB_CANCEL,
    391400                              error,
     
    394403                              __LINE__,
    395404                              GetPString(IDS_DOSKILLFAILEDTEXT));
     405                  }
    396406                  else
    397407                    WinSendDlgItemMsg(hwnd,
     
    409419
    410420        case DID_CANCEL:
    411           if(listdone)
     421          if(!listdone)
     422            Runtime_Error(pszSrcFile, __LINE__, "busy");
     423          else
    412424            WinDismissDlg(hwnd,0);
    413           else
    414             DosBeep(100,100);
    415425          break;
    416426
     
    426436    case WM_CLOSE:
    427437      if(!listdone) {
    428         DosBeep(100,100);
     438        Runtime_Error(pszSrcFile, __LINE__, "busy");
    429439        return 0;
    430440      }
Note: See TracChangeset for help on using the changeset viewer.