source: trunk/dll/subj.c@ 841

Last change on this file since 841 was 841, checked in by Gregg Young, 18 years ago

This implements large file support; The wrappers to allow WARP3 compatibility are not done so this will not run on Warp3or Warp 4 pre fixpack 12(?)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
RevLine 
[123]1
2/***********************************************************************
3
4 $Id: subj.c 841 2007-09-23 16:27:51Z gyoung $
5
[335]6 Edit .subject EAs
7
[123]8 Copyright (c) 1993-98 M. Kimes
[335]9 Copyright (c) 2004, 2006 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
[2]19#define INCL_WIN
20#define INCL_DOS
21#define INCL_DOSERRORS
[841]22#define INCL_LONGLONG
[335]23#include <os2.h>
[2]24
25#include <stdlib.h>
26#include <stdio.h>
27#include <string.h>
28#include <ctype.h>
[335]29
[2]30#include "fm3dll.h"
31#include "fm3dlg.h"
32#include "fm3str.h"
33
[335]34static PSZ pszSrcFile = __FILE__;
[2]35
[551]36INT Subject(HWND hwnd, CHAR * filename)
[335]37{
[551]38 APIRET rc;
39 EAOP2 eaop;
40 PGEA2LIST pgealist;
41 PFEA2LIST pfealist;
42 PGEA2 pgea;
43 PFEA2 pfea;
[771]44 CHAR *value, subject[1024], oldsubject[1024];
[2]45 STRINGINPARMS sip;
[551]46 INT ret = 0;
[2]47
48 *subject = 0;
[551]49 pgealist = xmallocz(sizeof(GEA2LIST) + 64, pszSrcFile, __LINE__);
[335]50 if (pgealist) {
[2]51 pgea = &pgealist->list[0];
[551]52 strcpy(pgea->szName, SUBJECT);
[2]53 pgea->cbName = strlen(pgea->szName);
[766]54 pgea->oNextEntryOffset = 0;
[2]55 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
[551]56 pfealist = xmallocz(1024, pszSrcFile, __LINE__);
57 if (pfealist)
[335]58 free(pgealist);
59 else {
[2]60 pfealist->cbList = 1024;
61 eaop.fpGEA2List = pgealist;
62 eaop.fpFEA2List = pfealist;
[766]63 eaop.oError = 0;
[551]64 rc = DosQueryPathInfo(filename, FIL_QUERYEASFROMLIST,
65 (PVOID) & eaop, (ULONG) sizeof(EAOP2));
[2]66 free(pgealist);
[335]67 if (!rc) {
[551]68 pfea = &eaop.fpFEA2List->list[0];
69 value = pfea->szName + pfea->cbName + 1;
70 value[pfea->cbValue] = 0;
71 if (*(USHORT *) value == EAT_ASCII)
[771]72 strncpy(subject, value + (sizeof(USHORT) * 2), 1023);
73 subject[1023] = 0;
[2]74 }
75 free(pfealist);
[335]76 if (rc == ERROR_SHARING_VIOLATION || rc == ERROR_ACCESS_DENIED) {
[551]77 saymsg(MB_CANCEL,
78 hwnd,
79 GetPString(IDS_OOPSTEXT),
80 GetPString(IDS_EASBUSYTEXT), filename);
81 return 2; // Error
[2]82 }
[335]83 else if (rc) {
[551]84 Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
85 "DosQueryPathInfo");
86 return 2; // Error
[2]87 }
88 }
89 }
[551]90 memset(&sip, 0, sizeof(sip));
91 strcpy(oldsubject, subject);
[2]92 sip.help = GetPString(IDS_SUBJECTINPUTHELPTEXT);
93 sip.ret = subject;
94 sip.prompt = GetPString(IDS_SUBJECTINPUTPROMPTTEXT);
[771]95 sip.inputlen = 1024;
[2]96 sip.title = filename;
[551]97 if (WinDlgBox
98 (HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle, STR_FRAME, &sip)
99 && isalpha(*filename)
100 && !(driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE)) {
[771]101 subject[1023] = 0;
[123]102 bstrip(subject);
[551]103 if (strcmp(oldsubject, subject)) {
[2]104
[551]105 ULONG ealen;
106 USHORT len;
107 CHAR *eaval;
[2]108
109 len = strlen(subject);
[335]110 if (len)
[551]111 ealen = sizeof(FEA2LIST) + 9 + len + 4;
[2]112 else
[551]113 ealen = sizeof(FEALIST) + 9;
114 rc = DosAllocMem((PPVOID) & pfealist, ealen + 1L,
115 OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE);
[335]116 if (rc)
[551]117 Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
118 GetPString(IDS_OUTOFMEMORY));
[335]119 else {
[551]120 memset(pfealist, 0, ealen + 1);
121 pfealist->cbList = ealen;
122 pfealist->list[0].oNextEntryOffset = 0L;
123 pfealist->list[0].fEA = 0;
124 pfealist->list[0].cbName = 8;
125 strcpy(pfealist->list[0].szName, SUBJECT);
126 if (len) {
127 eaval = pfealist->list[0].szName + 9;
128 *(USHORT *) eaval = (USHORT) EAT_ASCII;
129 eaval += sizeof(USHORT);
130 *(USHORT *) eaval = (USHORT) len;
131 eaval += sizeof(USHORT);
132 memcpy(eaval, subject, len);
133 pfealist->list[0].cbValue = len + (sizeof(USHORT) * 2);
[335]134 }
[551]135 else
136 pfealist->list[0].cbValue = 0;
137 eaop.fpGEA2List = (PGEA2LIST) 0;
138 eaop.fpFEA2List = pfealist;
[827]139 eaop.oError = 0;
140 rc = xDosSetPathInfo(filename, FIL_QUERYEASIZE,
141 &eaop, sizeof(eaop), DSPI_WRTTHRU);
[551]142 DosFreeMem(pfealist);
143 if (rc) {
144 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
145 GetPString(IDS_ERRORSETTINGSUBJECTTEXT), filename);
146 }
147 else
148 ret = 1; // OK
[2]149 }
150 }
151 }
[335]152 return ret; // No change?
[2]153}
[793]154
155#pragma alloc_text(FMINPUT,Subject)
Note: See TracBrowser for help on using the repository browser.