source: trunk/dll/subj.c@ 793

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

Move #pragma alloc_text to end for OpenWatcom compat

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