Changeset 342 for trunk/dll/assoc.c


Ignore:
Timestamp:
Jul 26, 2006, 4:00:11 AM (19 years ago)
Author:
root
Message:

Use Runtime_Error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/assoc.c

    r290 r342  
    55
    66  Copyright (c) 1993-98 M. Kimes
    7   Copyright (c) 2004 Steven H.Levine
     7  Copyright (c) 2004, 2006 Steven H.Levine
    88
    99  01 Aug 04 SHL Rework lstrip/rstrip usage
     10  14 Jul 06 SHL Use Runtime_Error
    1011
    1112***********************************************************************/
     
    4748static BOOL       assloaded = FALSE;
    4849
     50static PSZ pszSrcFile = __FILE__;
     51
    4952#pragma alloc_text(ASSOC2,free_commands,load_associations,save_associations)
    5053#pragma alloc_text(ASSOC2,ExecAssociation,AssocTextProc)
    5154
    52 
    53 MRESULT EXPENTRY AssocTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    54 
     55MRESULT EXPENTRY AssocTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     56{
    5557  PFNWP oldproc = (PFNWP)WinQueryWindowPtr(hwnd,QWL_USER);
    5658  static BOOL emphasized = FALSE;
     
    98100
    99101
    100 VOID free_associations (VOID) {
    101 
     102VOID free_associations (VOID)
     103{
    102104  LINKASSOC *info,*next;
    103105
     
    116118
    117119
    118 VOID load_associations (VOID) {
    119 
     120VOID load_associations (VOID)
     121{
    120122  FILE      *fp;
    121123  LINKASSOC *info;
     
    134136  strcat(mask,"ASSOC.DAT");
    135137  fp = _fsopen(mask,"r",SH_DENYWR);
    136   if(fp) {
     138  if (fp) {
    137139    while(!feof(fp)) {
    138140      if(!fgets(mask,CCHMAXPATH + 24,fp))
     
    157159      if(!*cl)
    158160        continue;
    159       info = malloc(sizeof(LINKASSOC));
    160       if(info) {
    161         memset(info,0,sizeof(LINKASSOC));
    162         info->cl = strdup(cl);
    163         info->mask = strdup(mask);
     161      info = xmallocz(sizeof(LINKASSOC),pszSrcFile,__LINE__);
     162      if (info) {
     163        info->cl = xstrdup(cl,pszSrcFile,__LINE__);
     164        info->mask = xstrdup(mask,pszSrcFile,__LINE__);
    164165        if(*sig)
    165           info->sig = strdup(sig);
     166          info->sig = xstrdup(sig,pszSrcFile,__LINE__);
    166167        info->offset = atol(offset);
    167168        info->flags = atol(flags);
    168         if(!info->cl || !info->mask) {
    169           if(info->cl)
     169        if (!info->cl || !info->mask) {
     170          if (info->cl)
    170171            free(info->cl);
    171           if(info->mask)
     172          if (info->mask)
    172173            free(info->mask);
    173           free(info);
     174          free (info);
    174175          break;
    175176        }
     
    188189
    189190
    190 VOID save_associations (VOID) {
    191 
     191VOID save_associations (VOID)
     192{
    192193  LINKASSOC *info;
    193194  FILE      *fp;
     
    220221    strcat(s,"\\");
    221222  strcat(s,"ASSOC.DAT");
    222   fp = fopen(s,"w");
    223   if(fp) {
     223  fp = xfopen(s,"w",pszSrcFile,__LINE__);
     224  if (fp) {
    224225    fputs(GetPString(IDS_ASSOCFILETEXT),fp);
    225226    info = asshead;
     
    244245
    245246
    246 LINKASSOC * add_association (ASSOC *addme) {
    247 
     247LINKASSOC * add_association (ASSOC *addme)
     248{
    248249  LINKASSOC *info;
    249250
     
    258259    }
    259260    if(!info) {
    260       info = malloc(sizeof(LINKASSOC));
     261      info = xmallocz(sizeof(LINKASSOC),pszSrcFile,__LINE__);
    261262      if(info) {
    262         memset(info,0,sizeof(LINKASSOC));
    263         info->cl = strdup(addme->cl);
    264         info->mask = strdup(addme->mask);
     263        info->cl = xstrdup(addme->cl,pszSrcFile,__LINE__);
     264        info->mask = xstrdup(addme->mask,pszSrcFile,__LINE__);
    265265        if(*addme->sig)
    266           info->sig = strdup(addme->sig);
     266          info->sig = xstrdup(addme->sig,pszSrcFile,__LINE__);
    267267        if(addme->offset)
    268268          info->offset = addme->offset;
     
    295295
    296296
    297 BOOL kill_association (ASSOC *killme) {
    298 
     297BOOL kill_association (ASSOC *killme)
     298{
    299299  LINKASSOC *info;
    300300
     
    333333
    334334
    335 INT ExecAssociation (HWND hwnd, CHAR *datafile) {
    336 
     335INT ExecAssociation (HWND hwnd, CHAR *datafile)
     336{
    337337  CHAR      *file,sig[CCHMAXPATH],sigl[CCHMAXPATH],mask[CCHMAXPATH],*p;
    338338  FILE      *fp;
     
    382382                 info->sig);
    383383          literal(sigl);
    384           fp = _fsopen(datafile,
    385                        "rb",
    386                        SH_DENYNO);
    387           if(fp) {
     384          fp = _fsopen(datafile,"rb",SH_DENYNO);
     385          if (fp) {
    388386            if(info->offset < 0L) {
    389387              fseek(fp,
     
    463461
    464462
    465 MRESULT EXPENTRY AssocDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    466 
     463MRESULT EXPENTRY AssocDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     464{
    467465  LINKASSOC *info;
    468466  SHORT      x;
     
    558556                                                    MPVOID);
    559557              if(!info) {
    560                 DosBeep(50,100);
     558                Runtime_Error(pszSrcFile, __LINE__, "Query item handle failed");
    561559                break;
    562560              }
     
    698696              temp.flags |= PROMPT;
    699697            info = add_association(&temp);
    700             if(info) {
     698            if(!info)
     699              Runtime_Error(pszSrcFile, __LINE__, "add_association");
     700            else {
    701701
    702702              CHAR s[1002 + CCHMAXPATH + 6];
     
    730730              save_associations();
    731731            }
    732             else
    733               DosBeep(50,200);
    734732          }
    735733          break;
     
    754752                                NULL,
    755753                                0L);
    756             if(kill_association(&temp)) {
     754            if(!kill_association(&temp))
     755              Runtime_Error(pszSrcFile, __LINE__, "kill_association");
     756            else {
    757757              x = (SHORT)WinSendDlgItemMsg(hwnd,
    758758                                           ASS_LISTBOX,
     
    772772              save_associations();
    773773            }
    774             else
    775               DosBeep(50,200);
    776774          }
    777775          break;
     
    783781
    784782
    785 VOID EditAssociations (HWND hwnd) {
    786 
     783VOID EditAssociations (HWND hwnd)
     784{
    787785  static CHAR stop = 0;
    788786
     
    795793  stop = 0;
    796794}
    797 
Note: See TracChangeset for help on using the changeset viewer.