source: trunk/dll/subj.c@ 335

Last change on this file since 335 was 335, checked in by root, 19 years ago

Use Runtime_Error

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1
2/***********************************************************************
3
4 $Id: subj.c 335 2006-07-25 19:03:44Z root $
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
14***********************************************************************/
15
16#define INCL_WIN
17#define INCL_DOS
18#define INCL_DOSERRORS
19#include <os2.h>
20
21#include <stdlib.h>
22#include <stdio.h>
23#include <string.h>
24#include <ctype.h>
25
26#include "fm3dll.h"
27#include "fm3dlg.h"
28#include "fm3str.h"
29
30#pragma alloc_text(FMINPUT,Subject)
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[42],oldsubject[42];
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 = 0L;
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 = 0L;
62 rc = DosQueryPathInfo(filename,FIL_QUERYEASFROMLIST,
63 (PVOID)&eaop,
64 (ULONG)sizeof(EAOP2));
65 free(pgealist);
66 if (!rc) {
67 pfea = &eaop.fpFEA2List->list[0];
68 value = pfea->szName + pfea->cbName + 1;
69 value[pfea->cbValue] = 0;
70 if(*(USHORT *)value == EAT_ASCII)
71 strncpy(subject,value + (sizeof(USHORT) * 2),39);
72 subject[39] = 0;
73 }
74 free(pfealist);
75 if (rc == ERROR_SHARING_VIOLATION || rc == ERROR_ACCESS_DENIED) {
76 saymsg(MB_CANCEL,
77 hwnd,
78 GetPString(IDS_OOPSTEXT),
79 GetPString(IDS_EASBUSYTEXT),
80 filename);
81 return 2; // Error
82 }
83 else if (rc) {
84 Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosQueryPathInfo");
85 return 2; // Error
86 }
87 }
88 }
89 memset(&sip,0,sizeof(sip));
90 strcpy(oldsubject,subject);
91 sip.help = GetPString(IDS_SUBJECTINPUTHELPTEXT);
92 sip.ret = subject;
93 sip.prompt = GetPString(IDS_SUBJECTINPUTPROMPTTEXT);
94 sip.inputlen = 40;
95 sip.title = filename;
96 if (WinDlgBox(HWND_DESKTOP,hwnd,InputDlgProc,FM3ModHandle,STR_FRAME,&sip)
97 && isalpha(*filename) &&
98 !(driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE)) {
99 subject[39] = 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__,GetPString(IDS_OUTOFMEMORY));
116 else {
117 memset(pfealist,0,ealen + 1);
118 pfealist->cbList = ealen;
119 pfealist->list[0].oNextEntryOffset = 0L;
120 pfealist->list[0].fEA = 0;
121 pfealist->list[0].cbName = 8;
122 strcpy(pfealist->list[0].szName,SUBJECT);
123 if (len) {
124 eaval = pfealist->list[0].szName + 9;
125 *(USHORT *)eaval = (USHORT)EAT_ASCII;
126 eaval += sizeof(USHORT);
127 *(USHORT *)eaval = (USHORT)len;
128 eaval += sizeof(USHORT);
129 memcpy(eaval,subject,len);
130 pfealist->list[0].cbValue = len + (sizeof(USHORT) * 2);
131 }
132 else
133 pfealist->list[0].cbValue = 0;
134 eaop.fpGEA2List = (PGEA2LIST)0;
135 eaop.fpFEA2List = pfealist;
136 eaop.oError = 0L;
137 rc = DosSetPathInfo(filename,FIL_QUERYEASIZE,(PVOID)&eaop,
138 (ULONG)sizeof(EAOP2),DSPI_WRTTHRU);
139 DosFreeMem(pfealist);
140 if (rc) {
141 Dos_Error(MB_ENTER,rc,HWND_DESKTOP,pszSrcFile,__LINE__,
142 GetPString(IDS_ERRORSETTINGSUBJECTTEXT),filename);
143 }
144 else
145 ret = 1; // OK
146 }
147 }
148 }
149 return ret; // No change?
150}
Note: See TracBrowser for help on using the repository browser.