source: trunk/dll/subj.c@ 1844

Last change on this file since 1844 was 1628, checked in by Gregg Young, 14 years ago

Hard coded the flags for the xDosAlloc* wrappers and added a description for each of them.

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