Changeset 342 for trunk/dll/assoc.c
- Timestamp:
- Jul 26, 2006, 4:00:11 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/dll/assoc.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/assoc.c
r290 r342 5 5 6 6 Copyright (c) 1993-98 M. Kimes 7 Copyright (c) 2004 Steven H.Levine7 Copyright (c) 2004, 2006 Steven H.Levine 8 8 9 9 01 Aug 04 SHL Rework lstrip/rstrip usage 10 14 Jul 06 SHL Use Runtime_Error 10 11 11 12 ***********************************************************************/ … … 47 48 static BOOL assloaded = FALSE; 48 49 50 static PSZ pszSrcFile = __FILE__; 51 49 52 #pragma alloc_text(ASSOC2,free_commands,load_associations,save_associations) 50 53 #pragma alloc_text(ASSOC2,ExecAssociation,AssocTextProc) 51 54 52 53 MRESULT EXPENTRY AssocTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 54 55 MRESULT EXPENTRY AssocTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 56 { 55 57 PFNWP oldproc = (PFNWP)WinQueryWindowPtr(hwnd,QWL_USER); 56 58 static BOOL emphasized = FALSE; … … 98 100 99 101 100 VOID free_associations (VOID) {101 102 VOID free_associations (VOID) 103 { 102 104 LINKASSOC *info,*next; 103 105 … … 116 118 117 119 118 VOID load_associations (VOID) {119 120 VOID load_associations (VOID) 121 { 120 122 FILE *fp; 121 123 LINKASSOC *info; … … 134 136 strcat(mask,"ASSOC.DAT"); 135 137 fp = _fsopen(mask,"r",SH_DENYWR); 136 if (fp) {138 if (fp) { 137 139 while(!feof(fp)) { 138 140 if(!fgets(mask,CCHMAXPATH + 24,fp)) … … 157 159 if(!*cl) 158 160 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__); 164 165 if(*sig) 165 info->sig = strdup(sig);166 info->sig = xstrdup(sig,pszSrcFile,__LINE__); 166 167 info->offset = atol(offset); 167 168 info->flags = atol(flags); 168 if (!info->cl || !info->mask) {169 if (info->cl)169 if (!info->cl || !info->mask) { 170 if (info->cl) 170 171 free(info->cl); 171 if (info->mask)172 if (info->mask) 172 173 free(info->mask); 173 free (info);174 free (info); 174 175 break; 175 176 } … … 188 189 189 190 190 VOID save_associations (VOID) {191 191 VOID save_associations (VOID) 192 { 192 193 LINKASSOC *info; 193 194 FILE *fp; … … 220 221 strcat(s,"\\"); 221 222 strcat(s,"ASSOC.DAT"); 222 fp = fopen(s,"w");223 if (fp) {223 fp = xfopen(s,"w",pszSrcFile,__LINE__); 224 if (fp) { 224 225 fputs(GetPString(IDS_ASSOCFILETEXT),fp); 225 226 info = asshead; … … 244 245 245 246 246 LINKASSOC * add_association (ASSOC *addme) {247 247 LINKASSOC * add_association (ASSOC *addme) 248 { 248 249 LINKASSOC *info; 249 250 … … 258 259 } 259 260 if(!info) { 260 info = malloc(sizeof(LINKASSOC));261 info = xmallocz(sizeof(LINKASSOC),pszSrcFile,__LINE__); 261 262 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__); 265 265 if(*addme->sig) 266 info->sig = strdup(addme->sig);266 info->sig = xstrdup(addme->sig,pszSrcFile,__LINE__); 267 267 if(addme->offset) 268 268 info->offset = addme->offset; … … 295 295 296 296 297 BOOL kill_association (ASSOC *killme) {298 297 BOOL kill_association (ASSOC *killme) 298 { 299 299 LINKASSOC *info; 300 300 … … 333 333 334 334 335 INT ExecAssociation (HWND hwnd, CHAR *datafile) {336 335 INT ExecAssociation (HWND hwnd, CHAR *datafile) 336 { 337 337 CHAR *file,sig[CCHMAXPATH],sigl[CCHMAXPATH],mask[CCHMAXPATH],*p; 338 338 FILE *fp; … … 382 382 info->sig); 383 383 literal(sigl); 384 fp = _fsopen(datafile, 385 "rb", 386 SH_DENYNO); 387 if(fp) { 384 fp = _fsopen(datafile,"rb",SH_DENYNO); 385 if (fp) { 388 386 if(info->offset < 0L) { 389 387 fseek(fp, … … 463 461 464 462 465 MRESULT EXPENTRY AssocDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {466 463 MRESULT EXPENTRY AssocDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 464 { 467 465 LINKASSOC *info; 468 466 SHORT x; … … 558 556 MPVOID); 559 557 if(!info) { 560 DosBeep(50,100);558 Runtime_Error(pszSrcFile, __LINE__, "Query item handle failed"); 561 559 break; 562 560 } … … 698 696 temp.flags |= PROMPT; 699 697 info = add_association(&temp); 700 if(info) { 698 if(!info) 699 Runtime_Error(pszSrcFile, __LINE__, "add_association"); 700 else { 701 701 702 702 CHAR s[1002 + CCHMAXPATH + 6]; … … 730 730 save_associations(); 731 731 } 732 else733 DosBeep(50,200);734 732 } 735 733 break; … … 754 752 NULL, 755 753 0L); 756 if(kill_association(&temp)) { 754 if(!kill_association(&temp)) 755 Runtime_Error(pszSrcFile, __LINE__, "kill_association"); 756 else { 757 757 x = (SHORT)WinSendDlgItemMsg(hwnd, 758 758 ASS_LISTBOX, … … 772 772 save_associations(); 773 773 } 774 else775 DosBeep(50,200);776 774 } 777 775 break; … … 783 781 784 782 785 VOID EditAssociations (HWND hwnd) {786 783 VOID EditAssociations (HWND hwnd) 784 { 787 785 static CHAR stop = 0; 788 786 … … 795 793 stop = 0; 796 794 } 797
Note:
See TracChangeset
for help on using the changeset viewer.
