Subversion Repositories filter_foundry

Rev

Rev 511 | Rev 516 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 511 Rev 515
Line 19... Line 19...
19
*/
19
*/
20
 
20
 
21
#include <stddef.h>
21
#include <stddef.h>
22
#include <stdint.h>
22
#include <stdint.h>
23
#include <assert.h>
23
#include <assert.h>
-
 
24
#include <time.h>
24
 
25
 
25
#include "ff.h"
26
#include "ff.h"
26
#include "symtab.h"
27
#include "symtab.h"
27
 
28
 
28
#include "scripting.h"
29
#include "scripting.h"
Line 151... Line 152...
151
        int pad = 4 - (x % 4);
152
        int pad = 4 - (x % 4);
152
        if (pad == 0) pad = 4;
153
        if (pad == 0) pad = 4;
153
        return x + pad;
154
        return x + pad;
154
}
155
}
155
 
156
 
156
size_t fixpipl(PIPropertyList *pipl, size_t origsize, char* title, char* category, long *event_id) {
157
size_t fixpipl(PIPropertyList *pipl, size_t origsize, char* title, char* component, char* category, long *event_id) {
157
        PIProperty *prop;
158
        PIProperty *prop;
158
        char *p;
159
        char *p;
159
        struct hstm_data {
160
        struct hstm_data {
160
                /* this structure must be 14+1 bytes long, to match PiPL structure */
161
                /* this structure must be 14+1 bytes long, to match PiPL structure */
161
                long version; /* = 0 */
162
                long version; /* = 0 */
Line 167... Line 168...
167
        struct hstm_data *hstm;
168
        struct hstm_data *hstm;
168
        int scopelen;
169
        int scopelen;
169
        unsigned long hash;
170
        unsigned long hash;
170
        size_t realLength;
171
        size_t realLength;
171
        size_t roundedLength;
172
        size_t roundedLength;
-
 
173
        unsigned long componentVersion;
-
 
174
        time_t curTime;
172
        char szScope[0x300];
175
        char szScope[0x300];
173
 
176
 
174
        pipl->count += 3; // 3 more keys in PiPL: name, catg, hstm
177
        pipl->count += 4; // 4 more keys in PiPL: catg, name, cmpt, hstm
175
 
178
 
176
        p = (char*)pipl + origsize;
179
        p = (char*)pipl + origsize;
177
        prop = (PIProperty*)p;
180
        prop = (PIProperty*)p;
178
 
181
 
179
        /* Important not about proptyLength:
182
        /* Important not about proptyLength:
Line 190... Line 193...
190
                are rounding the length to a multiple of 4 (actually, rounding to the next possible multiple 4,
193
                are rounding the length to a multiple of 4 (actually, rounding to the next possible multiple 4,
191
                so that padding is always guaranteed).
194
                so that padding is always guaranteed).
192
                Photoshop (tested with Photoshop 7) will crash if the propertyLength follows the definition of PICA.
195
                Photoshop (tested with Photoshop 7) will crash if the propertyLength follows the definition of PICA.
193
        */
196
        */
194
 
197
 
-
 
198
        /* add Category property key */
-
 
199
 
-
 
200
        prop->vendorID = kPhotoshopSignature;
-
 
201
        prop->propertyKey = PICategoryProperty;
-
 
202
        prop->propertyID = 0;
-
 
203
        prop->propertyLength = (SPInt32)roundToNext4(strlen(category) + 1);
-
 
204
        memset(prop->propertyData, 0x00, prop->propertyLength); // fill padding with 00h bytes (cosmetics)
-
 
205
        myc2pstrcpy((StringPtr)prop->propertyData, category);
-
 
206
        p += offsetof(PIProperty, propertyData) + prop->propertyLength; // skip past new property record, and any padding
-
 
207
        prop = (PIProperty*)p;
-
 
208
 
195
        /* add Title/Name property key */
209
        /* add Title/Name property key */
196
 
210
 
197
        prop->vendorID = kPhotoshopSignature;
211
        prop->vendorID = kPhotoshopSignature;
198
        prop->propertyKey = PINameProperty;
212
        prop->propertyKey = PINameProperty;
199
        prop->propertyID = 0;
213
        prop->propertyID = 0;
200
        prop->propertyLength = (SPInt32)roundToNext4(strlen(title) + 1);
214
        prop->propertyLength = (SPInt32)roundToNext4(strlen(title) + 1);
201
        memset(prop->propertyData, 0x00, prop->propertyLength); // fill padding with 00h bytes (cosmetics)
215
        memset(prop->propertyData, 0x00, prop->propertyLength); // fill padding with 00h bytes (cosmetics)
202
        myc2pstrcpy((StringPtr)prop->propertyData, title);
216
        myc2pstrcpy((StringPtr)prop->propertyData, title);
203
 
-
 
204
        // skip past new property record, and any padding
-
 
205
        p += offsetof(PIProperty, propertyData) + prop->propertyLength;
217
        p += offsetof(PIProperty, propertyData) + prop->propertyLength; // skip past new property record, and any padding
206
        prop = (PIProperty*)p;
218
        prop = (PIProperty*)p;
207
 
219
 
208
        /* add Category property key */
220
        /* add Component property key */
209
 
221
 
210
        prop->vendorID = kPhotoshopSignature;
222
        prop->vendorID = kPhotoshopSignature;
211
        prop->propertyKey = PICategoryProperty;
223
        prop->propertyKey = PIComponentProperty;
212
        prop->propertyID = 0;
224
        prop->propertyID = 0;
213
 
-
 
-
 
225
        time(&curTime);
-
 
226
        componentVersion = (unsigned long)curTime - 946681200/*01.Jan.2000 00:00:00*/;
214
        prop->propertyLength = (SPInt32)roundToNext4(strlen(category) + 1);
227
        prop->propertyLength = (SPInt32)roundToNext4(strlen(component) + 1 + sizeof(componentVersion));
215
        memset(prop->propertyData, 0x00, prop->propertyLength); // fill padding with 00h bytes (cosmetics)
228
        memset(prop->propertyData, 0x00, prop->propertyLength); // fill padding with 00h bytes (cosmetics)
-
 
229
        memcpy(prop->propertyData, &componentVersion, sizeof(componentVersion));
216
        myc2pstrcpy((StringPtr)prop->propertyData, category);
230
        strcpy((char*)(prop->propertyData+sizeof(componentVersion)), component);
217
 
-
 
218
        p += offsetof(PIProperty, propertyData) + prop->propertyLength;
231
        p += offsetof(PIProperty, propertyData) + prop->propertyLength; // skip past new property record, and any padding
219
        prop = (PIProperty*)p;
232
        prop = (PIProperty*)p;
220
 
233
 
221
        /* add HasTerminology property key */
234
        /* add HasTerminology property key */
222
 
235
 
223
        hstm = (struct hstm_data*)prop->propertyData;
236
        hstm = (struct hstm_data*)prop->propertyData;