Rev 218 | Rev 229 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 218 | Rev 228 | ||
---|---|---|---|
Line 161... | Line 161... | ||
161 | char scope[1]; |
161 | char scope[1]; |
162 | }; |
162 | }; |
163 | struct hstm_data *hstm; |
163 | struct hstm_data *hstm; |
164 | int scopelen; |
164 | int scopelen; |
165 | unsigned long hash; |
165 | unsigned long hash; |
- | 166 | size_t realLength; |
|
- | 167 | size_t roundedLength; |
|
- | 168 | char* scope; |
|
166 | 169 | ||
167 | pipl->count += 3; // 3 more keys in PiPL: name, catg, hstm |
170 | pipl->count += 3; // 3 more keys in PiPL: name, catg, hstm |
168 | 171 | ||
169 | p = (char*)pipl + origsize; |
172 | p = (char*)pipl + origsize; |
170 | prop = (PIProperty*)p; |
173 | prop = (PIProperty*)p; |
Line 197... | Line 200... | ||
197 | 200 | ||
198 | /* add HasTerminology property key */ |
201 | /* add HasTerminology property key */ |
199 | 202 | ||
200 | hstm = (struct hstm_data*)prop->propertyData; |
203 | hstm = (struct hstm_data*)prop->propertyData; |
201 | 204 | ||
- | 205 | scope = malloc(0x300); |
|
- | 206 | if (!scope) return -1; |
|
- | 207 | sprintf(scope, "%s %s", |
|
- | 208 | INPLACEP2CSTR(gdata->parm.category), |
|
- | 209 | INPLACEP2CSTR(title)); |
|
- | 210 | ||
202 | #ifdef ENABLE_APPLESCRIPT |
211 | #ifdef ENABLE_APPLESCRIPT |
203 | // If the uniqueString/scope is set, the plugin will only communicate with Photoshop. |
212 | // If the uniqueString/scope is set, the plugin will only communicate with Photoshop. |
204 | // Otherwise it can be accessed with AppleScript, but the AETE keys need to be unique then. |
213 | // Otherwise it can be accessed with AppleScript, but the AETE keys need to be unique then. |
205 | // This is achieved with getAeteKey(). |
214 | // This is achieved with getAeteKey(). |
206 | hstm->scope[0] = '\0'; |
- | |
207 | scopelen = 0; |
215 | scopelen = 0; |
- | 216 | hstm->scope[0] = '\0'; |
|
208 | #else |
217 | #else |
209 | // Construct scope string by concatenating Category and Title - hopefully unique! |
218 | // Construct scope string by concatenating Category and Title - hopefully unique! |
210 | // Note: In doresources() we malloc'ed 300h additional bytes, |
219 | // Note: In doresources() we malloc'ed 300h additional bytes, |
211 | // and in the build dialog, title and category are size-limited, |
220 | // and in the build dialog, title and category are size-limited, |
212 | // so we can write here without malloc. |
221 | // so we can write here without malloc. |
213 | scopelen = sprintf(hstm->scope, "%s %s", |
222 | scopelen = strlen(scope); |
214 | INPLACEP2CSTR(gdata->parm.category), |
223 | memcpy(&hstm->scope, scope, scopelen); |
215 | INPLACEP2CSTR(title)); |
- | |
216 | #endif |
224 | #endif |
217 | 225 | ||
218 | /* make up a new event ID for this aete, based on printable base-95 hash of scope */ |
226 | /* make up a new event ID for this aete, based on printable base-95 hash of scope */ |
219 | hash = djb2(hstm->scope); |
227 | hash = djb2(scope); |
220 | *event_id = printablehash(hash); /* this is used by aete_generate() later... */ |
228 | *event_id = printablehash(hash); /* this is used by aete_generate() later... */ |
221 | 229 | ||
222 | prop->vendorID = kPhotoshopSignature; |
230 | prop->vendorID = kPhotoshopSignature; |
223 | prop->propertyKey = PIHasTerminologyProperty; |
231 | prop->propertyKey = PIHasTerminologyProperty; |
224 | prop->propertyID = 0; |
232 | prop->propertyID = 0; |
225 | 233 | ||
226 | size_t realLength = offsetof(struct hstm_data, scope) + scopelen + 1/*null-term*/; |
234 | realLength = offsetof(struct hstm_data, scope) + scopelen + 1/*null-term*/; |
227 | size_t roundedLength = roundToNext4(realLength); |
235 | roundedLength = roundToNext4(realLength); |
228 | prop->propertyLength = roundedLength; |
236 | prop->propertyLength = roundedLength; |
229 | memset(prop->propertyData + realLength, 0x00, roundedLength - realLength); // fill padding with 00h bytes (cosmetics) |
237 | memset(prop->propertyData + realLength, 0x00, roundedLength - realLength); // fill padding with 00h bytes (cosmetics) |
230 | 238 | ||
231 | hstm->version = 0; |
239 | hstm->version = 0; |
232 | hstm->class_id = plugInClassID; |
240 | hstm->class_id = plugInClassID; |