source: trunk/dll/subj.c@ 1439

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

Changes to allow high mem loading of dll; Refactor .LONGNAME and .SUBJECT EA fetch to FetchCommonEAs. Add szFSType to FillInRecordFromFSA use to bypass EA scan and size formatting for tree container; Fix labels/FS type to work on scan on NOPRESCAN Drives; Fixed dbl directory names on restore of dir cnrs; (Tickets 47, 339, 363, 368, 369, 370)

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