Changeset 353


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

Check more run time errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/remap.c

    r246 r353  
    55
    66  Copyright (c) 1993, 1998 M. Kimes
    7   Copyright (c) 2004, 2005 Steven H.Levine
     7  Copyright (c) 2004, 2006 Steven H.Levine
    88
    99  01 Aug 04 SHL Rework lstrip/rstrip usage
    1010  06 Aug 05 SHL Renames
     11  22 Jul 06 SHL Check more run time errors
    1112
    1213***********************************************************************/
     
    2728
    2829#pragma data_seg(DATA1)
     30
     31static PSZ pszSrcFile = __FILE__;
     32
    2933#pragma alloc_text(FMREMAP,RemapDlgProc,load_resources,save_resources)
    3034#pragma alloc_text(FMREMAP,add_resource,remove_resource,free_resources)
     
    5155
    5256
    53 VOID load_resources (VOID) {
    54 
     57VOID load_resources (VOID)
     58{
    5559  /* load linked list of resources from RESOURCE.DAT file */
    5660
     
    6569    strcat(s,"\\");
    6670  strcat(s,"RESOURCE.DAT");
    67   fp = _fsopen(s,"r",SH_DENYWR);
    68   if(fp) {
     71  fp = xfsopen(s,"r",SH_DENYWR,pszSrcFile,__LINE__);
     72  if (fp) {
    6973    while(x < MAXNUMRES && !feof(fp)) {
    7074      if(!fgets(s,sizeof(s),fp))
     
    7377      bstripcr(s);
    7478      if(*s && *s != ';') {
    75         info = malloc(sizeof(LINKRES));
    76         if(info) {
    77           info->res = strdup(s);
    78           if(info->res) {
     79        info = xmalloc(sizeof(LINKRES),pszSrcFile,__LINE__);
     80        if (info) {
     81          info->res = xstrdup(s,pszSrcFile,__LINE__);
     82          if (!info->res)
     83            free(info);
     84          else {
    7985            x++;
    8086            info->next = NULL;
     
    8591            last = info;
    8692          }
    87           else
    88             free(info);
    8993        }
    9094      }
     
    9599
    96100
    97 VOID save_resources (VOID) {
    98 
     101VOID save_resources (VOID)
     102{
    99103  /* save linked list of resources to RESOURCE.DAT file */
    100104
     
    110114  strcat(s,"RESOURCE.DAT");
    111115  if(reshead) {
    112     fp = fopen(s,"w");
    113     if(fp) {
     116    fp = xfopen(s,"w",pszSrcFile,__LINE__);
     117    if (fp) {
    114118      fputs(GetPString(IDS_REMOTEFILETEXT),fp);
    115119      info = reshead;
    116       while(info) {
     120      while (info) {
    117121        fprintf(fp,
    118122                "%0.*s\n",
     
    129133
    130134
    131 BOOL add_resource (CHAR *res) {
    132 
     135BOOL add_resource (CHAR *res)
     136{
    133137  LINKRES *info,*last = NULL;
    134138  INT      x = 0;
     
    146150    x++;
    147151  }
    148   info = malloc(sizeof(LINKRES));
     152  info = xmalloc(sizeof(LINKRES),pszSrcFile,__LINE__);
    149153  if(info) {
    150     info->res = strdup(res);
    151     if(info->res) {
     154    info->res = xstrdup(res,pszSrcFile,__LINE__);
     155    if (!info->res)
     156      free(info);
     157    else {
    152158      info->next = NULL;
    153159      if(!reshead)
     
    162168      return TRUE;
    163169    }
    164     else
    165       free(info);
    166170  }
    167171  return FALSE;
     
    169173
    170174
    171 BOOL remove_resource (CHAR *res) {
    172 
     175BOOL remove_resource (CHAR *res)
     176{
    173177  LINKRES *info,*last = NULL;
    174178
     
    195199
    196200
    197 VOID free_resources (VOID) {
    198 
     201VOID free_resources (VOID)
     202{
    199203  LINKRES *info,*next;
    200204
     
    211215
    212216
    213 MRESULT EXPENTRY RemapDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    214 
     217MRESULT EXPENTRY RemapDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     218{
    215219  static BOOL fRemapped;
    216220  static APPNOTIFY *apphead = NULL,*apptail = NULL;
     
    601605                                          MAP_ATTACHTO,
    602606                                          NullStr);
    603                         info = malloc(sizeof(APPNOTIFY));
    604                         if(info) {
    605                           memset(info,0,sizeof(APPNOTIFY));
     607                        info = xmallocz(sizeof(APPNOTIFY),pszSrcFile,__LINE__);
     608                        if (info) {
    606609                          info->happ = happ;
    607610                          info->attach = FALSE;
     
    626629                               params);
    627630                    }
    628 #ifdef NEVER
     631#ifdef NEVER                            // fixme to be gone?
    629632                    DosError(FERR_DISABLEHARDERR);
    630633                    rc = DosFSAttach(d,
     
    633636                                     strlen(d) + 1,
    634637                                     FS_DETACH);
    635                     if(!rc) {
     638                    if (rc) {
     639                      Dos_Error(MB_CANCEL,
     640                                rc,
     641                                hwnd,
     642                                pszSrcFile,
     643                                __LINE__,
     644                                GetPString(IDS_DETACHFAILEDTEXT),
     645                                d,
     646                                s);
     647                    }
     648                    else {
    636649                      fRemapped = TRUE;
    637650                      WinSendDlgItemMsg(hwnd,
     
    646659                                        MPFROMP(d));
    647660                    }
    648                     else
    649                       Dos_Error(MB_CANCEL,
    650                                 rc,
    651                                 hwnd,
    652                                 __FILE__,
    653                                 __LINE__,
    654                                 GetPString(IDS_DETACHFAILEDTEXT),
    655                                 d,
    656                                 s);
    657 #endif
     661#endif                                  // fixme to be gone?
    658662                    break;
    659663
     
    727731                    APPNOTIFY *info;
    728732
    729                     info = malloc(sizeof(APPNOTIFY));
    730                     if(info) {
    731                       memset(info,0,sizeof(APPNOTIFY));
     733                    info = xmallocz(sizeof(APPNOTIFY),pszSrcFile,__LINE__);
     734                    if (info) {
    732735                      info->happ = happ;
    733736                      info->attach = TRUE;
     
    751754                           p,
    752755                           params);
    753 #ifdef NEVER
     756#ifdef NEVER                            // fixme to be gone?
    754757                  DosError(FERR_DISABLEHARDERR);
    755758                  rc = DosFSAttach(d,s,s,strlen(s) + 1,FS_ATTACH);
    756                   if(!rc) {
     759                  if (rc) {
     760                    Dos_Error(MB_CANCEL,
     761                              rc,
     762                              hwnd,
     763                              pszSrcFile,
     764                              __LINE__,
     765                              GetPString(IDS_ATTACHFAILEDTEXT),
     766                              s,
     767                              d);
     768                  }
     769                  else {
    757770                    fRemapped = TRUE;
    758771                    WinSendDlgItemMsg(hwnd,
     
    767780                                      MPFROMP(d));
    768781                  }
    769                   else
    770                     Dos_Error(MB_CANCEL,
    771                               rc,
    772                               hwnd,
    773                               __FILE__,
    774                               __LINE__,
    775                               GetPString(IDS_ATTACHFAILEDTEXT),
    776                               s,
    777                               d);
    778 #endif
     782#endif                                  // fixme to be gone?
    779783                }
    780784              }
Note: See TracChangeset for help on using the changeset viewer.