source: trunk/dll/subj.c@ 1398

Last change on this file since 1398 was 1398, checked in by Gregg Young, 17 years ago

Move embeded strings to PCSZ variables or string table; Eliminate Error2 functions Runtime_Error with NULL format string returns "No data" error. Change declares from PSZ to PCSZ in functions where the variable isn't changed. Added btm as an executable file type in several additional places. Use fProtectOnly to prevent attempt to execute Dos and Win programs on "Protect only" installs in several additional places.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
RevLine 
[123]1
2/***********************************************************************
3
4 $Id: subj.c 1398 2009-02-21 17:43:00Z gyoung $
5
[335]6 Edit .subject EAs
7
[123]8 Copyright (c) 1993-98 M. Kimes
[1348]9 Copyright (c) 2004, 2008 Steven H.Levine
[123]10
[335]11 01 Aug 04 SHL Rework lstrip/rstrip usage
12 17 Jul 06 SHL Use Runtime_Error
[775]13 06 Aug 07 GKY Increase Subject EA to 1024
[793]14 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[827]15 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
[123]16
17***********************************************************************/
18
[907]19#include <stdlib.h>
20#include <string.h>
21#include <ctype.h>
22
[2]23#define INCL_WIN
24#define INCL_DOS
25#define INCL_DOSERRORS
[841]26#define INCL_LONGLONG
[2]27
[1184]28#include "fm3dll.h"
[1213]29#include "info.h" // Data declaration(s)
30#include "mainwnd.h" // Data declaration(s)
[1398]31#include "init.h" // Data declaration(s)
[2]32#include "fm3dlg.h"
33#include "fm3str.h"
[907]34#include "errutil.h" // Dos_Error...
35#include "strutil.h" // GetPString
[1184]36#include "input.h" // InputDlgProc
37#include "subj.h"
38#include "wrappers.h" // xDosSetPathInfo
39#include "strips.h" // bstrip
[1039]40#include "fortify.h"
[2]41
[1213]42// Data definitions
[335]43static PSZ pszSrcFile = __FILE__;
[2]44
[1213]45#pragma data_seg(GLOBAL2)
46CHAR *SUBJECT;
47
[551]48INT Subject(HWND hwnd, CHAR * filename)
[335]49{
[551]50 APIRET rc;
51 EAOP2 eaop;
52 PGEA2LIST pgealist;
53 PFEA2LIST pfealist;
54 PGEA2 pgea;
55 PFEA2 pfea;
[771]56 CHAR *value, subject[1024], oldsubject[1024];
[2]57 STRINGINPARMS sip;
[551]58 INT ret = 0;
[2]59
60 *subject = 0;
[551]61 pgealist = xmallocz(sizeof(GEA2LIST) + 64, pszSrcFile, __LINE__);
[335]62 if (pgealist) {
[2]63 pgea = &pgealist->list[0];
[551]64 strcpy(pgea->szName, SUBJECT);
[2]65 pgea->cbName = strlen(pgea->szName);
[766]66 pgea->oNextEntryOffset = 0;
[2]67 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
[551]68 pfealist = xmallocz(1024, pszSrcFile, __LINE__);
69 if (pfealist)
[1039]70 free(pgealist);
[335]71 else {
[2]72 pfealist->cbList = 1024;
73 eaop.fpGEA2List = pgealist;
74 eaop.fpFEA2List = pfealist;
[766]75 eaop.oError = 0;
[551]76 rc = DosQueryPathInfo(filename, FIL_QUERYEASFROMLIST,
77 (PVOID) & eaop, (ULONG) sizeof(EAOP2));
[1039]78 free(pgealist);
[335]79 if (!rc) {
[551]80 pfea = &eaop.fpFEA2List->list[0];
81 value = pfea->szName + pfea->cbName + 1;
82 value[pfea->cbValue] = 0;
83 if (*(USHORT *) value == EAT_ASCII)
[771]84 strncpy(subject, value + (sizeof(USHORT) * 2), 1023);
85 subject[1023] = 0;
[2]86 }
[1039]87 free(pfealist);
[335]88 if (rc == ERROR_SHARING_VIOLATION || rc == ERROR_ACCESS_DENIED) {
[551]89 saymsg(MB_CANCEL,
90 hwnd,
91 GetPString(IDS_OOPSTEXT),
92 GetPString(IDS_EASBUSYTEXT), filename);
93 return 2; // Error
[2]94 }
[335]95 else if (rc) {
[551]96 Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
[1398]97 PCSZ_DOSQUERYPATHINFO);
[551]98 return 2; // Error
[2]99 }
100 }
101 }
[551]102 memset(&sip, 0, sizeof(sip));
103 strcpy(oldsubject, subject);
[2]104 sip.help = GetPString(IDS_SUBJECTINPUTHELPTEXT);
105 sip.ret = subject;
106 sip.prompt = GetPString(IDS_SUBJECTINPUTPROMPTTEXT);
[771]107 sip.inputlen = 1024;
[2]108 sip.title = filename;
[551]109 if (WinDlgBox
110 (HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle, STR_FRAME, &sip)
111 && isalpha(*filename)
112 && !(driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE)) {
[771]113 subject[1023] = 0;
[123]114 bstrip(subject);
[551]115 if (strcmp(oldsubject, subject)) {
[2]116
[551]117 ULONG ealen;
118 USHORT len;
119 CHAR *eaval;
[2]120
121 len = strlen(subject);
[335]122 if (len)
[551]123 ealen = sizeof(FEA2LIST) + 9 + len + 4;
[2]124 else
[551]125 ealen = sizeof(FEALIST) + 9;
126 rc = DosAllocMem((PPVOID) & pfealist, ealen + 1L,
127 OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE);
[335]128 if (rc)
[551]129 Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
130 GetPString(IDS_OUTOFMEMORY));
[335]131 else {
[551]132 memset(pfealist, 0, ealen + 1);
133 pfealist->cbList = ealen;
134 pfealist->list[0].oNextEntryOffset = 0L;
135 pfealist->list[0].fEA = 0;
136 pfealist->list[0].cbName = 8;
137 strcpy(pfealist->list[0].szName, SUBJECT);
138 if (len) {
139 eaval = pfealist->list[0].szName + 9;
140 *(USHORT *) eaval = (USHORT) EAT_ASCII;
141 eaval += sizeof(USHORT);
142 *(USHORT *) eaval = (USHORT) len;
143 eaval += sizeof(USHORT);
144 memcpy(eaval, subject, len);
145 pfealist->list[0].cbValue = len + (sizeof(USHORT) * 2);
[335]146 }
[551]147 else
148 pfealist->list[0].cbValue = 0;
149 eaop.fpGEA2List = (PGEA2LIST) 0;
150 eaop.fpFEA2List = pfealist;
[827]151 eaop.oError = 0;
152 rc = xDosSetPathInfo(filename, FIL_QUERYEASIZE,
153 &eaop, sizeof(eaop), DSPI_WRTTHRU);
[551]154 DosFreeMem(pfealist);
155 if (rc) {
156 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
157 GetPString(IDS_ERRORSETTINGSUBJECTTEXT), filename);
158 }
159 else
160 ret = 1; // OK
[2]161 }
162 }
163 }
[335]164 return ret; // No change?
[2]165}
[793]166
167#pragma alloc_text(FMINPUT,Subject)
Note: See TracBrowser for help on using the repository browser.