source: trunk/dll/subj.c@ 1570

Last change on this file since 1570 was 1480, checked in by Gregg Young, 16 years ago

Fix failure to correctly check for large file support in FindSwapperDat fall back code minor streamling. Add LVM.EXE to partition submenu. Stop using xDosQueryAppType where the file name it is passed is already a local stack variable. Correct a typo in several file header comments.

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