source: trunk/dll/subj.c@ 1438

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

Improved drivebar changes; Added AddBackslashToPath() to remove repeatative code. replaced "
" with PCSZ variable; ANY_OBJ added the DosAlloc... (experimental)

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